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 public: 32 OccDBusSensors(const OccDBusSensors&) = delete; 33 OccDBusSensors(OccDBusSensors&&) = delete; 34 OccDBusSensors& operator=(const OccDBusSensors&) = delete; 35 OccDBusSensors& operator=(OccDBusSensors&&) = delete; 36 ~OccDBusSensors() = default; 37 38 static OccDBusSensors& getOccDBus() 39 { 40 static OccDBusSensors customDBus; 41 return customDBus; 42 } 43 44 public: 45 /** @brief Set the max value of the Sensor 46 * 47 * @param[in] path - The object path 48 * @param[in] value - The value of the MaxValue property 49 * 50 * @return true or false 51 */ 52 bool setMaxValue(const std::string& path, double value); 53 54 /** @brief Get the max value of the Sensor 55 * 56 * @param[in] path - The object path 57 * 58 * @return bool - The value of the MaxValue property 59 */ 60 double getMaxValue(const std::string& path) const; 61 62 /** @brief Set the min value of the Sensor 63 * 64 * @param[in] path - The object path 65 * @param[in] value - The value of the MinValue property 66 * 67 * @return true or false 68 */ 69 bool setMinValue(const std::string& path, double value); 70 71 /** @brief Get the min value of the Sensor 72 * 73 * @param[in] path - The object path 74 * 75 * @return bool - The value of the MinValue property 76 */ 77 double getMinValue(const std::string& path) const; 78 79 /** @brief Set the value of the Sensor 80 * 81 * @param[in] path - The object path 82 * @param[in] value - The value of the Value property 83 * 84 * @return true or false 85 */ 86 bool setValue(const std::string& path, double value); 87 88 /** @brief Get the value of the Sensor 89 * 90 * @param[in] path - The object path 91 * 92 * @return bool - The value of the Value property 93 */ 94 double getValue(const std::string& path) const; 95 96 /** @brief Set the unit of the Sensor 97 * 98 * @param[in] path - The object path 99 * @param[in] value - The value of the Unit property 100 * 101 * @return true or false 102 */ 103 bool setUnit(const std::string& path, const std::string& value); 104 105 /** @brief Get the unit of the Sensor 106 * 107 * @param[in] path - The object path 108 * 109 * @return std::string - The value of the Unit property 110 */ 111 std::string getUnit(const std::string& path) const; 112 113 /** @brief Set the Functional property 114 * 115 * @param[in] path - The object path 116 * @param[in] value - PLDM operational fault status 117 * 118 * @return true or false 119 */ 120 bool setOperationalStatus(const std::string& path, bool value); 121 122 /** @brief Get the Functional property 123 * 124 * @param[in] path - The object path 125 * 126 * @return status - PLDM operational fault status 127 */ 128 bool getOperationalStatus(const std::string& path) const; 129 130 private: 131 std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors; 132 133 std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>> 134 operationalStatus; 135 }; 136 137 } // namespace dbus 138 } // namespace occ 139 } // namespace open_power 140