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* TriggerDiscreteConditionMet = 14 "Telemetry.1.0.TriggerDiscreteConditionMet"; 15 constexpr const char* TriggerNumericAboveLowerCritical = 16 "Telemetry.1.0.TriggerNumericAboveLowerCritical"; 17 constexpr const char* TriggerNumericAboveUpperCritical = 18 "Telemetry.1.0.TriggerNumericAboveUpperCritical"; 19 constexpr const char* TriggerNumericAboveUpperWarning = 20 "Telemetry.1.0.TriggerNumericAboveUpperWarning"; 21 constexpr const char* TriggerNumericBelowLowerCritical = 22 "Telemetry.1.0.TriggerNumericBelowLowerCritical"; 23 constexpr const char* TriggerNumericBelowLowerWarning = 24 "Telemetry.1.0.TriggerNumericBelowLowerWarning"; 25 constexpr const char* TriggerNumericBelowUpperCritical = 26 "Telemetry.1.0.TriggerNumericBelowUpperCritical"; 27 constexpr const char* TriggerNumericReadingNormal = 28 "Telemetry.1.0.TriggerNumericReadingNormal"; 29 } // namespace redfish_message_ids 30 31 namespace numeric 32 { 33 34 class LogToRedfishEventLog : public interfaces::TriggerAction 35 { 36 public: LogToRedfishEventLog(::numeric::Type type,double val)37 LogToRedfishEventLog(::numeric::Type type, double val) : 38 type(type), threshold(val) 39 {} 40 41 void commit(const std::string& triggerId, const ThresholdName thresholdName, 42 const std::string& sensorName, const Milliseconds timestamp, 43 const TriggerValue value) override; 44 45 private: 46 const ::numeric::Type type; 47 const double threshold; 48 49 const char* getRedfishMessageId(const double value) const; 50 }; 51 52 void fillActions( 53 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 54 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type, 55 double thresholdValue, boost::asio::io_context& ioc, 56 const std::shared_ptr<std::vector<std::string>>& reportIds); 57 } // namespace numeric 58 59 namespace discrete 60 { 61 62 class LogToRedfishEventLog : public interfaces::TriggerAction 63 { 64 public: LogToRedfishEventLog()65 explicit LogToRedfishEventLog() {} 66 67 void commit(const std::string& triggerId, const ThresholdName thresholdName, 68 const std::string& sensorName, const Milliseconds timestamp, 69 const TriggerValue value) override; 70 }; 71 72 void fillActions( 73 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 74 const std::vector<TriggerAction>& ActionsEnum, 75 ::discrete::Severity severity, boost::asio::io_context& ioc, 76 const std::shared_ptr<std::vector<std::string>>& reportIds); 77 78 namespace onChange 79 { 80 81 class LogToRedfishEventLog : public interfaces::TriggerAction 82 { 83 public: LogToRedfishEventLog()84 LogToRedfishEventLog() {} 85 86 void commit(const std::string& triggerId, const ThresholdName thresholdName, 87 const std::string& sensorName, const Milliseconds timestamp, 88 const TriggerValue value) override; 89 }; 90 91 void fillActions( 92 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 93 const std::vector<TriggerAction>& ActionsEnum, boost::asio::io_context& ioc, 94 const std::shared_ptr<std::vector<std::string>>& reportIds); 95 } // namespace onChange 96 97 } // namespace discrete 98 99 class UpdateReport : public interfaces::TriggerAction 100 { 101 public: UpdateReport(boost::asio::io_context & ioc,std::shared_ptr<std::vector<std::string>> ids)102 UpdateReport(boost::asio::io_context& ioc, 103 std::shared_ptr<std::vector<std::string>> ids) : 104 ioc(ioc), reportIds(std::move(ids)) 105 {} 106 107 void commit(const std::string& triggerId, const ThresholdName thresholdName, 108 const std::string& sensorName, const Milliseconds timestamp, 109 const TriggerValue value) override; 110 111 private: 112 boost::asio::io_context& ioc; 113 std::shared_ptr<std::vector<std::string>> reportIds; 114 }; 115 } // namespace action 116