1 #pragma once 2 3 #include "interfaces/sensor.hpp" 4 #include "interfaces/sensor_listener.hpp" 5 #include "interfaces/threshold.hpp" 6 #include "interfaces/trigger_action.hpp" 7 #include "types/trigger_types.hpp" 8 9 #include <boost/asio/steady_timer.hpp> 10 11 #include <chrono> 12 #include <memory> 13 #include <vector> 14 15 class OnChangeThreshold : 16 public interfaces::Threshold, 17 public interfaces::SensorListener, 18 public std::enable_shared_from_this<OnChangeThreshold> 19 { 20 public: 21 OnChangeThreshold( 22 Sensors sensors, std::vector<std::string> sensorNames, 23 std::vector<std::unique_ptr<interfaces::TriggerAction>> actions); 24 ~OnChangeThreshold() 25 {} 26 27 void initialize() override; 28 void sensorUpdated(interfaces::Sensor&, Milliseconds) override; 29 void sensorUpdated(interfaces::Sensor&, Milliseconds, double) override; 30 31 private: 32 const Sensors sensors; 33 const std::vector<std::string> sensorNames; 34 const std::vector<std::unique_ptr<interfaces::TriggerAction>> actions; 35 36 void commit(const std::string&, Milliseconds, double); 37 }; 38