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