From 979ff0ead938abd288f5b62249a53e9eed4965c4 Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Tue, 11 Nov 2025 09:41:38 -0600 Subject: [PATCH] Added defines for lighting output object present-value special values. (#1137) --- CHANGELOG.md | 1 + src/bacnet/basic/object/lo.c | 23 ++++++++++++++++------- src/bacnet/lighting.h | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea14ee8e..48af8938 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ The git repositories are hosted at the following sites: ### Added +* Added defines for lighting output object present-value special values. (#1137) * Added get copy API to timer object for state-change-value (#1134) * Added Audit Log and Time Value objects to basic device and builds. (#1128) * Added ListElement service callback for storing data. (#1128) diff --git a/src/bacnet/basic/object/lo.c b/src/bacnet/basic/object/lo.c index b56f9f43..907a1df6 100644 --- a/src/bacnet/basic/object/lo.c +++ b/src/bacnet/basic/object/lo.c @@ -873,38 +873,47 @@ bool Lighting_Output_Present_Value_Set( the corresponding lighting command and is subject to the same restrictions. The special value itself is not written to the priority array. */ - if (is_float_equal(value, -1.0)) { + if (is_float_equal(value, BACNET_LIGHTING_SPECIAL_VALUE_WARN)) { /* Provides the same functionality as the WARN lighting command. */ Lighting_Command_Warn(pObject, priority); status = true; - } else if (is_float_equal(value, -2.0)) { + } else if (is_float_equal( + value, + BACNET_LIGHTING_SPECIAL_VALUE_WARN_RELINQUISH)) { /* Provides the same functionality as the WARN_RELINQUISH lighting command. */ Lighting_Command_Warn_Relinquish(pObject, priority); status = true; - } else if (is_float_equal(value, -3.0)) { + } else if (is_float_equal( + value, BACNET_LIGHTING_SPECIAL_VALUE_WARN_OFF)) { /* Provides the same functionality as the WARN_OFF lighting command. */ Lighting_Command_Warn_Off(pObject, priority); status = true; #if (BACNET_PROTOCOL_REVISION >= 28) - } else if (is_float_equal(value, -4.0)) { + } else if (is_float_equal( + value, BACNET_LIGHTING_SPECIAL_VALUE_RESTORE_ON)) { /* Provides the same functionality as the RESTORE_ON lighting command. */ Lighting_Command_Restore_On(pObject, priority); status = true; - } else if (is_float_equal(value, -5.0)) { + } else if (is_float_equal( + value, BACNET_LIGHTING_SPECIAL_VALUE_DEFAULT_ON)) { /* Provides the same functionality as the DEFAULT_ON lighting command. */ Lighting_Command_Default_On(pObject, priority); status = true; - } else if (is_float_equal(value, -6.0)) { + } else if (is_float_equal( + value, + BACNET_LIGHTING_SPECIAL_VALUE_TOGGLE_RESTORE)) { /* Provides the same functionality as the TOGGLE_RESTORE lighting command. */ Lighting_Command_Toggle_Restore(pObject, priority); status = true; - } else if (is_float_equal(value, -7.0)) { + } else if (is_float_equal( + value, + BACNET_LIGHTING_SPECIAL_VALUE_TOGGLE_DEFAULT)) { /* Provides the same functionality as the TOGGLE_DEFAULT lighting command. */ Lighting_Command_Toggle_Default(pObject, priority); diff --git a/src/bacnet/lighting.h b/src/bacnet/lighting.h index f7503a50..97c23e78 100644 --- a/src/bacnet/lighting.h +++ b/src/bacnet/lighting.h @@ -40,6 +40,28 @@ typedef struct BACnetLightingCommand { uint8_t priority; } BACNET_LIGHTING_COMMAND; +/* The Lighting Output object Present_Value supports special values. + Some special values (e.g., 0.0, 1.0, 100.0) are within the normal + operating range (0.0–100.0%) but have specific semantic meanings + such as ON, OFF, and MIN. Other special values (negative values) are + outside of the normal range of values and trigger specific lighting + commands to provide functionality from objects and devices that are + unable to write the complex datatypes used in the Lighting Command + property (e.g., the BACnet Schedule object type). + Writing a special value has the same effect as writing the + corresponding lighting command and is subject to the same restrictions.*/ +/* Table 12-65. Special Values of the Present_Value Property */ +#define BACNET_LIGHTING_SPECIAL_VALUE_ON 100.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_MIN 1.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_OFF 0.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_WARN -1.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_WARN_RELINQUISH -2.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_WARN_OFF -3.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_RESTORE_ON -4.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_DEFAULT_ON -5.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_TOGGLE_RESTORE -6.0f +#define BACNET_LIGHTING_SPECIAL_VALUE_TOGGLE_DEFAULT -7.0f + /** * BACnetxyColor::= SEQUENCE { * x-coordinate REAL, --(0.0 to 1.0)