blob: cca4bb9da763d6c3bbbe38dc3b35145ffd982168 [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;
25
26 const char* getType() const;
27};
28
29class LogToRedfish : public interfaces::TriggerAction
30{
31 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010032 LogToRedfish(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010033 {}
34
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010035 void commit(const std::string& id, Milliseconds timestamp,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010036 double value) override;
37
38 private:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010039 ::numeric::Type type;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010040 double threshold;
41
42 const char* getMessageId() const;
43};
Szymon Dompke20013012021-07-23 09:54:20 +020044
45void fillActions(
46 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
47 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010048 double thresholdValue, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +010049 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010050} // namespace numeric
51
52namespace discrete
53{
54class LogToJournal : public interfaces::TriggerAction
55{
56 public:
Krzysztof Grobelnyfbeb5bf2022-01-03 09:41:29 +010057 explicit LogToJournal(::discrete::Severity severity) : severity(severity)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010058 {}
59
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010060 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010061 double value) override;
62
63 private:
64 ::discrete::Severity severity;
65
66 const char* getSeverity() const;
67};
68
69class LogToRedfish : public interfaces::TriggerAction
70{
71 public:
Krzysztof Grobelnyfbeb5bf2022-01-03 09:41:29 +010072 explicit LogToRedfish(::discrete::Severity severity) : severity(severity)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010073 {}
74
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010075 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010076 double value) override;
77
78 private:
79 ::discrete::Severity severity;
80
81 const char* getMessageId() const;
82};
83
Szymon Dompke20013012021-07-23 09:54:20 +020084void fillActions(
85 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
86 const std::vector<TriggerAction>& ActionsEnum,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010087 ::discrete::Severity severity, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +010088 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompke20013012021-07-23 09:54:20 +020089
Szymon Dompkef763c9e2021-03-12 09:19:22 +010090namespace onChange
91{
92class LogToJournal : public interfaces::TriggerAction
93{
94 public:
95 LogToJournal()
96 {}
97
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010098 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010099 double value) override;
100};
101
102class LogToRedfish : public interfaces::TriggerAction
103{
104 public:
105 LogToRedfish()
106 {}
107
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100108 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100109 double value) override;
110};
Szymon Dompke20013012021-07-23 09:54:20 +0200111
112void fillActions(
113 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100114 const std::vector<TriggerAction>& ActionsEnum, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +0100115 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100116} // namespace onChange
117
118} // namespace discrete
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100119
120class UpdateReport : public interfaces::TriggerAction
121{
122 public:
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100123 UpdateReport(boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +0100124 std::shared_ptr<std::vector<std::string>> ids) :
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100125 ioc(ioc),
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +0100126 reportIds(std::move(ids))
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100127 {}
128
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100129 void commit(const std::string& id, Milliseconds timestamp,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100130 double value) override;
131
132 private:
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100133 boost::asio::io_context& ioc;
Szymon Dompke94f71c52021-12-10 07:16:33 +0100134 std::shared_ptr<std::vector<std::string>> reportIds;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100135};
136} // namespace action