summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-02-20 12:11:07 -0600
committerMatthew Barth <msbarth@us.ibm.com>2018-03-01 09:38:44 -0600
commite11cbc605e79bbf6b2651c30ef8f64a9ae4167b0 (patch)
tree89996f309c3852cab8673e9160ce1ed6df36739f
parent3800ae715a5835e72754a03eac230ef00d14c538 (diff)
downloadphosphor-fan-presence-e11cbc605e79bbf6b2651c30ef8f64a9ae4167b0.tar.gz
phosphor-fan-presence-e11cbc605e79bbf6b2651c30ef8f64a9ae4167b0.zip
Handle timer expiration on state changes
Update to start all tach sensor functional state change timers on a fan where the corresponding state and inventory is updated when the timer expires. Only start the timer in nonfunctional mode when a tach sensor is out of range and is currently functional and start the functional mode timer when its in range and currently nonfunctional. Tested: Tach sensors are marked nonfunctional as normal. Tach sensors are updated to functional after 5sec(yaml test value) Nonfunctional timer is cancelled if fan returns within spec Functional timer is cancelled if fan returns out of spec Change-Id: I88622d07d8713f88e8070940a4bd96046a053fb5 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--monitor/fan.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 96db76c..39b32bb 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -100,8 +100,6 @@ void Fan::tachChanged(TachSensor& sensor)
}
}
- auto running = sensor.timerRunning();
-
//If this sensor is out of range at this moment, start
//its timer, at the end of which the inventory
//for the fan may get updated to not functional.
@@ -110,31 +108,22 @@ void Fan::tachChanged(TachSensor& sensor)
if (outOfRange(sensor))
{
- if (sensor.functional() && !running)
+ if (sensor.functional())
{
+ // Start nonfunctional timer if not already running
sensor.startTimer(TimerMode::nonfunc);
}
}
else
{
- if (!sensor.functional())
- {
- sensor.setFunctional(true);
- }
-
- if (running)
+ if (sensor.functional())
{
sensor.stopTimer();
}
-
- //If the fan was nonfunctional and enough sensors are now OK,
- //the fan can go back to functional
- if (!_functional && !tooManySensorsNonfunctional())
+ else
{
- log<level::INFO>("Setting a fan back to functional",
- entry("FAN=%s", _name.c_str()));
-
- updateInventory(true);
+ // Start functional timer if not already running
+ sensor.startTimer(TimerMode::func);
}
}
}
@@ -198,12 +187,21 @@ bool Fan::outOfRange(const TachSensor& sensor)
void Fan::timerExpired(TachSensor& sensor)
{
- sensor.setFunctional(false);
+ sensor.setFunctional(!sensor.functional());
+
+ //If the fan was nonfunctional and enough sensors are now OK,
+ //the fan can go back to functional
+ if (!_functional && !tooManySensorsNonfunctional())
+ {
+ log<level::INFO>("Setting a fan back to functional",
+ entry("FAN=%s", _name.c_str()));
+
+ updateInventory(true);
+ }
//If the fan is currently functional, but too many
//contained sensors are now nonfunctional, update
//the whole fan nonfunctional.
-
if (_functional && tooManySensorsNonfunctional())
{
log<level::ERR>("Setting a fan to nonfunctional",
OpenPOWER on IntegriCloud