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 | |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 11 | struct SensorParams |
| 12 | { |
| 13 | double minValue; |
| 14 | double maxValue; |
| 15 | double offsetValue; |
| 16 | double scaleValue; |
| 17 | std::string units; |
| 18 | std::string typeName; |
| 19 | }; |
| 20 | |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 21 | class HwmonTempSensor : |
| 22 | public Sensor, |
| 23 | public std::enable_shared_from_this<HwmonTempSensor> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 24 | { |
| 25 | public: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 26 | HwmonTempSensor(const std::string& path, const std::string& objectType, |
| 27 | sdbusplus::asio::object_server& objectServer, |
| 28 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
Bruce Mitchell | 5cf0f99 | 2021-07-30 08:49:12 -0500 | [diff] [blame] | 29 | boost::asio::io_service& io, const std::string& sensorName, |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 30 | std::vector<thresholds::Threshold>&& thresholds, |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 31 | const struct SensorParams& thisSensorParameters, |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame^] | 32 | float pollRate, const std::string& sensorConfiguration, |
| 33 | PowerState powerState); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 34 | ~HwmonTempSensor() override; |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 35 | void setupRead(void); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 36 | |
| 37 | private: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 38 | sdbusplus::asio::object_server& objServer; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 39 | boost::asio::posix::stream_descriptor inputDev; |
| 40 | boost::asio::deadline_timer waitTimer; |
| 41 | boost::asio::streambuf readBuf; |
James Feist | 930fcde | 2019-05-28 12:58:43 -0700 | [diff] [blame] | 42 | std::string path; |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 43 | double offsetValue; |
| 44 | double scaleValue; |
Jeff Lin | 87bc67f | 2020-12-04 20:58:01 +0800 | [diff] [blame] | 45 | unsigned int sensorPollMs; |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 46 | |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 47 | void handleResponse(const boost::system::error_code& err); |
Konstantin Aladyshev | a734594 | 2021-04-28 17:09:02 +0300 | [diff] [blame] | 48 | void restartRead(); |
James Feist | ce3fca4 | 2018-11-21 12:58:24 -0800 | [diff] [blame] | 49 | void checkThresholds(void) override; |
Patrick Venture | ca44b2f | 2019-10-31 11:02:26 -0700 | [diff] [blame] | 50 | }; |