1 #pragma once 2 3 #include "interfaces/trigger_action.hpp" 4 #include "types/trigger_types.hpp" 5 6 #include <boost/asio/io_context.hpp> 7 8 namespace action 9 { 10 11 namespace redfish_message_ids 12 { 13 constexpr const char* TriggerNumericWarning = 14 "OpenBMC.0.1.TriggerNumericWarning"; 15 constexpr const char* TriggerNumericCritical = 16 "OpenBMC.0.1.TriggerNumericCritical"; 17 constexpr const char* TriggerDiscreteOK = "OpenBMC.0.1.TriggerDiscreteOK"; 18 constexpr const char* TriggerDiscreteWarning = 19 "OpenBMC.0.1.TriggerDiscreteWarning"; 20 constexpr const char* TriggerDiscreteCritical = 21 "OpenBMC.0.1.TriggerDiscreteCritical"; 22 } // namespace redfish_message_ids 23 24 namespace numeric 25 { 26 class LogToJournal : public interfaces::TriggerAction 27 { 28 public: 29 LogToJournal(::numeric::Type type, double val) : type(type), threshold(val) 30 {} 31 32 void commit(const std::string& triggerId, const ThresholdName thresholdName, 33 const std::string& sensorName, const Milliseconds timestamp, 34 const TriggerValue value) override; 35 36 private: 37 const ::numeric::Type type; 38 const double threshold; 39 }; 40 41 class LogToRedfishEventLog : public interfaces::TriggerAction 42 { 43 public: 44 LogToRedfishEventLog(::numeric::Type type, double val) : 45 type(type), threshold(val) 46 {} 47 48 void commit(const std::string& triggerId, const ThresholdName thresholdName, 49 const std::string& sensorName, const Milliseconds timestamp, 50 const TriggerValue value) override; 51 52 private: 53 const ::numeric::Type type; 54 const double threshold; 55 56 const char* getRedfishMessageId() const; 57 }; 58 59 void fillActions( 60 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 61 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type, 62 double thresholdValue, boost::asio::io_context& ioc, 63 const std::shared_ptr<std::vector<std::string>>& reportIds); 64 } // namespace numeric 65 66 namespace discrete 67 { 68 class LogToJournal : public interfaces::TriggerAction 69 { 70 public: 71 explicit LogToJournal(::discrete::Severity severity) : severity(severity) 72 {} 73 74 void commit(const std::string& triggerId, const ThresholdName thresholdName, 75 const std::string& sensorName, const Milliseconds timestamp, 76 const TriggerValue value) override; 77 78 private: 79 const ::discrete::Severity severity; 80 }; 81 82 class LogToRedfishEventLog : public interfaces::TriggerAction 83 { 84 public: 85 explicit LogToRedfishEventLog(::discrete::Severity severity) : 86 severity(severity) 87 {} 88 89 void commit(const std::string& triggerId, const ThresholdName thresholdName, 90 const std::string& sensorName, const Milliseconds timestamp, 91 const TriggerValue value) override; 92 93 private: 94 const ::discrete::Severity severity; 95 96 const char* getRedfishMessageId() const; 97 }; 98 99 void fillActions( 100 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 101 const std::vector<TriggerAction>& ActionsEnum, 102 ::discrete::Severity severity, boost::asio::io_context& ioc, 103 const std::shared_ptr<std::vector<std::string>>& reportIds); 104 105 namespace onChange 106 { 107 class LogToJournal : public interfaces::TriggerAction 108 { 109 public: 110 LogToJournal() 111 {} 112 113 void commit(const std::string& triggerId, const ThresholdName thresholdName, 114 const std::string& sensorName, const Milliseconds timestamp, 115 const TriggerValue value) override; 116 }; 117 118 class LogToRedfishEventLog : public interfaces::TriggerAction 119 { 120 public: 121 LogToRedfishEventLog() 122 {} 123 124 void commit(const std::string& triggerId, const ThresholdName thresholdName, 125 const std::string& sensorName, const Milliseconds timestamp, 126 const TriggerValue value) override; 127 }; 128 129 void fillActions( 130 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 131 const std::vector<TriggerAction>& ActionsEnum, boost::asio::io_context& ioc, 132 const std::shared_ptr<std::vector<std::string>>& reportIds); 133 } // namespace onChange 134 135 } // namespace discrete 136 137 class UpdateReport : public interfaces::TriggerAction 138 { 139 public: 140 UpdateReport(boost::asio::io_context& ioc, 141 std::shared_ptr<std::vector<std::string>> ids) : 142 ioc(ioc), 143 reportIds(std::move(ids)) 144 {} 145 146 void commit(const std::string& triggerId, const ThresholdName thresholdName, 147 const std::string& sensorName, const Milliseconds timestamp, 148 const TriggerValue value) override; 149 150 private: 151 boost::asio::io_context& ioc; 152 std::shared_ptr<std::vector<std::string>> reportIds; 153 }; 154 } // namespace action 155