From 696aed8abe58696e5eb173da38b848825523883a Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Sun, 21 Jan 2018 19:50:17 -0600 Subject: Allow override of deviation with absolute minimum RPM If the devation is less than zero, treat as an absolute minimum RPM value --- monitor/fan.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'monitor/fan.cpp') diff --git a/monitor/fan.cpp b/monitor/fan.cpp index 014080d..6df98e5 100644 --- a/monitor/fan.cpp +++ b/monitor/fan.cpp @@ -36,7 +36,8 @@ Fan::Fan(Mode mode, const FanDefinition& def) : _bus(bus), _name(std::get(def)), - _deviation(std::get(def)), + _deviation((std::get(def) < 0)?abs(std::get(def)):std::get(def)), + _deviationIsMinRPM((std::get(def) < 0)?true:false), _numSensorFailsForNonFunc(std::get(def)), _trustManager(trust) { @@ -168,17 +169,26 @@ bool Fan::outOfRange(const TachSensor& sensor) auto factor = sensor.getFactor(); auto offset = sensor.getOffset(); - uint64_t min = target * (100 - _deviation) / 100; - uint64_t max = target * (100 + _deviation) / 100; - - // TODO: openbmc/openbmc#2937 enhance this function - // either by making it virtual, or by predefining different - // outOfRange ops and selecting by yaml config - min = min * factor + offset; - max = max * factor + offset; - if ((actual < min) || (actual > max)) + if (_deviationIsMinRPM) { - return true; + if (actual < _deviation) + { + return true; + } + } + else { + uint64_t min = target * (100 - _deviation) / 100; + uint64_t max = target * (100 + _deviation) / 100; + + // TODO: openbmc/openbmc#2937 enhance this function + // either by making it virtual, or by predefining different + // outOfRange ops and selecting by yaml config + min = min * factor + offset; + max = max * factor + offset; + if ((actual < min) || (actual > max)) + { + return true; + } } return false; -- cgit v1.2.1