Fixed structured view object subtype get and set. (#909)

This commit is contained in:
Steve Karg
2025-02-10 09:56:52 -06:00
committed by GitHub
parent 66329a05a0
commit bc2438f85b
5 changed files with 162 additions and 4 deletions
+70
View File
@@ -286,6 +286,31 @@ bool bacnet_device_object_property_reference_same(
return status;
}
/**
* @brief Copy the complex data of src into dest
* @param dest - destination structure
* @param src - source structure
* @return true if the values are the copied
*/
bool bacnet_device_object_property_reference_copy(
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *dest,
const BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *src)
{
bool status = false;
if (dest && src) {
dest->arrayIndex = src->arrayIndex;
dest->deviceIdentifier.instance = src->deviceIdentifier.instance;
dest->deviceIdentifier.type = src->deviceIdentifier.type;
dest->objectIdentifier.instance = src->objectIdentifier.instance;
dest->objectIdentifier.type = src->objectIdentifier.type;
dest->propertyIdentifier = src->propertyIdentifier;
status = true;
}
return status;
}
/**
* Decode a property reference of a device object.
*
@@ -551,6 +576,29 @@ bool bacnet_device_object_reference_same(
return status;
}
/**
* @brief Copy the complex data from src into dest
* @param dest - destination structure
* @param src - source structure
* @return true if the values are copied
*/
bool bacnet_device_object_reference_copy(
BACNET_DEVICE_OBJECT_REFERENCE *dest,
const BACNET_DEVICE_OBJECT_REFERENCE *src)
{
bool status = false;
if (dest && src) {
dest->deviceIdentifier.instance = src->deviceIdentifier.instance;
dest->deviceIdentifier.type = src->deviceIdentifier.type;
dest->objectIdentifier.instance = src->objectIdentifier.instance;
dest->objectIdentifier.type = src->objectIdentifier.type;
status = true;
}
return status;
}
/**
* Decode the device object reference.
*
@@ -822,6 +870,28 @@ bool bacnet_object_property_reference_same(
return status;
}
/**
* @brief Copy the complex data from src to dest
* @param dest - destination structure
* @param src - source structure
* @return true if the values are copied
*/
bool bacnet_object_property_reference_copy(
BACNET_OBJECT_PROPERTY_REFERENCE *dest,
const BACNET_OBJECT_PROPERTY_REFERENCE *src)
{
bool status = false;
if (src && dest) {
dest->property_identifier = src->property_identifier;
dest->object_identifier.instance = src->object_identifier.instance;
dest->object_identifier.type = src->object_identifier.type;
status = true;
}
return status;
}
/**
* @brief Encode a BACnetPropertyReference into a buffer
*
+12
View File
@@ -163,16 +163,28 @@ BACNET_STACK_EXPORT
bool bacnet_device_object_property_reference_same(
const BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value1,
const BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value2);
BACNET_STACK_EXPORT
bool bacnet_device_object_property_reference_copy(
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *dest,
const BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *src);
BACNET_STACK_EXPORT
bool bacnet_device_object_reference_same(
const BACNET_DEVICE_OBJECT_REFERENCE *value1,
const BACNET_DEVICE_OBJECT_REFERENCE *value2);
BACNET_STACK_EXPORT
bool bacnet_device_object_reference_copy(
BACNET_DEVICE_OBJECT_REFERENCE *dest,
const BACNET_DEVICE_OBJECT_REFERENCE *src);
BACNET_STACK_EXPORT
bool bacnet_object_property_reference_same(
const BACNET_OBJECT_PROPERTY_REFERENCE *value1,
const BACNET_OBJECT_PROPERTY_REFERENCE *value2);
BACNET_STACK_EXPORT
bool bacnet_object_property_reference_copy(
BACNET_OBJECT_PROPERTY_REFERENCE *dest,
const BACNET_OBJECT_PROPERTY_REFERENCE *src);
BACNET_STACK_EXPORT
int bacnet_property_reference_encode(
+4 -4
View File
@@ -325,7 +325,7 @@ const char *Structured_View_Node_Subtype(uint32_t object_instance)
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
if (pObject->Description) {
if (pObject->Node_Subtype) {
name = pObject->Node_Subtype;
} else {
name = "";
@@ -350,7 +350,7 @@ bool Structured_View_Node_Subtype_Set(
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
status = true;
pObject->Description = new_name;
pObject->Node_Subtype = new_name;
}
return status;
@@ -469,8 +469,8 @@ bool Structured_View_Represents_Set(
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
status = true;
pObject->Represents = *represents;
status = bacnet_device_object_reference_copy(
&pObject->Represents, represents);
}
return status;
+19
View File
@@ -29,7 +29,12 @@ static void testDevObjPropRef(BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *data)
int len = 0;
int test_len = 0;
int null_len = 0;
bool status;
status = bacnet_device_object_property_reference_copy(&test_data, data);
zassert_true(status, NULL);
status = bacnet_device_object_property_reference_same(&test_data, data);
zassert_true(status, NULL);
/* encode */
null_len = bacapp_encode_device_obj_property_ref(NULL, data);
len = bacapp_encode_device_obj_property_ref(apdu, data);
@@ -138,9 +143,16 @@ static void testDevIdRef(void)
int len;
int test_len;
int null_len;
bool status;
data.deviceIdentifier.instance = 0x4343;
data.deviceIdentifier.type = OBJECT_DEVICE;
status = bacnet_device_object_reference_copy(&test_data, &data);
zassert_true(status, NULL);
status = bacnet_device_object_reference_same(&test_data, &data);
zassert_true(status, NULL);
null_len = bacapp_encode_device_obj_ref(NULL, &data);
len = bacapp_encode_device_obj_ref(apdu, &data);
zassert_equal(null_len, len, NULL);
@@ -175,11 +187,18 @@ static void testObjPropRef(void)
int len;
int test_len;
int null_len;
bool status;
data.object_identifier.instance = 12345;
data.object_identifier.type = OBJECT_ANALOG_VALUE;
data.property_identifier = PROP_PRESENT_VALUE;
data.property_array_index = BACNET_ARRAY_ALL;
status = bacnet_object_property_reference_copy(&test_data, &data);
zassert_true(status, NULL);
status = bacnet_object_property_reference_same(&test_data, &data);
zassert_true(status, NULL);
null_len = bacapp_encode_obj_property_ref(NULL, &data);
len = bacapp_encode_obj_property_ref(apdu, &data);
zassert_equal(null_len, len, NULL);
@@ -25,9 +25,27 @@ static void test_object_structured_view(void)
#endif
{
bool status = false;
int diff = 0;
unsigned count = 0, index = 0;
const uint32_t instance = 123;
const int skip_fail_property_list[] = { -1 };
const char *test_name = "name-1234";
const char *test_description = "description-1234";
const char *test_node_subtype = "node-subtype-1234";
BACNET_NODE_TYPE test_node_type = BACNET_NODE_UNKNOWN;
BACNET_RELATIONSHIP test_relationship = BACNET_RELATIONSHIP_DEFAULT;
BACNET_DEVICE_OBJECT_REFERENCE test_represents = {
{ OBJECT_DEVICE, 1234 }, { OBJECT_DEVICE, 1234 }
};
BACNET_SUBORDINATE_DATA test_subordinate_data = {
1234,
OBJECT_DEVICE,
1234,
"annotations-1234",
BACNET_NODE_UNKNOWN,
BACNET_RELATIONSHIP_DEFAULT,
NULL
};
Structured_View_Init();
Structured_View_Create(instance);
@@ -42,6 +60,45 @@ static void test_object_structured_view(void)
Structured_View_Read_Property, NULL, skip_fail_property_list);
bacnet_object_name_ascii_test(
instance, Structured_View_Name_Set, Structured_View_Name_ASCII);
/* there is no WriteProperty test for structured view - use get/set */
status = Structured_View_Name_Set(instance, test_name);
zassert_true(status, NULL);
diff = strcmp(Structured_View_Name_ASCII(instance), test_name);
zassert_equal(diff, 0, NULL);
status = Structured_View_Description_Set(instance, test_description);
zassert_true(status, NULL);
diff = strcmp(Structured_View_Description(instance), test_description);
zassert_equal(diff, 0, NULL);
status = Structured_View_Node_Subtype_Set(instance, test_node_subtype);
zassert_true(status, NULL);
diff = strcmp(Structured_View_Node_Subtype(instance), test_node_subtype);
zassert_equal(diff, 0, NULL);
status = Structured_View_Node_Type_Set(instance, test_node_type);
zassert_true(status, NULL);
zassert_equal(Structured_View_Node_Type(instance), test_node_type, NULL);
status = Structured_View_Default_Subordinate_Relationship_Set(
instance, test_relationship);
zassert_true(status, NULL);
zassert_equal(
Structured_View_Default_Subordinate_Relationship(instance),
test_relationship, NULL);
status = Structured_View_Represents_Set(instance, &test_represents);
zassert_true(status, NULL);
diff = memcmp(
Structured_View_Represents(instance), &test_represents,
sizeof(test_represents));
zassert_equal(diff, 0, NULL);
Structured_View_Subordinate_List_Set(instance, &test_subordinate_data);
diff = memcmp(
Structured_View_Subordinate_List(instance), &test_subordinate_data,
sizeof(test_subordinate_data));
zassert_equal(diff, 0, NULL);
}
/**
* @}