George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 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::xyz::openbmc_project::Sensor::server::Value; |
| 16 | using 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 | */ |
| 23 | class 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 Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 47 | * @param[in] value - The value of the MaxValue property |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 48 | * |
| 49 | * @return true or false |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 50 | */ |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 51 | bool setMaxValue(const std::string& path, double value); |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 52 | |
| 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 Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 64 | * @param[in] value - The value of the MinValue property |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 65 | * |
| 66 | * @return true or false |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 67 | */ |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 68 | bool setMinValue(const std::string& path, double value); |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 69 | |
| 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 Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 81 | * @param[in] value - The value of the Value property |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 82 | * |
| 83 | * @return true or false |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 84 | */ |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 85 | bool setValue(const std::string& path, double value); |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 86 | |
| 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 Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 98 | * @param[in] value - The value of the Unit property |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 99 | * |
| 100 | * @return true or false |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 101 | */ |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 102 | bool setUnit(const std::string& path, const std::string& value); |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 103 | |
| 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 Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 115 | * @param[in] value - PLDM operational fault status |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 116 | * |
| 117 | * @return true or false |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 118 | */ |
George Liu | 0ad9dd8 | 2021-06-22 14:46:14 +0800 | [diff] [blame^] | 119 | bool setOperationalStatus(const std::string& path, bool value); |
George Liu | 6f777cd | 2021-06-10 09:16:28 +0800 | [diff] [blame] | 120 | |
| 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 |