add clamping of min/max
Ensure that the value of the sensor is clamped to be within the
limits imposed by the min/max of the sensor. Presently, these
limits may be defaulted by the object definition (to +/- infinity)
or set via config.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iceaea40daaba1324fd76122843b5520acb4a7726
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index 29e71eb..0d76fcf 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -247,6 +247,7 @@
void VirtualSensor::setSensorValue(double value)
{
+ value = std::clamp(value, ValueIface::minValue(), ValueIface::maxValue());
ValueIface::value(value);
}