James Feist | 139cb57 | 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 | af79dd3 | 2018-09-12 12:54:15 -0700 | [diff] [blame] | 5 | #include <sensor.hpp> |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 6 | |
James Feist | af79dd3 | 2018-09-12 12:54:15 -0700 | [diff] [blame] | 7 | class ADCSensor : public Sensor |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 8 | { |
| 9 | public: |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 10 | std::string configuration; |
| 11 | ADCSensor(const std::string &path, |
| 12 | sdbusplus::asio::object_server &objectServer, |
| 13 | std::shared_ptr<sdbusplus::asio::connection> &conn, |
Jae Hyun Yoo | f78ec41 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 14 | boost::asio::io_service &io, const std::string &sensorName, |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 15 | std::vector<thresholds::Threshold> &&thresholds, |
Jae Hyun Yoo | f78ec41 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 16 | const double scaleFactor, const std::string &sensorConfiguration); |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 17 | ~ADCSensor(); |
| 18 | |
| 19 | private: |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 20 | sdbusplus::asio::object_server &objServer; |
Jae Hyun Yoo | f78ec41 | 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; |
| 25 | double maxValue; |
| 26 | double minValue; |
| 27 | double scaleFactor; |
| 28 | void setupRead(void); |
| 29 | void handleResponse(const boost::system::error_code &err); |
| 30 | void checkThresholds(void); |
| 31 | void updateValue(const double &newValue); |
James Feist | af79dd3 | 2018-09-12 12:54:15 -0700 | [diff] [blame] | 32 | |
Jae Hyun Yoo | f78ec41 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 33 | void setInitialProperties( |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 34 | std::shared_ptr<sdbusplus::asio::connection> &conn); |
Jae Hyun Yoo | f78ec41 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 35 | }; |