James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | ca44b2f | 2019-10-31 11:02:26 -0700 | [diff] [blame] | 3 | #include "Thresholds.hpp" |
| 4 | #include "sensor.hpp" |
| 5 | |
James Feist | 8086aba | 2020-08-25 16:00:59 -0700 | [diff] [blame^] | 6 | #include <boost/asio/streambuf.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 7 | #include <sdbusplus/asio/object_server.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 8 | |
Patrick Venture | fd6ba73 | 2019-10-31 14:27:39 -0700 | [diff] [blame] | 9 | #include <string> |
| 10 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 11 | |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 12 | class HwmonTempSensor : |
| 13 | public Sensor, |
| 14 | public std::enable_shared_from_this<HwmonTempSensor> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 15 | { |
| 16 | public: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 17 | HwmonTempSensor(const std::string& path, const std::string& objectType, |
| 18 | sdbusplus::asio::object_server& objectServer, |
| 19 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 20 | boost::asio::io_service& io, const std::string& fanName, |
| 21 | std::vector<thresholds::Threshold>&& thresholds, |
James Feist | f9b01b6 | 2020-01-29 15:21:58 -0800 | [diff] [blame] | 22 | const std::string& sensorConfiguration, |
| 23 | const PowerState powerState); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 24 | ~HwmonTempSensor(); |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 25 | void setupRead(void); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 26 | |
| 27 | private: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 28 | sdbusplus::asio::object_server& objServer; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 29 | boost::asio::posix::stream_descriptor inputDev; |
| 30 | boost::asio::deadline_timer waitTimer; |
| 31 | boost::asio::streambuf readBuf; |
James Feist | 930fcde | 2019-05-28 12:58:43 -0700 | [diff] [blame] | 32 | std::string path; |
Brad Bishop | fbb44ad | 2019-11-08 09:42:37 -0500 | [diff] [blame] | 33 | size_t errCount; |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 34 | |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 35 | void handleResponse(const boost::system::error_code& err); |
James Feist | ce3fca4 | 2018-11-21 12:58:24 -0800 | [diff] [blame] | 36 | void checkThresholds(void) override; |
Patrick Venture | ca44b2f | 2019-10-31 11:02:26 -0700 | [diff] [blame] | 37 | }; |