Add timer option to run set speed event actions

For groups within set speed events where the property values of the
group may not signal its action to occur, an optional timer may be added
to the event. This timer is configured as a repeating timer on the
interval provided where upon timer expiration, the event's action is
run.

Change-Id: I4cbe8a0ab1b734bfc7828706a6515af7f6d78b52
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 45ca774..a2a49a8 100755
--- a/control/gen-fan-zone-defs.py
+++ b/control/gen-fan-zone-defs.py
@@ -112,6 +112,9 @@
                         %endif
                         %endfor
                         )),
+                        Timer{
+                            ${event['timer']['interval']}
+                        },
                         std::vector<PropertyChange>{
                         %for s in event['signal']:
                             PropertyChange{
@@ -146,6 +149,9 @@
                     %if ('pc' in event) and (event['pc'] is not None):
                     }
                         )),
+                        Timer{
+                            ${event['pc']['pctime']['interval']}
+                        },
                         std::vector<PropertyChange>{
                         %for s in event['pc']['pcsig']:
                             PropertyChange{
@@ -264,6 +270,20 @@
         signal.append(signals)
     precond['pcsig'] = signal
 
+    # Add optional action call timer
+    timer = {}
+    interval = "static_cast<std::chrono::seconds>"
+    if ('timer' in event['precondition']) and \
+       (event['precondition']['timer'] is not None):
+        timer['interval'] = (interval +
+                             "(" +
+                             str(event['precondition']['timer']['interval']) +
+                             ")")
+    else:
+        timer['interval'] = (interval +
+                             "(" + str(0) + ")")
+    precond['pctime'] = timer
+
     return precond
 
 
@@ -350,6 +370,18 @@
                 signal.append(signals)
             event['signal'] = signal
 
+            # Add optional action call timer
+            timer = {}
+            interval = "static_cast<std::chrono::seconds>"
+            if ('timer' in e) and \
+               (e['timer'] is not None):
+                timer['interval'] = (interval +
+                                     "(" + str(e['timer']['interval']) + ")")
+            else:
+                timer['interval'] = (interval +
+                                     "(" + str(0) + ")")
+            event['timer'] = timer
+
             events.append(event)
 
     return events