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