blob: e7a9540aa53d91bf39078a68e71c90ef98a2544d [file] [log] [blame]
James Feist6ef20402019-01-07 16:45:08 -08001#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
10enum class IpmbType
11{
12 meSensor,
13 PXE1410CVR,
14 IR38363VR,
Vijay Khemka682a5cb2019-07-18 17:34:03 -070015 ADM1278HSC,
James Feist6ef20402019-01-07 16:45:08 -080016 mpsVR
17};
18
Vijay Khemka682a5cb2019-07-18 17:34:03 -070019enum class IpmbSubType
20{
21 temp,
22 curr,
23 power,
24 volt
25};
26
James Feist6ef20402019-01-07 16:45:08 -080027struct IpmbSensor : public Sensor
28{
James Feistd8705872019-02-08 13:26:09 -080029 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 Khemka682a5cb2019-07-18 17:34:03 -070034 uint8_t deviceAddress, std::string& sensorTypeName);
James Feist6ef20402019-01-07 16:45:08 -080035 ~IpmbSensor();
36
37 void checkThresholds(void) override;
38 void read(void);
39 void init(void);
40 void loadDefaults(void);
James Feistf7e2c5d2019-02-13 17:27:51 -080041 void runInitCmd(void);
James Feist6ef20402019-01-07 16:45:08 -080042
43 IpmbType type;
Vijay Khemka682a5cb2019-07-18 17:34:03 -070044 IpmbSubType subType;
45 double scaleVal;
46 double offsetVal;
James Feist6ef20402019-01-07 16:45:08 -080047 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 Feist52497fd2019-06-07 13:01:33 -070056 PowerState readState;
James Feist6ef20402019-01-07 16:45:08 -080057
58 private:
James Feistd8705872019-02-08 13:26:09 -080059 sdbusplus::asio::object_server& objectServer;
James Feist6ef20402019-01-07 16:45:08 -080060 std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
61 boost::asio::deadline_timer waitTimer;
Vijay Khemka682a5cb2019-07-18 17:34:03 -070062};