Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "interfaces/report_manager.hpp" |
| 4 | #include "interfaces/trigger_action.hpp" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 5 | #include "types/trigger_types.hpp" |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 6 | |
| 7 | namespace action |
| 8 | { |
| 9 | |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 10 | namespace numeric |
| 11 | { |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 12 | class LogToJournal : public interfaces::TriggerAction |
| 13 | { |
| 14 | public: |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 15 | LogToJournal(::numeric::Type type, double val) : type(type), threshold(val) |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 16 | {} |
| 17 | |
| 18 | void commit(const std::string& id, uint64_t timestamp, |
| 19 | double value) override; |
| 20 | |
| 21 | private: |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 22 | ::numeric::Type type; |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 23 | double threshold; |
| 24 | |
| 25 | const char* getType() const; |
| 26 | }; |
| 27 | |
| 28 | class LogToRedfish : public interfaces::TriggerAction |
| 29 | { |
| 30 | public: |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 31 | LogToRedfish(::numeric::Type type, double val) : type(type), threshold(val) |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 32 | {} |
| 33 | |
| 34 | void commit(const std::string& id, uint64_t timestamp, |
| 35 | double value) override; |
| 36 | |
| 37 | private: |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 38 | ::numeric::Type type; |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 39 | double threshold; |
| 40 | |
| 41 | const char* getMessageId() const; |
| 42 | }; |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 43 | |
| 44 | void 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 Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 48 | const std::vector<std::string>& reportIds); |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 49 | } // namespace numeric |
| 50 | |
| 51 | namespace discrete |
| 52 | { |
| 53 | class LogToJournal : public interfaces::TriggerAction |
| 54 | { |
| 55 | public: |
| 56 | LogToJournal(::discrete::Severity severity) : severity(severity) |
| 57 | {} |
| 58 | |
| 59 | void commit(const std::string& id, uint64_t timestamp, |
| 60 | double value) override; |
| 61 | |
| 62 | private: |
| 63 | ::discrete::Severity severity; |
| 64 | |
| 65 | const char* getSeverity() const; |
| 66 | }; |
| 67 | |
| 68 | class LogToRedfish : public interfaces::TriggerAction |
| 69 | { |
| 70 | public: |
| 71 | LogToRedfish(::discrete::Severity severity) : severity(severity) |
| 72 | {} |
| 73 | |
| 74 | void commit(const std::string& id, uint64_t timestamp, |
| 75 | double value) override; |
| 76 | |
| 77 | private: |
| 78 | ::discrete::Severity severity; |
| 79 | |
| 80 | const char* getMessageId() const; |
| 81 | }; |
| 82 | |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 83 | void fillActions( |
| 84 | std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, |
| 85 | const std::vector<TriggerAction>& ActionsEnum, |
| 86 | ::discrete::Severity severity, interfaces::ReportManager& reportManager, |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 87 | const std::vector<std::string>& reportIds); |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 88 | |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 89 | namespace onChange |
| 90 | { |
| 91 | class LogToJournal : public interfaces::TriggerAction |
| 92 | { |
| 93 | public: |
| 94 | LogToJournal() |
| 95 | {} |
| 96 | |
| 97 | void commit(const std::string& id, uint64_t timestamp, |
| 98 | double value) override; |
| 99 | }; |
| 100 | |
| 101 | class LogToRedfish : public interfaces::TriggerAction |
| 102 | { |
| 103 | public: |
| 104 | LogToRedfish() |
| 105 | {} |
| 106 | |
| 107 | void commit(const std::string& id, uint64_t timestamp, |
| 108 | double value) override; |
| 109 | }; |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 110 | |
| 111 | void fillActions( |
| 112 | std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, |
| 113 | const std::vector<TriggerAction>& ActionsEnum, |
| 114 | interfaces::ReportManager& reportManager, |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 115 | const std::vector<std::string>& reportIds); |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 116 | } // namespace onChange |
| 117 | |
| 118 | } // namespace discrete |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 119 | |
| 120 | class UpdateReport : public interfaces::TriggerAction |
| 121 | { |
| 122 | public: |
| 123 | UpdateReport(interfaces::ReportManager& reportManager, |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 124 | std::vector<std::string> ids) : |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 125 | reportManager(reportManager), |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 126 | reportIds(std::move(ids)) |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 127 | {} |
| 128 | |
| 129 | void commit(const std::string& id, uint64_t timestamp, |
| 130 | double value) override; |
| 131 | |
| 132 | private: |
| 133 | interfaces::ReportManager& reportManager; |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 134 | std::vector<std::string> reportIds; |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 135 | }; |
| 136 | } // namespace action |