1 #pragma once 2 3 #include <xyz/openbmc_project/Sensor/Value/server.hpp> 4 #include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp> 5 6 namespace open_power 7 { 8 namespace occ 9 { 10 namespace dbus 11 { 12 13 using ObjectPath = std::string; 14 15 using SensorIntf = sdbusplus::server::object::object< 16 sdbusplus::xyz::openbmc_project::Sensor::server::Value>; 17 using OperationalStatusIntf = 18 sdbusplus::server::object::object<sdbusplus::xyz::openbmc_project::State:: 19 Decorator::server::OperationalStatus>; 20 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 */ 25 class 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 49 * @param[in] value - The value of the MaxValue property 50 * 51 * @return true or false 52 */ 53 bool setMaxValue(const std::string& path, double value); 54 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 66 * @param[in] value - The value of the MinValue property 67 * 68 * @return true or false 69 */ 70 bool setMinValue(const std::string& path, double value); 71 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 83 * @param[in] value - The value of the Value property 84 * 85 * @return true or false 86 */ 87 bool setValue(const std::string& path, double value); 88 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 100 * @param[in] value - The value of the Unit property 101 * 102 * @return true or false 103 */ 104 bool setUnit(const std::string& path, const std::string& value); 105 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 117 * @param[in] value - PLDM operational fault status 118 * 119 * @return true or false 120 */ 121 bool setOperationalStatus(const std::string& path, bool value); 122 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 141