Make IpmbSensor properly clear sensor value on PowerOff
Previously when platform was put in Off state, IpmbSensor stopped
polling ON-only sensors, which is fine.
However, it didn't clear sensor value and availability state (which is normally done
by updateValue() for such cases.
This commit introduces following changes:
- updateValue() in invalid power state sets sensor to 'nan'
- modified IpmbSensor to use the same logic as updateValue()
in optimized (skip reading in invalid state) flow
Testing:
- put platform in shutdown state - sensor Value is set to 'nan',
Available is 'false', Functional still 'true'
- after restarting platform - values and flags goes back to normal
Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
Change-Id: Ib413000560820d430fe726740c0e9ae5ca062f12
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 982365a..973362b 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -278,13 +278,11 @@
if (!readingStateGood())
{
markAvailable(false);
+ updateValueProperty(std::numeric_limits<double>::quiet_NaN());
return;
}
- // Indicate that it is internal set call
- internalSet = true;
- updateProperty(sensorInterface, value, newValue, "Value");
- internalSet = false;
+ updateValueProperty(newValue);
// Always check thresholds after changing the value,
// as the test against hysteresisTrigger now takes place in
@@ -327,4 +325,13 @@
}
return false;
}
+
+ private:
+ void updateValueProperty(const double& newValue)
+ {
+ // Indicate that it is internal set call, not an external overwrite
+ internalSet = true;
+ updateProperty(sensorInterface, value, newValue, "Value");
+ internalSet = false;
+ }
};