Fixed out-of-service writability to be consistent with present-value in objects using Write_Enabled flag (#921)

This commit is contained in:
Steve Karg
2025-02-20 09:42:15 -06:00
committed by GitHub
parent 97490dacb1
commit 08f152b4ac
7 changed files with 301 additions and 35 deletions
+57 -5
View File
@@ -262,6 +262,21 @@ bool BitString_Value_Out_Of_Service(uint32_t object_instance)
return value;
}
/**
* @brief For a given object instance-number, checks the out-of-service for COV
* @param pObject - specific object with valid data
* @param value - out-of-service value
*/
static void BitString_Value_Out_Of_Service_COV_Detect(
struct object_data *pObject, bool value)
{
if (pObject) {
if (pObject->Out_Of_Service != value) {
pObject->Change_Of_Value = true;
}
}
}
/**
* @brief For a given object instance-number, set the out of service value.
* @param object_instance - object-instance number of the object
@@ -273,15 +288,51 @@ void BitString_Value_Out_Of_Service_Set(uint32_t object_instance, bool value)
pObject = BitString_Value_Object(object_instance);
if (pObject) {
if (pObject->Out_Of_Service != value) {
pObject->Change_Of_Value = true;
}
BitString_Value_Out_Of_Service_COV_Detect(pObject, value);
pObject->Out_Of_Service = value;
}
return;
}
/**
* For a given object instance-number, sets the out of service flag
* from WriteProperty service
*
* @param object_instance - object-instance number of the object
* @param value - new value
* @param error_class - BACnet error class
* @param error_code - BACnet error code
*
* @return true if value is set, or false if not set or error occurred
*/
static bool BitString_Value_Out_Of_Service_Write(
uint32_t object_instance,
bool value,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
bool status = false;
struct object_data *pObject;
pObject = BitString_Value_Object(object_instance);
if (pObject) {
if (pObject->Write_Enabled) {
BitString_Value_Out_Of_Service_COV_Detect(pObject, value);
pObject->Out_Of_Service = value;
status = true;
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
} else {
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
}
return status;
}
/**
* @brief For a given object instance-number, read the reliability value.
* @param object_instance - object-instance number of the object
@@ -659,8 +710,9 @@ bool BitString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
BitString_Value_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
status = BitString_Value_Out_Of_Service_Write(
wp_data->object_instance, value.type.Boolean,
&wp_data->error_class, &wp_data->error_code);
}
break;
default: