summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Feist <james.feist@linux.intel.com>2019-02-25 09:19:13 -0800
committerJames Feist <james.feist@linux.intel.com>2019-02-25 17:43:18 +0000
commit473d68db2adb7a15061cfb4b4f91248bd98721a1 (patch)
tree213a97e2c05709cc2fbbda8fe55c785e97ef39d5
parent903b04276b98c072b3399ac20101ad44daf335cd (diff)
downloadphosphor-pid-control-473d68db2adb7a15061cfb4b4f91248bd98721a1.tar.gz
phosphor-pid-control-473d68db2adb7a15061cfb4b4f91248bd98721a1.zip
Allow removal from failsafe if timeout=0
Initialize cache on start adds all sensors to failsafe. Without being able to hit the removal in updatesensors this causes the system to go into failsafe and never remove. Closes #8 Change-Id: I83f495adb1475abc27dba1734022f28d89e03d8f Signed-off-by: James Feist <james.feist@linux.intel.com>
-rw-r--r--pid/zone.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/pid/zone.cpp b/pid/zone.cpp
index 4892409..fc0b40b 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -250,31 +250,25 @@ void PIDZone::updateSensors(void)
_cachedValuesByName[t] = r.value;
tstamp then = r.updated;
+ auto duration = duration_cast<std::chrono::seconds>(now - then).count();
+ auto period = std::chrono::seconds(timeout).count();
+
if (sensor->getFailed())
{
_failSafeSensors.insert(t);
}
- /* Only go into failsafe if the timeout is set for
- * the sensor.
- */
- else if (timeout > 0)
+ else if (timeout != 0 && duration >= period)
{
- auto duration =
- duration_cast<std::chrono::seconds>(now - then).count();
- auto period = std::chrono::seconds(timeout).count();
- if (duration >= period)
- {
- // std::cerr << "Entering fail safe mode.\n";
- _failSafeSensors.insert(t);
- }
- else
+ // std::cerr << "Entering fail safe mode.\n";
+ _failSafeSensors.insert(t);
+ }
+ else
+ {
+ // Check if it's in there: remove it.
+ auto kt = _failSafeSensors.find(t);
+ if (kt != _failSafeSensors.end())
{
- // Check if it's in there: remove it.
- auto kt = _failSafeSensors.find(t);
- if (kt != _failSafeSensors.end())
- {
- _failSafeSensors.erase(kt);
- }
+ _failSafeSensors.erase(kt);
}
}
}
OpenPOWER on IntegriCloud