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