added channel object to proplist. Added unit test to proplist.
This commit is contained in:
@@ -42,6 +42,13 @@ extern "C" {
|
|||||||
void property_list_special(
|
void property_list_special(
|
||||||
BACNET_OBJECT_TYPE object_type,
|
BACNET_OBJECT_TYPE object_type,
|
||||||
struct special_property_list_t *pPropertyList);
|
struct special_property_list_t *pPropertyList);
|
||||||
|
BACNET_PROPERTY_ID property_list_special_property(
|
||||||
|
BACNET_OBJECT_TYPE object_type,
|
||||||
|
BACNET_PROPERTY_ID special_property,
|
||||||
|
unsigned index);
|
||||||
|
unsigned property_list_special_count(
|
||||||
|
BACNET_OBJECT_TYPE object_type,
|
||||||
|
BACNET_PROPERTY_ID special_property);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
+139
-3
@@ -408,6 +408,30 @@ static const int Calendar_Properties_Optional[] = {
|
|||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int Channel_Properties_Required[] = {
|
||||||
|
PROP_OBJECT_IDENTIFIER,
|
||||||
|
PROP_OBJECT_NAME,
|
||||||
|
PROP_OBJECT_TYPE,
|
||||||
|
PROP_PRESENT_VALUE,
|
||||||
|
PROP_LAST_PRIORITY,
|
||||||
|
PROP_WRITE_STATUS,
|
||||||
|
PROP_STATUS_FLAGS,
|
||||||
|
PROP_OUT_OF_SERVICE,
|
||||||
|
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES,
|
||||||
|
PROP_CHANNEL_NUMBER,
|
||||||
|
PROP_CONTROL_GROUPS,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int Channel_Properties_Optional[] = {
|
||||||
|
PROP_DESCRIPTION,
|
||||||
|
PROP_RELIABILITY,
|
||||||
|
PROP_EXECUTION_DELAY,
|
||||||
|
PROP_ALLOW_GROUP_DELAY_INHIBIT,
|
||||||
|
PROP_PROFILE_NAME,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
static const int Command_Properties_Required[] = {
|
static const int Command_Properties_Required[] = {
|
||||||
PROP_OBJECT_IDENTIFIER,
|
PROP_OBJECT_IDENTIFIER,
|
||||||
PROP_OBJECT_NAME,
|
PROP_OBJECT_NAME,
|
||||||
@@ -698,7 +722,11 @@ static const int File_Properties_Optional[] = {
|
|||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Function that returns the number of properties in a list
|
/**
|
||||||
|
* Function that returns the number of BACnet object properties in a list
|
||||||
|
*
|
||||||
|
* @param pList - array of type 'int' that is a list of BACnet object
|
||||||
|
* properties, terminated by a '-1' value.
|
||||||
*/
|
*/
|
||||||
unsigned property_list_count(
|
unsigned property_list_count(
|
||||||
const int *pList)
|
const int *pList)
|
||||||
@@ -715,8 +743,14 @@ unsigned property_list_count(
|
|||||||
return property_count;
|
return property_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function that returns the list of Required or Optional properties
|
/**
|
||||||
|
* Function that returns the list of Required or Optional properties
|
||||||
* of known standard objects.
|
* of known standard objects.
|
||||||
|
*
|
||||||
|
* @param object_type - enumerated BACNET_OBJECT_TYPE
|
||||||
|
* @param pPropertyList - returns a pointer to two '-1' terminated arrays of
|
||||||
|
* type 'int' that contain BACnet object properties for the given object
|
||||||
|
* type.
|
||||||
*/
|
*/
|
||||||
void property_list_special(
|
void property_list_special(
|
||||||
BACNET_OBJECT_TYPE object_type,
|
BACNET_OBJECT_TYPE object_type,
|
||||||
@@ -768,6 +802,10 @@ void property_list_special(
|
|||||||
pPropertyList->Required.pList = Calendar_Properties_Required;
|
pPropertyList->Required.pList = Calendar_Properties_Required;
|
||||||
pPropertyList->Optional.pList = Calendar_Properties_Optional;
|
pPropertyList->Optional.pList = Calendar_Properties_Optional;
|
||||||
break;
|
break;
|
||||||
|
case OBJECT_CHANNEL:
|
||||||
|
pPropertyList->Required.pList = Channel_Properties_Required;
|
||||||
|
pPropertyList->Optional.pList = Channel_Properties_Optional;
|
||||||
|
break;
|
||||||
case OBJECT_COMMAND:
|
case OBJECT_COMMAND:
|
||||||
pPropertyList->Required.pList = Command_Properties_Required;
|
pPropertyList->Required.pList = Command_Properties_Required;
|
||||||
pPropertyList->Optional.pList = Command_Properties_Optional;
|
pPropertyList->Optional.pList = Command_Properties_Optional;
|
||||||
@@ -851,6 +889,8 @@ void property_list_special(
|
|||||||
case OBJECT_POSITIVE_INTEGER_VALUE:
|
case OBJECT_POSITIVE_INTEGER_VALUE:
|
||||||
case OBJECT_TIME_PATTERN_VALUE:
|
case OBJECT_TIME_PATTERN_VALUE:
|
||||||
case OBJECT_TIME_VALUE:
|
case OBJECT_TIME_VALUE:
|
||||||
|
case OBJECT_NOTIFICATION_FORWARDER:
|
||||||
|
case OBJECT_ALERT_ENROLLMENT:
|
||||||
pPropertyList->Required.pList = Default_Properties_Required;
|
pPropertyList->Required.pList = Default_Properties_Required;
|
||||||
pPropertyList->Optional.pList = NULL;
|
pPropertyList->Optional.pList = NULL;
|
||||||
pPropertyList->Proprietary.pList = NULL;
|
pPropertyList->Proprietary.pList = NULL;
|
||||||
@@ -876,6 +916,73 @@ void property_list_special(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BACNET_PROPERTY_ID property_list_special_property(
|
||||||
|
BACNET_OBJECT_TYPE object_type,
|
||||||
|
BACNET_PROPERTY_ID special_property,
|
||||||
|
unsigned index)
|
||||||
|
{
|
||||||
|
int property = -1; /* return value */
|
||||||
|
unsigned required, optional, proprietary;
|
||||||
|
struct special_property_list_t PropertyList = {{0}};
|
||||||
|
|
||||||
|
property_list_special(object_type, &PropertyList);
|
||||||
|
required = PropertyList.Required.count;
|
||||||
|
optional = PropertyList.Optional.count;
|
||||||
|
proprietary = PropertyList.Proprietary.count;
|
||||||
|
if (special_property == PROP_ALL) {
|
||||||
|
if (index < required) {
|
||||||
|
if (PropertyList.Required.pList) {
|
||||||
|
property = PropertyList.Required.pList[index];
|
||||||
|
}
|
||||||
|
} else if (index < (required + optional)) {
|
||||||
|
if (PropertyList.Optional.pList) {
|
||||||
|
index -= required;
|
||||||
|
property = PropertyList.Optional.pList[index];
|
||||||
|
}
|
||||||
|
} else if (index < (required + optional + proprietary)) {
|
||||||
|
if (PropertyList.Proprietary.pList) {
|
||||||
|
index -= (required + optional);
|
||||||
|
property = PropertyList.Proprietary.pList[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (special_property == PROP_REQUIRED) {
|
||||||
|
if (index < required) {
|
||||||
|
if (PropertyList.Required.pList) {
|
||||||
|
property = PropertyList.Required.pList[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (special_property == PROP_OPTIONAL) {
|
||||||
|
if (index < optional) {
|
||||||
|
if (PropertyList.Optional.pList) {
|
||||||
|
property = PropertyList.Optional.pList[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (BACNET_PROPERTY_ID) property;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned property_list_special_count(
|
||||||
|
BACNET_OBJECT_TYPE object_type,
|
||||||
|
BACNET_PROPERTY_ID special_property)
|
||||||
|
{
|
||||||
|
unsigned count = 0; /* return value */
|
||||||
|
struct special_property_list_t PropertyList = {{0}};
|
||||||
|
|
||||||
|
property_list_special(object_type, &PropertyList);
|
||||||
|
if (special_property == PROP_ALL) {
|
||||||
|
count =
|
||||||
|
PropertyList.Required.count + PropertyList.Optional.count +
|
||||||
|
PropertyList.Proprietary.count;
|
||||||
|
} else if (special_property == PROP_REQUIRED) {
|
||||||
|
count = PropertyList.Required.count;
|
||||||
|
} else if (special_property == PROP_OPTIONAL) {
|
||||||
|
count = PropertyList.Optional.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -884,7 +991,36 @@ void property_list_special(
|
|||||||
void testPropList(
|
void testPropList(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
ct_test(pTest, 0);
|
unsigned i = 0, j = 0;
|
||||||
|
unsigned count = 0;
|
||||||
|
BACNET_PROPERTY_ID property = MAX_BACNET_PROPERTY_ID;
|
||||||
|
unsigned object_id = 0, object_name = 0, object_type = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < PROPRIETARY_BACNET_OBJECT_TYPE; i++) {
|
||||||
|
count = property_list_special_count((BACNET_OBJECT_TYPE)i, PROP_ALL);
|
||||||
|
ct_test(pTest, count >= 3);
|
||||||
|
object_id = 0;
|
||||||
|
object_name = 0;
|
||||||
|
object_type = 0;
|
||||||
|
for (j = 0; j < count; j++) {
|
||||||
|
property = property_list_special_property(
|
||||||
|
(BACNET_OBJECT_TYPE)i,
|
||||||
|
PROP_ALL,
|
||||||
|
j);
|
||||||
|
if (property == PROP_OBJECT_TYPE) {
|
||||||
|
object_type++;
|
||||||
|
}
|
||||||
|
if (property == PROP_OBJECT_IDENTIFIER) {
|
||||||
|
object_id++;
|
||||||
|
}
|
||||||
|
if (property == PROP_OBJECT_NAME) {
|
||||||
|
object_name++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ct_test(pTest, object_type == 1);
|
||||||
|
ct_test(pTest, object_id == 1);
|
||||||
|
ct_test(pTest, object_name == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_PROPLIST
|
#ifdef TEST_PROPLIST
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ LOGFILE = test.log
|
|||||||
|
|
||||||
all: abort address arf awf bacapp bacdcode bacerror bacint bacstr \
|
all: abort address arf awf bacapp bacdcode bacerror bacint bacstr \
|
||||||
cov crc datetime dcc event filename fifo getevent iam ihave \
|
cov crc datetime dcc event filename fifo getevent iam ihave \
|
||||||
indtext keylist key memcopy npdu ptransfer \
|
indtext keylist key memcopy npdu proplist ptransfer \
|
||||||
rd reject ringbuf rp rpm sbuf timesync \
|
rd reject ringbuf rp rpm sbuf timesync \
|
||||||
whohas whois wp objects
|
whohas whois wp objects
|
||||||
|
|
||||||
@@ -141,6 +141,11 @@ npdu: logfile test/npdu.mak
|
|||||||
( ./test/npdu >> ${LOGFILE} )
|
( ./test/npdu >> ${LOGFILE} )
|
||||||
$(MAKE) -s -C test -f npdu.mak clean
|
$(MAKE) -s -C test -f npdu.mak clean
|
||||||
|
|
||||||
|
proplist: logfile test/proplist.mak
|
||||||
|
$(MAKE) -s -C test -f proplist.mak clean all
|
||||||
|
( ./test/proplist >> ${LOGFILE} )
|
||||||
|
$(MAKE) -s -C test -f proplist.mak clean
|
||||||
|
|
||||||
ptransfer: logfile test/ptransfer.mak
|
ptransfer: logfile test/ptransfer.mak
|
||||||
$(MAKE) -s -C test -f ptransfer.mak clean all
|
$(MAKE) -s -C test -f ptransfer.mak clean all
|
||||||
( ./test/ptransfer >> ${LOGFILE} )
|
( ./test/ptransfer >> ${LOGFILE} )
|
||||||
|
|||||||
Reference in New Issue
Block a user