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