Added property-list property to Lighting Output and Channel objects (untested). Fixed some compiler warnings.

This commit is contained in:
skarg
2013-11-15 20:51:38 +00:00
parent 80a4cca173
commit 2f0bf7744a
6 changed files with 408 additions and 213 deletions
+14 -17
View File
@@ -42,6 +42,7 @@
#include "config.h" /* the custom stuff */
#include "wp.h"
#include "handlers.h"
#include "proplist.h"
#include "lighting.h"
#include "device.h"
#if defined (CHANNEL_LIGHTING_COMMAND) || defined (BACAPP_LIGHTING_COMMAND)
@@ -74,22 +75,8 @@ struct bacnet_channel_object {
struct bacnet_channel_object Channel[BACNET_CHANNELS_MAX];
/* These three arrays are used by the ReadPropertyMultiple handler */
static const int 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
};
/* These arrays are used by the ReadPropertyMultiple handler
property-list property (as of protocol-revision 14) */
static const int Properties_Optional[] = {
-1
};
@@ -114,7 +101,7 @@ void Channel_Property_Lists(const int **pRequired,
const int **pProprietary)
{
if (pRequired)
*pRequired = Properties_Required;
*pRequired = property_list_required(OBJECT_CHANNEL);
if (pOptional)
*pOptional = Properties_Optional;
if (pProprietary)
@@ -1374,6 +1361,7 @@ int Channel_Read_Property(BACNET_READ_PROPERTY_DATA * rpdata)
bool state = false;
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *pMember = NULL;
uint8_t *apdu = NULL;
const int *pRequired = NULL, *pOptional = NULL, *pProprietary = NULL;
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
@@ -1512,6 +1500,14 @@ int Channel_Read_Property(BACNET_READ_PROPERTY_DATA * rpdata)
}
}
break;
case PROP_PROPERTY_LIST:
Channel_Property_Lists(&pRequired, &pOptional, &pProprietary);
apdu_len = property_list_encode(
rpdata,
pRequired,
pOptional,
pProprietary);
break;
default:
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
@@ -1521,6 +1517,7 @@ int Channel_Read_Property(BACNET_READ_PROPERTY_DATA * rpdata)
/* only array properties can have array options */
if ((apdu_len >= 0)
&& (rpdata->object_property != PROP_PRIORITY_ARRAY)
&& (rpdata->object_property != PROP_PROPERTY_LIST)
&& (rpdata->array_index != BACNET_ARRAY_ALL)) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
+2 -17
View File
@@ -426,21 +426,6 @@ rr_info_function Device_Objects_RR_Info(
return (pObject != NULL ? pObject->Object_RR_Info : NULL);
}
static unsigned property_list_count(
const int *pList)
{
unsigned property_count = 0;
if (pList) {
while (*pList != -1) {
property_count++;
pList++;
}
}
return property_count;
}
/** For a given object type, returns the special property list.
* This function is used for ReadPropertyMultiple calls which want
* just Required, just Optional, or All properties.
@@ -1143,10 +1128,10 @@ int tm_isdst Daylight Savings flag.
*/
#if defined(_MSC_VER)
time(&tTemp);
tblock = localtime(&tTemp);
tblock = (struct tm *)localtime(&tTemp);
#else
if (gettimeofday(&tv, NULL) == 0) {
tblock = localtime(&tv.tv_sec);
tblock = (struct tm *)localtime((const time_t *)&tv.tv_sec);
}
#endif
+16 -18
View File
@@ -39,6 +39,7 @@
#include "wp.h"
#include "lighting.h"
#include "handlers.h"
#include "proplist.h"
/* me! */
#include "lo.h"
@@ -72,21 +73,8 @@ struct lighting_output_object {
};
struct lighting_output_object Lighting_Output[MAX_LIGHTING_OUTPUTS];
/* These three arrays are used by the ReadPropertyMultiple handler */
static const int 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
};
/* These arrays are used by the ReadPropertyMultiple handler and
property-list property (as of protocol-revision 14) */
static const int Properties_Optional[] = {
-1
};
@@ -112,7 +100,7 @@ void Lighting_Output_Property_Lists(
const int **pProprietary)
{
if (pRequired)
*pRequired = Properties_Required;
*pRequired = property_list_required(OBJECT_LIGHTING_OUTPUT);
if (pOptional)
*pOptional = Properties_Optional;
if (pProprietary)
@@ -963,6 +951,7 @@ int Lighting_Output_Read_Property(
unsigned i = 0;
bool state = false;
uint8_t *apdu = NULL;
const int *pRequired = NULL, *pOptional = NULL, *pProprietary = NULL;
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
@@ -1051,12 +1040,12 @@ int Lighting_Output_Read_Property(
break;
case PROP_PRIORITY_ARRAY:
/* Array element zero is the number of elements in the array */
if (rpdata->array_index == 0)
if (rpdata->array_index == 0) {
apdu_len =
encode_application_unsigned(&apdu[0], BACNET_MAX_PRIORITY);
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
} else if (rpdata->array_index == BACNET_ARRAY_ALL) {
for (i = 1; i <= BACNET_MAX_PRIORITY; i++) {
if (Lighting_Output_Priority_Active(
rpdata->object_instance, i)) {
@@ -1110,6 +1099,14 @@ int Lighting_Output_Read_Property(
apdu_len = encode_application_unsigned(&apdu[0],
unsigned_value);
break;
case PROP_PROPERTY_LIST:
Lighting_Output_Property_Lists(&pRequired, &pOptional, &pProprietary);
apdu_len = property_list_encode(
rpdata,
pRequired,
pOptional,
pProprietary);
break;
default:
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
@@ -1118,6 +1115,7 @@ int Lighting_Output_Read_Property(
}
/* only array properties can have array options */
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
(rpdata->object_property != PROP_PROPERTY_LIST) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;