Adding ReadPropertyMultiple handler (thank you to John Stachler for this contribution!). Untested and not finished integrating with the demos.

This commit is contained in:
skarg
2007-07-17 00:21:31 +00:00
parent 5e68e165f5
commit b952a54966
3 changed files with 547 additions and 0 deletions
+133
View File
@@ -47,6 +47,45 @@
#include "bacfile.h" /* object list dependency */
#endif
/* These three arrays are used by the ReadPropertyMultiple handler */
static int Device_Properties_Required[] =
{
PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME,
PROP_OBJECT_TYPE,
PROP_SYSTEM_STATUS,
PROP_VENDOR_NAME,
PROP_VENDOR_IDENTIFIER,
PROP_MODEL_NAME,
PROP_FIRMWARE_REVISION,
PROP_APPLICATION_SOFTWARE_VERSION,
PROP_DESCRIPTION,
PROP_PROTOCOL_VERSION,
PROP_PROTOCOL_REVISION,
PROP_PROTOCOL_SERVICES_SUPPORTED,
PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED,
PROP_OBJECT_LIST,
PROP_MAX_APDU_LENGTH_ACCEPTED,
PROP_SEGMENTATION_SUPPORTED,
PROP_APDU_TIMEOUT,
PROP_NUMBER_OF_APDU_RETRIES,
PROP_MAX_MASTER,
PROP_MAX_INFO_FRAMES,
PROP_DEVICE_ADDRESS_BINDING,
PROP_DATABASE_REVISION,
-1
};
static int Device_Properties_Optional[] =
{
-1
};
static int Device_Properties_Proprietary[] =
{
-1
};
/* note: you really only need to define variables for
properties that are writable or that may change.
The properties that are constant can be hard coded
@@ -900,6 +939,100 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
return status;
}
int int_list_count(const int *pList)
{
int property_count = 0;
while (*pList != -1) {
property_count++;
}
return property_count;
}
/* used to count the ALL, REQUIRED and OPTIONAL */
int Device_Special_Property_Count(BACNET_PROPERTY_ID special_property)
{
const int *pList = NULL;
int property_count = 0;
if (special_property == PROP_ALL) {
property_count =
int_list_count(Device_Properties_Required);
property_count +=
int_list_count(Device_Properties_Optional);
property_count +=
int_list_count(Device_Properties_Proprietary);
} else if (special_property == PROP_REQUIRED) {
property_count =
int_list_count(Device_Properties_Required);
} else if (special_property == PROP_OPTIONAL) {
property_count =
int_list_count(Device_Properties_Optional);
}
return property_count;
}
/* returns the property ID given by the index into the list
or MAX_BACNET_PROPERTY_ID if not found or out of bounds */
BACNET_PROPERTY_ID Device_Special_Property_By_Index(
BACNET_PROPERTY_ID special_property, /* ALL, OPTIONAL, REQUIRED */
int index)
{
BACNET_PROPERTY_ID property = MAX_BACNET_PROPERTY_ID;
int required = 0, optional = 0, proprietary = 0;
/* FIXME: we could use static vars to speed up access */
if (special_property == PROP_ALL) {
required =
property_list_count(Device_Properties_Required);
optional =
property_list_count(Device_Properties_Optional);
proprietary =
property_list_count(Device_Properties_Proprietary);
if (index < required) {
property = Device_Properties_Required[index];
} else if (index < (required + optional)) {
property = Device_Properties_Optional[index];
} else if (index < (required + optional + proprietary)) {
property = Device_Properties_Proprietary[index];
}
} else if (special_property == PROP_REQUIRED) {
required =
property_list_count(Device_Properties_Required);
if (index < required) {
property = Device_Properties_Required[index];
}
} else if (special_property == PROP_OPTIONAL) {
optional =
property_list_count(Device_Properties_Optional);
if (index < optional) {
property = Device_Properties_Optional[index];
}
}
return property;
}
/* added for rpm service support when requesting prop_all,
prop_required, or prop_optional */
bool Device_Property(uint8 *pIndex, BACNET_PROPERTY_ID *pProperty, BACNET_PROPERTY_ID special_property)
{
bool result = false;
BACNET_PROPERTY_ID property;
property = Device_Special_Property_By_Index(
special_property, *pIndex);
if (property != MAX_BACNET_PROPERTY_ID) {
(*pIndex)++;
*pProperty = property;
result = true;
}
return result;
}
#ifdef TEST
#include <assert.h>
#include <string.h>
+14
View File
@@ -104,6 +104,20 @@ extern "C" {
bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
/* support for RPM */
int Device_Special_Property_Count(BACNET_PROPERTY_ID special_property);
/* returns the property ID given by the index into the list
or MAX_BACNET_PROPERTY_ID if not found or out of bounds */
BACNET_PROPERTY_ID Device_Special_Property_By_Index(
BACNET_PROPERTY_ID special_property, /* ALL, OPTIONAL, REQUIRED */
int index);
bool Device_Property(uint8 *pIndex, BACNET_PROPERTY_ID *pProperty,
BACNET_PROPERTY_ID special_property);
#ifdef __cplusplus
}
#endif /* __cplusplus */