blob: d59bd5faea60808d3a28abcd2e9fbd08269e823b [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,
15 boost::asio::io_service &io, const std::string &sensor_name,
16 std::vector<thresholds::Threshold> &&thresholds,
17 const double scale_factor,
18 const std::string &sensorConfiguration);
19 ~ADCSensor();
20
21 private:
22 std::string path;
23 sdbusplus::asio::object_server &objServer;
James Feist139cb572018-09-10 15:26:18 -070024 boost::asio::posix::stream_descriptor input_dev;
25 boost::asio::deadline_timer wait_timer;
26 boost::asio::streambuf read_buf;
James Feist139cb572018-09-10 15:26:18 -070027 int err_count;
28 double max_value;
29 double min_value;
30 double scale_factor;
31 void setup_read(void);
32 void handle_response(const boost::system::error_code &err);
33 void check_thresholds(void);
34 void update_value(const double &new_value);
James Feistaf79dd32018-09-12 12:54:15 -070035
James Feist139cb572018-09-10 15:26:18 -070036 void set_initial_properties(
37 std::shared_ptr<sdbusplus::asio::connection> &conn);
38};