blob: 7a7c69cf109929e3e8525974ffc8d782dac18669 [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
George Liu6f777cd2021-06-10 09:16:28 +080047 * @param[in] value - The value of the MaxValue property
George Liu0ad9dd82021-06-22 14:46:14 +080048 *
49 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +080050 */
George Liu0ad9dd82021-06-22 14:46:14 +080051 bool setMaxValue(const std::string& path, double value);
George Liu6f777cd2021-06-10 09:16:28 +080052
53 /** @brief Get the max value of the Sensor
54 *
55 * @param[in] path - The object path
56 *
57 * @return bool - The value of the MaxValue property
58 */
59 double getMaxValue(const std::string& path) const;
60
61 /** @brief Set the min value of the Sensor
62 *
63 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +080064 * @param[in] value - The value of the MinValue property
George Liu0ad9dd82021-06-22 14:46:14 +080065 *
66 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +080067 */
George Liu0ad9dd82021-06-22 14:46:14 +080068 bool setMinValue(const std::string& path, double value);
George Liu6f777cd2021-06-10 09:16:28 +080069
70 /** @brief Get the min value of the Sensor
71 *
72 * @param[in] path - The object path
73 *
74 * @return bool - The value of the MinValue property
75 */
76 double getMinValue(const std::string& path) const;
77
78 /** @brief Set the value of the Sensor
79 *
80 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +080081 * @param[in] value - The value of the Value property
George Liu0ad9dd82021-06-22 14:46:14 +080082 *
83 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +080084 */
George Liu0ad9dd82021-06-22 14:46:14 +080085 bool setValue(const std::string& path, double value);
George Liu6f777cd2021-06-10 09:16:28 +080086
87 /** @brief Get the value of the Sensor
88 *
89 * @param[in] path - The object path
90 *
91 * @return bool - The value of the Value property
92 */
93 double getValue(const std::string& path) const;
94
95 /** @brief Set the unit of the Sensor
96 *
97 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +080098 * @param[in] value - The value of the Unit property
George Liu0ad9dd82021-06-22 14:46:14 +080099 *
100 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +0800101 */
George Liu0ad9dd82021-06-22 14:46:14 +0800102 bool setUnit(const std::string& path, const std::string& value);
George Liu6f777cd2021-06-10 09:16:28 +0800103
104 /** @brief Get the unit of the Sensor
105 *
106 * @param[in] path - The object path
107 *
108 * @return std::string - The value of the Unit property
109 */
110 std::string getUnit(const std::string& path) const;
111
112 /** @brief Set the Functional property
113 *
114 * @param[in] path - The object path
George Liu6f777cd2021-06-10 09:16:28 +0800115 * @param[in] value - PLDM operational fault status
George Liu0ad9dd82021-06-22 14:46:14 +0800116 *
117 * @return true or false
George Liu6f777cd2021-06-10 09:16:28 +0800118 */
George Liu0ad9dd82021-06-22 14:46:14 +0800119 bool setOperationalStatus(const std::string& path, bool value);
George Liu6f777cd2021-06-10 09:16:28 +0800120
121 /** @brief Get the Functional property
122 *
123 * @param[in] path - The object path
124 *
125 * @return status - PLDM operational fault status
126 */
127 bool getOperationalStatus(const std::string& path) const;
128
129 private:
130 std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors;
131
132 std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>>
133 operationalStatus;
134};
135
136} // namespace dbus
137} // namespace occ
138} // namespace open_power