monitor: Support a separate upper deviation
Add an optional 'upper_deviation' field to the fan monitor config and if
supplied it will be used for the allowed deviation when the fan value is
over the target. If not supplied it will work as today and the single
deviation value will be used for both the upper and lower bounds.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I085dc1996832e79b94bd1df3a05681d107f466eb
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 9e05009..3030d5c 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -207,11 +207,12 @@
}
std::pair<uint64_t, std::optional<uint64_t>>
- TachSensor::getRange(const size_t deviation) const
+ TachSensor::getRange(const size_t lowerDeviation,
+ const size_t upperDeviation) const
{
// Determine min/max range applying the deviation
- uint64_t min = getTarget() * (100 - deviation) / 100;
- std::optional<uint64_t> max = getTarget() * (100 + deviation) / 100;
+ uint64_t min = getTarget() * (100 - lowerDeviation) / 100;
+ std::optional<uint64_t> max = getTarget() * (100 + upperDeviation) / 100;
// Adjust the min/max range by applying the factor & offset
min = min * _factor + _offset;