blob: fdf07fe8c7390dee67095594a59b6e510f59fa77 [file] [log] [blame]
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01001#pragma once
2
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01003#include "interfaces/trigger_action.hpp"
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00004#include "types/trigger_types.hpp"
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01005
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +01006#include <boost/asio/io_context.hpp>
7
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01008namespace action
9{
10
Szymon Dompkef763c9e2021-03-12 09:19:22 +010011namespace numeric
12{
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010013class LogToJournal : public interfaces::TriggerAction
14{
15 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010016 LogToJournal(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010017 {}
18
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010019 void commit(const std::string& id, Milliseconds timestamp,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010020 double value) override;
21
22 private:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010023 ::numeric::Type type;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010024 double threshold;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010025};
26
27class LogToRedfish : public interfaces::TriggerAction
28{
29 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010030 LogToRedfish(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010031 {}
32
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010033 void commit(const std::string& id, Milliseconds timestamp,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010034 double value) override;
35
36 private:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010037 ::numeric::Type type;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010038 double threshold;
39
40 const char* getMessageId() const;
41};
Szymon Dompke20013012021-07-23 09:54:20 +020042
43void fillActions(
44 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
45 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010046 double thresholdValue, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +010047 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010048} // namespace numeric
49
50namespace discrete
51{
52class LogToJournal : public interfaces::TriggerAction
53{
54 public:
Krzysztof Grobelnyfbeb5bf2022-01-03 09:41:29 +010055 explicit LogToJournal(::discrete::Severity severity) : severity(severity)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010056 {}
57
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010058 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010059 double value) override;
60
61 private:
62 ::discrete::Severity severity;
Szymon Dompkef763c9e2021-03-12 09:19:22 +010063};
64
65class LogToRedfish : public interfaces::TriggerAction
66{
67 public:
Krzysztof Grobelnyfbeb5bf2022-01-03 09:41:29 +010068 explicit LogToRedfish(::discrete::Severity severity) : severity(severity)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010069 {}
70
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010071 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010072 double value) override;
73
74 private:
75 ::discrete::Severity severity;
76
77 const char* getMessageId() const;
78};
79
Szymon Dompke20013012021-07-23 09:54:20 +020080void fillActions(
81 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
82 const std::vector<TriggerAction>& ActionsEnum,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010083 ::discrete::Severity severity, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +010084 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompke20013012021-07-23 09:54:20 +020085
Szymon Dompkef763c9e2021-03-12 09:19:22 +010086namespace onChange
87{
88class LogToJournal : public interfaces::TriggerAction
89{
90 public:
91 LogToJournal()
92 {}
93
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010094 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010095 double value) override;
96};
97
98class LogToRedfish : public interfaces::TriggerAction
99{
100 public:
101 LogToRedfish()
102 {}
103
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100104 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100105 double value) override;
106};
Szymon Dompke20013012021-07-23 09:54:20 +0200107
108void fillActions(
109 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100110 const std::vector<TriggerAction>& ActionsEnum, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +0100111 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100112} // namespace onChange
113
114} // namespace discrete
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100115
116class UpdateReport : public interfaces::TriggerAction
117{
118 public:
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100119 UpdateReport(boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +0100120 std::shared_ptr<std::vector<std::string>> ids) :
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100121 ioc(ioc),
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +0100122 reportIds(std::move(ids))
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100123 {}
124
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100125 void commit(const std::string& id, Milliseconds timestamp,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100126 double value) override;
127
128 private:
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100129 boost::asio::io_context& ioc;
Szymon Dompke94f71c52021-12-10 07:16:33 +0100130 std::shared_ptr<std::vector<std::string>> reportIds;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100131};
132} // namespace action