16f777cdaSGeorge Liu #pragma once
26f777cdaSGeorge Liu 
35901abdaSMatt Spinler #include <xyz/openbmc_project/Association/Definitions/server.hpp>
46f777cdaSGeorge Liu #include <xyz/openbmc_project/Sensor/Value/server.hpp>
56f777cdaSGeorge Liu #include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp>
66f777cdaSGeorge Liu 
76f777cdaSGeorge Liu namespace open_power
86f777cdaSGeorge Liu {
96f777cdaSGeorge Liu namespace occ
106f777cdaSGeorge Liu {
116f777cdaSGeorge Liu namespace dbus
126f777cdaSGeorge Liu {
136f777cdaSGeorge Liu 
146f777cdaSGeorge Liu using ObjectPath = std::string;
156f777cdaSGeorge Liu 
16af40808fSPatrick Williams using SensorIntf = sdbusplus::server::object_t<
17bb895cb8SChicago Duan     sdbusplus::xyz::openbmc_project::Sensor::server::Value>;
18bb895cb8SChicago Duan using OperationalStatusIntf =
19af40808fSPatrick Williams     sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::State::
20bb895cb8SChicago Duan                                     Decorator::server::OperationalStatus>;
216f777cdaSGeorge Liu 
225901abdaSMatt Spinler // Note: Not using object<> so the PropertiesVariant ctor is available.
235901abdaSMatt Spinler using AssociationIntf =
245901abdaSMatt Spinler     sdbusplus::xyz::openbmc_project::Association::server::Definitions;
255901abdaSMatt Spinler 
266f777cdaSGeorge Liu /** @class OccDBusSensors
276f777cdaSGeorge Liu  *  @brief This is a custom D-Bus object, used to add D-Bus interface and update
286f777cdaSGeorge Liu  *         the corresponding properties value.
296f777cdaSGeorge Liu  */
306f777cdaSGeorge Liu class OccDBusSensors
316f777cdaSGeorge Liu {
326f777cdaSGeorge Liu   private:
OccDBusSensors()33*a49c987eSPatrick Williams     OccDBusSensors() {}
346f777cdaSGeorge Liu 
356f777cdaSGeorge Liu   public:
366f777cdaSGeorge Liu     OccDBusSensors(const OccDBusSensors&) = delete;
376f777cdaSGeorge Liu     OccDBusSensors(OccDBusSensors&&) = delete;
386f777cdaSGeorge Liu     OccDBusSensors& operator=(const OccDBusSensors&) = delete;
396f777cdaSGeorge Liu     OccDBusSensors& operator=(OccDBusSensors&&) = delete;
406f777cdaSGeorge Liu     ~OccDBusSensors() = default;
416f777cdaSGeorge Liu 
getOccDBus()426f777cdaSGeorge Liu     static OccDBusSensors& getOccDBus()
436f777cdaSGeorge Liu     {
446f777cdaSGeorge Liu         static OccDBusSensors customDBus;
456f777cdaSGeorge Liu         return customDBus;
466f777cdaSGeorge Liu     }
476f777cdaSGeorge Liu 
486f777cdaSGeorge Liu   public:
496f777cdaSGeorge Liu     /** @brief Set the max value of the Sensor
506f777cdaSGeorge Liu      *
516f777cdaSGeorge Liu      *  @param[in] path  - The object path
526f777cdaSGeorge Liu      *  @param[in] value - The value of the MaxValue property
530ad9dd87SGeorge Liu      *
540ad9dd87SGeorge Liu      *  @return true or false
556f777cdaSGeorge Liu      */
560ad9dd87SGeorge Liu     bool setMaxValue(const std::string& path, double value);
576f777cdaSGeorge Liu 
586f777cdaSGeorge Liu     /** @brief Get the max value of the Sensor
596f777cdaSGeorge Liu      *
606f777cdaSGeorge Liu      *  @param[in] path  - The object path
616f777cdaSGeorge Liu      *
626f777cdaSGeorge Liu      *  @return bool     - The value of the MaxValue property
636f777cdaSGeorge Liu      */
646f777cdaSGeorge Liu     double getMaxValue(const std::string& path) const;
656f777cdaSGeorge Liu 
666f777cdaSGeorge Liu     /** @brief Set the min value of the Sensor
676f777cdaSGeorge Liu      *
686f777cdaSGeorge Liu      *  @param[in] path  - The object path
696f777cdaSGeorge Liu      *  @param[in] value - The value of the MinValue property
700ad9dd87SGeorge Liu      *
710ad9dd87SGeorge Liu      *  @return true or false
726f777cdaSGeorge Liu      */
730ad9dd87SGeorge Liu     bool setMinValue(const std::string& path, double value);
746f777cdaSGeorge Liu 
756f777cdaSGeorge Liu     /** @brief Get the min value of the Sensor
766f777cdaSGeorge Liu      *
776f777cdaSGeorge Liu      *  @param[in] path  - The object path
786f777cdaSGeorge Liu      *
796f777cdaSGeorge Liu      *  @return bool     - The value of the MinValue property
806f777cdaSGeorge Liu      */
816f777cdaSGeorge Liu     double getMinValue(const std::string& path) const;
826f777cdaSGeorge Liu 
836f777cdaSGeorge Liu     /** @brief Set the value of the Sensor
846f777cdaSGeorge Liu      *
856f777cdaSGeorge Liu      *  @param[in] path  - The object path
866f777cdaSGeorge Liu      *  @param[in] value - The value of the Value property
870ad9dd87SGeorge Liu      *
880ad9dd87SGeorge Liu      *  @return true or false
896f777cdaSGeorge Liu      */
900ad9dd87SGeorge Liu     bool setValue(const std::string& path, double value);
916f777cdaSGeorge Liu 
926f777cdaSGeorge Liu     /** @brief Get the value of the Sensor
936f777cdaSGeorge Liu      *
946f777cdaSGeorge Liu      *  @param[in] path  - The object path
956f777cdaSGeorge Liu      *
966f777cdaSGeorge Liu      *  @return bool     - The value of the Value property
976f777cdaSGeorge Liu      */
986f777cdaSGeorge Liu     double getValue(const std::string& path) const;
996f777cdaSGeorge Liu 
1006f777cdaSGeorge Liu     /** @brief Set the unit of the Sensor
1016f777cdaSGeorge Liu      *
1026f777cdaSGeorge Liu      *  @param[in] path  - The object path
1036f777cdaSGeorge Liu      *  @param[in] value - The value of the Unit property
1040ad9dd87SGeorge Liu      *
1050ad9dd87SGeorge Liu      *  @return true or false
1066f777cdaSGeorge Liu      */
1070ad9dd87SGeorge Liu     bool setUnit(const std::string& path, const std::string& value);
1086f777cdaSGeorge Liu 
1096f777cdaSGeorge Liu     /** @brief Get the unit of the Sensor
1106f777cdaSGeorge Liu      *
1116f777cdaSGeorge Liu      *  @param[in] path       - The object path
1126f777cdaSGeorge Liu      *
1136f777cdaSGeorge Liu      *  @return std::string   - The value of the Unit property
1146f777cdaSGeorge Liu      */
1156f777cdaSGeorge Liu     std::string getUnit(const std::string& path) const;
1166f777cdaSGeorge Liu 
1176f777cdaSGeorge Liu     /** @brief Set the Functional property
1186f777cdaSGeorge Liu      *
1196f777cdaSGeorge Liu      *  @param[in] path   - The object path
1206f777cdaSGeorge Liu      *  @param[in] value  - PLDM operational fault status
1210ad9dd87SGeorge Liu      *
1220ad9dd87SGeorge Liu      *  @return true or false
1236f777cdaSGeorge Liu      */
1240ad9dd87SGeorge Liu     bool setOperationalStatus(const std::string& path, bool value);
1256f777cdaSGeorge Liu 
1266f777cdaSGeorge Liu     /** @brief Get the Functional property
1276f777cdaSGeorge Liu      *
1286f777cdaSGeorge Liu      *  @param[in] path   - The object path
1296f777cdaSGeorge Liu      *
1306f777cdaSGeorge Liu      *  @return status    - PLDM operational fault status
1316f777cdaSGeorge Liu      */
1326f777cdaSGeorge Liu     bool getOperationalStatus(const std::string& path) const;
1336f777cdaSGeorge Liu 
1345901abdaSMatt Spinler     /** @brief Returns the Chassis inventory path
1355901abdaSMatt Spinler      *
1365901abdaSMatt Spinler      * @return path       - The chassis D-Bus path
1375901abdaSMatt Spinler      */
1385901abdaSMatt Spinler     std::string getChassisPath();
1395901abdaSMatt Spinler 
1405901abdaSMatt Spinler     /** @brief Set the association to the chassis
1415901abdaSMatt Spinler      *
1425901abdaSMatt Spinler      *  @param[in] path   - The object path
1435901abdaSMatt Spinler      */
1445901abdaSMatt Spinler     void setChassisAssociation(const std::string& path);
1455901abdaSMatt Spinler 
146ace67d85SMatt Spinler     /** @brief Set the value of the DVFS temp sensor
147ace67d85SMatt Spinler      *
148ace67d85SMatt Spinler      *  @param[in] path  - The object path
149ace67d85SMatt Spinler      *  @param[in] value - The value of the Value property
150ace67d85SMatt Spinler      */
151ace67d85SMatt Spinler     void setDvfsTemp(const std::string& path, double value);
152ace67d85SMatt Spinler 
153ace67d85SMatt Spinler     /** @brief Says if the DVFS temp sensor is already present
154ace67d85SMatt Spinler      *
155ace67d85SMatt Spinler      *  @param[in] value - The value of the Value property
156ace67d85SMatt Spinler      *  @return bool - If the sensor is already present
157ace67d85SMatt Spinler      */
158ace67d85SMatt Spinler     bool hasDvfsTemp(const std::string& path) const;
159ace67d85SMatt Spinler 
1606f777cdaSGeorge Liu   private:
1616f777cdaSGeorge Liu     std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors;
1626f777cdaSGeorge Liu 
1636f777cdaSGeorge Liu     std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>>
1646f777cdaSGeorge Liu         operationalStatus;
1655901abdaSMatt Spinler 
1665901abdaSMatt Spinler     std::map<ObjectPath, std::unique_ptr<AssociationIntf>> chassisAssociations;
1675901abdaSMatt Spinler 
1685901abdaSMatt Spinler     std::string chassisPath;
169ace67d85SMatt Spinler 
170ace67d85SMatt Spinler     /** @brief Map of DVFS (Dynamic Voltage and Frequency Slewing) temps
171ace67d85SMatt Spinler      *
172ace67d85SMatt Spinler      * These do not have associations and do not get set to NaN when the OCC
173ace67d85SMatt Spinler      * isn't active.
174ace67d85SMatt Spinler      */
175ace67d85SMatt Spinler     std::map<std::string, std::unique_ptr<SensorIntf>> dvfsTemps;
1766f777cdaSGeorge Liu };
1776f777cdaSGeorge Liu 
1786f777cdaSGeorge Liu } // namespace dbus
1796f777cdaSGeorge Liu } // namespace occ
1806f777cdaSGeorge Liu } // namespace open_power
181