Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 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" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 7 | #include "types/trigger_types.hpp" |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 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( |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame^] | 22 | Sensors sensors, |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 23 | std::vector<std::unique_ptr<interfaces::TriggerAction>> actions); |
| 24 | ~OnChangeThreshold() |
| 25 | {} |
| 26 | |
| 27 | void initialize() override; |
Krzysztof Grobelny | 51f0fd5 | 2021-12-28 16:32:08 +0100 | [diff] [blame] | 28 | void sensorUpdated(interfaces::Sensor&, Milliseconds) override; |
| 29 | void sensorUpdated(interfaces::Sensor&, Milliseconds, double) override; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame^] | 30 | LabeledThresholdParam getThresholdParam() const override; |
| 31 | void updateSensors(Sensors newSensors) override; |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 32 | |
| 33 | private: |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame^] | 34 | Sensors sensors; |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 35 | const std::vector<std::unique_ptr<interfaces::TriggerAction>> actions; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame^] | 36 | bool initialized = false; |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 37 | |
Krzysztof Grobelny | 51f0fd5 | 2021-12-28 16:32:08 +0100 | [diff] [blame] | 38 | void commit(const std::string&, Milliseconds, double); |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 39 | }; |