blob: 6a5f7c23da9c20c41c8540a1eb5296189febfba4 [file] [log] [blame]
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01001#pragma once
2
3#include "interfaces/report_manager.hpp"
4#include "interfaces/trigger_action.hpp"
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00005#include "types/trigger_types.hpp"
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01006
7namespace action
8{
9
Szymon Dompkef763c9e2021-03-12 09:19:22 +010010namespace numeric
11{
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010012class LogToJournal : public interfaces::TriggerAction
13{
14 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010015 LogToJournal(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010016 {}
17
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010018 void commit(const std::string& id, Milliseconds timestamp,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010019 double value) override;
20
21 private:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010022 ::numeric::Type type;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010023 double threshold;
24
25 const char* getType() const;
26};
27
28class LogToRedfish : public interfaces::TriggerAction
29{
30 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010031 LogToRedfish(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010032 {}
33
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010034 void commit(const std::string& id, Milliseconds timestamp,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010035 double value) override;
36
37 private:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010038 ::numeric::Type type;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010039 double threshold;
40
41 const char* getMessageId() const;
42};
Szymon Dompke20013012021-07-23 09:54:20 +020043
44void fillActions(
45 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
46 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type,
47 double thresholdValue, interfaces::ReportManager& reportManager,
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010048 const std::vector<std::string>& reportIds);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010049} // namespace numeric
50
51namespace discrete
52{
53class LogToJournal : public interfaces::TriggerAction
54{
55 public:
Krzysztof Grobelnyfbeb5bf2022-01-03 09:41:29 +010056 explicit LogToJournal(::discrete::Severity severity) : severity(severity)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010057 {}
58
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010059 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010060 double value) override;
61
62 private:
63 ::discrete::Severity severity;
64
65 const char* getSeverity() const;
66};
67
68class LogToRedfish : public interfaces::TriggerAction
69{
70 public:
Krzysztof Grobelnyfbeb5bf2022-01-03 09:41:29 +010071 explicit LogToRedfish(::discrete::Severity severity) : severity(severity)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010072 {}
73
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010074 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010075 double value) override;
76
77 private:
78 ::discrete::Severity severity;
79
80 const char* getMessageId() const;
81};
82
Szymon Dompke20013012021-07-23 09:54:20 +020083void fillActions(
84 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
85 const std::vector<TriggerAction>& ActionsEnum,
86 ::discrete::Severity severity, interfaces::ReportManager& reportManager,
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010087 const std::vector<std::string>& reportIds);
Szymon Dompke20013012021-07-23 09:54:20 +020088
Szymon Dompkef763c9e2021-03-12 09:19:22 +010089namespace onChange
90{
91class LogToJournal : public interfaces::TriggerAction
92{
93 public:
94 LogToJournal()
95 {}
96
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010097 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +010098 double value) override;
99};
100
101class LogToRedfish : public interfaces::TriggerAction
102{
103 public:
104 LogToRedfish()
105 {}
106
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100107 void commit(const std::string& id, Milliseconds timestamp,
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100108 double value) override;
109};
Szymon Dompke20013012021-07-23 09:54:20 +0200110
111void fillActions(
112 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
113 const std::vector<TriggerAction>& ActionsEnum,
114 interfaces::ReportManager& reportManager,
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +0100115 const 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:
123 UpdateReport(interfaces::ReportManager& reportManager,
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +0100124 std::vector<std::string> ids) :
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100125 reportManager(reportManager),
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:
133 interfaces::ReportManager& reportManager;
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +0100134 std::vector<std::string> reportIds;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100135};
136} // namespace action