1 #pragma once 2 3 #include "interfaces/report_manager.hpp" 4 #include "interfaces/trigger_action.hpp" 5 #include "types/trigger_types.hpp" 6 7 namespace action 8 { 9 10 namespace numeric 11 { 12 class LogToJournal : public interfaces::TriggerAction 13 { 14 public: 15 LogToJournal(::numeric::Type type, double val) : type(type), threshold(val) 16 {} 17 18 void commit(const std::string& id, Milliseconds timestamp, 19 double value) override; 20 21 private: 22 ::numeric::Type type; 23 double threshold; 24 25 const char* getType() const; 26 }; 27 28 class LogToRedfish : public interfaces::TriggerAction 29 { 30 public: 31 LogToRedfish(::numeric::Type type, double val) : type(type), threshold(val) 32 {} 33 34 void commit(const std::string& id, Milliseconds timestamp, 35 double value) override; 36 37 private: 38 ::numeric::Type type; 39 double threshold; 40 41 const char* getMessageId() const; 42 }; 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, 48 const std::shared_ptr<std::vector<std::string>>& reportIds); 49 } // namespace numeric 50 51 namespace discrete 52 { 53 class LogToJournal : public interfaces::TriggerAction 54 { 55 public: 56 explicit LogToJournal(::discrete::Severity severity) : severity(severity) 57 {} 58 59 void commit(const std::string& id, Milliseconds 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 explicit LogToRedfish(::discrete::Severity severity) : severity(severity) 72 {} 73 74 void commit(const std::string& id, Milliseconds timestamp, 75 double value) override; 76 77 private: 78 ::discrete::Severity severity; 79 80 const char* getMessageId() const; 81 }; 82 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, 87 const std::shared_ptr<std::vector<std::string>>& reportIds); 88 89 namespace onChange 90 { 91 class LogToJournal : public interfaces::TriggerAction 92 { 93 public: 94 LogToJournal() 95 {} 96 97 void commit(const std::string& id, Milliseconds 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, Milliseconds timestamp, 108 double value) override; 109 }; 110 111 void fillActions( 112 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 113 const std::vector<TriggerAction>& ActionsEnum, 114 interfaces::ReportManager& reportManager, 115 const std::shared_ptr<std::vector<std::string>>& reportIds); 116 } // namespace onChange 117 118 } // namespace discrete 119 120 class UpdateReport : public interfaces::TriggerAction 121 { 122 public: 123 UpdateReport(interfaces::ReportManager& reportManager, 124 std::shared_ptr<std::vector<std::string>> ids) : 125 reportManager(reportManager), 126 reportIds(std::move(ids)) 127 {} 128 129 void commit(const std::string& id, Milliseconds timestamp, 130 double value) override; 131 132 private: 133 interfaces::ReportManager& reportManager; 134 std::shared_ptr<std::vector<std::string>> reportIds; 135 }; 136 } // namespace action 137