blob: b5a9e9a25b22fee4bf4a12cfb15bacb8fec1c796 [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001#pragma once
2
3#include <Thresholds.hpp>
Zhu, Yungea5b1bbc2019-04-09 19:49:36 -04004#include <optional>
James Feist6714a252018-09-10 15:26:18 -07005#include <sdbusplus/asio/object_server.hpp>
James Feist251c7822018-09-12 12:54:15 -07006#include <sensor.hpp>
James Feist6714a252018-09-10 15:26:18 -07007
James Feist251c7822018-09-12 12:54:15 -07008class ADCSensor : public Sensor
James Feist6714a252018-09-10 15:26:18 -07009{
10 public:
James Feistd8705872019-02-08 13:26:09 -080011 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 Feist71d31b22019-01-02 16:57:54 -080016 const double scaleFactor, PowerState readState,
Zhu, Yungea5b1bbc2019-04-09 19:49:36 -040017 const std::string& sensorConfiguration,
18 std::optional<int> bridgeGpio);
James Feist6714a252018-09-10 15:26:18 -070019 ~ADCSensor();
20
21 private:
James Feistd8705872019-02-08 13:26:09 -080022 sdbusplus::asio::object_server& objServer;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070023 boost::asio::posix::stream_descriptor inputDev;
24 boost::asio::deadline_timer waitTimer;
25 boost::asio::streambuf readBuf;
James Feist930fcde2019-05-28 12:58:43 -070026 std::string path;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070027 int errCount;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070028 double scaleFactor;
Zhu, Yungea5b1bbc2019-04-09 19:49:36 -040029 std::optional<int> bridgeGpio;
James Feist71d31b22019-01-02 16:57:54 -080030 PowerState readState;
James Feist46342ec2019-03-06 14:03:41 -080031 thresholds::ThresholdTimer thresholdTimer;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070032 void setupRead(void);
James Feistd8705872019-02-08 13:26:09 -080033 void handleResponse(const boost::system::error_code& err);
James Feistce3fca42018-11-21 12:58:24 -080034 void checkThresholds(void) override;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070035};