blob: 0d0f8419ffb15b240a7a480071a2e8f01ff07260 [file] [log] [blame]
Szymon Dompkef763c9e2021-03-12 09:19:22 +01001#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 "interfaces/trigger_types.hpp"
8
9#include <boost/asio/steady_timer.hpp>
10
11#include <chrono>
12#include <memory>
13#include <vector>
14
15class OnChangeThreshold :
16 public interfaces::Threshold,
17 public interfaces::SensorListener,
18 public std::enable_shared_from_this<OnChangeThreshold>
19{
20 public:
21 OnChangeThreshold(
22 std::vector<std::shared_ptr<interfaces::Sensor>> sensors,
23 std::vector<std::string> sensorNames,
24 std::vector<std::unique_ptr<interfaces::TriggerAction>> actions);
25 ~OnChangeThreshold()
26 {}
27
28 void initialize() override;
29 void sensorUpdated(interfaces::Sensor&, uint64_t) override;
30 void sensorUpdated(interfaces::Sensor&, uint64_t, double) override;
31
32 private:
33 const std::vector<std::shared_ptr<interfaces::Sensor>> sensors;
34 const std::vector<std::string> sensorNames;
35 const std::vector<std::unique_ptr<interfaces::TriggerAction>> actions;
36
37 void commit(const std::string&, uint64_t, double);
38};