16f777cdaSGeorge Liu #pragma once
26f777cdaSGeorge Liu 
36f777cdaSGeorge Liu #include <xyz/openbmc_project/Sensor/Value/server.hpp>
46f777cdaSGeorge Liu #include <xyz/openbmc_project/State/Decorator/OperationalStatus/server.hpp>
56f777cdaSGeorge Liu 
66f777cdaSGeorge Liu namespace open_power
76f777cdaSGeorge Liu {
86f777cdaSGeorge Liu namespace occ
96f777cdaSGeorge Liu {
106f777cdaSGeorge Liu namespace dbus
116f777cdaSGeorge Liu {
126f777cdaSGeorge Liu 
136f777cdaSGeorge Liu using ObjectPath = std::string;
146f777cdaSGeorge Liu 
15*bb895cb8SChicago Duan using SensorIntf = sdbusplus::server::object::object<
16*bb895cb8SChicago Duan     sdbusplus::xyz::openbmc_project::Sensor::server::Value>;
17*bb895cb8SChicago Duan using OperationalStatusIntf =
18*bb895cb8SChicago Duan     sdbusplus::server::object::object<sdbusplus::xyz::openbmc_project::State::
19*bb895cb8SChicago Duan                                           Decorator::server::OperationalStatus>;
206f777cdaSGeorge Liu 
216f777cdaSGeorge Liu /** @class OccDBusSensors
226f777cdaSGeorge Liu  *  @brief This is a custom D-Bus object, used to add D-Bus interface and update
236f777cdaSGeorge Liu  *         the corresponding properties value.
246f777cdaSGeorge Liu  */
256f777cdaSGeorge Liu class OccDBusSensors
266f777cdaSGeorge Liu {
276f777cdaSGeorge Liu   private:
286f777cdaSGeorge Liu     OccDBusSensors()
296f777cdaSGeorge Liu     {
306f777cdaSGeorge Liu     }
316f777cdaSGeorge Liu 
326f777cdaSGeorge Liu   public:
336f777cdaSGeorge Liu     OccDBusSensors(const OccDBusSensors&) = delete;
346f777cdaSGeorge Liu     OccDBusSensors(OccDBusSensors&&) = delete;
356f777cdaSGeorge Liu     OccDBusSensors& operator=(const OccDBusSensors&) = delete;
366f777cdaSGeorge Liu     OccDBusSensors& operator=(OccDBusSensors&&) = delete;
376f777cdaSGeorge Liu     ~OccDBusSensors() = default;
386f777cdaSGeorge Liu 
396f777cdaSGeorge Liu     static OccDBusSensors& getOccDBus()
406f777cdaSGeorge Liu     {
416f777cdaSGeorge Liu         static OccDBusSensors customDBus;
426f777cdaSGeorge Liu         return customDBus;
436f777cdaSGeorge Liu     }
446f777cdaSGeorge Liu 
456f777cdaSGeorge Liu   public:
466f777cdaSGeorge Liu     /** @brief Set the max value of the Sensor
476f777cdaSGeorge Liu      *
486f777cdaSGeorge Liu      *  @param[in] path  - The object path
496f777cdaSGeorge Liu      *  @param[in] value - The value of the MaxValue property
500ad9dd87SGeorge Liu      *
510ad9dd87SGeorge Liu      *  @return true or false
526f777cdaSGeorge Liu      */
530ad9dd87SGeorge Liu     bool setMaxValue(const std::string& path, double value);
546f777cdaSGeorge Liu 
556f777cdaSGeorge Liu     /** @brief Get the max value of the Sensor
566f777cdaSGeorge Liu      *
576f777cdaSGeorge Liu      *  @param[in] path  - The object path
586f777cdaSGeorge Liu      *
596f777cdaSGeorge Liu      *  @return bool     - The value of the MaxValue property
606f777cdaSGeorge Liu      */
616f777cdaSGeorge Liu     double getMaxValue(const std::string& path) const;
626f777cdaSGeorge Liu 
636f777cdaSGeorge Liu     /** @brief Set the min value of the Sensor
646f777cdaSGeorge Liu      *
656f777cdaSGeorge Liu      *  @param[in] path  - The object path
666f777cdaSGeorge Liu      *  @param[in] value - The value of the MinValue property
670ad9dd87SGeorge Liu      *
680ad9dd87SGeorge Liu      *  @return true or false
696f777cdaSGeorge Liu      */
700ad9dd87SGeorge Liu     bool setMinValue(const std::string& path, double value);
716f777cdaSGeorge Liu 
726f777cdaSGeorge Liu     /** @brief Get the min value of the Sensor
736f777cdaSGeorge Liu      *
746f777cdaSGeorge Liu      *  @param[in] path  - The object path
756f777cdaSGeorge Liu      *
766f777cdaSGeorge Liu      *  @return bool     - The value of the MinValue property
776f777cdaSGeorge Liu      */
786f777cdaSGeorge Liu     double getMinValue(const std::string& path) const;
796f777cdaSGeorge Liu 
806f777cdaSGeorge Liu     /** @brief Set the value of the Sensor
816f777cdaSGeorge Liu      *
826f777cdaSGeorge Liu      *  @param[in] path  - The object path
836f777cdaSGeorge Liu      *  @param[in] value - The value of the Value property
840ad9dd87SGeorge Liu      *
850ad9dd87SGeorge Liu      *  @return true or false
866f777cdaSGeorge Liu      */
870ad9dd87SGeorge Liu     bool setValue(const std::string& path, double value);
886f777cdaSGeorge Liu 
896f777cdaSGeorge Liu     /** @brief Get the value of the Sensor
906f777cdaSGeorge Liu      *
916f777cdaSGeorge Liu      *  @param[in] path  - The object path
926f777cdaSGeorge Liu      *
936f777cdaSGeorge Liu      *  @return bool     - The value of the Value property
946f777cdaSGeorge Liu      */
956f777cdaSGeorge Liu     double getValue(const std::string& path) const;
966f777cdaSGeorge Liu 
976f777cdaSGeorge Liu     /** @brief Set the unit of the Sensor
986f777cdaSGeorge Liu      *
996f777cdaSGeorge Liu      *  @param[in] path  - The object path
1006f777cdaSGeorge Liu      *  @param[in] value - The value of the Unit property
1010ad9dd87SGeorge Liu      *
1020ad9dd87SGeorge Liu      *  @return true or false
1036f777cdaSGeorge Liu      */
1040ad9dd87SGeorge Liu     bool setUnit(const std::string& path, const std::string& value);
1056f777cdaSGeorge Liu 
1066f777cdaSGeorge Liu     /** @brief Get the unit of the Sensor
1076f777cdaSGeorge Liu      *
1086f777cdaSGeorge Liu      *  @param[in] path       - The object path
1096f777cdaSGeorge Liu      *
1106f777cdaSGeorge Liu      *  @return std::string   - The value of the Unit property
1116f777cdaSGeorge Liu      */
1126f777cdaSGeorge Liu     std::string getUnit(const std::string& path) const;
1136f777cdaSGeorge Liu 
1146f777cdaSGeorge Liu     /** @brief Set the Functional property
1156f777cdaSGeorge Liu      *
1166f777cdaSGeorge Liu      *  @param[in] path   - The object path
1176f777cdaSGeorge Liu      *  @param[in] value  - PLDM operational fault status
1180ad9dd87SGeorge Liu      *
1190ad9dd87SGeorge Liu      *  @return true or false
1206f777cdaSGeorge Liu      */
1210ad9dd87SGeorge Liu     bool setOperationalStatus(const std::string& path, bool value);
1226f777cdaSGeorge Liu 
1236f777cdaSGeorge Liu     /** @brief Get the Functional property
1246f777cdaSGeorge Liu      *
1256f777cdaSGeorge Liu      *  @param[in] path   - The object path
1266f777cdaSGeorge Liu      *
1276f777cdaSGeorge Liu      *  @return status    - PLDM operational fault status
1286f777cdaSGeorge Liu      */
1296f777cdaSGeorge Liu     bool getOperationalStatus(const std::string& path) const;
1306f777cdaSGeorge Liu 
1316f777cdaSGeorge Liu   private:
1326f777cdaSGeorge Liu     std::map<ObjectPath, std::unique_ptr<SensorIntf>> sensors;
1336f777cdaSGeorge Liu 
1346f777cdaSGeorge Liu     std::map<ObjectPath, std::unique_ptr<OperationalStatusIntf>>
1356f777cdaSGeorge Liu         operationalStatus;
1366f777cdaSGeorge Liu };
1376f777cdaSGeorge Liu 
1386f777cdaSGeorge Liu } // namespace dbus
1396f777cdaSGeorge Liu } // namespace occ
1406f777cdaSGeorge Liu } // namespace open_power
141