Indented and cleaned up build. Added Multi-state Output to unit test script.
This commit is contained in:
@@ -46,8 +46,7 @@
|
||||
/* Here is our Priority Array. They are supposed to be Real, but */
|
||||
/* we don't have that kind of memory, so we will use a single byte */
|
||||
/* and load a Real for returning the value when asked. */
|
||||
static uint8_t
|
||||
Analog_Value_Level[MAX_ANALOG_VALUES][BACNET_MAX_PRIORITY];
|
||||
static uint8_t Analog_Value_Level[MAX_ANALOG_VALUES][BACNET_MAX_PRIORITY];
|
||||
/* Writable out-of-service allows others to play with our Present Value */
|
||||
/* without changing the physical output */
|
||||
static bool Analog_Value_Out_Of_Service[MAX_ANALOG_VALUES];
|
||||
@@ -178,8 +177,7 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_OBJECT_TYPE:
|
||||
apdu_len =
|
||||
encode_tagged_enumerated(&apdu[0], OBJECT_ANALOG_VALUE);
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], OBJECT_ANALOG_VALUE);
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
real_value = Analog_Value_Present_Value(object_instance);
|
||||
@@ -212,11 +210,11 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu,
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (array_index == BACNET_ARRAY_ALL) {
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(object_instance);
|
||||
object_index = Analog_Value_Instance_To_Index(object_instance);
|
||||
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||
/* FIXME: check if we have room before adding it to APDU */
|
||||
if (Analog_Value_Level[object_index][i] == ANALOG_LEVEL_NULL)
|
||||
if (Analog_Value_Level[object_index][i] ==
|
||||
ANALOG_LEVEL_NULL)
|
||||
len = encode_tagged_null(&apdu[apdu_len]);
|
||||
else {
|
||||
real_value = Analog_Value_Level[object_index][i];
|
||||
@@ -233,8 +231,7 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(object_instance);
|
||||
object_index = Analog_Value_Instance_To_Index(object_instance);
|
||||
if (array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (Analog_Value_Level[object_index][array_index] ==
|
||||
ANALOG_LEVEL_NULL)
|
||||
@@ -412,5 +409,5 @@ int main(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* TEST_ANALOG_VALUE*/
|
||||
#endif /* TEST_ANALOG_VALUE */
|
||||
#endif /* TEST */
|
||||
|
||||
@@ -190,12 +190,12 @@ int bacfile_encode_property_apdu(uint8_t * apdu,
|
||||
break;
|
||||
case PROP_ARCHIVE:
|
||||
/* 12.13.8 Archive
|
||||
This property, of type BOOLEAN, indicates whether the File
|
||||
object has been saved for historical or backup purposes. This
|
||||
property shall be logical TRUE only if no changes have been
|
||||
made to the file data by internal processes or through File
|
||||
Access Services since the last time the object was archived.
|
||||
*/
|
||||
This property, of type BOOLEAN, indicates whether the File
|
||||
object has been saved for historical or backup purposes. This
|
||||
property shall be logical TRUE only if no changes have been
|
||||
made to the file data by internal processes or through File
|
||||
Access Services since the last time the object was archived.
|
||||
*/
|
||||
/* FIXME: get the actual value: note it may be inverse... */
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], true);
|
||||
break;
|
||||
@@ -231,20 +231,17 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_ARCHIVE:
|
||||
/* 12.13.8 Archive
|
||||
This property, of type BOOLEAN, indicates whether the File
|
||||
object has been saved for historical or backup purposes. This
|
||||
property shall be logical TRUE only if no changes have been
|
||||
made to the file data by internal processes or through File
|
||||
Access Services since the last time the object was archived. */
|
||||
This property, of type BOOLEAN, indicates whether the File
|
||||
object has been saved for historical or backup purposes. This
|
||||
property shall be logical TRUE only if no changes have been
|
||||
made to the file data by internal processes or through File
|
||||
Access Services since the last time the object was archived. */
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
if (wp_data->value.type.Boolean)
|
||||
{
|
||||
/* FIXME: do something to wp_data->object_instance */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: do something to wp_data->object_instance */
|
||||
}
|
||||
if (wp_data->value.type.Boolean) {
|
||||
/* FIXME: do something to wp_data->object_instance */
|
||||
} else {
|
||||
/* FIXME: do something to wp_data->object_instance */
|
||||
}
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
@@ -252,11 +249,11 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
break;
|
||||
case PROP_FILE_SIZE:
|
||||
/* If the file size can be changed by writing to the file,
|
||||
and File_Access_Method is STREAM_ACCESS, then this property
|
||||
shall be writable. */
|
||||
and File_Access_Method is STREAM_ACCESS, then this property
|
||||
shall be writable. */
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
/* FIXME: do something with wp_data->value.type.Unsigned
|
||||
to wp_data->object_instance */
|
||||
/* FIXME: do something with wp_data->value.type.Unsigned
|
||||
to wp_data->object_instance */
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
|
||||
@@ -70,8 +70,8 @@ extern "C" {
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
|
||||
/* handling for write property service */
|
||||
bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -170,8 +170,7 @@ int Binary_Value_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_OBJECT_TYPE:
|
||||
apdu_len =
|
||||
encode_tagged_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
present_value = Binary_Value_Present_Value(object_instance);
|
||||
@@ -206,8 +205,7 @@ int Binary_Value_Encode_Property_APDU(uint8_t * apdu,
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (array_index == BACNET_ARRAY_ALL) {
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(object_instance);
|
||||
object_index = Binary_Value_Instance_To_Index(object_instance);
|
||||
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||
/* FIXME: check if we have room before adding it to APDU */
|
||||
if (Binary_Value_Level[object_index][i] == BINARY_NULL)
|
||||
@@ -229,8 +227,7 @@ int Binary_Value_Encode_Property_APDU(uint8_t * apdu,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(object_instance);
|
||||
object_index = Binary_Value_Instance_To_Index(object_instance);
|
||||
if (array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (Binary_Value_Level[object_index][array_index] ==
|
||||
BINARY_NULL)
|
||||
|
||||
@@ -657,7 +657,8 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
if (Life_Safety_Point_Count())
|
||||
bitstring_set_bit(&bit_string, OBJECT_LIFE_SAFETY_POINT, true);
|
||||
if (Multistate_Output_Count())
|
||||
bitstring_set_bit(&bit_string, OBJECT_MULTI_STATE_OUTPUT, true);
|
||||
bitstring_set_bit(&bit_string, OBJECT_MULTI_STATE_OUTPUT,
|
||||
true);
|
||||
#if BACFILE
|
||||
if (bacfile_count())
|
||||
bitstring_set_bit(&bit_string, OBJECT_FILE, true);
|
||||
|
||||
@@ -109,8 +109,7 @@ unsigned Multistate_Output_Instance_To_Index(uint32_t object_instance)
|
||||
return index;
|
||||
}
|
||||
|
||||
static uint32_t Multistate_Output_Present_Value(uint32_t
|
||||
object_instance)
|
||||
static uint32_t Multistate_Output_Present_Value(uint32_t object_instance)
|
||||
{
|
||||
uint32_t value = MULTISTATE_RELINQUISH_DEFAULT;
|
||||
unsigned index = 0;
|
||||
@@ -162,7 +161,8 @@ int Multistate_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
Multistate_Output_Init();
|
||||
switch (property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
apdu_len = encode_tagged_object_id(&apdu[0], OBJECT_MULTI_STATE_OUTPUT,
|
||||
apdu_len =
|
||||
encode_tagged_object_id(&apdu[0], OBJECT_MULTI_STATE_OUTPUT,
|
||||
object_instance);
|
||||
break;
|
||||
/* note: Name and Description don't have to be the same.
|
||||
@@ -195,7 +195,8 @@ int Multistate_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
object_index = Multistate_Output_Instance_To_Index(object_instance);
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(object_instance);
|
||||
state = Multistate_Output_Out_Of_Service[object_index];
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], state);
|
||||
break;
|
||||
@@ -211,10 +212,12 @@ int Multistate_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
Multistate_Output_Instance_To_Index(object_instance);
|
||||
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||
/* FIXME: check if we have room before adding it to APDU */
|
||||
if (Multistate_Output_Level[object_index][i] == MULTISTATE_NULL)
|
||||
if (Multistate_Output_Level[object_index][i] ==
|
||||
MULTISTATE_NULL)
|
||||
len = encode_tagged_null(&apdu[apdu_len]);
|
||||
else {
|
||||
present_value = Multistate_Output_Level[object_index][i];
|
||||
present_value =
|
||||
Multistate_Output_Level[object_index][i];
|
||||
len =
|
||||
encode_tagged_unsigned(&apdu[apdu_len],
|
||||
present_value);
|
||||
@@ -295,7 +298,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
object. */
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(priority != 6 /* reserved */ ) &&
|
||||
(wp_data->value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
|
||||
(wp_data->value.type.Unsigned_Int <=
|
||||
MULTISTATE_NUMBER_OF_STATES)) {
|
||||
level = wp_data->value.type.Unsigned_Int;
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
@@ -321,7 +325,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
} else if (wp_data->value.tag == BACNET_APPLICATION_TAG_NULL) {
|
||||
level = MULTISTATE_NULL;
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->object_instance);
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
@@ -345,7 +350,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->object_instance);
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Output_Out_Of_Service[object_index] =
|
||||
wp_data->value.type.Boolean;
|
||||
status = true;
|
||||
|
||||
@@ -46,8 +46,9 @@ extern "C" {
|
||||
int32_t array_index,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
|
||||
bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *
|
||||
wp_data, BACNET_ERROR_CLASS * error_class,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
|
||||
Reference in New Issue
Block a user