blob: 59b445002ae7244d8065d9bf534e250219906c36 [file] [log] [blame]
James Feist139cb572018-09-10 15:26:18 -07001#pragma once
2
3#include <Thresholds.hpp>
4#include <sdbusplus/asio/object_server.hpp>
James Feistaf79dd32018-09-12 12:54:15 -07005#include <sensor.hpp>
James Feist139cb572018-09-10 15:26:18 -07006
James Feistaf79dd32018-09-12 12:54:15 -07007class ADCSensor : public Sensor
James Feist139cb572018-09-10 15:26:18 -07008{
9 public:
James Feist139cb572018-09-10 15:26:18 -070010 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 Yoof78ec412018-10-25 10:42:39 -070014 boost::asio::io_service &io, const std::string &sensorName,
James Feist139cb572018-09-10 15:26:18 -070015 std::vector<thresholds::Threshold> &&thresholds,
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070016 const double scaleFactor, const std::string &sensorConfiguration);
James Feist139cb572018-09-10 15:26:18 -070017 ~ADCSensor();
18
19 private:
James Feist139cb572018-09-10 15:26:18 -070020 sdbusplus::asio::object_server &objServer;
Jae Hyun Yoof78ec412018-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;
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 Feistaf79dd32018-09-12 12:54:15 -070032
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070033 void setInitialProperties(
James Feist139cb572018-09-10 15:26:18 -070034 std::shared_ptr<sdbusplus::asio::connection> &conn);
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070035};