Add Timer support to TachSensor
Add a Timer object to the TachSensor class
Change-Id: I419b5712de9e8e94f2a08de84d13170e44c33c7a
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index c991bb6..806eed7 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -84,13 +84,14 @@
Fan& fan,
const std::string& id,
bool hasTarget,
- size_t timeout) :
-
+ size_t timeout,
+ std::shared_ptr<sd_event>& events) :
_bus(bus),
_fan(fan),
_name(FAN_SENSOR_PATH + id),
_hasTarget(hasTarget),
- _timeout(timeout)
+ _timeout(timeout),
+ _timer(events, [this, &fan](){ fan.timerExpired(*this); })
{
auto service = getService();
@@ -232,6 +233,14 @@
}
+std::chrono::microseconds TachSensor::getTimeout()
+{
+ using namespace std::chrono;
+
+ return duration_cast<microseconds>(seconds(_timeout));
+}
+
+
}
}
}