James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <Thresholds.hpp> |
| 4 | #include <sdbusplus/asio/object_server.hpp> |
James Feist | 251c782 | 2018-09-12 12:54:15 -0700 | [diff] [blame] | 5 | #include <sensor.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 6 | |
James Feist | 251c782 | 2018-09-12 12:54:15 -0700 | [diff] [blame] | 7 | class ADCSensor : public Sensor |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 8 | { |
| 9 | public: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame^] | 10 | ADCSensor(const std::string& path, |
| 11 | sdbusplus::asio::object_server& objectServer, |
| 12 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 13 | boost::asio::io_service& io, const std::string& sensorName, |
| 14 | std::vector<thresholds::Threshold>&& thresholds, |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 15 | const double scaleFactor, PowerState readState, |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame^] | 16 | const std::string& sensorConfiguration); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 17 | ~ADCSensor(); |
| 18 | |
| 19 | private: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame^] | 20 | sdbusplus::asio::object_server& objServer; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 21 | boost::asio::posix::stream_descriptor inputDev; |
| 22 | boost::asio::deadline_timer waitTimer; |
| 23 | boost::asio::streambuf readBuf; |
| 24 | int errCount; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 25 | double scaleFactor; |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 26 | PowerState readState; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 27 | void setupRead(void); |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame^] | 28 | void handleResponse(const boost::system::error_code& err); |
James Feist | ce3fca4 | 2018-11-21 12:58:24 -0800 | [diff] [blame] | 29 | void checkThresholds(void) override; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 30 | }; |