summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2019-02-18 11:03:07 -0600
committerMatthew Barth <msbarth@us.ibm.com>2019-02-18 11:03:07 -0600
commit70b2e7da829b9b11f4fa4d9141383a5dbc63e6e1 (patch)
treec103befa0745f7b1b01a8316a2cf9dc6210274da
parent221c90c39a5cbd4ed71211b47af80f967c4575c3 (diff)
downloadphosphor-fan-presence-70b2e7da829b9b11f4fa4d9141383a5dbc63e6e1.zip
phosphor-fan-presence-70b2e7da829b9b11f4fa4d9141383a5dbc63e6e1.tar.gz
Persist zone object properties option
Add functions to set and get persisted properties on a zone by the interface and property name. When a property exists, it is persisted each time it is updated. Tested: Current property is added and persisted. When Current property not added, it is not persisted. Change-Id: I2540c3673affcda871c9342cad44e85a4510d756 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--control/zone.cpp24
-rw-r--r--control/zone.hpp28
2 files changed, 51 insertions, 1 deletions
diff --git a/control/zone.cpp b/control/zone.cpp
index 6efbe73..fddca53 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -638,6 +638,25 @@ const std::string& Zone::addServices(const std::string& path,
return empty;
}
+auto Zone::getPersisted(const std::string& intf,
+ const std::string& prop)
+{
+ auto persisted = false;
+
+ auto it = _persisted.find(intf);
+ if (it != _persisted.end())
+ {
+ return std::any_of(it->second.begin(),
+ it->second.end(),
+ [&prop](auto& p)
+ {
+ return prop == p;
+ });
+ }
+
+ return persisted;
+}
+
std::string Zone::current(std::string value)
{
auto current = ThermalObject::current();
@@ -656,7 +675,10 @@ std::string Zone::current(std::string value)
if (value != current && isSupported)
{
current = ThermalObject::current(value);
- saveCurrentMode();
+ if (getPersisted("xyz.openbmc_project.Control.ThermalMode", "Current"))
+ {
+ saveCurrentMode();
+ }
// Trigger event(s) for current mode property change
auto eData = _objects[_path]
["xyz.openbmc_project.Control.ThermalMode"]
diff --git a/control/zone.hpp b/control/zone.hpp
index 2633902..6da3091 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -470,6 +470,29 @@ class Zone : public ThermalObject
int32_t depth);
/**
+ * @brief Set a property to be persisted
+ *
+ * @param[in] intf - Interface containing property
+ * @param[in] prop - Property to be persisted
+ */
+ inline void setPersisted(const std::string& intf,
+ const std::string& prop)
+ {
+ _persisted[intf].emplace_back(prop);
+ }
+
+ /**
+ * @brief Get persisted property
+ *
+ * @param[in] intf - Interface containing property
+ * @param[in] prop - Property persisted
+ *
+ * @return - True if property is to be persisted, false otherwise
+ */
+ auto getPersisted(const std::string& intf,
+ const std::string& prop);
+
+ /**
* @brief Get a property value from the zone object or the bus when
* the property requested is not on the zone object
*
@@ -653,6 +676,11 @@ class Zone : public ThermalObject
EventData*>>> _objects;
/**
+ * @brief Map of interfaces to persisted properties
+ */
+ std::map<std::string, std::vector<std::string>> _persisted;
+
+ /**
* @brief Map of active fan control allowed by groups
*/
std::map<const Group, bool> _active;
OpenPOWER on IntegriCloud