summaryrefslogtreecommitdiffstats
path: root/monitor
diff options
context:
space:
mode:
Diffstat (limited to 'monitor')
-rw-r--r--monitor/fan.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 7d657a0..d1101b9 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -26,6 +26,7 @@ namespace monitor
{
using namespace phosphor::logging;
+using TimerType = phosphor::fan::util::Timer::TimerType;
Fan::Fan(sdbusplus::bus::bus& bus,
std::shared_ptr<sd_event>& events,
@@ -47,6 +48,10 @@ Fan::Fan(sdbusplus::bus::bus& bus,
std::get<timeoutField>(def),
events));
}
+
+ //The TachSensors will now have already read the input
+ //and target values, so check them.
+ tachChanged();
}
@@ -61,7 +66,44 @@ void Fan::tachChanged()
void Fan::tachChanged(TachSensor& sensor)
{
- //TODO
+ auto& timer = sensor.getTimer();
+ auto running = timer.running();
+
+ //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.
+
+ //If this sensor is OK, put everything back into a good state.
+
+ if (outOfRange(sensor))
+ {
+ if (sensor.functional() && !running)
+ {
+ timer.start(sensor.getTimeout(), TimerType::oneshot);
+ }
+ }
+ else
+ {
+ if (!sensor.functional())
+ {
+ sensor.setFunctional(true);
+ }
+
+ if (running)
+ {
+ timer.stop();
+ }
+
+ //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()));
+
+ //TODO: actually update inventory
+ }
+ }
}
OpenPOWER on IntegriCloud