Consider nan too as an override value

Sensors can be overridden for testing purpose. Start treating
nan too as an override value. With this commit, the only way
to reset the override is to restart the service / BMC F/W.

Unit-test:
1. Verified that overriden value is taken effect by setting the value
property
2. Tried setting nan to the value property and verified it's still
in overriden state.

Change-Id: I6a931377bdaf918e37057275e1dde93f0fd5aa22
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/include/sensor.hpp b/include/sensor.hpp
index f333e6a..73e44d2 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -29,6 +29,7 @@
     std::shared_ptr<sdbusplus::asio::dbus_interface> thresholdInterfaceCritical;
     double value = std::numeric_limits<double>::quiet_NaN();
     double overriddenValue = std::numeric_limits<double>::quiet_NaN();
+    bool overridenState = false;
     bool internalSet = false;
 
     int setSensorValue(const double &newValue, double &oldValue)
@@ -40,6 +41,7 @@
             return 1;
         }
         overriddenValue = newValue;
+        overridenState = true;
         return 1;
     }
 
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 63cc5dd..4a61655 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -107,7 +107,7 @@
             nvalue = (nvalue / sensorScaleFactor) / scaleFactor;
             nvalue = std::round(nvalue * roundFactor) / roundFactor;
 
-            if (!isnan(overriddenValue))
+            if (overridenState)
             {
                 nvalue = overriddenValue;
             }
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index aebaa4c..d54263a 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -99,7 +99,7 @@
             float nvalue = std::stof(response);
             responseStream.clear();
             nvalue /= CPUSensor::sensorScaleFactor;
-            if (!isnan(overriddenValue))
+            if (overridenState)
             {
                 nvalue = overriddenValue;
             }
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 8966957..7d443ad 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -99,7 +99,7 @@
         {
             float nvalue = std::stof(response);
             nvalue /= sensorScaleFactor;
-            if (!isnan(overriddenValue))
+            if (overridenState)
             {
                 nvalue = overriddenValue;
             }
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index 70d7d4c..b42062c 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -114,7 +114,7 @@
                 std::getline(responseStream, response);
                 float nvalue = std::stof(response);
                 responseStream.clear();
-                if (!isnan(overriddenValue))
+                if (overridenState)
                 {
                     nvalue = overriddenValue;
                 }