control: Remove JSON zone object include of YAML zone object
This completes another step at separating the JSON based zone object
from the YAML based zone object. Unfortunately a couple ties to the YAML
based zone object still exists thru including the current set of
functors. Those will need to be replicated into the JSON based binary in
a follow-up commit.
The primary addition here was to extend the `ThermalMode` interface by
the JSON based zone object including the necessary methods to support
it. Some `TODO`s were noted and will be handled later as additional
functionality is ported over the JSON based binary.
Change-Id: Ia1c4a680541609933f733497c0987d3b6b0f1c33
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/zone.hpp b/control/json/zone.hpp
index b91af2f..291a5c5 100644
--- a/control/json/zone.hpp
+++ b/control/json/zone.hpp
@@ -17,7 +17,7 @@
#include "config_base.hpp"
#include "fan.hpp"
-#include "types.hpp"
+#include "xyz/openbmc_project/Control/ThermalMode/server.hpp"
#include <nlohmann/json.hpp>
#include <sdbusplus/bus.hpp>
@@ -32,6 +32,10 @@
using json = nlohmann::json;
+/* Extend the Control::ThermalMode interface */
+using ThermalObject = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Control::server::ThermalMode>;
+
/* Interface property handler function */
using propHandler = std::function<ZoneHandler(const json&, bool)>;
@@ -48,7 +52,7 @@
* (When no profile for a zone is given, the zone defaults to always exist)
*
*/
-class Zone : public ConfigBase
+class Zone : public ConfigBase, public ThermalObject
{
public:
/* JSON file name for zones */
@@ -187,6 +191,23 @@
*/
void requestIncrease(uint64_t targetDelta);
+ /**
+ * @brief Set a property to be persisted
+ *
+ * @param[in] intf - Interface containing property
+ * @param[in] prop - Property to be persisted
+ */
+ void setPersisted(const std::string& intf, const std::string& prop);
+
+ /**
+ * @brief Overridden thermal object's set 'Current' property function
+ *
+ * @param[in] value - Value to set 'Current' to
+ *
+ * @return - The updated value of the 'Current' property
+ */
+ std::string current(std::string value) override;
+
private:
/* The zone's full speed value for fans */
uint64_t _fullSpeed;
@@ -209,6 +230,9 @@
/* Map of whether floor changes are allowed by a string identifier */
std::map<std::string, bool> _floorChange;
+ /* Map of interfaces to persisted properties the zone hosts*/
+ std::map<std::string, std::vector<std::string>> _propsPersisted;
+
/**
* Zone interface handler functions for its
* configured interfaces (OPTIONAL)
@@ -262,6 +286,22 @@
* to not be persisted when not given.
*/
void setInterfaces(const json& jsonObj);
+
+ /**
+ * @brief Is the property persisted
+ *
+ * @param[in] intf - Interface containing property
+ * @param[in] prop - Property to check if persisted
+ *
+ * @return - True if property is to be persisted, false otherwise
+ */
+ bool isPersisted(const std::string& intf, const std::string& prop);
+
+ /**
+ * @brief Save the thermal control current mode property to persisted
+ * storage
+ */
+ void saveCurrentMode();
};
/**