Added additional BACnet demo object API (header files) for various properties. Updated demo objects to compile cleanly with the updated API.
This commit is contained in:
@@ -118,6 +118,19 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
bool oos_flag);
|
||||
|
||||
bool Analog_Input_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
void Analog_Input_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
bool Analog_Input_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list);
|
||||
float Analog_Input_COV_Increment(
|
||||
uint32_t instance);
|
||||
void Analog_Input_COV_Increment_Set(
|
||||
uint32_t instance,
|
||||
float value);
|
||||
|
||||
/* note: header of Intrinsic_Reporting function is required
|
||||
even when INTRINSIC_REPORTING is not defined */
|
||||
void Analog_Input_Intrinsic_Reporting(
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
static uint8_t Analog_Output_Level[MAX_ANALOG_OUTPUTS][BACNET_MAX_PRIORITY];
|
||||
/* Writable out-of-service allows others to play with our Present Value */
|
||||
/* without changing the physical output */
|
||||
static bool Analog_Output_Out_Of_Service[MAX_ANALOG_OUTPUTS];
|
||||
static bool Out_Of_Service[MAX_ANALOG_OUTPUTS];
|
||||
|
||||
/* we need to have our arrays initialized before answering any calls */
|
||||
static bool Analog_Output_Initialized = false;
|
||||
@@ -268,6 +268,32 @@ bool Analog_Output_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Analog_Output_Out_Of_Service(
|
||||
uint32_t instance)
|
||||
{
|
||||
unsigned index = 0;
|
||||
bool oos_flag = false;
|
||||
|
||||
index = Analog_Output_Instance_To_Index(instance);
|
||||
if (index < MAX_ANALOG_OUTPUTS) {
|
||||
oos_flag = Out_Of_Service[index];
|
||||
}
|
||||
|
||||
return oos_flag;
|
||||
}
|
||||
|
||||
void Analog_Output_Out_Of_Service_Set(
|
||||
uint32_t instance,
|
||||
bool oos_flag)
|
||||
{
|
||||
unsigned index = 0;
|
||||
|
||||
index = Analog_Output_Instance_To_Index(instance);
|
||||
if (index < MAX_ANALOG_OUTPUTS) {
|
||||
Out_Of_Service[index] = oos_flag;
|
||||
}
|
||||
}
|
||||
|
||||
/* return apdu len, or BACNET_STATUS_ERROR on error */
|
||||
int Analog_Output_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||
@@ -312,7 +338,8 @@ int Analog_Output_Read_Property(
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, false);
|
||||
state = Analog_Output_Out_Of_Service(rpdata->object_instance);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, state);
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -320,9 +347,7 @@ int Analog_Output_Read_Property(
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
object_index =
|
||||
Analog_Output_Instance_To_Index(rpdata->object_instance);
|
||||
state = Analog_Output_Out_Of_Service[object_index];
|
||||
state = Analog_Output_Out_Of_Service(rpdata->object_instance);
|
||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_UNITS:
|
||||
@@ -404,7 +429,6 @@ bool Analog_Output_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
unsigned int object_index = 0;
|
||||
int len = 0;
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
|
||||
@@ -450,9 +474,6 @@ bool Analog_Output_Write_Property(
|
||||
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Analog_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
status =
|
||||
Analog_Output_Present_Value_Relinquish
|
||||
(wp_data->object_instance, wp_data->priority);
|
||||
@@ -468,10 +489,8 @@ bool Analog_Output_Write_Property(
|
||||
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
||||
Analog_Output_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
Analog_Output_Out_Of_Service_Set(wp_data->object_instance,
|
||||
value.type.Boolean);
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
|
||||
@@ -63,6 +63,19 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
unsigned priority);
|
||||
|
||||
bool Analog_Output_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
void Analog_Output_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
bool Analog_Output_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list);
|
||||
float Analog_Output_COV_Increment(
|
||||
uint32_t instance);
|
||||
void Analog_Output_COV_Increment_Set(
|
||||
uint32_t instance,
|
||||
float value);
|
||||
|
||||
bool Analog_Output_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
@@ -82,6 +95,11 @@ extern "C" {
|
||||
uint16_t Analog_Output_Units(
|
||||
uint32_t instance);
|
||||
|
||||
bool Analog_Output_Out_Of_Service(
|
||||
uint32_t instance);
|
||||
void Analog_Output_Out_Of_Service_Set(
|
||||
uint32_t instance,
|
||||
bool oos_flag);
|
||||
|
||||
void Analog_Output_Init(
|
||||
void);
|
||||
|
||||
@@ -101,6 +101,36 @@ extern "C" {
|
||||
float Analog_Value_Present_Value(
|
||||
uint32_t object_instance);
|
||||
|
||||
bool Analog_Value_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
void Analog_Value_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
bool Analog_Value_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list);
|
||||
float Analog_Value_COV_Increment(
|
||||
uint32_t instance);
|
||||
void Analog_Value_COV_Increment_Set(
|
||||
uint32_t instance,
|
||||
float value);
|
||||
|
||||
char *Analog_Value_Description(
|
||||
uint32_t instance);
|
||||
bool Analog_Value_Description_Set(
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
|
||||
uint16_t Analog_Value_Units(
|
||||
uint32_t instance);
|
||||
bool Analog_Value_Units_Set(
|
||||
uint32_t instance, uint16_t unit);
|
||||
|
||||
bool Analog_Value_Out_Of_Service(
|
||||
uint32_t instance);
|
||||
void Analog_Value_Out_Of_Service_Set(
|
||||
uint32_t instance,
|
||||
bool oos_flag);
|
||||
|
||||
/* note: header of Intrinsic_Reporting function is required
|
||||
even when INTRINSIC_REPORTING is not defined */
|
||||
void Analog_Value_Intrinsic_Reporting(
|
||||
|
||||
@@ -272,7 +272,7 @@ bool Binary_Input_Present_Value_Set(
|
||||
return status;
|
||||
}
|
||||
|
||||
static void Binary_Input_Out_Of_Service_Set(
|
||||
void Binary_Input_Out_Of_Service_Set(
|
||||
uint32_t object_instance,
|
||||
bool value)
|
||||
{
|
||||
@@ -339,6 +339,7 @@ int Binary_Input_Read_Property(
|
||||
BACNET_BIT_STRING bit_string;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
uint8_t *apdu = NULL;
|
||||
bool state = false;
|
||||
|
||||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||
(rpdata->application_data_len == 0)) {
|
||||
@@ -374,13 +375,8 @@ int Binary_Input_Read_Property(
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
if (Binary_Input_Out_Of_Service(rpdata->object_instance)) {
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
true);
|
||||
} else {
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
false);
|
||||
}
|
||||
state = Binary_Input_Out_Of_Service(rpdata->object_instance);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, state);
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -389,9 +385,8 @@ int Binary_Input_Read_Property(
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
apdu_len =
|
||||
encode_application_boolean(&apdu[0],
|
||||
Binary_Input_Out_Of_Service(rpdata->object_instance));
|
||||
state = Binary_Input_Out_Of_Service(rpdata->object_instance);
|
||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
apdu_len =
|
||||
|
||||
@@ -59,6 +59,12 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
|
||||
BACNET_BINARY_PV Binary_Input_Present_Value(
|
||||
uint32_t object_instance);
|
||||
bool Binary_Input_Present_Value_Set(
|
||||
uint32_t object_instance,
|
||||
BACNET_BINARY_PV value);
|
||||
|
||||
char *Binary_Input_Description(
|
||||
uint32_t instance);
|
||||
bool Binary_Input_Description_Set(
|
||||
@@ -75,13 +81,18 @@ extern "C" {
|
||||
bool Binary_Input_Active_Text_Set(
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
|
||||
BACNET_POLARITY Binary_Input_Polarity(
|
||||
uint32_t object_instance);
|
||||
bool Binary_Input_Polarity_Set(
|
||||
uint32_t object_instance,
|
||||
BACNET_POLARITY polarity);
|
||||
|
||||
bool Binary_Input_Out_Of_Service(
|
||||
uint32_t object_instance);
|
||||
void Binary_Input_Out_Of_Service_Set(
|
||||
uint32_t object_instance,
|
||||
bool value);
|
||||
|
||||
bool Binary_Input_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
@@ -98,12 +109,6 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
void Binary_Input_Init(
|
||||
void);
|
||||
BACNET_BINARY_PV Binary_Input_Present_Value(
|
||||
uint32_t object_instance);
|
||||
|
||||
bool Binary_Input_Present_Value_Set(
|
||||
uint32_t object_instance,
|
||||
BACNET_BINARY_PV value);
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
|
||||
@@ -79,12 +79,6 @@ extern "C" {
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
|
||||
int Binary_Output_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||
|
||||
bool Binary_Output_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_BINARY_PV Binary_Output_Present_Value(
|
||||
uint32_t instance);
|
||||
bool Binary_Output_Present_Value_Set(
|
||||
@@ -94,10 +88,18 @@ extern "C" {
|
||||
bool Binary_Output_Present_Value_Relinquish(
|
||||
uint32_t instance,
|
||||
unsigned priority);
|
||||
|
||||
BACNET_POLARITY Binary_Output_Polarity(
|
||||
uint32_t instance);
|
||||
bool Binary_Output_Polarity_Set(
|
||||
uint32_t object_instance,
|
||||
BACNET_POLARITY polarity);
|
||||
|
||||
bool Binary_Output_Out_Of_Service(
|
||||
uint32_t instance);
|
||||
void Binary_Output_Out_Of_Service_Set(
|
||||
uint32_t object_instance,
|
||||
bool value);
|
||||
|
||||
bool Binary_Output_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
@@ -107,6 +109,12 @@ extern "C" {
|
||||
void Binary_Output_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
|
||||
int Binary_Output_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||
|
||||
bool Binary_Output_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
void testBinaryOutput(
|
||||
|
||||
@@ -50,7 +50,7 @@ static BACNET_BINARY_PV
|
||||
Binary_Value_Level[MAX_BINARY_VALUES][BACNET_MAX_PRIORITY];
|
||||
/* Writable out-of-service allows others to play with our Present Value */
|
||||
/* without changing the physical output */
|
||||
static bool Binary_Value_Out_Of_Service[MAX_BINARY_VALUES];
|
||||
static bool Out_Of_Service[MAX_BINARY_VALUES];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Binary_Value_Properties_Required[] = {
|
||||
@@ -153,7 +153,7 @@ unsigned Binary_Value_Instance_To_Index(
|
||||
return index;
|
||||
}
|
||||
|
||||
static BACNET_BINARY_PV Binary_Value_Present_Value(
|
||||
BACNET_BINARY_PV Binary_Value_Present_Value(
|
||||
uint32_t object_instance)
|
||||
{
|
||||
BACNET_BINARY_PV value = RELINQUISH_DEFAULT;
|
||||
@@ -190,6 +190,32 @@ bool Binary_Value_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Binary_Value_Out_Of_Service(
|
||||
uint32_t instance)
|
||||
{
|
||||
unsigned index = 0;
|
||||
bool oos_flag = false;
|
||||
|
||||
index = Binary_Value_Instance_To_Index(instance);
|
||||
if (index < MAX_BINARY_VALUES) {
|
||||
oos_flag = Out_Of_Service[index];
|
||||
}
|
||||
|
||||
return oos_flag;
|
||||
}
|
||||
|
||||
void Binary_Value_Out_Of_Service_Set(
|
||||
uint32_t instance,
|
||||
bool oos_flag)
|
||||
{
|
||||
unsigned index = 0;
|
||||
|
||||
index = Binary_Value_Instance_To_Index(instance);
|
||||
if (index < MAX_BINARY_VALUES) {
|
||||
Out_Of_Service[index] = oos_flag;
|
||||
}
|
||||
}
|
||||
|
||||
/* return apdu len, or BACNET_STATUS_ERROR on error */
|
||||
int Binary_Value_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||
@@ -238,7 +264,7 @@ int Binary_Value_Read_Property(
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
state = Binary_Value_Out_Of_Service[object_index];
|
||||
state = Binary_Value_Out_Of_Service(rpdata->object_instance);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, state);
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
@@ -248,9 +274,7 @@ int Binary_Value_Read_Property(
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(rpdata->object_instance);
|
||||
state = Binary_Value_Out_Of_Service[object_index];
|
||||
state = Binary_Value_Out_Of_Service(rpdata->object_instance);
|
||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
@@ -418,9 +442,8 @@ bool Binary_Value_Write_Property(
|
||||
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->object_instance);
|
||||
Binary_Value_Out_Of_Service[object_index] = value.type.Boolean;
|
||||
Binary_Value_Out_Of_Service_Set(wp_data->object_instance,
|
||||
value.type.Boolean);
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
|
||||
@@ -62,6 +62,49 @@ extern "C" {
|
||||
bool Binary_Value_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
bool Binary_Value_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list);
|
||||
bool Binary_Value_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
void Binary_Value_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
|
||||
BACNET_BINARY_PV Binary_Value_Present_Value(
|
||||
uint32_t instance);
|
||||
bool Binary_Value_Present_Value_Set(
|
||||
uint32_t instance,
|
||||
BACNET_BINARY_PV value);
|
||||
|
||||
bool Binary_Value_Out_Of_Service(
|
||||
uint32_t instance);
|
||||
void Binary_Value_Out_Of_Service_Set(
|
||||
uint32_t instance,
|
||||
bool value);
|
||||
|
||||
char *Binary_Value_Description(
|
||||
uint32_t instance);
|
||||
bool Binary_Value_Description_Set(
|
||||
uint32_t object_instance,
|
||||
char *text_string);
|
||||
|
||||
char *Binary_Value_Inactive_Text(
|
||||
uint32_t instance);
|
||||
bool Binary_Value_Inactive_Text_Set(
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
char *Binary_Value_Active_Text(
|
||||
uint32_t instance);
|
||||
bool Binary_Value_Active_Text_Set(
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
|
||||
BACNET_POLARITY Binary_Value_Polarity(
|
||||
uint32_t instance);
|
||||
bool Binary_Value_Polarity_Set(
|
||||
uint32_t object_instance,
|
||||
BACNET_POLARITY polarity);
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
void testBinary_Value(
|
||||
|
||||
@@ -218,7 +218,7 @@ void Multistate_Input_Out_Of_Service_Set(
|
||||
return;
|
||||
}
|
||||
|
||||
static char *Multistate_Input_Description(
|
||||
char *Multistate_Input_Description(
|
||||
uint32_t object_instance)
|
||||
{
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
@@ -380,7 +380,7 @@ static bool Multistate_Input_Object_Name_Write(
|
||||
return status;
|
||||
}
|
||||
|
||||
static char *Multistate_Input_State_Text(
|
||||
char *Multistate_Input_State_Text(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index)
|
||||
{
|
||||
|
||||
@@ -73,15 +73,26 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
uint32_t value);
|
||||
|
||||
bool Multistate_Input_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
void Multistate_Input_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
bool Multistate_Input_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list);
|
||||
|
||||
bool Multistate_Input_Out_Of_Service(
|
||||
uint32_t object_instance);
|
||||
void Multistate_Input_Out_Of_Service_Set(
|
||||
uint32_t object_instance,
|
||||
bool value);
|
||||
|
||||
char *Multistate_Input_Description(
|
||||
uint32_t instance);
|
||||
bool Multistate_Input_Description_Set(
|
||||
uint32_t object_instance,
|
||||
char *text_string);
|
||||
|
||||
bool Multistate_Input_State_Text_Set(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index,
|
||||
@@ -89,6 +100,9 @@ extern "C" {
|
||||
bool Multistate_Input_Max_States_Set(
|
||||
uint32_t instance,
|
||||
uint32_t max_states_requested);
|
||||
char *Multistate_Input_State_Text(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index);
|
||||
|
||||
void Multistate_Input_Init(
|
||||
void);
|
||||
|
||||
@@ -55,7 +55,7 @@ static uint8_t
|
||||
Multistate_Output_Level[MAX_MULTISTATE_OUTPUTS][BACNET_MAX_PRIORITY];
|
||||
/* Writable out-of-service allows others to play with our Present Value */
|
||||
/* without changing the physical output */
|
||||
static bool Multistate_Output_Out_Of_Service[MAX_MULTISTATE_OUTPUTS];
|
||||
static bool Out_Of_Service[MAX_MULTISTATE_OUTPUTS];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Multistate_Output_Properties_Required[] = {
|
||||
@@ -159,7 +159,7 @@ unsigned Multistate_Output_Instance_To_Index(
|
||||
return index;
|
||||
}
|
||||
|
||||
static uint32_t Multistate_Output_Present_Value(
|
||||
uint32_t Multistate_Output_Present_Value(
|
||||
uint32_t object_instance)
|
||||
{
|
||||
uint32_t value = MULTISTATE_RELINQUISH_DEFAULT;
|
||||
@@ -195,6 +195,32 @@ bool Multistate_Output_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Multistate_Output_Out_Of_Service(
|
||||
uint32_t instance)
|
||||
{
|
||||
unsigned index = 0;
|
||||
bool oos_flag = false;
|
||||
|
||||
index = Multistate_Output_Instance_To_Index(instance);
|
||||
if (index < MAX_MULTISTATE_OUTPUTS) {
|
||||
oos_flag = Out_Of_Service[index];
|
||||
}
|
||||
|
||||
return oos_flag;
|
||||
}
|
||||
|
||||
void Multistate_Output_Out_Of_Service_Set(
|
||||
uint32_t instance,
|
||||
bool oos_flag)
|
||||
{
|
||||
unsigned index = 0;
|
||||
|
||||
index = Multistate_Output_Instance_To_Index(instance);
|
||||
if (index < MAX_MULTISTATE_OUTPUTS) {
|
||||
Out_Of_Service[index] = oos_flag;
|
||||
}
|
||||
}
|
||||
|
||||
/* return apdu len, or BACNET_STATUS_ERROR on error */
|
||||
int Multistate_Output_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||
@@ -245,7 +271,8 @@ int Multistate_Output_Read_Property(
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, false);
|
||||
state = Multistate_Output_Out_Of_Service(rpdata->object_instance);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, state);
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -254,9 +281,7 @@ int Multistate_Output_Read_Property(
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(rpdata->object_instance);
|
||||
state = Multistate_Output_Out_Of_Service[object_index];
|
||||
state = Multistate_Output_Out_Of_Service(rpdata->object_instance);
|
||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
@@ -440,11 +465,8 @@ bool Multistate_Output_Write_Property(
|
||||
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Multistate_Output_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
Multistate_Output_Out_Of_Service_Set(wp_data->object_instance,
|
||||
value.type.Boolean);
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
|
||||
@@ -62,6 +62,48 @@ extern "C" {
|
||||
bool Multistate_Output_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
bool Multistate_Output_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
void Multistate_Output_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
bool Multistate_Output_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list);
|
||||
|
||||
uint32_t Multistate_Output_Present_Value(
|
||||
uint32_t instance);
|
||||
bool Multistate_Output_Present_Value_Set(
|
||||
uint32_t instance,
|
||||
unsigned value,
|
||||
unsigned priority);
|
||||
bool Multistate_Output_Present_Value_Relinquish(
|
||||
uint32_t instance,
|
||||
unsigned priority);
|
||||
|
||||
bool Multistate_Output_Out_Of_Service(
|
||||
uint32_t instance);
|
||||
void Multistate_Output_Out_Of_Service_Set(
|
||||
uint32_t instance,
|
||||
bool value);
|
||||
|
||||
char *Multistate_Output_Description(
|
||||
uint32_t instance);
|
||||
bool Multistate_Output_Description_Set(
|
||||
uint32_t object_instance,
|
||||
char *text_string);
|
||||
|
||||
bool Multistate_Output_State_Text_Set(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index,
|
||||
char *new_name);
|
||||
bool Multistate_Output_Max_States_Set(
|
||||
uint32_t instance,
|
||||
uint32_t max_states_requested);
|
||||
char *Multistate_Output_State_Text(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index);
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
void testMultistateOutput(
|
||||
|
||||
@@ -211,7 +211,7 @@ void Multistate_Value_Out_Of_Service_Set(
|
||||
return;
|
||||
}
|
||||
|
||||
static char *Multistate_Value_Description(
|
||||
char *Multistate_Value_Description(
|
||||
uint32_t object_instance)
|
||||
{
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
@@ -298,7 +298,7 @@ bool Multistate_Value_Name_Set(
|
||||
return status;
|
||||
}
|
||||
|
||||
static char *Multistate_Value_State_Text(
|
||||
char *Multistate_Value_State_Text(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index)
|
||||
{
|
||||
@@ -357,7 +357,6 @@ int Multistate_Value_Read_Property(
|
||||
BACNET_BIT_STRING bit_string;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
uint32_t present_value = 0;
|
||||
unsigned object_index = 0;
|
||||
unsigned i = 0;
|
||||
bool state = false;
|
||||
uint8_t *apdu = NULL;
|
||||
@@ -403,13 +402,8 @@ int Multistate_Value_Read_Property(
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
if (Multistate_Value_Out_Of_Service(rpdata->object_instance)) {
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
true);
|
||||
} else {
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
false);
|
||||
}
|
||||
state = Multistate_Value_Out_Of_Service(rpdata->object_instance);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, state);
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -418,9 +412,7 @@ int Multistate_Value_Read_Property(
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
object_index =
|
||||
Multistate_Value_Instance_To_Index(rpdata->object_instance);
|
||||
state = Out_Of_Service[object_index];
|
||||
state = Multistate_Value_Out_Of_Service(rpdata->object_instance);
|
||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_NUMBER_OF_STATES:
|
||||
@@ -437,9 +429,6 @@ int Multistate_Value_Read_Property(
|
||||
} else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
object_index =
|
||||
Multistate_Value_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
|
||||
characterstring_init_ansi(&char_string,
|
||||
Multistate_Value_State_Text(rpdata->object_instance,
|
||||
@@ -459,9 +448,6 @@ int Multistate_Value_Read_Property(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
object_index =
|
||||
Multistate_Value_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
|
||||
characterstring_init_ansi(&char_string,
|
||||
Multistate_Value_State_Text(rpdata->object_instance,
|
||||
|
||||
@@ -73,15 +73,26 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
uint32_t value);
|
||||
|
||||
bool Multistate_Value_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
void Multistate_Value_Change_Of_Value_Clear(
|
||||
uint32_t instance);
|
||||
bool Multistate_Value_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list);
|
||||
|
||||
bool Multistate_Value_Out_Of_Service(
|
||||
uint32_t object_instance);
|
||||
void Multistate_Value_Out_Of_Service_Set(
|
||||
uint32_t object_instance,
|
||||
bool value);
|
||||
|
||||
char *Multistate_Value_Description(
|
||||
uint32_t instance);
|
||||
bool Multistate_Value_Description_Set(
|
||||
uint32_t object_instance,
|
||||
char *text_string);
|
||||
|
||||
bool Multistate_Value_State_Text_Set(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index,
|
||||
@@ -89,6 +100,9 @@ extern "C" {
|
||||
bool Multistate_Value_Max_States_Set(
|
||||
uint32_t instance,
|
||||
uint32_t max_states_requested);
|
||||
char *Multistate_Value_State_Text(
|
||||
uint32_t object_instance,
|
||||
uint32_t state_index);
|
||||
|
||||
void Multistate_Value_Init(
|
||||
void);
|
||||
|
||||
@@ -63,7 +63,7 @@ int rp_encode_apdu(
|
||||
rpdata->object_type, rpdata->object_instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
if (rpdata->object_property <= 4194303) {
|
||||
if (rpdata->object_property <= MAX_BACNET_PROPERTY_ID) {
|
||||
/* check bounds so that we could create malformed
|
||||
messages for testing */
|
||||
len =
|
||||
|
||||
Reference in New Issue
Block a user