Added support for non contiguous object arrays to the device object. This allows, for example, a single table of objects to be used for configuration of the device with the objects of a given type not required to be in a contiguous block.
This commit is contained in:
@@ -94,6 +94,7 @@ static struct object_functions {
|
|||||||
write_property_function Object_Write_Property;
|
write_property_function Object_Write_Property;
|
||||||
rpm_property_lists_function Object_RPM_List;
|
rpm_property_lists_function Object_RPM_List;
|
||||||
rr_info_function Object_RR_Info;
|
rr_info_function Object_RR_Info;
|
||||||
|
object_iterate_function Object_Iterator;
|
||||||
} Object_Table[] =
|
} Object_Table[] =
|
||||||
{
|
{
|
||||||
{OBJECT_DEVICE,
|
{OBJECT_DEVICE,
|
||||||
@@ -105,7 +106,8 @@ static struct object_functions {
|
|||||||
Device_Read_Property_Local,
|
Device_Read_Property_Local,
|
||||||
Device_Write_Property_Local,
|
Device_Write_Property_Local,
|
||||||
Device_Property_Lists,
|
Device_Property_Lists,
|
||||||
DeviceGetRRInfo},
|
DeviceGetRRInfo,
|
||||||
|
NULL},
|
||||||
{OBJECT_ANALOG_INPUT,
|
{OBJECT_ANALOG_INPUT,
|
||||||
Analog_Input_Init,
|
Analog_Input_Init,
|
||||||
Analog_Input_Count,
|
Analog_Input_Count,
|
||||||
@@ -115,6 +117,7 @@ static struct object_functions {
|
|||||||
Analog_Input_Read_Property,
|
Analog_Input_Read_Property,
|
||||||
NULL,
|
NULL,
|
||||||
Analog_Input_Property_Lists,
|
Analog_Input_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_ANALOG_OUTPUT,
|
{OBJECT_ANALOG_OUTPUT,
|
||||||
Analog_Output_Init,
|
Analog_Output_Init,
|
||||||
@@ -125,6 +128,7 @@ static struct object_functions {
|
|||||||
Analog_Output_Read_Property,
|
Analog_Output_Read_Property,
|
||||||
Analog_Output_Write_Property,
|
Analog_Output_Write_Property,
|
||||||
Analog_Output_Property_Lists,
|
Analog_Output_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_ANALOG_VALUE,
|
{OBJECT_ANALOG_VALUE,
|
||||||
Analog_Value_Init,
|
Analog_Value_Init,
|
||||||
@@ -135,6 +139,7 @@ static struct object_functions {
|
|||||||
Analog_Value_Read_Property,
|
Analog_Value_Read_Property,
|
||||||
Analog_Value_Write_Property,
|
Analog_Value_Write_Property,
|
||||||
Analog_Value_Property_Lists,
|
Analog_Value_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_BINARY_INPUT,
|
{OBJECT_BINARY_INPUT,
|
||||||
Binary_Input_Init,
|
Binary_Input_Init,
|
||||||
@@ -145,6 +150,7 @@ static struct object_functions {
|
|||||||
Binary_Input_Read_Property,
|
Binary_Input_Read_Property,
|
||||||
NULL,
|
NULL,
|
||||||
Binary_Input_Property_Lists,
|
Binary_Input_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_BINARY_OUTPUT,
|
{OBJECT_BINARY_OUTPUT,
|
||||||
Binary_Output_Init,
|
Binary_Output_Init,
|
||||||
@@ -155,6 +161,7 @@ static struct object_functions {
|
|||||||
Binary_Output_Read_Property,
|
Binary_Output_Read_Property,
|
||||||
Binary_Output_Write_Property,
|
Binary_Output_Write_Property,
|
||||||
Binary_Output_Property_Lists,
|
Binary_Output_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_BINARY_VALUE,
|
{OBJECT_BINARY_VALUE,
|
||||||
Binary_Value_Init,
|
Binary_Value_Init,
|
||||||
@@ -165,6 +172,7 @@ static struct object_functions {
|
|||||||
Binary_Value_Read_Property,
|
Binary_Value_Read_Property,
|
||||||
Binary_Value_Write_Property,
|
Binary_Value_Write_Property,
|
||||||
Binary_Value_Property_Lists,
|
Binary_Value_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_LIFE_SAFETY_POINT,
|
{OBJECT_LIFE_SAFETY_POINT,
|
||||||
Life_Safety_Point_Init,
|
Life_Safety_Point_Init,
|
||||||
@@ -175,6 +183,7 @@ static struct object_functions {
|
|||||||
Life_Safety_Point_Read_Property,
|
Life_Safety_Point_Read_Property,
|
||||||
Life_Safety_Point_Write_Property,
|
Life_Safety_Point_Write_Property,
|
||||||
Life_Safety_Point_Property_Lists,
|
Life_Safety_Point_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_LOAD_CONTROL,
|
{OBJECT_LOAD_CONTROL,
|
||||||
Load_Control_Init,
|
Load_Control_Init,
|
||||||
@@ -185,6 +194,7 @@ static struct object_functions {
|
|||||||
Load_Control_Read_Property,
|
Load_Control_Read_Property,
|
||||||
Load_Control_Write_Property,
|
Load_Control_Write_Property,
|
||||||
Load_Control_Property_Lists,
|
Load_Control_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_MULTI_STATE_OUTPUT,
|
{OBJECT_MULTI_STATE_OUTPUT,
|
||||||
Multistate_Output_Init,
|
Multistate_Output_Init,
|
||||||
@@ -195,6 +205,7 @@ static struct object_functions {
|
|||||||
Multistate_Output_Read_Property,
|
Multistate_Output_Read_Property,
|
||||||
Multistate_Output_Write_Property,
|
Multistate_Output_Write_Property,
|
||||||
Multistate_Output_Property_Lists,
|
Multistate_Output_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_MULTI_STATE_INPUT,
|
{OBJECT_MULTI_STATE_INPUT,
|
||||||
Multistate_Input_Init,
|
Multistate_Input_Init,
|
||||||
@@ -205,6 +216,7 @@ static struct object_functions {
|
|||||||
Multistate_Input_Read_Property,
|
Multistate_Input_Read_Property,
|
||||||
Multistate_Input_Write_Property,
|
Multistate_Input_Write_Property,
|
||||||
Multistate_Input_Property_Lists,
|
Multistate_Input_Property_Lists,
|
||||||
|
NULL,
|
||||||
NULL},
|
NULL},
|
||||||
{OBJECT_TRENDLOG,
|
{OBJECT_TRENDLOG,
|
||||||
Trend_Log_Init,
|
Trend_Log_Init,
|
||||||
@@ -215,7 +227,8 @@ static struct object_functions {
|
|||||||
Trend_Log_Read_Property,
|
Trend_Log_Read_Property,
|
||||||
Trend_Log_Write_Property,
|
Trend_Log_Write_Property,
|
||||||
Trend_Log_Property_Lists,
|
Trend_Log_Property_Lists,
|
||||||
TrendLogGetRRInfo},
|
TrendLogGetRRInfo,
|
||||||
|
NULL},
|
||||||
#if defined(BACFILE)
|
#if defined(BACFILE)
|
||||||
{OBJECT_FILE,
|
{OBJECT_FILE,
|
||||||
bacfile_init,
|
bacfile_init,
|
||||||
@@ -225,10 +238,11 @@ static struct object_functions {
|
|||||||
bacfile_name,
|
bacfile_name,
|
||||||
bacfile_read_property,
|
bacfile_read_property,
|
||||||
bacfile_write_property,
|
bacfile_write_property,
|
||||||
BACfile_Property_Lists},
|
BACfile_Property_Lists,
|
||||||
|
NULL},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Glue function to let the Device object, when called by a handler,
|
/** Glue function to let the Device object, when called by a handler,
|
||||||
@@ -840,6 +854,7 @@ bool Device_Object_List_Identifier(
|
|||||||
bool status = false;
|
bool status = false;
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
unsigned object_index = 0;
|
unsigned object_index = 0;
|
||||||
|
unsigned temp_index = 0;
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
|
|
||||||
/* array index zero is length - so invalid */
|
/* array index zero is length - so invalid */
|
||||||
@@ -850,16 +865,30 @@ bool Device_Object_List_Identifier(
|
|||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if (pObject->Object_Count &&
|
if (pObject->Object_Count) {
|
||||||
pObject->Object_Index_To_Instance) {
|
|
||||||
object_index -= count;
|
object_index -= count;
|
||||||
count = pObject->Object_Count();
|
count = pObject->Object_Count();
|
||||||
if (object_index < count) {
|
if (object_index < count) {
|
||||||
*object_type = pObject->Object_Type;
|
/* Use the iterator function if available otherwise
|
||||||
*instance = pObject->Object_Index_To_Instance(object_index);
|
* look for the index to instance to get the ID */
|
||||||
status = true;
|
if(pObject->Object_Iterator) {
|
||||||
break;
|
/* First find the first object */
|
||||||
}
|
temp_index = pObject->Object_Iterator(~0);
|
||||||
|
/* Then step through the objects to find the nth */
|
||||||
|
while(object_index != 0) {
|
||||||
|
temp_index = pObject->Object_Iterator(temp_index);
|
||||||
|
object_index--;
|
||||||
|
}
|
||||||
|
/* set the object_index up before falling through to next bit */
|
||||||
|
object_index = temp_index;
|
||||||
|
}
|
||||||
|
if(pObject->Object_Index_To_Instance) {
|
||||||
|
*object_type = pObject->Object_Type;
|
||||||
|
*instance = pObject->Object_Index_To_Instance(object_index);
|
||||||
|
status = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pObject++;
|
pObject++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,21 @@ typedef bool(
|
|||||||
*object_valid_instance_function) (
|
*object_valid_instance_function) (
|
||||||
uint32_t object_instance);
|
uint32_t object_instance);
|
||||||
|
|
||||||
|
/** Helper function to step through an array of objects and find either the
|
||||||
|
* first one or the next one of a given type. Used to step through an array
|
||||||
|
* of objects which is not necessarily contiguious for each type i.e. the
|
||||||
|
* index for the 'n'th object of a given type is not necessarily 'n'.
|
||||||
|
* @ingroup ObjHelpers
|
||||||
|
* @param [in] The index of the current object or a value of ~0 to indicate
|
||||||
|
* start at the beginning.
|
||||||
|
* @return The index of the next object of the required type or ~0 (all bits
|
||||||
|
* == 1) to indicate no more objects found.
|
||||||
|
*/
|
||||||
|
typedef unsigned (
|
||||||
|
*object_iterate_function)(
|
||||||
|
unsigned current_index);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
Reference in New Issue
Block a user