Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 4 | #include <sdbusplus/server.hpp> |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 5 | #include "sensor_base.hpp" |
| 6 | |
| 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace fan |
| 11 | { |
| 12 | namespace presence |
| 13 | { |
| 14 | |
| 15 | class TachSensor : public Sensor |
| 16 | { |
| 17 | public: |
| 18 | TachSensor() = delete; |
| 19 | TachSensor(const TachSensor&) = delete; |
| 20 | TachSensor(TachSensor&&) = delete; |
| 21 | TachSensor& operator=(const TachSensor&) = delete; |
| 22 | TachSensor& operator=(TachSensor&&) = delete; |
| 23 | ~TachSensor() = default; |
| 24 | |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 25 | TachSensor( |
| 26 | sdbusplus::bus::bus& bus, |
| 27 | const std::string& id, |
| 28 | FanEnclosure& fanEnc) : |
| 29 | Sensor(id, fanEnc), |
| 30 | bus(bus), |
| 31 | tachSignal(bus, |
| 32 | match(id).c_str(), |
| 33 | handleTachChangeSignal, |
| 34 | this) |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 35 | { |
| 36 | // Nothing to do here |
| 37 | } |
| 38 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 39 | bool isPresent(); |
| 40 | |
| 41 | private: |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 42 | sdbusplus::bus::bus& bus; |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 43 | sdbusplus::server::match::match tachSignal; |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 44 | int64_t tach = 0; |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 45 | |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 46 | static std::string match(std::string id) |
| 47 | { |
| 48 | return std::string("type='signal'," |
| 49 | "interface='org.freedesktop.DBus.Properties'," |
| 50 | "member='PropertiesChanged'," |
| 51 | "path='/xyz/openbmc_project/sensors/fan_tach/" + |
| 52 | id + "'"); |
| 53 | } |
| 54 | // Tach signal callback handler |
| 55 | static int handleTachChangeSignal(sd_bus_message* msg, |
| 56 | void* data, |
| 57 | sd_bus_error* err); |
| 58 | |
| 59 | void handleTachChange(sdbusplus::message::message& msg, |
| 60 | sd_bus_error* err); |
| 61 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | } // namespace presence |
| 65 | } // namespace fan |
| 66 | } // namespace phosphor |