Integrated ReadPropertyMultiple with the demo/server application. Compiles, but untested.
This commit is contained in:
@@ -35,6 +35,49 @@
|
||||
|
||||
#define MAX_ANALOG_INPUTS 7
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Analog_Input_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_UNITS,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Analog_Input_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Analog_Input_Properties_Proprietary[] =
|
||||
{
|
||||
9997,
|
||||
9998,
|
||||
9999,
|
||||
-1
|
||||
};
|
||||
|
||||
void Analog_Input_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Analog_Input_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Analog_Input_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Analog_Input_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need validate that the */
|
||||
/* given instance exists */
|
||||
|
||||
@@ -32,7 +32,10 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Analog_Input_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Analog_Input_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Analog_Input_Count(void);
|
||||
uint32_t Analog_Input_Index_To_Instance(unsigned index);
|
||||
|
||||
@@ -56,6 +56,48 @@ static bool Analog_Output_Out_Of_Service[MAX_ANALOG_OUTPUTS];
|
||||
/* we need to have our arrays initialized before answering any calls */
|
||||
static bool Analog_Output_Initialized = false;
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Analog_Output_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_UNITS,
|
||||
PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Analog_Output_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Analog_Output_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Analog_Output_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Analog_Output_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Analog_Output_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Analog_Output_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Analog_Output_Init(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
@@ -172,8 +214,8 @@ bool Analog_Output_Present_Value_Set(uint32_t object_instance,
|
||||
/* Note: you could set the physical output here to the next
|
||||
highest priority, or to the relinquish default if no
|
||||
priorities are set.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
}
|
||||
@@ -196,8 +238,8 @@ bool Analog_Output_Present_Value_Relinquish(uint32_t object_instance,
|
||||
/* Note: you could set the physical output here to the next
|
||||
highest priority, or to the relinquish default if no
|
||||
priorities are set.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Analog_Output_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Analog_Output_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Analog_Output_Count(void);
|
||||
uint32_t Analog_Output_Index_To_Instance(unsigned index);
|
||||
|
||||
@@ -55,6 +55,48 @@ static bool Analog_Value_Out_Of_Service[MAX_ANALOG_VALUES];
|
||||
/* we need to have our arrays initialized before answering any calls */
|
||||
static bool Analog_Value_Initialized = false;
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Analog_Value_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_UNITS,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Analog_Value_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Analog_Value_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Analog_Value_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Analog_Value_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Analog_Value_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Analog_Value_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Analog_Value_Init(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
@@ -304,8 +346,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
Analog_Value_Level[object_index][priority] = level;
|
||||
/* Note: you could set the physical output here if we
|
||||
are the highest priority.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
} else if (priority == 6) {
|
||||
@@ -329,8 +371,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
/* Note: you could set the physical output here to the next
|
||||
highest priority, or to the relinquish default if no
|
||||
priorities are set.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,10 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Analog_Value_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Analog_Value_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Analog_Value_Count(void);
|
||||
uint32_t Analog_Value_Index_To_Instance(unsigned index);
|
||||
|
||||
@@ -52,6 +52,48 @@ static BACNET_FILE_LISTING BACnet_File_Listing[] = {
|
||||
{0, NULL} /* last file indication */
|
||||
};
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int bacfile_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_FILE_TYPE,
|
||||
PROP_FILE_SIZE,
|
||||
PROP_MODIFICATION_DATE,
|
||||
PROP_ARCHIVE,
|
||||
PROP_READ_ONLY,
|
||||
PROP_FILE_ACCESS_METHOD,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int bacfile_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int bacfile_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void BACfile_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = bacfile_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = bacfile_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = bacfile_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char *bacfile_name(uint32_t instance)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
@@ -393,7 +435,7 @@ bool bacfile_write_stream_data(BACNET_ATOMIC_WRITE_FILE_DATA * data)
|
||||
(void)fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
|
||||
if (fwrite(octetstring_value(&data->fileData),
|
||||
octetstring_length(&data->fileData),1,pFile) != 1) {
|
||||
|
||||
|
||||
}
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void BACfile_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
char *bacfile_name(uint32_t instance);
|
||||
bool bacfile_valid_instance(uint32_t object_instance);
|
||||
uint32_t bacfile_count(void);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
/* Analog Input Objects customize for your use */
|
||||
/* Binary Input Objects customize for your use */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -37,6 +37,46 @@
|
||||
|
||||
static BACNET_BINARY_PV Present_Value[MAX_BINARY_INPUTS];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Binary_Input_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_POLARITY,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Input_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Input_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Binary_Input_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Binary_Input_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Binary_Input_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Binary_Input_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need validate that the */
|
||||
/* given instance exists */
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Binary_Input_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Binary_Input_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Binary_Input_Count(void);
|
||||
uint32_t Binary_Input_Index_To_Instance(unsigned index);
|
||||
|
||||
@@ -47,6 +47,48 @@ static BACNET_BINARY_PV
|
||||
/* without changing the physical output */
|
||||
static bool Binary_Output_Out_Of_Service[MAX_BINARY_OUTPUTS];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Binary_Output_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_POLARITY,
|
||||
PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Output_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Output_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Binary_Output_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Binary_Output_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Binary_Output_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Binary_Output_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Binary_Output_Init(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Binary_Output_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Binary_Output_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Binary_Output_Count(void);
|
||||
uint32_t Binary_Output_Index_To_Instance(unsigned index);
|
||||
|
||||
@@ -47,6 +47,47 @@ static BACNET_BINARY_PV
|
||||
/* without changing the physical output */
|
||||
static bool Binary_Value_Out_Of_Service[MAX_BINARY_VALUES];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Binary_Value_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Value_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Value_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Binary_Value_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Binary_Value_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Binary_Value_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Binary_Value_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Binary_Value_Init(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
@@ -195,9 +236,6 @@ int Binary_Value_Encode_Property_APDU(uint8_t * apdu,
|
||||
state = Binary_Value_Out_Of_Service[object_index];
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], polarity);
|
||||
break;
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
/* Array element zero is the number of elements in the array */
|
||||
if (array_index == 0)
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Binary_Value_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Binary_Value_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Binary_Value_Count(void);
|
||||
uint32_t Binary_Value_Index_To_Instance(unsigned index);
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#endif
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static int Device_Properties_Required[] =
|
||||
static const int Device_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
@@ -76,7 +76,7 @@ static int Device_Properties_Required[] =
|
||||
-1
|
||||
};
|
||||
|
||||
static int Device_Properties_Optional[] =
|
||||
static const int Device_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
PROP_LOCAL_TIME,
|
||||
@@ -87,11 +87,26 @@ static int Device_Properties_Optional[] =
|
||||
-1
|
||||
};
|
||||
|
||||
static int Device_Properties_Proprietary[] =
|
||||
static const int Device_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Device_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Device_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Device_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Device_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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
|
||||
@@ -945,100 +960,6 @@ 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>
|
||||
|
||||
@@ -44,6 +44,11 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Device_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
|
||||
uint32_t Device_Object_Instance_Number(void);
|
||||
bool Device_Set_Object_Instance_Number(uint32_t object_id);
|
||||
bool Device_Valid_Object_Instance_Number(uint32_t object_id);
|
||||
@@ -76,7 +81,7 @@ extern "C" {
|
||||
const char *Device_Location(void);
|
||||
bool Device_Set_Location(const char *name, size_t length);
|
||||
|
||||
/* some stack-centric constant values - no set methods */
|
||||
/* some stack-centric constant values - no set methods */
|
||||
uint8_t Device_Protocol_Version(void);
|
||||
uint8_t Device_Protocol_Revision(void);
|
||||
uint16_t Device_Max_APDU_Length_Accepted(void);
|
||||
@@ -104,20 +109,6 @@ 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 */
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*********************************************************************/
|
||||
|
||||
/* Load Control Objects - customize for your use */
|
||||
/* from 135-2004-Addendum e */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -105,20 +106,20 @@ static bool Start_Time_Property_Written[MAX_LOAD_CONTROLS];
|
||||
static float Full_Duty_Baseline[MAX_LOAD_CONTROLS];
|
||||
|
||||
#define MAX_SHED_LEVELS 3
|
||||
/* Represents the shed levels for the LEVEL choice of
|
||||
BACnetShedLevel that have meaning for this particular
|
||||
/* Represents the shed levels for the LEVEL choice of
|
||||
BACnetShedLevel that have meaning for this particular
|
||||
Load Control object. */
|
||||
/* The elements of the array are required to be writable,
|
||||
allowing local configuration of how this Load Control
|
||||
/* The elements of the array are required to be writable,
|
||||
allowing local configuration of how this Load Control
|
||||
object will participate in load shedding for the
|
||||
facility. This array is not required to be resizable
|
||||
through BACnet write services. The size of this array
|
||||
shall be equal to the size of the Shed_Level_Descriptions
|
||||
array. The behavior of this object when the Shed_Levels
|
||||
facility. This array is not required to be resizable
|
||||
through BACnet write services. The size of this array
|
||||
shall be equal to the size of the Shed_Level_Descriptions
|
||||
array. The behavior of this object when the Shed_Levels
|
||||
array contains duplicate entries is a local matter. */
|
||||
static unsigned Shed_Levels[MAX_LOAD_CONTROLS][MAX_SHED_LEVELS];
|
||||
|
||||
/* represents a description of the shed levels that the
|
||||
/* represents a description of the shed levels that the
|
||||
Load Control object can take on. It is the same for
|
||||
all the load control objects in this example device. */
|
||||
static char *Shed_Level_Descriptions[MAX_SHED_LEVELS] = {
|
||||
@@ -136,6 +137,54 @@ static float Shed_Level_Values[MAX_SHED_LEVELS] = {
|
||||
/* we need to have our arrays initialized before answering any calls */
|
||||
static bool Load_Control_Initialized = false;
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Load_Control_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_REQUESTED_SHED_LEVEL,
|
||||
PROP_START_TIME,
|
||||
PROP_SHED_DURATION,
|
||||
PROP_DUTY_WINDOW,
|
||||
PROP_ENABLE,
|
||||
PROP_EXPECTED_SHED_LEVEL,
|
||||
PROP_ACTUAL_SHED_LEVEL,
|
||||
PROP_SHED_LEVELS,
|
||||
PROP_SHED_LEVEL_DESCRIPTIONS,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Load_Control_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
PROP_FULL_DUTY_BASELINE,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Load_Control_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Load_Control_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Load_Control_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Load_Control_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Load_Control_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Load_Control_Init(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
@@ -673,15 +722,15 @@ int Load_Control_Encode_Property_APDU(uint8_t * apdu,
|
||||
break;
|
||||
case PROP_STATUS_FLAGS:
|
||||
bitstring_init(&bit_string);
|
||||
/* IN_ALARM - Logical FALSE (0) if the Event_State property
|
||||
/* IN_ALARM - Logical FALSE (0) if the Event_State property
|
||||
has a value of NORMAL, otherwise logical TRUE (1). */
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
/* FAULT - Logical TRUE (1) if the Reliability property is
|
||||
present and does not have a value of NO_FAULT_DETECTED,
|
||||
/* FAULT - Logical TRUE (1) if the Reliability property is
|
||||
present and does not have a value of NO_FAULT_DETECTED,
|
||||
otherwise logical FALSE (0). */
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
/* OVERRIDDEN - Logical TRUE (1) if the point has been
|
||||
overridden by some mechanism local to the BACnet Device,
|
||||
/* OVERRIDDEN - Logical TRUE (1) if the point has been
|
||||
overridden by some mechanism local to the BACnet Device,
|
||||
otherwise logical FALSE (0). */
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
/* OUT_OF_SERVICE - This bit shall always be Logical FALSE (0). */
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Load_Control_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
void Load_Control_State_Machine_Handler(void);
|
||||
|
||||
bool Load_Control_Valid_Instance(uint32_t object_instance);
|
||||
|
||||
@@ -50,6 +50,50 @@ static BACNET_LIFE_SAFETY_OPERATION
|
||||
/* without changing the physical output */
|
||||
static bool Life_Safety_Point_Out_Of_Service[MAX_LIFE_SAFETY_POINTS];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Life_Safety_Point_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_RELIABILITY,
|
||||
PROP_MODE,
|
||||
PROP_ACCEPTED_MODES,
|
||||
PROP_SILENCED,
|
||||
PROP_OPERATION_EXPECTED,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Life_Safety_Point_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Life_Safety_Point_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Life_Safety_Point_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Life_Safety_Point_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Life_Safety_Point_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Life_Safety_Point_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Life_Safety_Point_Init(void)
|
||||
{
|
||||
static bool initialized = false;
|
||||
@@ -159,7 +203,7 @@ int Life_Safety_Point_Encode_Property_APDU(uint8_t * apdu,
|
||||
unsigned object_index = 0;
|
||||
bool state = false;
|
||||
BACNET_RELIABILITY reliability = RELIABILITY_NO_FAULT_DETECTED;
|
||||
|
||||
|
||||
(void) array_index; /* currently not used */
|
||||
Life_Safety_Point_Init();
|
||||
switch (property) {
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Life_Safety_Point_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Life_Safety_Point_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Life_Safety_Point_Count(void);
|
||||
uint32_t Life_Safety_Point_Index_To_Instance(unsigned index);
|
||||
|
||||
@@ -52,6 +52,48 @@ static uint8_t
|
||||
/* without changing the physical output */
|
||||
static bool Multistate_Output_Out_Of_Service[MAX_MULTISTATE_OUTPUTS];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Multistate_Output_Properties_Required[] =
|
||||
{
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_NUMBER_OF_STATES,
|
||||
PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Multistate_Output_Properties_Optional[] =
|
||||
{
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Multistate_Output_Properties_Proprietary[] =
|
||||
{
|
||||
-1
|
||||
};
|
||||
|
||||
void Multistate_Output_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
{
|
||||
if (*pRequired)
|
||||
*pRequired = Multistate_Output_Properties_Required;
|
||||
if (*pOptional)
|
||||
*pOptional = Multistate_Output_Properties_Optional;
|
||||
if (*pProprietary)
|
||||
*pProprietary = Multistate_Output_Properties_Proprietary;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Multistate_Output_Init(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
@@ -315,8 +357,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
(uint8_t) level;
|
||||
/* Note: you could set the physical output here if we
|
||||
are the highest priority.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
} else if (priority == 6) {
|
||||
@@ -342,8 +384,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
/* Note: you could set the physical output here to the next
|
||||
highest priority, or to the relinquish default if no
|
||||
priorities are set.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
} else {
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void Multistate_Output_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
bool Multistate_Output_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Multistate_Output_Count(void);
|
||||
uint32_t Multistate_Output_Index_To_Instance(unsigned index);
|
||||
|
||||
Reference in New Issue
Block a user