Implement de-glitch for output overcurrent fault

If three consecutive reads in a row, one second apart, show the fault
on, create and log an error.

Change-Id: I0a51241ac00514c50fac49c050cf5bf086ca9ab4
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index 931a3e0..1598c56 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -352,28 +352,40 @@
 {
     using namespace witherspoon::pmbus;
 
-    // Check for an output overcurrent fault.
-    if ((statusWord & status_word::IOUT_OC_FAULT) &&
-        !outputOCFault)
+    if (outputOCFault < FAULT_COUNT)
     {
-        util::NamesValues nv;
-        nv.add("STATUS_WORD", statusWord);
-        captureCmd(nv, STATUS_INPUT, Type::Debug);
-        auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
-        captureCmd(nv, status0Vout, Type::Debug);
-        captureCmd(nv, STATUS_IOUT, Type::Debug);
-        captureCmd(nv, STATUS_MFR, Type::Debug);
+        // Check for an output overcurrent fault.
+        if ((statusWord & status_word::IOUT_OC_FAULT))
+        {
+            outputOCFault++;
+        }
+        else
+        {
+            if (outputOCFault > 0)
+            {
+                outputOCFault = 0;
+            }
+        }
 
-        using metadata = org::open_power::Witherspoon::Fault::
-                PowerSupplyOutputOvercurrent;
+        if (outputOCFault >= FAULT_COUNT)
+        {
+            util::NamesValues nv;
+            nv.add("STATUS_WORD", statusWord);
+            captureCmd(nv, STATUS_INPUT, Type::Debug);
+            auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
+            captureCmd(nv, status0Vout, Type::Debug);
+            captureCmd(nv, STATUS_IOUT, Type::Debug);
+            captureCmd(nv, STATUS_MFR, Type::Debug);
 
-        report<PowerSupplyOutputOvercurrent>(metadata::RAW_STATUS(
-                                                     nv.get().c_str()),
-                                             metadata::CALLOUT_INVENTORY_PATH(
-                                                     inventoryPath.c_str()));
+            using metadata = org::open_power::Witherspoon::Fault::
+                    PowerSupplyOutputOvercurrent;
 
-        faultFound = true;
-        outputOCFault = true;
+            report<PowerSupplyOutputOvercurrent>(
+                    metadata::RAW_STATUS(nv.get().c_str()),
+                    metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+
+            faultFound = true;
+        }
     }
 }
 
@@ -479,7 +491,7 @@
     readFailLogged = false;
     inputFault = false;
     powerOnFault = 0;
-    outputOCFault = false;
+    outputOCFault = 0;
     outputOVFault = false;
     fanFault = false;
     temperatureFault = false;
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index eefefff..5e7bee7 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -165,12 +165,12 @@
         bool inputFault = false;
 
         /**
-         * @brief Set to true when an output over current fault is detected
+         * @brief Indicates output over current fault if equal to FAULT_COUNT
          *
-         * This is the "IOUT_OC_FAULT" bit in the low byte from the STATUS_WORD
-         * command response.
+         * @details This is incremented when the "IOUT_OC_FAULT" bit in the low
+         *          byte from the STATUS_WORD command response is on.
          */
-        bool outputOCFault = false;
+        size_t outputOCFault = 0;
 
         /**
          * @brief Set to true when the output overvoltage fault is detected