Fixed the lighting command RAMP TO ramp rate to always clamp within 0.1 and 100.0 to avoid endless rate of 0.0. (#1100)
* Fixed the lighting command RAMP TO ramp rate to always clamp within 0.1 and 100.0 to avoid endless rate of 0.0. * Fixed the use of default fade, ramp, or step when those optional parameters are missing from lighting command.
This commit is contained in:
@@ -117,6 +117,8 @@ The git repositories are hosted at the following sites:
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed the lighting command RAMP TO ramp rate to always clamp within
|
||||
0.1 and 100.0 to avoid endless rate of 0.0. (#1100)
|
||||
* Fixed Lighting Output step operations mixup. (#1099)
|
||||
* Fixed Lighting Output step operations to set the Priority_Array slot. (#1098)
|
||||
* Fixed the lighting output objects current priority comparison during
|
||||
|
||||
@@ -1328,6 +1328,8 @@ bool Lighting_Output_Lighting_Command_Set(
|
||||
bool status = false;
|
||||
struct object_data *pObject;
|
||||
unsigned priority;
|
||||
float ramp_rate, step_increment;
|
||||
uint32_t fade_time;
|
||||
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
@@ -1344,43 +1346,71 @@ bool Lighting_Output_Lighting_Command_Set(
|
||||
status = true;
|
||||
break;
|
||||
case BACNET_LIGHTS_FADE_TO:
|
||||
if (!value->use_target_level) {
|
||||
/* Error if the Target_Level is not specified */
|
||||
break;
|
||||
}
|
||||
if (value->use_fade_time) {
|
||||
fade_time = value->fade_time;
|
||||
} else {
|
||||
fade_time = pObject->Default_Fade_Time;
|
||||
}
|
||||
debug_printf(
|
||||
"LO[%u]: Lighting-Command@%u Fade-To "
|
||||
"Target=%f Fade=%u\n",
|
||||
object_instance, priority, (double)value->target_level,
|
||||
value->fade_time);
|
||||
(unsigned)fade_time);
|
||||
Lighting_Command_Fade_To(
|
||||
pObject, priority, value->target_level, value->fade_time);
|
||||
pObject, priority, value->target_level, fade_time);
|
||||
status = true;
|
||||
break;
|
||||
case BACNET_LIGHTS_RAMP_TO:
|
||||
if (!value->use_target_level) {
|
||||
/* Error if the Target_Level is not specified */
|
||||
break;
|
||||
}
|
||||
if (value->use_ramp_rate) {
|
||||
ramp_rate = value->ramp_rate;
|
||||
} else {
|
||||
ramp_rate = pObject->Default_Ramp_Rate;
|
||||
}
|
||||
debug_printf(
|
||||
"LO[%u]: Lighting-Command@%u Ramp-To "
|
||||
"Target=%f Ramp-Rate=%f\n",
|
||||
object_instance, priority, (double)value->target_level,
|
||||
(double)value->ramp_rate);
|
||||
(double)ramp_rate);
|
||||
Lighting_Command_Ramp_To(
|
||||
pObject, priority, value->target_level, value->ramp_rate);
|
||||
pObject, priority, value->target_level, ramp_rate);
|
||||
status = true;
|
||||
break;
|
||||
case BACNET_LIGHTS_STEP_UP:
|
||||
case BACNET_LIGHTS_STEP_ON:
|
||||
if (value->use_step_increment) {
|
||||
step_increment = value->step_increment;
|
||||
} else {
|
||||
step_increment = pObject->Default_Step_Increment;
|
||||
}
|
||||
debug_printf(
|
||||
"LO[%u]: Lighting-Command@%u Step "
|
||||
"Step-Increment=%f\n",
|
||||
object_instance, priority, (double)value->step_increment);
|
||||
object_instance, priority, (double)step_increment);
|
||||
Lighting_Command_Step_Up_On(
|
||||
pObject, priority, value->operation, value->step_increment);
|
||||
pObject, priority, value->operation, step_increment);
|
||||
status = true;
|
||||
break;
|
||||
case BACNET_LIGHTS_STEP_DOWN:
|
||||
case BACNET_LIGHTS_STEP_OFF:
|
||||
if (value->use_step_increment) {
|
||||
step_increment = value->step_increment;
|
||||
} else {
|
||||
step_increment = pObject->Default_Step_Increment;
|
||||
}
|
||||
debug_printf(
|
||||
"LO[%u]: Lighting-Command@%u Step "
|
||||
"Step-Increment=%f\n",
|
||||
object_instance, priority, (double)value->step_increment);
|
||||
object_instance, priority, (double)step_increment);
|
||||
Lighting_Command_Step_Down_Off(
|
||||
pObject, priority, value->operation, value->step_increment);
|
||||
pObject, priority, value->operation, step_increment);
|
||||
status = true;
|
||||
break;
|
||||
case BACNET_LIGHTS_WARN:
|
||||
|
||||
@@ -105,6 +105,23 @@ void lighting_command_timer_notfication_add(
|
||||
} while (head);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clamps the ramp rate value
|
||||
* @param ramp_rate [in] ramp rate value
|
||||
* @return clamped ramp rate value
|
||||
*/
|
||||
float lighting_command_ramp_rate_clamp(float ramp_rate)
|
||||
{
|
||||
if (isless(ramp_rate, 0.1f)) {
|
||||
ramp_rate = 0.1f;
|
||||
}
|
||||
if (isgreater(ramp_rate, 100.0f)) {
|
||||
ramp_rate = 100.0f;
|
||||
}
|
||||
|
||||
return ramp_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clamps the step increment value
|
||||
* @param step_increment [in] step increment value
|
||||
@@ -314,19 +331,11 @@ static void lighting_command_fade_handler(
|
||||
static void lighting_command_ramp_handler(
|
||||
struct bacnet_lighting_command_data *data, uint16_t milliseconds)
|
||||
{
|
||||
float old_value, target_value, step_value, steps;
|
||||
float old_value, target_value, step_value, steps, ramp_rate;
|
||||
|
||||
old_value = data->Tracking_Value;
|
||||
target_value =
|
||||
lighting_command_normalized_on_range_clamp(data, data->Target_Level);
|
||||
/* determine the number of steps */
|
||||
if (milliseconds <= 1000) {
|
||||
/* percent per second */
|
||||
steps = linear_interpolate(
|
||||
0.0f, (float)milliseconds, 1000.0f, 0.0f, data->Ramp_Rate);
|
||||
} else {
|
||||
steps = ((float)milliseconds * data->Ramp_Rate) / 1000.0f;
|
||||
}
|
||||
if (!islessgreater(data->Tracking_Value, target_value)) {
|
||||
/* stop ramping */
|
||||
if (isless(data->Target_Level, 1.0f)) {
|
||||
@@ -338,6 +347,15 @@ static void lighting_command_ramp_handler(
|
||||
data->In_Progress = BACNET_LIGHTING_IDLE;
|
||||
data->Lighting_Operation = BACNET_LIGHTS_STOP;
|
||||
} else {
|
||||
ramp_rate = lighting_command_ramp_rate_clamp(data->Ramp_Rate);
|
||||
/* determine the number of steps */
|
||||
if (milliseconds <= 1000) {
|
||||
/* percent per second */
|
||||
steps = linear_interpolate(
|
||||
0.0f, (float)milliseconds, 1000.0f, 0.0f, ramp_rate);
|
||||
} else {
|
||||
steps = ((float)milliseconds * ramp_rate) / 1000.0f;
|
||||
}
|
||||
if (isless(old_value, target_value)) {
|
||||
step_value = old_value + steps;
|
||||
if (isgreater(step_value, target_value)) {
|
||||
@@ -693,7 +711,7 @@ void lighting_command_ramp_to(
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
data->Ramp_Rate = ramp_rate;
|
||||
data->Ramp_Rate = lighting_command_ramp_rate_clamp(ramp_rate);
|
||||
data->Lighting_Operation = BACNET_LIGHTS_RAMP_TO;
|
||||
data->Target_Level = value;
|
||||
}
|
||||
@@ -714,7 +732,6 @@ void lighting_command_step(
|
||||
}
|
||||
data->Lighting_Operation = operation;
|
||||
data->Fade_Time = 0;
|
||||
data->Ramp_Rate = 0.0f;
|
||||
data->Step_Increment = step_increment;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,8 @@ BACNET_STACK_EXPORT
|
||||
void lighting_command_override(
|
||||
struct bacnet_lighting_command_data *data, float value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
float lighting_command_ramp_rate_clamp(float ramp_rate);
|
||||
BACNET_STACK_EXPORT
|
||||
float lighting_command_step_increment_clamp(float step_increment);
|
||||
BACNET_STACK_EXPORT
|
||||
|
||||
Reference in New Issue
Block a user