bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING * object_name1, int *object_type, uint32_t * object_instance) { bool found = false; int type = 0; uint32_t instance; unsigned max_objects = 0, i = 0; bool check_id = false; BACNET_CHARACTER_STRING object_name2; struct my_object_functions *pObject = NULL; max_objects = Device_Object_List_Count(); for (i = 1; i <= max_objects; i++) { check_id = Device_Object_List_Identifier(i, &type, &instance); if (check_id) { pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) type); if ((pObject != NULL) && (pObject->Object_Name != NULL) && (pObject->Object_Name(instance, &object_name2) && characterstring_same(object_name1, &object_name2))) { found = true; if (object_type) { *object_type = type; } if (object_instance) { *object_instance = instance; } break; } } } return found; }
/* for a given object type, returns the special property list */ void Device_Objects_Property_List(BACNET_OBJECT_TYPE object_type, struct special_property_list_t *pPropertyList) { struct my_object_functions *pObject = NULL; pPropertyList->Required.pList = NULL; pPropertyList->Optional.pList = NULL; pPropertyList->Proprietary.pList = NULL; /* If we can find an entry for the required object type * and there is an Object_List_RPM fn ptr then call it * to populate the pointers to the individual list counters. */ pObject = Device_Objects_Find_Functions(object_type); if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) { pObject->Object_RPM_List(&pPropertyList->Required.pList, &pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList); } /* Fetch the counts if available otherwise zero them */ pPropertyList->Required.count = pPropertyList->Required.pList == NULL ? 0 : property_list_count(pPropertyList->Required.pList); pPropertyList->Optional.count = pPropertyList->Optional.pList == NULL ? 0 : property_list_count(pPropertyList->Optional.pList); pPropertyList->Proprietary.count = pPropertyList->Proprietary.pList == NULL ? 0 : property_list_count(pPropertyList->Proprietary.pList); return; }
bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data) { bool status = false; struct my_object_functions *pObject = NULL; /* initialize the default return values */ pObject = Device_Objects_Find_Functions(wp_data->object_type); if (pObject) { if (pObject->Object_Valid_Instance && pObject->Object_Valid_Instance(wp_data->object_instance)) { if (pObject->Object_Write_Property) { status = pObject->Object_Write_Property(wp_data); } else { wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; } } else { wp_data->error_class = ERROR_CLASS_OBJECT; wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT; } } else { wp_data->error_class = ERROR_CLASS_OBJECT; wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT; } return status; }
/** Looks up the requested Object and Property, and encodes its Value in an APDU. * @ingroup ObjIntf * If the Object or Property can't be found, sets the error class and code. * * @param rpdata [in,out] Structure with the desired Object and Property info * on entry, and APDU message on return. * @return The length of the APDU on success, else BACNET_STATUS_ERROR */ int Device_Read_Property( BACNET_READ_PROPERTY_DATA * rpdata) { int apdu_len = BACNET_STATUS_ERROR; struct object_functions *pObject = NULL; /* initialize the default return values */ rpdata->error_class = ERROR_CLASS_OBJECT; rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT; pObject = Device_Objects_Find_Functions(rpdata->object_type); if (pObject != NULL) { if (pObject->Object_Valid_Instance && pObject->Object_Valid_Instance(rpdata->object_instance)) { if (pObject->Object_Read_Property) { apdu_len = pObject->Object_Read_Property(rpdata); } } else { rpdata->error_class = ERROR_CLASS_OBJECT; rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT; } } else { rpdata->error_class = ERROR_CLASS_OBJECT; rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT; } return apdu_len; }
bool Device_Valid_Object_Id(int object_type, uint32_t object_instance) { bool status = false; /* return value */ struct my_object_functions *pObject = NULL; pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) object_type); if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) { status = pObject->Object_Valid_Instance(object_instance); } return status; }
bool Device_Object_Name_Copy(BACNET_OBJECT_TYPE object_type, uint32_t object_instance, BACNET_CHARACTER_STRING * object_name) { struct my_object_functions *pObject = NULL; bool found = false; pObject = Device_Objects_Find_Functions(object_type); if ((pObject != NULL) && (pObject->Object_Name != NULL)) { found = pObject->Object_Name(object_instance, object_name); } return found; }
bool Device_Value_List_Supported( BACNET_OBJECT_TYPE object_type) { bool status = false; /* Ever the pessimist! */ struct my_object_functions *pObject = NULL; pObject = Device_Objects_Find_Functions(object_type); if (pObject != NULL) { if (pObject->Object_Value_List) { status = true; } } return (status); }
void Device_COV_Clear( BACNET_OBJECT_TYPE object_type, uint32_t object_instance) { struct my_object_functions *pObject = NULL; pObject = Device_Objects_Find_Functions(object_type); if (pObject != NULL) { if (pObject->Object_Valid_Instance && pObject->Object_Valid_Instance(object_instance)) { if (pObject->Object_COV_Clear) { pObject->Object_COV_Clear(object_instance); } } } }
bool Device_COV( BACNET_OBJECT_TYPE object_type, uint32_t object_instance) { bool status = false; /* Ever the pessamist! */ struct my_object_functions *pObject = NULL; pObject = Device_Objects_Find_Functions(object_type); if (pObject != NULL) { if (pObject->Object_Valid_Instance && pObject->Object_Valid_Instance(object_instance)) { if (pObject->Object_COV) { status = pObject->Object_COV( object_instance); } } } return (status); }
bool Device_Encode_Value_List( BACNET_OBJECT_TYPE object_type, uint32_t object_instance, BACNET_PROPERTY_VALUE * value_list) { bool status = false; /* Ever the pessamist! */ struct my_object_functions *pObject = NULL; pObject = Device_Objects_Find_Functions(object_type); if (pObject != NULL) { if (pObject->Object_Valid_Instance && pObject->Object_Valid_Instance(object_instance)) { if (pObject->Object_Value_List) { status = pObject->Object_Value_List( object_instance, value_list); } } } return (status); }