Fan floor by median sensor value within a range
Add action to set the floor speed based on sensors from within a defined
valid range and using their median value. The floor speed is selected
from the first map key entry that the median value is less than where 3
or more sensor values are valid. In the case where less than 3 sensor
values are valid, use the highest valid value and default the floor
speed when 0 sensor values are valid.
Tested:
Configured wspoon with this action & correct floor resulted:
Sensor value invalidated outside of range
Single valid ambient sensor
Default floor with no valid sensors(kill ambient service)
Highest value used w/ 2 valid sensors
Middle value used w/ odd number of valid sensors(median)
Average value of middle two valid sensors w/ even number(median)
Change-Id: Ia1599ff13e25dbd7caa7b02c9340cc3e1e9947c6
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/actions.hpp b/control/actions.hpp
index 9b9bbed..f7053cb 100644
--- a/control/actions.hpp
+++ b/control/actions.hpp
@@ -347,6 +347,28 @@
};
}
+/**
+ * @brief An action to set the floor speed on a zone
+ * @details Using sensor group values that are within a defined range, the
+ * floor speed is selected from the first map key entry that the median
+ * sensor value is less than where 3 or more sensor group values are valid.
+ * In the case where less than 3 sensor values are valid, use the highest
+ * sensor group value and default the floor speed when 0 sensor group values
+ * are valid.
+ *
+ * @param[in] lowerBound - Lowest allowed sensor value to be valid
+ * @param[in] upperBound - Highest allowed sensor value to be valid
+ * @param[in] valueToSpeed - Ordered map of sensor value-to-speed
+ *
+ * @return Action lambda function
+ * An Action function to set the zone's floor speed from a resulting group
+ * of valid sensor values based on their highest value or median.
+ */
+Action set_floor_from_median_sensor_value(
+ int64_t lowerBound,
+ int64_t upperBound,
+ std::map<int64_t, uint64_t>&& valueToSpeed);
+
} // namespace action
} // namespace control
} // namespace fan