monitor: Add up/down count fault detection

Create an up/down count fault determination algorithm that
could be used in place of the current timer based outOfRange()
function.
The up/down count is a different method for determining when
a fan is faulted by counting up each iteration a rotor is
out of spec and removing those counts when the rotor
returns within spec.

Tested:
    1. Remove a fan and run Mihawk, the counter add 1 when sensor
       is out of spec, and replaced the fan back before hit the
       threshold, the counter decrement back to 0.
    2. Remove a fan, counter add 1 and mark the removed fan as
       nonfunctional when counter reaches the threshold, and
       Replaced the fan back, counter will decrement back to 0
       and fan back to functional.

Change-Id: I632dd2c7553b007beb7ae6bb694a590d2cfc2a1c
Signed-off-by: Jolie Ku <jolie_ku@wistron.com>
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/example/monitor.yaml b/monitor/example/monitor.yaml
index 59be7e6..8d70c4f 100644
--- a/monitor/example/monitor.yaml
+++ b/monitor/example/monitor.yaml
@@ -7,10 +7,14 @@
 #fans:
 # - inventory:
 #    [The system inventory location for the fan]
+#  method: [timebased|count](optional)
+#    [Available methods:
+#     * timebased - use a percentage based deviation
+#     * count - run up/down count fault detection]
 #  functional_delay:
 #    [Delay (in secs) before a fan is marked functional after returning
 #     within the allowed deviation]
-#  allowed_out_of_range_time:
+#  allowed_out_of_range_time: (required for method timebased)
 #    [Time (in secs) actual speed can be outside of deviation of
 #     target speed]
 #  deviation:
@@ -88,3 +92,24 @@
 #      - name: fan0_0
 #        in_trust: false
 #      - name: fan0_1
+
+#Example entries for count method fan system:
+#fans:
+#  - inventory: /system/chassis/motherboard/fan2
+#    method: count
+#    functional_delay: 5
+#    deviation: 15
+#    num_sensors_nonfunc_for_fan_nonfunc: 1
+#    sensors:
+#      - name: fan2
+#        has_target: true
+#    # Only create fan functional properties and monitor on air cooled
+#    condition:
+#      name: propertiesMatch
+#      properties:
+#        - object: /xyz/openbmc_project/inventory/system/chassis
+#          interface: xyz.openbmc_project.Inventory.Decorator.CoolingType
+#          property:
+#            name: WaterCooled
+#            type: bool
+#            value: false