Bugfix/property list consistency testing (#910)
* Added unit test while reading all object properties to flag properties not in the property-list. * Added enumeration for last-property used in unit testing. * Added missing reliability property in the basic multistate output object example. * Removed polarity property in binary value object as it is not standard.
This commit is contained in:
@@ -37,7 +37,6 @@ struct object_data {
|
||||
bool Change_Of_Value : 1;
|
||||
bool Present_Value : 1;
|
||||
bool Write_Enabled : 1;
|
||||
bool Polarity : 1;
|
||||
unsigned Event_State : 3;
|
||||
uint8_t Reliability;
|
||||
const char *Object_Name;
|
||||
@@ -221,38 +220,6 @@ static bool Binary_Present_Value_Boolean(BACNET_BINARY_PV binary_value)
|
||||
return boolean_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert from boolean to BACNET_POLARITY enumeration
|
||||
* @param value - boolean value
|
||||
* @return BACNET_POLARITY enumeration
|
||||
*/
|
||||
static BACNET_POLARITY Binary_Polarity(bool value)
|
||||
{
|
||||
BACNET_POLARITY polarity = POLARITY_NORMAL;
|
||||
|
||||
if (value) {
|
||||
polarity = POLARITY_REVERSE;
|
||||
}
|
||||
|
||||
return polarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert from BACNET_POLARITY enumeration to boolean
|
||||
* @param binary_value BACNET_POLARITY enumeration
|
||||
* @return boolean value
|
||||
*/
|
||||
static bool Binary_Polarity_Boolean(BACNET_POLARITY polarity)
|
||||
{
|
||||
bool boolean_value = false;
|
||||
|
||||
if (polarity == POLARITY_REVERSE) {
|
||||
boolean_value = true;
|
||||
}
|
||||
|
||||
return boolean_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, return the present value.
|
||||
*
|
||||
@@ -268,13 +235,6 @@ BACNET_BINARY_PV Binary_Value_Present_Value(uint32_t object_instance)
|
||||
pObject = Binary_Value_Object(object_instance);
|
||||
if (pObject) {
|
||||
value = Binary_Present_Value(pObject->Present_Value);
|
||||
if (Binary_Polarity(pObject->Polarity) != POLARITY_NORMAL) {
|
||||
if (value == BINARY_INACTIVE) {
|
||||
value = BINARY_ACTIVE;
|
||||
} else {
|
||||
value = BINARY_INACTIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -502,14 +462,6 @@ bool Binary_Value_Present_Value_Set(
|
||||
pObject = Binary_Value_Object(object_instance);
|
||||
if (pObject) {
|
||||
if (value <= MAX_BINARY_PV) {
|
||||
/* de-polarize */
|
||||
if (Binary_Polarity(pObject->Polarity) != POLARITY_NORMAL) {
|
||||
if (value == BINARY_INACTIVE) {
|
||||
value = BINARY_ACTIVE;
|
||||
} else {
|
||||
value = BINARY_INACTIVE;
|
||||
}
|
||||
}
|
||||
Binary_Value_Present_Value_COV_Detect(pObject, value);
|
||||
pObject->Present_Value = Binary_Present_Value_Boolean(value);
|
||||
status = true;
|
||||
@@ -640,44 +592,6 @@ const char *Binary_Value_Name_ASCII(uint32_t object_instance)
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief For a given object instance-number, returns the polarity property.
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @return the polarity property of the object.
|
||||
*/
|
||||
BACNET_POLARITY Binary_Value_Polarity(uint32_t object_instance)
|
||||
{
|
||||
BACNET_POLARITY polarity = POLARITY_NORMAL;
|
||||
struct object_data *pObject;
|
||||
|
||||
pObject = Binary_Value_Object(object_instance);
|
||||
if (pObject) {
|
||||
polarity = Binary_Polarity(pObject->Polarity);
|
||||
}
|
||||
|
||||
return polarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief For a given object instance-number, sets the polarity property
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param polarity - polarity property value
|
||||
* @return true if polarity was set
|
||||
*/
|
||||
bool Binary_Value_Polarity_Set(
|
||||
uint32_t object_instance, BACNET_POLARITY polarity)
|
||||
{
|
||||
bool status = false;
|
||||
struct object_data *pObject;
|
||||
|
||||
pObject = Binary_Value_Object(object_instance);
|
||||
if (pObject) {
|
||||
pObject->Polarity = Binary_Polarity_Boolean(polarity);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief For a given object instance-number, returns the description
|
||||
* @param object_instance - object-instance number of the object
|
||||
@@ -931,10 +845,6 @@ int Binary_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
state = Binary_Value_Out_Of_Service(rpdata->object_instance);
|
||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
apdu_len = encode_application_enumerated(
|
||||
&apdu[0], Binary_Value_Polarity(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_RELIABILITY:
|
||||
apdu_len = encode_application_enumerated(
|
||||
&apdu[0], Binary_Value_Reliability(rpdata->object_instance));
|
||||
@@ -1098,21 +1008,6 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
}
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated < MAX_POLARITY) {
|
||||
Binary_Value_Polarity_Set(
|
||||
wp_data->object_instance,
|
||||
(BACNET_POLARITY)value.type.Enumerated);
|
||||
} else {
|
||||
status = false;
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if defined(INTRINSIC_REPORTING) && (BINARY_VALUE_INTRINSIC_REPORTING)
|
||||
case PROP_TIME_DELAY:
|
||||
status = write_property_type_valid(
|
||||
@@ -1291,7 +1186,6 @@ uint32_t Binary_Value_Create(uint32_t object_instance)
|
||||
pObject->Inactive_Text = Default_Inactive_Text;
|
||||
pObject->Change_Of_Value = false;
|
||||
pObject->Write_Enabled = false;
|
||||
pObject->Polarity = false;
|
||||
#if defined(INTRINSIC_REPORTING) && (BINARY_VALUE_INTRINSIC_REPORTING)
|
||||
pObject->Event_State = EVENT_STATE_NORMAL;
|
||||
pObject->Event_Detection_Enable = true;
|
||||
@@ -1886,10 +1780,6 @@ bool Binary_Value_Alarm_Value_Set(
|
||||
struct object_data *pObject = Binary_Value_Object(object_instance);
|
||||
|
||||
if (pObject) {
|
||||
if (pObject->Polarity != POLARITY_NORMAL) {
|
||||
value =
|
||||
(value == BINARY_INACTIVE) ? BINARY_ACTIVE : BINARY_INACTIVE;
|
||||
}
|
||||
pObject->Alarm_Value = value;
|
||||
status = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user