Preconditions use signal triggers
Merge precondition events to use the same signal trigger generation
function.
Tested:
Generated code remains unchanged
Change-Id: I4c3e9df2567a0f4290ddeba2bf76aecbfb674dea
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py
index 511e910..03346bc 100755
--- a/control/gen-fan-zone-defs.py
+++ b/control/gen-fan-zone-defs.py
@@ -540,85 +540,15 @@
pcevents.append(pcevent)
precond['pcevts'] = pcevents
- # Add precondition signal handlers
- signals = []
- for group in precond['pcgrps']:
- for member in group['members']:
- for eMatches in event['precondition']['matches']:
- signal = {}
- eMatch = next(m for m in events_data['matches']
- if m['name'] == eMatches['name'])
- # If service not given, subscribe to signal match
- if ('service' not in member):
- signal['match'] = eMatch['name']
- params = []
- if ('parameters' in eMatch) and \
- (eMatch['parameters'] is not None):
- for p in eMatch['parameters']:
- params.append(member[str(p)])
- signal['mparams'] = params
-
- if ('parameters' in eMatch['signal']) and \
- (eMatch['signal']['parameters'] is not None):
- eSignal = eMatch['signal']
- else:
- eSignal = next(s for s in events_data['signals']
- if s['name'] == eMatch['signal'])
- signal['signal'] = eSignal['name']
- sparams = {}
- if ('parameters' in eSignal) and \
- (eSignal['parameters'] is not None):
- splist = []
- for p in eSignal['parameters']:
- sp = str(p)
- if (sp != 'type'):
- splist.append(sp)
- if (sp != 'group'):
- sparams[sp] = "\"" + member[sp] + "\""
- else:
- sparams[sp] = "Group{\n"
- for m in group:
- sparams[sp] += (
- "{\n" +
- "\"" + str(m['object']) + "\",\n" +
- "{\"" + str(m['interface']) + "\"," +
- "\"" + str(m['property']) + "\"}\n" +
- "},\n")
- sparams[sp] += "}"
- else:
- sparams[sp] = member[sp]
- sparams['params'] = splist
- signal['sparams'] = sparams
- # Add signal handler
- eHandler = next(h for h in events_data['handlers']
- if h['name'] == eSignal['handler'])
- signal['handler'] = eHandler['name']
- hparams = {}
- if ('parameters' in eHandler) and \
- (eHandler['parameters'] is not None):
- hplist = []
- for p in eHandler['parameters']:
- hp = str(p)
- if (hp != 'type'):
- hplist.append(hp)
- if (hp != 'group'):
- hparams[hp] = "\"" + member[hp] + "\""
- else:
- hparams[hp] = "Group{\n"
- for m in group:
- hparams[hp] += (
- "{\n" +
- "\"" + str(m['object']) + "\",\n" +
- "{\"" + str(m['interface']) + "\"," +
- "\"" + str(m['property']) + "\"}\n" +
- "},\n")
- hparams[hp] += "}"
- else:
- hparams[hp] = member[hp]
- hparams['params'] = hplist
- signal['hparams'] = hparams
- signals.append(signal)
- precond['pcsigs'] = signals
+ # Add precondition event triggers
+ precond['triggers'] = {}
+ for trig in event['precondition']['triggers']:
+ triggers = []
+ if (trig['name'] == "signal"):
+ if ('pcsigs' not in precond['triggers']):
+ precond['triggers']['pcsigs'] = []
+ triggers = getSignal(precond['pcgrps'], trig, events_data)
+ precond['triggers']['pcsigs'].extend(triggers)
# Add optional action call timer
timer = {}
diff --git a/control/templates/fan_zone_defs.mako.cpp b/control/templates/fan_zone_defs.mako.cpp
index e05d1fc..a4ba615 100644
--- a/control/templates/fan_zone_defs.mako.cpp
+++ b/control/templates/fan_zone_defs.mako.cpp
@@ -160,7 +160,7 @@
${event['pc']['pctime']['type']}
},
std::vector<Signal>{
- %for s in event['pc']['pcsigs']:
+ %for s in event['pc']['triggers']['pcsigs']:
Signal{
%if ('match' in s) and \
(s['match'] is not None):