blob: 330f140454487f4e43101e8095e1ccfe15f554a1 [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
Chicago Duanbb895cb2021-06-18 19:37:16 +080015using SensorIntf = sdbusplus::server::object::object<
16 sdbusplus::xyz::openbmc_project::Sensor::server::Value>;
17using OperationalStatusIntf =
18 sdbusplus::server::object::object<sdbusplus::xyz::openbmc_project::State::
19 Decorator::server::OperationalStatus>;
George Liu6f777cd2021-06-10 09:16:28 +080020
21/** @class OccDBusSensors
22 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
23 * the corresponding properties value.
24 */
25class OccDBusSensors
26{
27 private:
28 OccDBusSensors()
29 {
30 }
31
32 public:
33 OccDBusSensors(const OccDBusSensors&) = delete;
34 OccDBusSensors(OccDBusSensors&&) = delete;
35 OccDBusSensors& operator=(const OccDBusSensors&) = delete;
36 OccDBusSensors& operator=(OccDBusSensors&&) = delete;
37 ~OccDBusSensors() = default;
38
39 static OccDBusSensors& getOccDBus()
40 {
41 static OccDBusSensors customDBus;
42 return customDBus;
43 }
44
45 public:
46 /** @brief Set the max value of the Sensor
47 *
48 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +080049 * @param[in] value - The value of the MaxValue property
George Liu0ad9dd82021-06-22 14:46:14 +080050 *
51 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +080052 */
George Liu0ad9dd82021-06-22 14:46:14 +080053 bool setMaxValue(const std::string& path, double value);
George Liu6f777cd2021-06-10 09:16:28 +080054
55 /** @brief Get the max value of the Sensor
56 *
57 * @param[in] path - The object path
58 *
59 * @return bool - The value of the MaxValue property
60 */
61 double getMaxValue(const std::string& path) const;
62
63 /** @brief Set the min value of the Sensor
64 *
65 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +080066 * @param[in] value - The value of the MinValue property
George Liu0ad9dd82021-06-22 14:46:14 +080067 *
68 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +080069 */
George Liu0ad9dd82021-06-22 14:46:14 +080070 bool setMinValue(const std::string& path, double value);
George Liu6f777cd2021-06-10 09:16:28 +080071
72 /** @brief Get the min value of the Sensor
73 *
74 * @param[in] path - The object path
75 *
76 * @return bool - The value of the MinValue property
77 */
78 double getMinValue(const std::string& path) const;
79
80 /** @brief Set the value of the Sensor
81 *
82 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +080083 * @param[in] value - The value of the Value property
George Liu0ad9dd82021-06-22 14:46:14 +080084 *
85 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +080086 */
George Liu0ad9dd82021-06-22 14:46:14 +080087 bool setValue(const std::string& path, double value);
George Liu6f777cd2021-06-10 09:16:28 +080088
89 /** @brief Get the value of the Sensor
90 *
91 * @param[in] path - The object path
92 *
93 * @return bool - The value of the Value property
94 */
95 double getValue(const std::string& path) const;
96
97 /** @brief Set the unit of the Sensor
98 *
99 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +0800100 * @param[in] value - The value of the Unit property
George Liu0ad9dd82021-06-22 14:46:14 +0800101 *
102 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +0800103 */
George Liu0ad9dd82021-06-22 14:46:14 +0800104 bool setUnit(const std::string& path, const std::string& value);
George Liu6f777cd2021-06-10 09:16:28 +0800105
106 /** @brief Get the unit of the Sensor
107 *
108 * @param[in] path - The object path
109 *
110 * @return std::string - The value of the Unit property
111 */
112 std::string getUnit(const std::string& path) const;
113
114 /** @brief Set the Functional property
115 *
116 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +0800117 * @param[in] value - PLDM operational fault status
George Liu0ad9dd82021-06-22 14:46:14 +0800118 *
119 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +0800120 */
George Liu0ad9dd82021-06-22 14:46:14 +0800121 bool setOperationalStatus(const std::string& path, bool value);
George Liu6f777cd2021-06-10 09:16:28 +0800122
123 /** @brief Get the Functional property
124 *
125 * @param[in] path - The object path
126 *
127 * @return status - PLDM operational fault status
128 */
129 bool getOperationalStatus(const std::string& path) const;
130
131 private:
132 std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors;
133
134 std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>>
135 operationalStatus;
136};
137
138} // namespace dbus
139} // namespace occ
140} // namespace open_power