diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-04-27 14:29:24 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2017-05-11 13:52:50 -0500 |
commit | a9406a774a35c02fabc94ab842788dd9891f59e8 (patch) | |
tree | ea5e5cfd98ba88f293ba31137e697903237d92d5 /monitor/tach_sensor.cpp | |
parent | ebaae6115ff5248d7f46d065ca96229c1f4e583d (diff) | |
download | phosphor-fan-presence-a9406a774a35c02fabc94ab842788dd9891f59e8.tar.gz phosphor-fan-presence-a9406a774a35c02fabc94ab842788dd9891f59e8.zip |
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>
Diffstat (limited to 'monitor/tach_sensor.cpp')
-rw-r--r-- | monitor/tach_sensor.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
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 @@ TachSensor::TachSensor(sdbusplus::bus::bus& bus, 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 @@ void TachSensor::handleTachChange(sdbusplus::message::message& msg, } +std::chrono::microseconds TachSensor::getTimeout() +{ + using namespace std::chrono; + + return duration_cast<microseconds>(seconds(_timeout)); +} + + } } } |