From cc8912e93eb55e938b5cdb189a70d1f342fb49ea Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Mon, 21 Jan 2019 11:35:27 -0600 Subject: Persist current mode property framework Add the ability to save the current mode property value to persisted storage. Change-Id: I354fce7c11a61871a49c9b205dc79ee598f8b1c8 Signed-off-by: Matthew Barth --- control/zone.cpp | 17 +++++++++++++++++ control/zone.hpp | 6 ++++++ 2 files changed, 23 insertions(+) (limited to 'control') diff --git a/control/zone.cpp b/control/zone.cpp index 9333daa..7d836ba 100644 --- a/control/zone.cpp +++ b/control/zone.cpp @@ -15,11 +15,16 @@ */ #include #include +#include +#include +#include +#include #include #include #include #include #include +#include "config.h" #include "zone.hpp" #include "utility.hpp" #include "sdbusplus.hpp" @@ -34,6 +39,7 @@ namespace control using namespace std::chrono; using namespace phosphor::fan; using namespace phosphor::logging; +namespace fs = std::experimental::filesystem; using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: Error::InternalFailure; @@ -597,6 +603,17 @@ const std::string& Zone::addServices(const std::string& path, return empty; } +void Zone::saveCurrentMode() +{ + fs::path path{CONTROL_PERSIST_ROOT_PATH}; + // Append zone and property description + path /= std::to_string(_zoneNum); + path /= "CurrentMode"; + std::ofstream ofs(path.c_str(), std::ios::binary); + cereal::JSONOutputArchive oArch(ofs); + oArch(ThermalObject::current()); +} + } } } diff --git a/control/zone.hpp b/control/zone.hpp index ad4d4b4..feaa8c8 100644 --- a/control/zone.hpp +++ b/control/zone.hpp @@ -615,6 +615,12 @@ class Zone : public ThermalObject */ std::vector _timerEvents; + /** + * @brief Save the thermal control current mode property + * to persisted storage + */ + void saveCurrentMode(); + /** * @brief Get the request speed base if defined, otherwise the * the current target speed is returned -- cgit v1.2.1