Added post-write notifications for channel, timer, and loop objects. (#1204)

This commit is contained in:
Steve Karg
2026-01-20 13:13:45 -06:00
committed by GitHub
parent 5802bd0ecc
commit 89cf25c2b2
10 changed files with 367 additions and 13 deletions
+56
View File
@@ -35,6 +35,20 @@ static int Read_Property_Internal(BACNET_READ_PROPERTY_DATA *data)
return Read_Property_Internal_Length;
}
static struct loop_write_property_notification Write_Property_Notification;
static BACNET_WRITE_PROPERTY_DATA Write_Property_Notification_Data;
static uint32_t Write_Property_Notification_Instance;
static bool Write_Property_Notification_Status;
static void Loop_Write_Property_Notification_Callback(
uint32_t instance, bool status, BACNET_WRITE_PROPERTY_DATA *wp_data)
{
Write_Property_Notification_Instance = instance;
Write_Property_Notification_Status = status;
memcpy(
&Write_Property_Notification_Data, wp_data,
sizeof(BACNET_WRITE_PROPERTY_DATA));
}
static int Proprietary_Properties[] = { 512, 513, -1 };
static uint8_t Proprietary_Serial_Number[16];
@@ -369,6 +383,8 @@ static void test_Loop_Operation(void)
bool status = false;
uint32_t elapsed_time = 0;
BACNET_OBJECT_PROPERTY_REFERENCE reference = { 0 };
BACNET_APPLICATION_DATA_VALUE test_value = { 0 };
int len = 0;
/* init */
Loop_Init();
@@ -379,6 +395,10 @@ static void test_Loop_Operation(void)
/* connect the read and write property callbacks */
Loop_Write_Property_Internal_Callback_Set(Write_Property_Internal);
Loop_Read_Property_Internal_Callback_Set(Read_Property_Internal);
Write_Property_Notification.callback =
Loop_Write_Property_Notification_Callback;
Write_Property_Notification.next = NULL;
Loop_Write_Property_Notification_Add(&Write_Property_Notification);
/* run the PID loop */
Loop_Timer(instance, elapsed_time);
elapsed_time += 1000;
@@ -402,6 +422,42 @@ static void test_Loop_Operation(void)
Loop_Manipulated_Variable_Reference_Set(instance, &reference);
elapsed_time += 100;
Loop_Timer(instance, elapsed_time);
/* references - test by referencing another internal object */
reference.object_identifier.type = OBJECT_ANALOG_OUTPUT;
reference.property_identifier = PROP_PRESENT_VALUE;
Loop_Manipulated_Variable_Reference_Set(instance, &reference);
elapsed_time += 100;
Loop_Timer(instance, elapsed_time);
/* verify that the internal read/write property callbacks were used */
zassert_equal(
Write_Property_Internal_Data.object_type, OBJECT_ANALOG_OUTPUT,
"WriteProperty=%s:%d",
bactext_object_type_name(Write_Property_Internal_Data.object_type),
Write_Property_Internal_Data.object_instance);
zassert_equal(
Write_Property_Internal_Data.object_instance, instance,
"WriteProperty=%s:%d",
bactext_object_type_name(Write_Property_Internal_Data.object_type),
Write_Property_Internal_Data.object_instance);
zassert_equal(
Write_Property_Internal_Data.object_property, PROP_PRESENT_VALUE,
"WriteProperty=%s:%d %s",
bactext_object_type_name(Write_Property_Internal_Data.object_type),
Write_Property_Internal_Data.object_instance,
bactext_property_name(Write_Property_Internal_Data.object_property));
len = bacapp_decode_application_data(
Write_Property_Internal_Data.application_data,
Write_Property_Internal_Data.application_data_len, &test_value);
zassert_true(len > 0, "len=%d", len);
zassert_equal(Write_Property_Notification_Instance, instance, NULL);
zassert_equal(Write_Property_Notification_Status, true, NULL);
zassert_equal(
Write_Property_Notification_Data.object_property, PROP_PRESENT_VALUE,
NULL);
len = bacapp_decode_application_data(
Write_Property_Notification_Data.application_data,
Write_Property_Notification_Data.application_data_len, &test_value);
zassert_true(len > 0, "len=%d", len);
/* cleanup instance */
status = Loop_Delete(instance);
zassert_true(status, NULL);