Standardize read errors

Each sensor handled read errors their own way,
making it inconsistant. This helps to align them all
in the base class, so that error handling happens the
same for each sensor. It also aligns the power state
change handling.

Tested: Tested DC Cycling and Enabling/Disabling ME to
make sure functional change correctly

Change-Id: I1a191d27629602e1ca3871d933af07b15bf9f331
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index 4d6bc1d..577f3e4 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -47,7 +47,7 @@
     Sensor(boost::replace_all_copy(sensorName, " ", "_"),
            std::move(_thresholds), sensorConfiguration, objectType, max, min),
     std::enable_shared_from_this<PSUSensor>(), objServer(objectServer),
-    inputDev(io), waitTimer(io), path(path), errCount(0), sensorFactor(factor)
+    inputDev(io), waitTimer(io), path(path), sensorFactor(factor)
 {
     if constexpr (DEBUG)
     {
@@ -147,28 +147,17 @@
             nvalue /= sensorFactor;
 
             updateValue(nvalue);
-            errCount = 0;
         }
         catch (const std::invalid_argument&)
         {
             std::cerr << "Could not parse " << response << "\n";
-            errCount++;
+            incrementError();
         }
     }
     else
     {
         std::cerr << "System error " << err << "\n";
-        errCount++;
-    }
-
-    if (errCount >= warnAfterErrorCount)
-    {
-        if (errCount == warnAfterErrorCount)
-        {
-            std::cerr << "Failure to read sensor " << name << "\n";
-        }
-        updateValue(0);
-        errCount++;
+        incrementError();
     }
 
     lseek(fd, 0, SEEK_SET);