James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 3 | #include <Thresholds.hpp> |
James Feist | 8086aba | 2020-08-25 16:00:59 -0700 | [diff] [blame] | 4 | #include <boost/asio/streambuf.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 5 | #include <sdbusplus/asio/object_server.hpp> |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 6 | #include <sensor.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 7 | |
Patrick Venture | fd6ba73 | 2019-10-31 14:27:39 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 10 | |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 11 | class HwmonTempSensor : |
| 12 | public Sensor, |
| 13 | public std::enable_shared_from_this<HwmonTempSensor> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 14 | { |
| 15 | public: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 16 | HwmonTempSensor(const std::string& path, const std::string& objectType, |
| 17 | sdbusplus::asio::object_server& objectServer, |
| 18 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
Bruce Mitchell | 5cf0f99 | 2021-07-30 08:49:12 -0500 | [diff] [blame^] | 19 | boost::asio::io_service& io, const std::string& sensorName, |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 20 | std::vector<thresholds::Threshold>&& thresholds, |
Jeff Lin | 87bc67f | 2020-12-04 20:58:01 +0800 | [diff] [blame] | 21 | const float pollRate, |
James Feist | f9b01b6 | 2020-01-29 15:21:58 -0800 | [diff] [blame] | 22 | const std::string& sensorConfiguration, |
| 23 | const PowerState powerState); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 24 | ~HwmonTempSensor() override; |
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; |
Jeff Lin | 87bc67f | 2020-12-04 20:58:01 +0800 | [diff] [blame] | 33 | unsigned int sensorPollMs; |
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); |
Konstantin Aladyshev | a734594 | 2021-04-28 17:09:02 +0300 | [diff] [blame] | 36 | void restartRead(); |
James Feist | ce3fca4 | 2018-11-21 12:58:24 -0800 | [diff] [blame] | 37 | void checkThresholds(void) override; |
Patrick Venture | ca44b2f | 2019-10-31 11:02:26 -0700 | [diff] [blame] | 38 | }; |