blob: fd248dabe5f68fc339e5e41771402e2f1bf8ca77 [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001#pragma once
2
3#include <Thresholds.hpp>
4#include <sdbusplus/asio/object_server.hpp>
James Feist251c7822018-09-12 12:54:15 -07005#include <sensor.hpp>
James Feist6714a252018-09-10 15:26:18 -07006
James Feist251c7822018-09-12 12:54:15 -07007class ADCSensor : public Sensor
James Feist6714a252018-09-10 15:26:18 -07008{
9 public:
James Feistd8705872019-02-08 13:26:09 -080010 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 Feist71d31b22019-01-02 16:57:54 -080015 const double scaleFactor, PowerState readState,
James Feistd8705872019-02-08 13:26:09 -080016 const std::string& sensorConfiguration);
James Feist6714a252018-09-10 15:26:18 -070017 ~ADCSensor();
18
19 private:
James Feistd8705872019-02-08 13:26:09 -080020 sdbusplus::asio::object_server& objServer;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070021 boost::asio::posix::stream_descriptor inputDev;
22 boost::asio::deadline_timer waitTimer;
23 boost::asio::streambuf readBuf;
24 int errCount;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070025 double scaleFactor;
James Feist71d31b22019-01-02 16:57:54 -080026 PowerState readState;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070027 void setupRead(void);
James Feistd8705872019-02-08 13:26:09 -080028 void handleResponse(const boost::system::error_code& err);
James Feistce3fca42018-11-21 12:58:24 -080029 void checkThresholds(void) override;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070030};