Add support for sensor override value

Write support Value property under xyz.openbmc_project.Sensor.Value
interface is added which will be used to do sensor override.
Sensor can be overridden by setting a value, which will be preserved,
till the service is restarted or Value is overridden again with NaN.

Change-Id: Ia606031a97e532cd12d768e36f1feaa4c7350620
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index 0f441cd..a68c894 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -115,6 +115,10 @@
                 std::getline(responseStream, response);
                 float nvalue = std::stof(response);
                 responseStream.clear();
+                if (!isnan(overriddenValue))
+                {
+                    nvalue = overriddenValue;
+                }
                 if (nvalue != value)
                 {
                     updateValue(nvalue);
@@ -181,7 +185,10 @@
 
 void TachSensor::updateValue(const double &newValue)
 {
+    // Indicate that it is internal set call
+    internalSet = true;
     sensorInterface->set_property("Value", newValue);
+    internalSet = false;
     value = newValue;
     checkThresholds();
 }
@@ -192,7 +199,10 @@
     // todo, get max and min from configuration
     sensorInterface->register_property("MaxValue", maxValue);
     sensorInterface->register_property("MinValue", minValue);
-    sensorInterface->register_property("Value", value);
+    sensorInterface->register_property(
+        "Value", value, [&](const double &newValue, double &oldValue) {
+            return setSensorValue(newValue, oldValue);
+        });
 
     for (auto &threshold : thresholds)
     {