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
@@ -187,8 +187,8 @@ static object_functions_t 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;
@@ -220,7 +220,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);
}
@@ -252,7 +252,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,
@@ -860,7 +860,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(type);
pObject = Device_Object_Functions_Find(type);
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
(pObject->Object_Name(instance, &object_name2) &&
characterstring_same(object_name1, &object_name2))) {
@@ -890,7 +890,7 @@ bool Device_Valid_Object_Id(
bool status = false; /* return value */
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) {
status = pObject->Object_Valid_Instance(object_instance);
}
@@ -912,7 +912,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) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
@@ -1219,7 +1219,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)) {
@@ -1335,7 +1335,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)) {
+27 -18
View File
@@ -404,8 +404,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;
@@ -436,7 +436,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);
}
@@ -468,7 +468,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,
@@ -1294,7 +1294,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(type);
pObject = Device_Object_Functions_Find(type);
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
(pObject->Object_Name(instance, &object_name2) &&
characterstring_same(object_name1, &object_name2))) {
@@ -1324,7 +1324,7 @@ bool Device_Valid_Object_Id(
bool status = false; /* return value */
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
pObject = Device_Object_Functions_Find(object_type);
if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) {
status = pObject->Object_Valid_Instance(object_instance);
}
@@ -1346,7 +1346,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) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
@@ -1741,7 +1741,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)) {
@@ -2095,7 +2095,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)) {
@@ -2153,7 +2153,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)) {
@@ -2187,7 +2187,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)) {
@@ -2225,7 +2225,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)) {
@@ -2250,7 +2250,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)) {
@@ -2272,7 +2272,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)) {
@@ -2295,7 +2295,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
@@ -2354,7 +2354,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
@@ -2403,7 +2403,7 @@ void Device_local_reporting(void)
for (idx = 1; idx <= objects_count; idx++) {
Device_Object_List_Identifier(idx, &object_type, &object_instance);
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)) {
@@ -2426,7 +2426,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;
@@ -2436,6 +2436,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.
+6 -1
View File
@@ -197,6 +197,11 @@ extern "C" {
BACNET_STACK_EXPORT
void Device_Init(object_functions_t *object_table);
BACNET_STACK_EXPORT
struct object_functions *Device_Object_Functions(void);
BACNET_STACK_EXPORT
struct object_functions *
Device_Object_Functions_Find(BACNET_OBJECT_TYPE Object_Type);
BACNET_STACK_EXPORT
void Device_Timer(uint16_t milliseconds);
@@ -488,7 +493,7 @@ int Routed_Device_Service_Approval(
* situated in the Device Object, which "knows" how to reach its child Objects.
*
* Most of these calls have a common operation:
* -# Call Device_Objects_Find_Functions( for the desired Object_Type )
* -# Call Device_Object_Functions_Find( for the desired Object_Type )
* - Gets a pointer to the object_functions for this Type of Object.
* -# Call the Object's Object_Valid_Instance( for the desired object_instance
* ) to make sure there is such an instance.