blob: 2443a53a6a91d812fd1184f3da123b42510525e8 [file] [log] [blame]
George Liu6f777cd2021-06-10 09:16:28 +08001#pragma once
2
3#include <xyz/openbmc_project/Sensor/Value/server.hpp>
4#include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp>
5
6namespace open_power
7{
8namespace occ
9{
10namespace dbus
11{
12
13using ObjectPath = std::string;
14
15using SensorIntf = sdbusplus::xyz::openbmc_project::Sensor::server::Value;
16using OperationalStatusIntf = sdbusplus::xyz::openbmc_project::State::
17 Decorator::server::OperationalStatus;
18
19/** @class OccDBusSensors
20 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
21 * the corresponding properties value.
22 */
23class OccDBusSensors
24{
25 private:
26 OccDBusSensors()
27 {
28 }
29
30 public:
31 OccDBusSensors(const OccDBusSensors&) = delete;
32 OccDBusSensors(OccDBusSensors&&) = delete;
33 OccDBusSensors& operator=(const OccDBusSensors&) = delete;
34 OccDBusSensors& operator=(OccDBusSensors&&) = delete;
35 ~OccDBusSensors() = default;
36
37 static OccDBusSensors& getOccDBus()
38 {
39 static OccDBusSensors customDBus;
40 return customDBus;
41 }
42
43 public:
44 /** @brief Set the max value of the Sensor
45 *
46 * @param[in] path - The object path
47 *
48 * @param[in] value - The value of the MaxValue property
49 */
50 void setMaxValue(const std::string& path, double value);
51
52 /** @brief Get the max value of the Sensor
53 *
54 * @param[in] path - The object path
55 *
56 * @return bool - The value of the MaxValue property
57 */
58 double getMaxValue(const std::string& path) const;
59
60 /** @brief Set the min value of the Sensor
61 *
62 * @param[in] path - The object path
63 *
64 * @param[in] value - The value of the MinValue property
65 */
66 void setMinValue(const std::string& path, double value);
67
68 /** @brief Get the min value of the Sensor
69 *
70 * @param[in] path - The object path
71 *
72 * @return bool - The value of the MinValue property
73 */
74 double getMinValue(const std::string& path) const;
75
76 /** @brief Set the value of the Sensor
77 *
78 * @param[in] path - The object path
79 *
80 * @param[in] value - The value of the Value property
81 */
82 void setValue(const std::string& path, double value);
83
84 /** @brief Get the value of the Sensor
85 *
86 * @param[in] path - The object path
87 *
88 * @return bool - The value of the Value property
89 */
90 double getValue(const std::string& path) const;
91
92 /** @brief Set the unit of the Sensor
93 *
94 * @param[in] path - The object path
95 *
96 * @param[in] value - The value of the Unit property
97 */
98 void setUnit(const std::string& path, const std::string& value);
99
100 /** @brief Get the unit of the Sensor
101 *
102 * @param[in] path - The object path
103 *
104 * @return std::string - The value of the Unit property
105 */
106 std::string getUnit(const std::string& path) const;
107
108 /** @brief Set the Functional property
109 *
110 * @param[in] path - The object path
111 *
112 * @param[in] value - PLDM operational fault status
113 */
114 void setOperationalStatus(const std::string& path, bool value);
115
116 /** @brief Get the Functional property
117 *
118 * @param[in] path - The object path
119 *
120 * @return status - PLDM operational fault status
121 */
122 bool getOperationalStatus(const std::string& path) const;
123
124 private:
125 std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors;
126
127 std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>>
128 operationalStatus;
129};
130
131} // namespace dbus
132} // namespace occ
133} // namespace open_power