summaryrefslogtreecommitdiffstats
path: root/monitor/fan.cpp
diff options
context:
space:
mode:
authorRaptor Engineering Development Team <support@raptorengineering.com>2018-01-21 19:50:17 -0600
committerRaptor Engineering Development Team <support@raptorengineering.com>2019-04-19 22:07:46 +0000
commit696aed8abe58696e5eb173da38b848825523883a (patch)
treea473da809bcb73f4b7441820c51a0e020048d654 /monitor/fan.cpp
parent71779ab4b3699a22f3bb88f2d94ee25c81b15d6f (diff)
downloadphosphor-fan-presence-696aed8abe58696e5eb173da38b848825523883a.zip
phosphor-fan-presence-696aed8abe58696e5eb173da38b848825523883a.tar.gz
Allow override of deviation with absolute minimum RPM
If the devation is less than zero, treat as an absolute minimum RPM value
Diffstat (limited to 'monitor/fan.cpp')
-rw-r--r--monitor/fan.cpp32
1 files changed, 21 insertions, 11 deletions
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<fanNameField>(def)),
- _deviation(std::get<fanDeviationField>(def)),
+ _deviation((std::get<fanDeviationField>(def) < 0)?abs(std::get<fanDeviationField>(def)):std::get<fanDeviationField>(def)),
+ _deviationIsMinRPM((std::get<fanDeviationField>(def) < 0)?true:false),
_numSensorFailsForNonFunc(std::get<numSensorFailsForNonfuncField>(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;
OpenPOWER on IntegriCloud