Feature/add-device-object-functions-find-api (#1115)

* Added Device_Object_Functions_Find() API to enable override of basic object API function.

* Added Device_Object_Functions() API to return basic object API table of functions for all objects.
This commit is contained in:
Steve Karg
2025-09-30 15:59:08 -05:00
committed by GitHub
parent 83dfe50294
commit 5b7932ee62
7 changed files with 107 additions and 81 deletions
+26 -17
View File
@@ -804,8 +804,8 @@ static object_functions_t My_Object_Table[] = {
* @return Pointer to the group of object helper functions that implement this
* type of Object.
*/
static struct object_functions *
Device_Objects_Find_Functions(BACNET_OBJECT_TYPE Object_Type)
struct object_functions *
Device_Object_Functions_Find(BACNET_OBJECT_TYPE Object_Type)
{
struct object_functions *pObject = NULL;
@@ -836,7 +836,7 @@ rr_info_function Device_Objects_RR_Info(BACNET_OBJECT_TYPE object_type)
{
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
return (pObject != NULL ? pObject->Object_RR_Info : NULL);
}
@@ -868,7 +868,7 @@ void Device_Objects_Property_List(
* to populate the pointers to the individual list counters.
*/
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
pObject->Object_RPM_List(
&pPropertyList->Required.pList, &pPropertyList->Optional.pList,
@@ -1618,7 +1618,7 @@ bool Device_Valid_Object_Name(
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);
pObject = Device_Object_Functions_Find((BACNET_OBJECT_TYPE)type);
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
(pObject->Object_Name(instance, &object_name2) &&
characterstring_same(object_name1, &object_name2))) {
@@ -1648,7 +1648,7 @@ bool Device_Valid_Object_Id(
bool status = false; /* return value */
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)object_type);
pObject = Device_Object_Functions_Find((BACNET_OBJECT_TYPE)object_type);
if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) {
status = pObject->Object_Valid_Instance(object_instance);
}
@@ -1670,7 +1670,7 @@ bool Device_Object_Name_Copy(
struct object_functions *pObject = NULL;
bool found = false;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if ((pObject != NULL) && (pObject->Object_Name != NULL)) {
found = pObject->Object_Name(object_instance, object_name);
}
@@ -2064,7 +2064,7 @@ int Device_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
/* 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);
pObject = Device_Object_Functions_Find(rpdata->object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(rpdata->object_instance)) {
@@ -2419,7 +2419,7 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* initialize the default return values */
wp_data->error_class = ERROR_CLASS_OBJECT;
wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT;
pObject = Device_Objects_Find_Functions(wp_data->object_type);
pObject = Device_Object_Functions_Find(wp_data->object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(wp_data->object_instance)) {
@@ -2477,7 +2477,7 @@ int Device_Add_List_Element(BACNET_LIST_ELEMENT_DATA *list_element)
int status = BACNET_STATUS_ERROR;
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(list_element->object_type);
pObject = Device_Object_Functions_Find(list_element->object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(list_element->object_instance)) {
@@ -2511,7 +2511,7 @@ int Device_Remove_List_Element(BACNET_LIST_ELEMENT_DATA *list_element)
int status = BACNET_STATUS_ERROR;
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(list_element->object_type);
pObject = Device_Object_Functions_Find(list_element->object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(list_element->object_instance)) {
@@ -2550,7 +2550,7 @@ bool Device_Encode_Value_List(
bool status = false; /* Ever the pessimist! */
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
@@ -2575,7 +2575,7 @@ bool Device_COV(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
bool status = false; /* Ever the pessamist! */
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
@@ -2597,7 +2597,7 @@ void Device_COV_Clear(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
{
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
@@ -2620,7 +2620,7 @@ bool Device_Create_Object(BACNET_CREATE_OBJECT_DATA *data)
struct object_functions *pObject = NULL;
uint32_t object_instance;
pObject = Device_Objects_Find_Functions(data->object_type);
pObject = Device_Object_Functions_Find(data->object_type);
if (pObject != NULL) {
if (!pObject->Object_Create) {
/* The device supports the object type and may have
@@ -2679,7 +2679,7 @@ bool Device_Delete_Object(BACNET_DELETE_OBJECT_DATA *data)
bool status = false;
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(data->object_type);
pObject = Device_Object_Functions_Find(data->object_type);
if (pObject != NULL) {
if (!pObject->Object_Delete) {
/* The device supports the object type
@@ -2723,7 +2723,7 @@ bool Device_Value_List_Supported(BACNET_OBJECT_TYPE object_type)
bool status = false; /* Ever the pessamist! */
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if (pObject != NULL) {
if (pObject->Object_Value_List) {
status = true;
@@ -2733,6 +2733,15 @@ bool Device_Value_List_Supported(BACNET_OBJECT_TYPE object_type)
return (status);
}
/**
* @brief Get the Device object functions table
* @return the Device object function table
*/
struct object_functions *Device_Object_Functions(void)
{
return Object_Table;
}
/** Initialize the Device Object.
Initialize the group of object helper functions for any supported Object.
Initialize each of the Device Object child Object instances.