Fix: Move overriding logic to base sensor class

Instead of having the overridden value check inside each
sensor type, move the same to sensor base class, so that
any future addition of new sensor model, will be able to
inherit this feature automatically

Tested:
1. Verified the behaviour of overriden value by setting
the Value property.
2. restarting the sensor initializes the value back correctly

Change-Id: Iddf280cafcf6d9299e1edc13b942683bf60ea89b
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index 22c03ab..4bf7fdc 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -54,6 +54,7 @@
     // indicate that it is internal set call
     mInternalSet = true;
     mIface->set_property("Status", newValue);
+    mInternalSet = false;
 
     mValue = newValue;
 
@@ -147,12 +148,6 @@
             int statusValue = i2cReadFromPch(mBusId, mSlaveAddr);
             std::string newValue = statusValue ? "HardwareIntrusion" : "Normal";
 
-            // save value
-            if (mOverridenState)
-            {
-                newValue = mOverriddenValue;
-            }
-
             if (newValue != "unknown" && mValue != newValue)
             {
                 std::cout << "update value from " << mValue << " to "
@@ -200,12 +195,6 @@
             std::cout << "Intrusion sensor value is " << newValue << "\n";
         }
 
-        // save value
-        if (mOverridenState)
-        {
-            newValue = mOverriddenValue;
-        }
-
         if (newValue != "unknown" && mValue != newValue)
         {
             std::cout << "update value from " << mValue << " to " << newValue
@@ -251,16 +240,15 @@
 int ChassisIntrusionSensor::setSensorValue(const std::string& req,
                                            std::string& propertyValue)
 {
-    if (mInternalSet)
+    if (!mInternalSet)
     {
-        mInternalSet = false;
         propertyValue = req;
-    }
-    else
-    {
-        mOverriddenValue = req;
         mOverridenState = true;
     }
+    else if (!mOverridenState)
+    {
+        propertyValue = req;
+    }
     return 1;
 }