-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathocc_dbus.hpp
182 lines (154 loc) · 5.24 KB
/
occ_dbus.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#pragma once
#include <xyz/openbmc_project/Association/Definitions/server.hpp>
#include <xyz/openbmc_project/Sensor/Value/server.hpp>
#include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp>
namespace open_power
{
namespace occ
{
namespace dbus
{
using ObjectPath = std::string;
using SensorIntf = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Sensor::server::Value>;
using OperationalStatusIntf =
sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::State::
Decorator::server::OperationalStatus>;
// Note: Not using object<> so the PropertiesVariant ctor is available.
using AssociationIntf =
sdbusplus::xyz::openbmc_project::Association::server::Definitions;
/** @class OccDBusSensors
* @brief This is a custom D-Bus object, used to add D-Bus interface and update
* the corresponding properties value.
*/
class OccDBusSensors
{
private:
OccDBusSensors() {}
public:
OccDBusSensors(const OccDBusSensors&) = delete;
OccDBusSensors(OccDBusSensors&&) = delete;
OccDBusSensors& operator=(const OccDBusSensors&) = delete;
OccDBusSensors& operator=(OccDBusSensors&&) = delete;
~OccDBusSensors() = default;
static OccDBusSensors& getOccDBus()
{
static OccDBusSensors customDBus;
return customDBus;
}
public:
/** @brief Set the max value of the Sensor
*
* @param[in] path - The object path
* @param[in] value - The value of the MaxValue property
*
* @return true or false
*/
bool setMaxValue(const std::string& path, double value);
/** @brief Get the max value of the Sensor
*
* @param[in] path - The object path
*
* @return bool - The value of the MaxValue property
*/
double getMaxValue(const std::string& path) const;
/** @brief Set the min value of the Sensor
*
* @param[in] path - The object path
* @param[in] value - The value of the MinValue property
*
* @return true or false
*/
bool setMinValue(const std::string& path, double value);
/** @brief Get the min value of the Sensor
*
* @param[in] path - The object path
*
* @return bool - The value of the MinValue property
*/
double getMinValue(const std::string& path) const;
/** @brief Set the value of the Sensor
*
* @param[in] path - The object path
* @param[in] value - The value of the Value property
*
* @return true or false
*/
bool setValue(const std::string& path, double value);
/** @brief Get the value of the Sensor
*
* @param[in] path - The object path
*
* @return bool - The value of the Value property
*/
double getValue(const std::string& path) const;
/** @brief Set the unit of the Sensor
*
* @param[in] path - The object path
* @param[in] value - The value of the Unit property
*
* @return true or false
*/
bool setUnit(const std::string& path, const std::string& value);
/** @brief Get the unit of the Sensor
*
* @param[in] path - The object path
*
* @return std::string - The value of the Unit property
*/
std::string getUnit(const std::string& path) const;
/** @brief Set the Functional property
*
* @param[in] path - The object path
* @param[in] value - PLDM operational fault status
*
* @return true or false
*/
bool setOperationalStatus(const std::string& path, bool value);
/** @brief Get the Functional property
*
* @param[in] path - The object path
*
* @return status - PLDM operational fault status
*/
bool getOperationalStatus(const std::string& path) const;
/** @brief Returns the Chassis inventory path
*
* @return path - The chassis D-Bus path
*/
std::string getChassisPath();
/** @brief Set the association to the chassis
*
* @param[in] path - The object path
* @param[in] fType - vector of forward types
*/
void setChassisAssociation(const std::string& path,
const std::vector<std::string>& fTypes);
/** @brief Set the value of the DVFS temp sensor
*
* @param[in] path - The object path
* @param[in] value - The value of the Value property
*/
void setDvfsTemp(const std::string& path, double value);
/** @brief Says if the DVFS temp sensor is already present
*
* @param[in] value - The value of the Value property
* @return bool - If the sensor is already present
*/
bool hasDvfsTemp(const std::string& path) const;
private:
std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors;
std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>>
operationalStatus;
std::map<ObjectPath, std::unique_ptr<AssociationIntf>> chassisAssociations;
std::string chassisPath;
/** @brief Map of DVFS (Dynamic Voltage and Frequency Slewing) temps
*
* These do not have associations and do not get set to NaN when the OCC
* isn't active.
*/
std::map<std::string, std::unique_ptr<SensorIntf>> dvfsTemps;
};
} // namespace dbus
} // namespace occ
} // namespace open_power