Fixed Lighting Output Relinquish values. (#1094)
* Fixed Lighting Output Relinquish values. * Added lighting command refresh from tracking value API.
This commit is contained in:
@@ -253,6 +253,22 @@ static float Priority_Array_Value(
|
||||
return real_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Relinquish Default property value of the lighting output
|
||||
* @param object [in] BACnet object instance
|
||||
* @return The relinquish-default value for this object
|
||||
*/
|
||||
static float Relinquish_Default_Value(const struct object_data *pObject)
|
||||
{
|
||||
float value = 0.0;
|
||||
|
||||
if (pObject) {
|
||||
value = pObject->Relinquish_Default;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value of the next highest non-NULL priority, including
|
||||
* Relinquish_Default
|
||||
@@ -264,10 +280,10 @@ static float Priority_Array_Value(
|
||||
static float Priority_Array_Next_Value(
|
||||
const struct object_data *pObject, BACNET_ARRAY_INDEX priority)
|
||||
{
|
||||
float real_value = 0.0;
|
||||
unsigned p = 0;
|
||||
float real_value;
|
||||
unsigned p;
|
||||
|
||||
real_value = pObject->Relinquish_Default;
|
||||
real_value = Relinquish_Default_Value(pObject);
|
||||
for (p = priority; p < BACNET_MAX_PRIORITY; p++) {
|
||||
if (Priority_Array_Active(pObject, p)) {
|
||||
real_value = pObject->Priority_Array[p];
|
||||
@@ -883,14 +899,7 @@ bool Lighting_Output_Present_Value_Relinquish(
|
||||
status = Present_Value_Relinquish(pObject, priority);
|
||||
new_priority = Present_Value_Priority(pObject);
|
||||
if (status && (old_priority != new_priority)) {
|
||||
if (new_priority > BACNET_MAX_PRIORITY) {
|
||||
/* BACNET_LIGHTS_WARN_RELINQUISH? */
|
||||
value =
|
||||
(float)Lighting_Output_Relinquish_Default(object_instance);
|
||||
} else {
|
||||
value = (float)Lighting_Output_Present_Value_Priority(
|
||||
object_instance);
|
||||
}
|
||||
value = Priority_Array_Next_Value(pObject, 0);
|
||||
/* we have priority - configure the Lighting Command */
|
||||
Lighting_Command_Transition_Default(pObject, new_priority, value);
|
||||
}
|
||||
@@ -1283,6 +1292,26 @@ bool Lighting_Output_Lighting_Command_Set(
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief For a given object instance-number, refreshes the tracking-value
|
||||
* to the current lighting command value.
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @return true if lighting command was set
|
||||
*/
|
||||
bool Lighting_Output_Lighting_Command_Refresh(uint32_t object_instance)
|
||||
{
|
||||
bool status = false;
|
||||
struct object_data *pObject;
|
||||
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
lighting_command_refresh(&pObject->Lighting_Command);
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, gets the in-progress property value
|
||||
*
|
||||
@@ -1931,9 +1960,7 @@ float Lighting_Output_Relinquish_Default(uint32_t object_instance)
|
||||
struct object_data *pObject;
|
||||
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
value = pObject->Relinquish_Default;
|
||||
}
|
||||
value = Relinquish_Default_Value(pObject);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,8 @@ bool Lighting_Output_Out_Of_Service(uint32_t instance);
|
||||
BACNET_STACK_EXPORT
|
||||
void Lighting_Output_Out_Of_Service_Set(uint32_t instance, bool oos_flag);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Lighting_Output_Lighting_Command_Refresh(uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Lighting_Output_Lighting_Command_Set(
|
||||
uint32_t object_instance, const BACNET_LIGHTING_COMMAND *value);
|
||||
|
||||
@@ -592,6 +592,21 @@ void lighting_command_override(
|
||||
lighting_command_tracking_value_event(data, old_value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Refreshes the current lighting command at the tracking value
|
||||
* @param data [in] dimmer data
|
||||
*/
|
||||
void lighting_command_refresh(struct bacnet_lighting_command_data *data)
|
||||
{
|
||||
float value;
|
||||
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
value = data->Tracking_Value;
|
||||
lighting_command_tracking_value_event(data, value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the dimmer tracking value per ramp or fade or step
|
||||
* @param data [in] dimmer data
|
||||
|
||||
@@ -136,6 +136,8 @@ BACNET_STACK_EXPORT
|
||||
float lighting_command_normalized_on_range_clamp(
|
||||
struct bacnet_lighting_command_data *data, float value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void lighting_command_refresh(struct bacnet_lighting_command_data *data);
|
||||
BACNET_STACK_EXPORT
|
||||
void lighting_command_init(struct bacnet_lighting_command_data *data);
|
||||
BACNET_STACK_EXPORT
|
||||
|
||||
Reference in New Issue
Block a user