Implement de-glitch for output overvoltage fault

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

Change-Id: I4ab029b24f5afd263ade7eeccca00b34efd99d3e
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index 1598c56..a03eb74 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -393,28 +393,40 @@
 {
     using namespace witherspoon::pmbus;
 
-    // Check for an output overvoltage fault.
-    if ((statusWord & status_word::VOUT_OV_FAULT) &&
-        !outputOVFault)
+    if (outputOVFault < 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 overvoltage fault.
+        if (statusWord & status_word::VOUT_OV_FAULT)
+        {
+            outputOVFault++;
+        }
+        else
+        {
+            if (outputOVFault > 0)
+            {
+                outputOVFault = 0;
+            }
+        }
 
-        using metadata = org::open_power::Witherspoon::Fault::
-                PowerSupplyOutputOvervoltage;
+        if (outputOVFault >= 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<PowerSupplyOutputOvervoltage>(metadata::RAW_STATUS(
-                                                     nv.get().c_str()),
-                                             metadata::CALLOUT_INVENTORY_PATH(
-                                                     inventoryPath.c_str()));
+            using metadata = org::open_power::Witherspoon::Fault::
+                    PowerSupplyOutputOvervoltage;
 
-        faultFound = true;
-        outputOVFault = true;
+            report<PowerSupplyOutputOvervoltage>(
+                    metadata::RAW_STATUS(nv.get().c_str()),
+                    metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+
+            faultFound = true;
+        }
     }
 }
 
@@ -492,7 +504,7 @@
     inputFault = false;
     powerOnFault = 0;
     outputOCFault = 0;
-    outputOVFault = false;
+    outputOVFault = 0;
     fanFault = false;
     temperatureFault = false;
     faultFound = false;
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index 5e7bee7..ba3a511 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -173,9 +173,12 @@
         size_t outputOCFault = 0;
 
         /**
-         * @brief Set to true when the output overvoltage fault is detected
+         * @brief Indicates output overvoltage fault if equal to FAULT_COUNT.
+         *
+         * @details This is incremented when the "VOUT_OV_FAULT" bit in the
+         *          STATUS_WORD command response is on.
          */
-        bool outputOVFault = false;
+        size_t outputOVFault = 0;
 
         /**
          * @brief Set to true when a fan fault or warning condition is detected