summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2019-02-18 12:23:38 -0600
committerMatthew Barth <msbarth@us.ibm.com>2019-02-18 13:01:02 -0600
commit59096e50db52d85d2252bb5c7de054bd3c8156c5 (patch)
tree5773a3401c7f9f6eb1a698594ce3c65964565d21
parent70b2e7da829b9b11f4fa4d9141383a5dbc63e6e1 (diff)
downloadphosphor-fan-presence-59096e50db52d85d2252bb5c7de054bd3c8156c5.zip
phosphor-fan-presence-59096e50db52d85d2252bb5c7de054bd3c8156c5.tar.gz
Generate zone property persist configs
Each zone object's hosted interfaces' properties can be configured to be persisted or not at compile time. Those properties configured to be persisted are set to be persisted after the initial value is set. When this value doesnt change on a system, there's no need to persist it since the initial value is compiled into the fan control application per zone. Once this value is changed and therefore persisted, upon a application restart, initially the value would be what's compiled in until its configured again to be persisted and then restored. Tested: Current property always set to what's persisted between restarts Nothing persisted when Current property doesnt change from default Change-Id: I93109730796af2058ecab0e78e612b7919886b33 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rwxr-xr-xcontrol/gen-fan-zone-defs.py10
-rw-r--r--control/handlers.hpp17
-rw-r--r--control/templates/fan_zone_defs.mako.cpp11
3 files changed, 30 insertions, 8 deletions
diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py
index e875e32..a5e4809 100755
--- a/control/gen-fan-zone-defs.py
+++ b/control/gen-fan-zone-defs.py
@@ -702,8 +702,16 @@ def getIfacesInZone(zone_ifaces):
props = []
for p in i['properties']:
prop = {}
- prop['name'] = str(p['name']).lower()
+ prop['name'] = p['name']
+ prop['func'] = str(p['name']).lower()
prop['type'] = parse_cpp_type(p['type'])
+ if ('persist' in p):
+ persist = p['persist']
+ if (persist is not None):
+ if (isinstance(persist, bool)):
+ prop['persist'] = 'true' if persist else 'false'
+ else:
+ prop['persist'] = 'false'
vals = []
for v in p['values']:
val = v['value']
diff --git a/control/handlers.hpp b/control/handlers.hpp
index 215662a..6b512fd 100644
--- a/control/handlers.hpp
+++ b/control/handlers.hpp
@@ -14,18 +14,29 @@ namespace handler
* @details Sets or updates a zone property to the given value using the
* provided zone dbus object's set property function
*
- * @param[in] value - Value to set property to
+ * @param[in] intf - Interface on zone object
+ * @param[in] prop - Property on interface
* @param[in] func - Zone set property function pointer
+ * @param[in] value - Value to set property to
+ * @param[in] persist - Persist property value or not
*
* @return Lambda function
* A lambda function to set/update the zone property
*/
template <typename T>
-auto setZoneProperty(T (Zone::*func)(T), T&& value)
+auto setZoneProperty(const char* intf,
+ const char* prop,
+ T (Zone::*func)(T),
+ T&& value,
+ bool persist)
{
- return [func, value = std::forward<T>(value)](auto& zone)
+ return [=, value = std::forward<T>(value)](auto& zone)
{
(zone.*func)(value);
+ if (persist)
+ {
+ zone.setPersisted(intf, prop);
+ }
};
}
diff --git a/control/templates/fan_zone_defs.mako.cpp b/control/templates/fan_zone_defs.mako.cpp
index cb46986..e05d1fc 100644
--- a/control/templates/fan_zone_defs.mako.cpp
+++ b/control/templates/fan_zone_defs.mako.cpp
@@ -54,13 +54,15 @@ const std::vector<ZoneGroup> Manager::_zoneLayouts
%for p in i['props']:
ZoneHandler{
make_zoneHandler(handler::setZoneProperty(
- &Zone::${p['name']},
+ "${i['name']}",
+ "${p['name']}",
+ &Zone::${p['func']},
static_cast<${p['type']}>(
%if "vector" in p['type'] or "map" in p['type']:
${p['type']}{
%endif
- %for i, v in enumerate(p['values']):
- %if (i+1) != len(p['values']):
+ %for j, v in enumerate(p['values']):
+ %if (j+1) != len(p['values']):
${v},
%else:
${v}
@@ -69,7 +71,8 @@ const std::vector<ZoneGroup> Manager::_zoneLayouts
%if "vector" in p['type'] or "map" in p['type']:
}
%endif
- )
+ ),
+ ${p['persist']}
))
},
%endfor
OpenPOWER on IntegriCloud