blob: f2264837f6e8b172b657c428cffd8bea7eea72c5 [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>
Patrick Venturefd6ba732019-10-31 14:27:39 -07008#include <memory>
9#include <optional>
10#include <string>
James Feist6ef20402019-01-07 16:45:08 -080011#include <vector>
12
13enum class IpmbType
14{
15 meSensor,
16 PXE1410CVR,
17 IR38363VR,
Vijay Khemka682a5cb2019-07-18 17:34:03 -070018 ADM1278HSC,
James Feist6ef20402019-01-07 16:45:08 -080019 mpsVR
20};
21
Vijay Khemka682a5cb2019-07-18 17:34:03 -070022enum class IpmbSubType
23{
24 temp,
25 curr,
26 power,
27 volt
28};
29
James Feist6ef20402019-01-07 16:45:08 -080030struct IpmbSensor : public Sensor
31{
James Feistd8705872019-02-08 13:26:09 -080032 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 Khemka682a5cb2019-07-18 17:34:03 -070037 uint8_t deviceAddress, std::string& sensorTypeName);
James Feist6ef20402019-01-07 16:45:08 -080038 ~IpmbSensor();
39
40 void checkThresholds(void) override;
41 void read(void);
42 void init(void);
43 void loadDefaults(void);
James Feistf7e2c5d2019-02-13 17:27:51 -080044 void runInitCmd(void);
James Feist6ef20402019-01-07 16:45:08 -080045
46 IpmbType type;
Vijay Khemka682a5cb2019-07-18 17:34:03 -070047 IpmbSubType subType;
48 double scaleVal;
49 double offsetVal;
James Feist6ef20402019-01-07 16:45:08 -080050 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 Feist52497fd2019-06-07 13:01:33 -070059 PowerState readState;
James Feist6ef20402019-01-07 16:45:08 -080060
61 private:
James Feistd8705872019-02-08 13:26:09 -080062 sdbusplus::asio::object_server& objectServer;
James Feist6ef20402019-01-07 16:45:08 -080063 std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
64 boost::asio::deadline_timer waitTimer;
Vijay Khemka682a5cb2019-07-18 17:34:03 -070065};