Update parser to support optional preconditions

Set speed events are now allowed to have preconditions defined within
the event where those preconditions must be met before the set speed
event is enabled and active. The supported precondition added is against
a list of groups and their properties matching a given value.

The parser generates a precondition with the same layout as a set speed
event where the event is nested as the last parameter to the
precondition function. Having the set speed event as the last input
parameter to precondition functions is required.

Resolves openbmc/openbmc#1835

Change-Id: I7a247e7eb2d6b31ba9a60da1bc321a35edda9b24
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/example/events.yaml b/control/example/events.yaml
index ed62ce6..b2c22cf 100644
--- a/control/example/events.yaml
+++ b/control/example/events.yaml
@@ -32,7 +32,7 @@
 #groups:
 #    - name: zone0_fans
 #      description: Group of fan inventory objects for zone 0
-#      type: inventory
+#      type: /xyz/openbmc_project/inventory
 #      members:
 #          - /system/chassis/motherboard/fan0
 #          - /system/chassis/motherboard/fan1
@@ -40,9 +40,22 @@
 #          - /system/chassis/motherboard/fan3
 #    - name: zone0_ambient
 #      description: Group of ambient temperature sensors for zone 0
-#      type: sensors
+#      type: /xyz/openbmc_project/sensors
 #      members:
 #          - /temperature/ambient
+#    - name: occ0_object
+#      description: Dbus object containing OCC0 properties
+#      type: /org/open_power/control
+#      members:
+#          - /occ0
+#
+#preconditions:
+#    - name: property_states_match
+#      description: >
+#          All defined properties must match the values given to
+#          enable a set speed event otherwise fan speeds are set to full
+#      parameters:
+#          - groups
 #
 #actions:
 #    - name: count_state_before_speed
@@ -88,10 +101,10 @@
 #          name: set_floor_from_average_sensor_value
 #          map:
 #              value:
-#                  - 25: 3500
-#                  - 30: 4600
-#                  - 35: 5200
-#                  - 40: 5800
+#                  - 25000: 3500
+#                  - 30000: 4600
+#                  - 35000: 5200
+#                  - 40000: 5800
 #              type: std::map<int64_t, uint64_t>
 #    - name: update_water_cooled_floor_speed_based_on_ambient
 #      zone_conditions:
@@ -107,8 +120,37 @@
 #          name: set_floor_from_average_sensor_value
 #          map:
 #              value:
-#                  - 25: 2500
-#                  - 30: 3600
-#                  - 35: 4200
-#                  - 40: 4800
+#                  - 25000: 2500
+#                  - 30000: 3600
+#                  - 35000: 4200
+#                  - 40000: 4800
+#              type: std::map<int64_t, uint64_t>
+#    - name: update_ceiling_speed_based_on_ambient
+#      zone_conditions:
+#          - name: air_cooled_chassis
+#            zones:
+#                - 0
+#          - name: water_and_air_cooled_chassis
+#            zones:
+#                - 0
+#      precondition:
+#          name: property_states_match
+#          groups:
+#              - name: occ0_object
+#                interface: org.open_power.OCC.Status
+#                property:
+#                    name: OccActive
+#                    type: bool
+#                    value: true
+#      group: zone0_ambient
+#      interface: xyz.openbmc_project.Sensor.Value
+#      property:
+#          name: Value
+#          type: int64_t
+#      action:
+#          name: set_ceiling_from_average_sensor_value
+#          map:
+#              value:
+#                  - 25000: 7200
+#                  - 27000: 10500
 #              type: std::map<int64_t, uint64_t>