Update parser for properties on zone objects

Create a service attribute that can be optionally defined on a group
denoting what service is hosting the group members. Initially, defining
a service name generates the group member(s) to be zone objects only.

This service attribute will be enhanced to specifically note what
service provides the group members and allow for a better trigger for
properties on zone objects instead of generating a blank signal match.

Tested:
    Blank signal match generated for group members in events used

Change-Id: I483fcf6a5e210e5d70bc9d5c4c0dee15524b01b9
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 e83512a..fdbdab8 100755
--- a/control/gen-fan-zone-defs.py
+++ b/control/gen-fan-zone-defs.py
@@ -130,6 +130,10 @@
             member['interface'] = eGroups['interface']
             member['property'] = eGroups['property']['name']
             member['type'] = eGroups['property']['type']
+            # Use defined service to note member on zone object
+            if ('service' in eGroup) and \
+               (eGroup['service'] is not None):
+                member['service'] = eGroup['service']
             # Add expected group member's property value if given
             if ('value' in eGroups['property']) and \
                (eGroups['property']['value'] is not None):
@@ -266,13 +270,16 @@
                 signal = {}
                 eMatch = next(m for m in events_data['matches']
                               if m['name'] == eMatches['name'])
-                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 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']
@@ -418,13 +425,16 @@
                 signal = {}
                 eMatch = next(m for m in events_data['matches']
                               if m['name'] == eMatches['name'])
-                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 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']
diff --git a/control/templates/defs.mako b/control/templates/defs.mako
index 2fd3856..bcc0c5b 100644
--- a/control/templates/defs.mako
+++ b/control/templates/defs.mako
@@ -65,6 +65,8 @@
 std::vector<Signal>{
 %for s in event['signals']:
     Signal{
+        %if ('match' in s) and \
+            (s['match'] is not None):
         match::${s['match']}(
         %for i, mp in enumerate(s['mparams']):
         %if (i+1) != len(s['mparams']):
@@ -74,6 +76,9 @@
         %endif
         %endfor
         ),
+        %else:
+        "",
+        %endif
         make_handler(\
         ${indent(genHandler(sig=s), 3)}\
         )
diff --git a/control/templates/fan_zone_defs.mako.cpp b/control/templates/fan_zone_defs.mako.cpp
index fdf5bb2..a73449f 100644
--- a/control/templates/fan_zone_defs.mako.cpp
+++ b/control/templates/fan_zone_defs.mako.cpp
@@ -127,6 +127,8 @@
                         std::vector<Signal>{
                         %for s in event['pc']['pcsigs']:
                             Signal{
+                                %if ('match' in s) and \
+                                    (s['match'] is not None):
                                 match::${s['match']}(
                                 %for i, mp in enumerate(s['mparams']):
                                 %if (i+1) != len(s['mparams']):
@@ -136,6 +138,9 @@
                                 %endif
                                 %endfor
                                 ),
+                                %else:
+                                "",
+                                %endif
                                 make_handler(\
                                 ${indent(genHandler(sig=s), 9)}\
                                 )