dbus-sensors updateValue update hysteresis logic question

James Feist james.feist at linux.intel.com
Thu Feb 27 04:46:38 AEDT 2020


On 2/26/20 9:34 AM, Andrew Macrae wrote:
>     On 2/25/20 5:26 PM, Josh Lehan wrote:
>     > Hi there! Question about updateValue(), in sensor.hpp file, in
>     > dbus-sensors package.
>     >
>     > In updateValue(), it always calls set_property() to update the stored
>     > value to the new passed-in value, sending the new value on D-Bus.
>     > However, it then tests the hysteresis variable, to avoid a very small
>     > change. It only updates the stored value if the change is significant
>     > enough. This logic in updateValue() seems strange to me. Wouldn't you
>     > want to either do both of these operations at once, or none of them at all?
> 
>     This is to not trip thresholds if the change is small, so you don't jump
>     back and forth over thresholds. We still update the value on d-bus for
>     anyone reading the value to have the most recent value.
> 
> 
> If this is just for threshold comparison, would it make more sense to 
> use a more typical method of applying hysteresis?
> To simplify the code could we implement something with no hidden state, 
> and only one bit of state like a schmitt trigger?
> 
> For clarification, could we say the threshold is violated when the value 
> rises above it, but the violation is only 
> resolved/cleared/no-longer-violated when the readings have fallen by an 
> additional hysteresis value below the threshold?
> 
> static bool overThreshold;
> overThreshold = (reading>__threshold-overThreshold*__thresholdHysteresis)
> 
> by making the state observable we make it much easier to understand, 
> test and cover all the behavior.

Sure, I see no problems with that.


More information about the openbmc mailing list