Refactor/property lists member function (#609)

* Refactor property lists member function for WriteProperty default case.

* Refactor time-value object unit testing

* Added test for unsupported property to common property test
This commit is contained in:
Steve Karg
2024-03-27 09:52:01 -05:00
committed by GitHub
parent 4e0a37fd75
commit 6bd1942635
14 changed files with 118 additions and 304 deletions
+3 -30
View File
@@ -66,34 +66,6 @@ void Analog_Input_Property_Lists(
return;
}
/**
* @brief Determine if the object property is a member of this object instance
* @param object_instance - object-instance number of the object
* @param object_property - object-property to be checked
* @return true if the property is a member of this object instance
*/
static bool Property_List_Member(
uint32_t object_instance, int object_property)
{
bool found = false;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
(void)object_instance;
Analog_Input_Property_Lists(
&pRequired, &pOptional, &pProprietary);
found = property_list_member(pRequired, object_property);
if (!found) {
found = property_list_member(pOptional, object_property);
}
if (!found) {
found = property_list_member(pProprietary, object_property);
}
return found;
}
void Analog_Input_Init(void)
{
unsigned i;
@@ -903,8 +875,9 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
#endif
default:
if (Property_List_Member(
wp_data->object_instance, wp_data->object_property)) {
if (property_lists_member(
Properties_Required, Properties_Optional,
Properties_Proprietary, wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {
+5 -30
View File
@@ -86,34 +86,6 @@ void Analog_Value_Property_Lists(
return;
}
/**
* @brief Determine if the object property is a member of this object instance
* @param object_instance - object-instance number of the object
* @param object_property - object-property to be checked
* @return true if the property is a member of this object instance
*/
static bool Property_List_Member(
uint32_t object_instance, int object_property)
{
bool found = false;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
(void)object_instance;
Analog_Value_Property_Lists(
&pRequired, &pOptional, &pProprietary);
found = property_list_member(pRequired, object_property);
if (!found) {
found = property_list_member(pOptional, object_property);
}
if (!found) {
found = property_list_member(pProprietary, object_property);
}
return found;
}
/**
* Initialize the analog values.
*/
@@ -1026,8 +998,11 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
#endif
default:
if (Property_List_Member(
wp_data->object_instance, wp_data->object_property)) {
if (property_lists_member(
Analog_Value_Properties_Required,
Analog_Value_Properties_Optional,
Analog_Value_Properties_Proprietary,
wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {
+5 -30
View File
@@ -466,34 +466,6 @@ bool Calendar_Description_Set(uint32_t object_instance, char *new_name)
return status;
}
/**
* @brief Determine if the object property is a member of this object instance
* @param object_instance - object-instance number of the object
* @param object_property - object-property to be checked
* @return true if the property is a member of this object instance
*/
static bool Property_List_Member(
uint32_t object_instance, int object_property)
{
bool found = false;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
(void)object_instance;
Calendar_Property_Lists(
&pRequired, &pOptional, &pProprietary);
found = property_list_member(pRequired, object_property);
if (!found) {
found = property_list_member(pOptional, object_property);
}
if (!found) {
found = property_list_member(pProprietary, object_property);
}
return found;
}
/**
* @brief Determine if the object property is a BACnetARRAY property
* @param object_property - object-property to be checked
@@ -637,8 +609,11 @@ bool Calendar_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
&wp_data->error_code);
break;
default:
if (Property_List_Member(
wp_data->object_instance, wp_data->object_property)) {
if (property_lists_member(
Calendar_Properties_Required,
Calendar_Properties_Optional,
Calendar_Properties_Proprietary,
wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {
+3 -30
View File
@@ -380,34 +380,6 @@ void Command_Property_Lists(
return;
}
/**
* @brief Determine if the object property is a member of this object instance
* @param object_instance - object-instance number of the object
* @param object_property - object-property to be checked
* @return true if the property is a member of this object instance
*/
static bool Property_List_Member(
uint32_t object_instance, int object_property)
{
bool found = false;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
(void)object_instance;
Command_Property_Lists(
&pRequired, &pOptional, &pProprietary);
found = property_list_member(pRequired, object_property);
if (!found) {
found = property_list_member(pOptional, object_property);
}
if (!found) {
found = property_list_member(pProprietary, object_property);
}
return found;
}
/**
* Initializes the Command object data
*/
@@ -828,8 +800,9 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
default:
if (Property_List_Member(
wp_data->object_instance, wp_data->object_property)) {
if (property_lists_member(
Command_Properties_Required, Command_Properties_Optional,
Command_Properties_Proprietary, wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {
+5 -28
View File
@@ -92,32 +92,6 @@ void Life_Safety_Zone_Property_Lists(
return;
}
/**
* @brief Determine if the object property is a member of this object instance
* @param object_instance - object-instance number of the object
* @param object_property - object-property to be checked
* @return true if the property is a member of this object instance
*/
static bool Property_List_Member(uint32_t object_instance, int object_property)
{
bool found = false;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
(void)object_instance;
Life_Safety_Zone_Property_Lists(&pRequired, &pOptional, &pProprietary);
found = property_list_member(pRequired, object_property);
if (!found) {
found = property_list_member(pOptional, object_property);
}
if (!found) {
found = property_list_member(pProprietary, object_property);
}
return found;
}
/**
* @brief Determines if a given object instance is valid
* @param object_instance - object-instance number of the object
@@ -832,8 +806,11 @@ bool Life_Safety_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
status = Life_Safety_Zone_Members_Write(wp_data);
break;
default:
if (Property_List_Member(
wp_data->object_instance, wp_data->object_property)) {
if (property_lists_member(
Life_Safety_Zone_Properties_Required,
Life_Safety_Zone_Properties_Optional,
Life_Safety_Zone_Properties_Proprietary,
wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {
+9 -17
View File
@@ -354,24 +354,16 @@ bool Schedule_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->object_instance, value.type.Boolean);
}
break;
case PROP_OBJECT_IDENTIFIER:
case PROP_OBJECT_NAME:
case PROP_OBJECT_TYPE:
case PROP_PRESENT_VALUE:
case PROP_EFFECTIVE_PERIOD:
case PROP_WEEKLY_SCHEDULE:
case PROP_SCHEDULE_DEFAULT:
case PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES:
case PROP_PRIORITY_FOR_WRITING:
case PROP_STATUS_FLAGS:
case PROP_RELIABILITY:
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
default:
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
if (property_lists_member(
Schedule_Properties_Required, Schedule_Properties_Optional,
Schedule_Properties_Proprietary, wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
}
break;
}
+3 -30
View File
@@ -391,34 +391,6 @@ bool Time_Value_Description_Set(uint32_t object_instance, char *new_name)
return status;
}
/**
* @brief Determine if the object property is a member of this object instance
* @param object_instance - object-instance number of the object
* @param object_property - object-property to be checked
* @return true if the property is a member of this object instance
*/
static bool Property_List_Member(
uint32_t object_instance, int object_property)
{
bool found = false;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
(void)object_instance;
Time_Value_Property_Lists(
&pRequired, &pOptional, &pProprietary);
found = property_list_member(pRequired, object_property);
if (!found) {
found = property_list_member(pOptional, object_property);
}
if (!found) {
found = property_list_member(pProprietary, object_property);
}
return found;
}
/**
* @brief Determine if the object property is a BACnetARRAY property
* @param object_property - object-property to be checked
@@ -564,8 +536,9 @@ bool Time_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
default:
if (Property_List_Member(
wp_data->object_instance, wp_data->object_property)) {
if (property_lists_member(
Time_Value_Properties_Required, Time_Value_Properties_Optional,
Time_Value_Properties_Proprietary, wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {