blob: e15ba0a822d3a4e74eee75030d69552663cca65a [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:
10 std::string name;
11 std::string configuration;
12 ADCSensor(const std::string &path,
13 sdbusplus::asio::object_server &objectServer,
14 std::shared_ptr<sdbusplus::asio::connection> &conn,
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070015 boost::asio::io_service &io, const std::string &sensorName,
James Feist139cb572018-09-10 15:26:18 -070016 std::vector<thresholds::Threshold> &&thresholds,
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070017 const double scaleFactor, const std::string &sensorConfiguration);
James Feist139cb572018-09-10 15:26:18 -070018 ~ADCSensor();
19
20 private:
21 std::string path;
22 sdbusplus::asio::object_server &objServer;
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070023 boost::asio::posix::stream_descriptor inputDev;
24 boost::asio::deadline_timer waitTimer;
25 boost::asio::streambuf readBuf;
26 int errCount;
27 double maxValue;
28 double minValue;
29 double scaleFactor;
30 void setupRead(void);
31 void handleResponse(const boost::system::error_code &err);
32 void checkThresholds(void);
33 void updateValue(const double &newValue);
James Feistaf79dd32018-09-12 12:54:15 -070034
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070035 void setInitialProperties(
James Feist139cb572018-09-10 15:26:18 -070036 std::shared_ptr<sdbusplus::asio::connection> &conn);
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070037};