diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-05-16 16:13:56 -0500 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2017-05-31 11:29:56 -0500 |
commit | ba102b3826ff28a4f9ccce8ed54aaf4114fbd1db (patch) | |
tree | 1d25e4d8e5367be270dae9d71da4b7019af71eed | |
parent | d4d0f083679e6b23c4e4fe72f4958c1f313b582d (diff) | |
download | phosphor-fan-presence-ba102b3826ff28a4f9ccce8ed54aaf4114fbd1db.tar.gz phosphor-fan-presence-ba102b3826ff28a4f9ccce8ed54aaf4114fbd1db.zip |
Generate set speed event actions
Adds the set speed event action functions with the associated parameters
in the order required for the function
Change-Id: Ib08f2442d8ff1fb3d49ab5234eacc2db8304a20d
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rwxr-xr-x | control/gen-fan-zone-defs.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py index 221b322..97d62ea 100755 --- a/control/gen-fan-zone-defs.py +++ b/control/gen-fan-zone-defs.py @@ -14,6 +14,8 @@ from mako.template import Template #Note: Condition is a TODO (openbmc/openbmc#1500) tmpl = '''/* This is a generated file. */ #include "manager.hpp" +#include "functor.hpp" +#include "actions.hpp" using namespace phosphor::fan::control; @@ -49,6 +51,16 @@ const std::vector<ZoneGroup> Manager::_zoneLayouts "${member['property']}"} }, %endfor + }, + make_action(action::${event['action']['name']}( + %for index, param in enumerate(event['action']['parameters']): + %if (index+1) != len(event['action']['parameters']): + static_cast<${param['type']}>(${param['value']}), + %else: + static_cast<${param['type']}>(${param['value']}) + %endif + %endfor + )), }, %endfor } @@ -67,6 +79,7 @@ def getEventsInZone(zone_num, events_data): provided. """ events = [] + if 'events' in events_data: for e in events_data['events']: for z in e['zone_conditions']: @@ -87,6 +100,31 @@ def getEventsInZone(zone_num, events_data): members['property'] = e['property']['name'] group.append(members) event['group'] = group + + # Add set speed action and function parameters + action = {} + actions = next(a for a in events_data['actions'] + if a['name'] == e['action']['name']) + action['name'] = actions['name'] + params = [] + for p in actions['parameters']: + param = {} + if type(e['action'][p]) is not dict: + if p == 'property': + param['value'] = str(e['action'][p]).lower() + param['type'] = str(e['property']['type']).lower() + else: + # Default type to 'size_t' when not given + param['value'] = str(e['action'][p]).lower() + param['type'] = 'size_t' + params.append(param) + else: + param['value'] = str(e['action'][p]['value']).lower() + param['type'] = str(e['action'][p]['type']).lower() + params.append(param) + action['parameters'] = params + event['action'] = action + events.append(event) return events |