From 88abd3a488a79f3489e32ae366213b7bd642b1c6 Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Thu, 18 Dec 2025 16:25:52 -0600 Subject: [PATCH] Fixed lighting-output object blink warn relinquish. (#1192) * Fixed lighting-output object blink warn to honor blink-warn-enable. * Fixed the blink warn logic for a non-zero percent value blink inhibit. * Fixed the warn relinquish to actually relinquish. --- CHANGELOG.md | 3 +++ src/bacnet/basic/object/lo.c | 33 +++++++++++++------------- test/bacnet/basic/object/lo/src/main.c | 6 +++++ 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5027dfe5..34d2e2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,9 @@ The git repositories are hosted at the following sites: ### Fixed +* Fixed lighting-output object blink warn to honor blink-warn-enable. + Fixed the blink warn logic for a non-zero percent value blink inhibit. + Fixed the warn relinquish to actually relinquish. (#1192) * Fixed channel-value encoding in the channel object when no-coercian is required for lighting-command, color-command, and xy-color. (#1190) * Fixed NULL handling in CharacterString sprintf which caused an endless diff --git a/src/bacnet/basic/object/lo.c b/src/bacnet/basic/object/lo.c index ed727e55..10d1e2d9 100644 --- a/src/bacnet/basic/object/lo.c +++ b/src/bacnet/basic/object/lo.c @@ -477,7 +477,8 @@ Lighting_Command_Warn(struct object_data *pObject, unsigned priority) current_priority = Present_Value_Priority(pObject); if ((priority <= current_priority) && (Priority_Array_Active(pObject, priority - 1)) && - (isgreater(Priority_Array_Value(pObject, priority - 1), 0.0))) { + (!is_float_equal(Priority_Array_Value(pObject, priority - 1), 0.0)) && + pObject->Blink_Warn_Enable) { /* The blink-warn notification shall not occur if any of the following conditions occur: (a) The specified priority is not the highest @@ -506,8 +507,10 @@ Lighting_Command_Warn_Off(struct object_data *pObject, unsigned priority) current_priority = Present_Value_Priority(pObject); if ((priority <= current_priority) && (Priority_Array_Active(pObject, priority - 1)) && - (isgreater(Priority_Array_Value(pObject, priority - 1), 0.0)) && - (isgreater(Priority_Array_Next_Value(pObject, priority - 1), 0.0))) { + (!is_float_equal(Priority_Array_Value(pObject, priority - 1), 0.0)) && + (is_float_equal( + Priority_Array_Next_Value(pObject, priority - 1), 0.0)) && + pObject->Blink_Warn_Enable) { /* The blink-warn notification shall not occur and the value 0.0% written at the specified priority immediately if any of the following @@ -521,9 +524,8 @@ Lighting_Command_Warn_Off(struct object_data *pObject, unsigned priority) lighting_command_blink_warn( &pObject->Lighting_Command, BACNET_LIGHTS_WARN_OFF, &pObject->Lighting_Command.Blink); - } else { - Present_Value_Set(pObject, 0.0, priority); } + Present_Value_Set(pObject, 0.0, priority); } /** @@ -542,28 +544,25 @@ Lighting_Command_Warn_Relinquish(struct object_data *pObject, unsigned priority) current_priority = Present_Value_Priority(pObject); if ((priority <= current_priority) && (Priority_Array_Active(pObject, priority - 1)) && - (isgreater(Priority_Array_Value(pObject, priority - 1), 0.0)) && - (isgreater(Priority_Array_Next_Value(pObject, priority - 1), 0.0))) { + (!is_float_equal(Priority_Array_Value(pObject, priority - 1), 0.0)) && + (is_float_equal( + Priority_Array_Next_Value(pObject, priority - 1), 0.0)) && + pObject->Blink_Warn_Enable) { /* The blink-warn notification shall not occur, and the value at the specified priority shall be relinquished immediately if any of the following conditions occur: - (a) The specified priority is not the highest - active priority, or - (b) The value at the specified priority - is 0.0% or NULL, or - (c) The value of the next highest non-NULL - priority, including Relinquish_Default, - is greater than 0.0%, or - (d) Blink_Warn_Enable is FALSE. */ + (a) Blink_Warn_Enable is FALSE, or + (b) The Present_Value is 0.0%, or + (c) The Present_Value would not evaluate to 0.0% after + the priority slot is relinquished. */ pObject->Lighting_Command.Blink.Duration = pObject->Egress_Time_Seconds * 1000UL; lighting_command_blink_warn( &pObject->Lighting_Command, BACNET_LIGHTS_WARN_RELINQUISH, &pObject->Lighting_Command.Blink); - } else { - Present_Value_Relinquish(pObject, priority); } + Present_Value_Relinquish(pObject, priority); } /** diff --git a/test/bacnet/basic/object/lo/src/main.c b/test/bacnet/basic/object/lo/src/main.c index 9b625a97..e9041fdb 100644 --- a/test/bacnet/basic/object/lo/src/main.c +++ b/test/bacnet/basic/object/lo/src/main.c @@ -180,6 +180,8 @@ static void testLightingOutput(void) /* WARN - start with lights on */ real_value = -1.0; priority = 8; + status = Lighting_Output_Blink_Warn_Enable_Set(instance, true); + zassert_true(status, NULL); status = Lighting_Output_Present_Value_Set(instance, 100.0f, priority); zassert_true(status, NULL); Lighting_Output_Timer(instance, 10); @@ -201,6 +203,8 @@ static void testLightingOutput(void) /* WARN RELINQUISH */ real_value = -2.0; priority = 8; + status = Lighting_Output_Blink_Warn_Enable(instance); + zassert_true(status, NULL); Lighting_Output_Present_Value_Set(instance, real_value, priority); Lighting_Output_Timer(instance, 10); in_progress = Lighting_Output_In_Progress(instance); @@ -210,6 +214,8 @@ static void testLightingOutput(void) /* WARN_OFF */ real_value = -3.0; priority = 8; + status = Lighting_Output_Blink_Warn_Enable(instance); + zassert_true(status, NULL); Lighting_Output_Present_Value_Set(instance, real_value, priority); Lighting_Output_Timer(instance, 10); in_progress = Lighting_Output_In_Progress(instance);