blob: 07c7893cf14f82ccf68d392f79b4843a0fe0ee76 [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>
5
6class ADCSensor
7{
8 public:
9 std::string name;
10 std::string configuration;
11 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 &sensor_name,
15 std::vector<thresholds::Threshold> &&thresholds,
16 const double scale_factor,
17 const std::string &sensorConfiguration);
18 ~ADCSensor();
19
20 private:
21 std::string path;
22 sdbusplus::asio::object_server &objServer;
23 std::vector<thresholds::Threshold> thresholds;
24 std::shared_ptr<sdbusplus::asio::dbus_interface> sensor_interface;
25 std::shared_ptr<sdbusplus::asio::dbus_interface>
26 threshold_interface_warning;
27 std::shared_ptr<sdbusplus::asio::dbus_interface>
28 threshold_interface_critical;
29 boost::asio::posix::stream_descriptor input_dev;
30 boost::asio::deadline_timer wait_timer;
31 boost::asio::streambuf read_buf;
32 double value;
33 int err_count;
34 double max_value;
35 double min_value;
36 double scale_factor;
37 void setup_read(void);
38 void handle_response(const boost::system::error_code &err);
39 void check_thresholds(void);
40 void update_value(const double &new_value);
41 void assert_thresholds(thresholds::Level level,
42 thresholds::Direction direction, bool assert);
43 void set_initial_properties(
44 std::shared_ptr<sdbusplus::asio::connection> &conn);
45};