16f777cdaSGeorge Liu #pragma once 26f777cdaSGeorge Liu 35901abdaSMatt Spinler #include <xyz/openbmc_project/Association/Definitions/server.hpp> 4*ff0ce409SChris Cain #include <xyz/openbmc_project/Sensor/Purpose/server.hpp> 56f777cdaSGeorge Liu #include <xyz/openbmc_project/Sensor/Value/server.hpp> 66f777cdaSGeorge Liu #include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp> 76f777cdaSGeorge Liu 86f777cdaSGeorge Liu namespace open_power 96f777cdaSGeorge Liu { 106f777cdaSGeorge Liu namespace occ 116f777cdaSGeorge Liu { 126f777cdaSGeorge Liu namespace dbus 136f777cdaSGeorge Liu { 146f777cdaSGeorge Liu 156f777cdaSGeorge Liu using ObjectPath = std::string; 166f777cdaSGeorge Liu 17af40808fSPatrick Williams using SensorIntf = sdbusplus::server::object_t< 18bb895cb8SChicago Duan sdbusplus::xyz::openbmc_project::Sensor::server::Value>; 19bb895cb8SChicago Duan using OperationalStatusIntf = 20af40808fSPatrick Williams sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::State:: 21bb895cb8SChicago Duan Decorator::server::OperationalStatus>; 22*ff0ce409SChris Cain using PurposeIntf = sdbusplus::server::object_t< 23*ff0ce409SChris Cain sdbusplus::xyz::openbmc_project::Sensor::server::Purpose>; 246f777cdaSGeorge Liu 255901abdaSMatt Spinler // Note: Not using object<> so the PropertiesVariant ctor is available. 265901abdaSMatt Spinler using AssociationIntf = 275901abdaSMatt Spinler sdbusplus::xyz::openbmc_project::Association::server::Definitions; 285901abdaSMatt Spinler 296f777cdaSGeorge Liu /** @class OccDBusSensors 306f777cdaSGeorge Liu * @brief This is a custom D-Bus object, used to add D-Bus interface and update 316f777cdaSGeorge Liu * the corresponding properties value. 326f777cdaSGeorge Liu */ 336f777cdaSGeorge Liu class OccDBusSensors 346f777cdaSGeorge Liu { 356f777cdaSGeorge Liu private: OccDBusSensors()36a49c987eSPatrick Williams OccDBusSensors() {} 376f777cdaSGeorge Liu 386f777cdaSGeorge Liu public: 396f777cdaSGeorge Liu OccDBusSensors(const OccDBusSensors&) = delete; 406f777cdaSGeorge Liu OccDBusSensors(OccDBusSensors&&) = delete; 416f777cdaSGeorge Liu OccDBusSensors& operator=(const OccDBusSensors&) = delete; 426f777cdaSGeorge Liu OccDBusSensors& operator=(OccDBusSensors&&) = delete; 436f777cdaSGeorge Liu ~OccDBusSensors() = default; 446f777cdaSGeorge Liu getOccDBus()456f777cdaSGeorge Liu static OccDBusSensors& getOccDBus() 466f777cdaSGeorge Liu { 476f777cdaSGeorge Liu static OccDBusSensors customDBus; 486f777cdaSGeorge Liu return customDBus; 496f777cdaSGeorge Liu } 506f777cdaSGeorge Liu 516f777cdaSGeorge Liu public: 526f777cdaSGeorge Liu /** @brief Set the max value of the Sensor 536f777cdaSGeorge Liu * 546f777cdaSGeorge Liu * @param[in] path - The object path 556f777cdaSGeorge Liu * @param[in] value - The value of the MaxValue property 560ad9dd87SGeorge Liu * 570ad9dd87SGeorge Liu * @return true or false 586f777cdaSGeorge Liu */ 590ad9dd87SGeorge Liu bool setMaxValue(const std::string& path, double value); 606f777cdaSGeorge Liu 616f777cdaSGeorge Liu /** @brief Get the max value of the Sensor 626f777cdaSGeorge Liu * 636f777cdaSGeorge Liu * @param[in] path - The object path 646f777cdaSGeorge Liu * 656f777cdaSGeorge Liu * @return bool - The value of the MaxValue property 666f777cdaSGeorge Liu */ 676f777cdaSGeorge Liu double getMaxValue(const std::string& path) const; 686f777cdaSGeorge Liu 696f777cdaSGeorge Liu /** @brief Set the min value of the Sensor 706f777cdaSGeorge Liu * 716f777cdaSGeorge Liu * @param[in] path - The object path 726f777cdaSGeorge Liu * @param[in] value - The value of the MinValue property 730ad9dd87SGeorge Liu * 740ad9dd87SGeorge Liu * @return true or false 756f777cdaSGeorge Liu */ 760ad9dd87SGeorge Liu bool setMinValue(const std::string& path, double value); 776f777cdaSGeorge Liu 786f777cdaSGeorge Liu /** @brief Get the min value of the Sensor 796f777cdaSGeorge Liu * 806f777cdaSGeorge Liu * @param[in] path - The object path 816f777cdaSGeorge Liu * 826f777cdaSGeorge Liu * @return bool - The value of the MinValue property 836f777cdaSGeorge Liu */ 846f777cdaSGeorge Liu double getMinValue(const std::string& path) const; 856f777cdaSGeorge Liu 866f777cdaSGeorge Liu /** @brief Set the value of the Sensor 876f777cdaSGeorge Liu * 886f777cdaSGeorge Liu * @param[in] path - The object path 896f777cdaSGeorge Liu * @param[in] value - The value of the Value property 900ad9dd87SGeorge Liu * 910ad9dd87SGeorge Liu * @return true or false 926f777cdaSGeorge Liu */ 930ad9dd87SGeorge Liu bool setValue(const std::string& path, double value); 946f777cdaSGeorge Liu 956f777cdaSGeorge Liu /** @brief Get the value of the Sensor 966f777cdaSGeorge Liu * 976f777cdaSGeorge Liu * @param[in] path - The object path 986f777cdaSGeorge Liu * 996f777cdaSGeorge Liu * @return bool - The value of the Value property 1006f777cdaSGeorge Liu */ 1016f777cdaSGeorge Liu double getValue(const std::string& path) const; 1026f777cdaSGeorge Liu 1036f777cdaSGeorge Liu /** @brief Set the unit of the Sensor 1046f777cdaSGeorge Liu * 1056f777cdaSGeorge Liu * @param[in] path - The object path 1066f777cdaSGeorge Liu * @param[in] value - The value of the Unit property 1070ad9dd87SGeorge Liu * 1080ad9dd87SGeorge Liu * @return true or false 1096f777cdaSGeorge Liu */ 1100ad9dd87SGeorge Liu bool setUnit(const std::string& path, const std::string& value); 1116f777cdaSGeorge Liu 1126f777cdaSGeorge Liu /** @brief Get the unit of the Sensor 1136f777cdaSGeorge Liu * 1146f777cdaSGeorge Liu * @param[in] path - The object path 1156f777cdaSGeorge Liu * 1166f777cdaSGeorge Liu * @return std::string - The value of the Unit property 1176f777cdaSGeorge Liu */ 1186f777cdaSGeorge Liu std::string getUnit(const std::string& path) const; 1196f777cdaSGeorge Liu 1206f777cdaSGeorge Liu /** @brief Set the Functional property 1216f777cdaSGeorge Liu * 1226f777cdaSGeorge Liu * @param[in] path - The object path 1236f777cdaSGeorge Liu * @param[in] value - PLDM operational fault status 1240ad9dd87SGeorge Liu * 1250ad9dd87SGeorge Liu * @return true or false 1266f777cdaSGeorge Liu */ 1270ad9dd87SGeorge Liu bool setOperationalStatus(const std::string& path, bool value); 1286f777cdaSGeorge Liu 1296f777cdaSGeorge Liu /** @brief Get the Functional property 1306f777cdaSGeorge Liu * 1316f777cdaSGeorge Liu * @param[in] path - The object path 1326f777cdaSGeorge Liu * 1336f777cdaSGeorge Liu * @return status - PLDM operational fault status 1346f777cdaSGeorge Liu */ 1356f777cdaSGeorge Liu bool getOperationalStatus(const std::string& path) const; 1366f777cdaSGeorge Liu 1375901abdaSMatt Spinler /** @brief Returns the Chassis inventory path 1385901abdaSMatt Spinler * 1395901abdaSMatt Spinler * @return path - The chassis D-Bus path 1405901abdaSMatt Spinler */ 1415901abdaSMatt Spinler std::string getChassisPath(); 1425901abdaSMatt Spinler 1435901abdaSMatt Spinler /** @brief Set the association to the chassis 1445901abdaSMatt Spinler * 1455901abdaSMatt Spinler * @param[in] path - The object path 1463523cc00SChris Cain * @param[in] fType - vector of forward types 1475901abdaSMatt Spinler */ 1483523cc00SChris Cain void setChassisAssociation(const std::string& path, 1493523cc00SChris Cain const std::vector<std::string>& fTypes); 1505901abdaSMatt Spinler 151ace67d85SMatt Spinler /** @brief Set the value of the DVFS temp sensor 152ace67d85SMatt Spinler * 153ace67d85SMatt Spinler * @param[in] path - The object path 154ace67d85SMatt Spinler * @param[in] value - The value of the Value property 155ace67d85SMatt Spinler */ 156ace67d85SMatt Spinler void setDvfsTemp(const std::string& path, double value); 157ace67d85SMatt Spinler 158ace67d85SMatt Spinler /** @brief Says if the DVFS temp sensor is already present 159ace67d85SMatt Spinler * 160ace67d85SMatt Spinler * @param[in] value - The value of the Value property 161ace67d85SMatt Spinler * @return bool - If the sensor is already present 162ace67d85SMatt Spinler */ 163ace67d85SMatt Spinler bool hasDvfsTemp(const std::string& path) const; 164ace67d85SMatt Spinler 165*ff0ce409SChris Cain /** @brief Set the purpose of the Sensor 166*ff0ce409SChris Cain * 167*ff0ce409SChris Cain * @param[in] path - The object path 168*ff0ce409SChris Cain * @param[in] value - The value of the Purpose property 169*ff0ce409SChris Cain * 170*ff0ce409SChris Cain * @return true or false 171*ff0ce409SChris Cain */ 172*ff0ce409SChris Cain bool setPurpose(const std::string& path, const std::string& value); 173*ff0ce409SChris Cain 1746f777cdaSGeorge Liu private: 1756f777cdaSGeorge Liu std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors; 176*ff0ce409SChris Cain std::map<ObjectPath, std::unique_ptr<PurposeIntf>> purposes; 1776f777cdaSGeorge Liu 1786f777cdaSGeorge Liu std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>> 1796f777cdaSGeorge Liu operationalStatus; 1805901abdaSMatt Spinler 1815901abdaSMatt Spinler std::map<ObjectPath, std::unique_ptr<AssociationIntf>> chassisAssociations; 1825901abdaSMatt Spinler 1835901abdaSMatt Spinler std::string chassisPath; 184ace67d85SMatt Spinler 185ace67d85SMatt Spinler /** @brief Map of DVFS (Dynamic Voltage and Frequency Slewing) temps 186ace67d85SMatt Spinler * 187ace67d85SMatt Spinler * These do not have associations and do not get set to NaN when the OCC 188ace67d85SMatt Spinler * isn't active. 189ace67d85SMatt Spinler */ 190ace67d85SMatt Spinler std::map<std::string, std::unique_ptr<SensorIntf>> dvfsTemps; 1916f777cdaSGeorge Liu }; 1926f777cdaSGeorge Liu 1936f777cdaSGeorge Liu } // namespace dbus 1946f777cdaSGeorge Liu } // namespace occ 1956f777cdaSGeorge Liu } // namespace open_power 196