Fix numeric threshold
There was an issue when sensor value reach threshold set by the user.
Example: given numeric threshold, set as increasing with value of 20.0,
and following sensor updates: 20 -> 30 -> 40, trigger action would not
start, which is clearly a defect, as 30 is crossed.
Testing done:
- numeric threshold now works with example given above.
- UTs were updated and are passing.
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I955876e076f2286efd98d187cae775a7ab2f4e28
diff --git a/src/discrete_threshold.hpp b/src/discrete_threshold.hpp
index 48510de..3b0d101 100644
--- a/src/discrete_threshold.hpp
+++ b/src/discrete_threshold.hpp
@@ -51,17 +51,24 @@
struct ThresholdDetail
{
- std::string sensorName;
- bool dwell;
+ bool dwell = false;
boost::asio::steady_timer timer;
- ThresholdDetail(const std::string& name, bool dwell,
+ ThresholdDetail(const std::string& sensorNameIn,
boost::asio::io_context& ioc) :
- sensorName(name),
- dwell(dwell), timer(ioc)
+ timer(ioc),
+ sensorName(sensorNameIn)
{}
ThresholdDetail(const ThresholdDetail&) = delete;
ThresholdDetail(ThresholdDetail&&) = delete;
+
+ const std::string& getSensorName()
+ {
+ return sensorName;
+ }
+
+ private:
+ std::string sensorName;
};
using SensorDetails =
std::unordered_map<std::shared_ptr<interfaces::Sensor>,