James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <Thresholds.hpp> |
| 4 | #include <sdbusplus/asio/object_server.hpp> |
James Feist | af79dd3 | 2018-09-12 12:54:15 -0700 | [diff] [blame^] | 5 | #include <sensor.hpp> |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 6 | |
James Feist | af79dd3 | 2018-09-12 12:54:15 -0700 | [diff] [blame^] | 7 | class CPUSensor : public Sensor |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 8 | { |
| 9 | private: |
| 10 | std::string path; |
| 11 | std::string objectType; |
| 12 | sdbusplus::asio::object_server &objServer; |
| 13 | std::shared_ptr<sdbusplus::asio::connection> dbusConnection; |
| 14 | std::string name; |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 15 | boost::asio::posix::stream_descriptor input_dev; |
| 16 | boost::asio::deadline_timer wait_timer; |
| 17 | boost::asio::streambuf read_buf; |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 18 | int err_count; |
| 19 | double max_value; |
| 20 | double min_value; |
| 21 | void setup_read(void); |
| 22 | void handle_response(const boost::system::error_code &err); |
| 23 | void check_thresholds(void); |
| 24 | void update_value(const double &new_value); |
James Feist | af79dd3 | 2018-09-12 12:54:15 -0700 | [diff] [blame^] | 25 | |
James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 26 | void set_initial_properties( |
| 27 | std::shared_ptr<sdbusplus::asio::connection> &conn); |
| 28 | |
| 29 | public: |
| 30 | std::string configuration; |
| 31 | CPUSensor(const std::string &path, const std::string &objectType, |
| 32 | sdbusplus::asio::object_server &object_server, |
| 33 | std::shared_ptr<sdbusplus::asio::connection> &conn, |
| 34 | boost::asio::io_service &io, const std::string &fan_name, |
| 35 | std::vector<thresholds::Threshold> &&thresholds, |
| 36 | const std::string &configuration); |
| 37 | ~CPUSensor(); |
| 38 | constexpr static unsigned int SENSOR_SCALE_FACTOR = 1000; |
| 39 | constexpr static unsigned int SENSOR_POLL_MS = 1000; |
| 40 | }; |