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