blob: 3064c539b49ef9cc57733f08707434fdd149420c [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001#pragma once
2
Patrick Ventureca44b2f2019-10-31 11:02:26 -07003#include "Thresholds.hpp"
4#include "sensor.hpp"
5
James Feist8086aba2020-08-25 16:00:59 -07006#include <boost/asio/streambuf.hpp>
James Feist6714a252018-09-10 15:26:18 -07007#include <sdbusplus/asio/object_server.hpp>
James Feist38fb5982020-05-28 10:09:54 -07008
Patrick Venturefd6ba732019-10-31 14:27:39 -07009#include <string>
10#include <vector>
James Feist6714a252018-09-10 15:26:18 -070011
James Feist38fb5982020-05-28 10:09:54 -070012class HwmonTempSensor :
13 public Sensor,
14 public std::enable_shared_from_this<HwmonTempSensor>
James Feist6714a252018-09-10 15:26:18 -070015{
16 public:
James Feistd8705872019-02-08 13:26:09 -080017 HwmonTempSensor(const std::string& path, const std::string& objectType,
18 sdbusplus::asio::object_server& objectServer,
19 std::shared_ptr<sdbusplus::asio::connection>& conn,
20 boost::asio::io_service& io, const std::string& fanName,
21 std::vector<thresholds::Threshold>&& thresholds,
James Feistf9b01b62020-01-29 15:21:58 -080022 const std::string& sensorConfiguration,
23 const PowerState powerState);
James Feist6714a252018-09-10 15:26:18 -070024 ~HwmonTempSensor();
Yong Lif3fd1912020-03-25 21:35:23 +080025 void setupRead(void);
James Feist6714a252018-09-10 15:26:18 -070026
27 private:
James Feistd8705872019-02-08 13:26:09 -080028 sdbusplus::asio::object_server& objServer;
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070029 boost::asio::posix::stream_descriptor inputDev;
30 boost::asio::deadline_timer waitTimer;
31 boost::asio::streambuf readBuf;
James Feist930fcde2019-05-28 12:58:43 -070032 std::string path;
Brad Bishopfbb44ad2019-11-08 09:42:37 -050033 size_t errCount;
Yong Lif3fd1912020-03-25 21:35:23 +080034
James Feistd8705872019-02-08 13:26:09 -080035 void handleResponse(const boost::system::error_code& err);
James Feistce3fca42018-11-21 12:58:24 -080036 void checkThresholds(void) override;
Patrick Ventureca44b2f2019-10-31 11:02:26 -070037};