blob: e352855d6afda90b557514f59db3a8cf07b55492 [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 TachSensor : public Sensor
James Feist139cb572018-09-10 15:26:18 -07008{
9 public:
10 std::string name;
11 std::string configuration;
12 TachSensor(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 &fan_name,
16 std::vector<thresholds::Threshold> &&thresholds,
17 const std::string &sensorConfiguration);
18 ~TachSensor();
19
20 private:
21 std::string path;
22 sdbusplus::asio::object_server &objServer;
23 std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
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 void setup_read(void);
31 void handle_response(const boost::system::error_code &err);
32 void check_thresholds(void);
33 void update_value(const double &new_value);
James Feistaf79dd32018-09-12 12:54:15 -070034
James Feist139cb572018-09-10 15:26:18 -070035 void set_initial_properties(
36 std::shared_ptr<sdbusplus::asio::connection> &conn);
37};