James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | #include "sensor.hpp" |
| 3 | |
| 4 | #include <boost/asio/deadline_timer.hpp> |
| 5 | #include <boost/container/flat_map.hpp> |
| 6 | #include <chrono> |
| 7 | #include <limits> |
| 8 | #include <vector> |
| 9 | |
| 10 | enum class IpmbType |
| 11 | { |
| 12 | meSensor, |
| 13 | PXE1410CVR, |
| 14 | IR38363VR, |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame^] | 15 | ADM1278HSC, |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 16 | mpsVR |
| 17 | }; |
| 18 | |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame^] | 19 | enum class IpmbSubType |
| 20 | { |
| 21 | temp, |
| 22 | curr, |
| 23 | power, |
| 24 | volt |
| 25 | }; |
| 26 | |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 27 | struct IpmbSensor : public Sensor |
| 28 | { |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 29 | IpmbSensor(std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 30 | boost::asio::io_service& io, const std::string& name, |
| 31 | const std::string& sensorConfiguration, |
| 32 | sdbusplus::asio::object_server& objectServer, |
| 33 | std::vector<thresholds::Threshold>&& thresholds, |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame^] | 34 | uint8_t deviceAddress, std::string& sensorTypeName); |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 35 | ~IpmbSensor(); |
| 36 | |
| 37 | void checkThresholds(void) override; |
| 38 | void read(void); |
| 39 | void init(void); |
| 40 | void loadDefaults(void); |
James Feist | f7e2c5d | 2019-02-13 17:27:51 -0800 | [diff] [blame] | 41 | void runInitCmd(void); |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 42 | |
| 43 | IpmbType type; |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame^] | 44 | IpmbSubType subType; |
| 45 | double scaleVal; |
| 46 | double offsetVal; |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 47 | uint8_t commandAddress; |
| 48 | uint8_t netfn; |
| 49 | uint8_t command; |
| 50 | uint8_t deviceAddress; |
| 51 | std::vector<uint8_t> commandData; |
| 52 | std::optional<uint8_t> initCommand; |
| 53 | std::vector<uint8_t> initData; |
| 54 | |
| 55 | // to date all ipmb sensors are power on only |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 56 | PowerState readState; |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 57 | |
| 58 | private: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 59 | sdbusplus::asio::object_server& objectServer; |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 60 | std::shared_ptr<sdbusplus::asio::connection> dbusConnection; |
| 61 | boost::asio::deadline_timer waitTimer; |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame^] | 62 | }; |