1 #pragma once 2 3 #include "types/duration_types.hpp" 4 #include "types/trigger_types.hpp" 5 6 #include <sdbusplus/message.hpp> 7 8 #include <chrono> 9 #include <utility> 10 11 class TriggerParams 12 { 13 public: 14 TriggerParams& id(std::string val) 15 { 16 idProperty = std::move(val); 17 return *this; 18 } 19 20 const std::string& id() const 21 { 22 return idProperty; 23 } 24 25 TriggerParams& name(std::string val) 26 { 27 nameProperty = std::move(val); 28 return *this; 29 } 30 31 const std::string& name() const 32 { 33 return nameProperty; 34 } 35 36 TriggerParams& triggerActions(const std::vector<TriggerAction>& val) 37 { 38 triggerActionsProperty = val; 39 return *this; 40 } 41 42 const std::vector<TriggerAction>& triggerActions() const 43 { 44 return triggerActionsProperty; 45 } 46 47 const std::vector<LabeledSensorInfo>& sensors() const 48 { 49 return labeledSensorsProperty; 50 } 51 52 const std::vector<std::string>& reportIds() const 53 { 54 return reportIdsProperty; 55 } 56 57 TriggerParams& reportIds(std::vector<std::string> val) 58 { 59 reportIdsProperty = std::move(val); 60 return *this; 61 } 62 63 TriggerParams& thresholdParams(LabeledTriggerThresholdParams val) 64 { 65 labeledThresholdsProperty = std::move(val); 66 return *this; 67 } 68 69 const LabeledTriggerThresholdParams& thresholdParams() const 70 { 71 return labeledThresholdsProperty; 72 } 73 74 private: 75 std::string idProperty = "Trigger1"; 76 std::string nameProperty = "My Numeric Trigger"; 77 std::vector<TriggerAction> triggerActionsProperty = { 78 TriggerAction::UpdateReport}; 79 std::vector<LabeledSensorInfo> labeledSensorsProperty = { 80 {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp", 81 "metadata1"}}; 82 std::vector<std::string> reportIdsProperty = {"Report1"}; 83 LabeledTriggerThresholdParams labeledThresholdsProperty = 84 std::vector<numeric::LabeledThresholdParam>{ 85 numeric::LabeledThresholdParam{numeric::Type::lowerCritical, 86 Milliseconds(10).count(), 87 numeric::Direction::decreasing, 0.5}, 88 numeric::LabeledThresholdParam{ 89 numeric::Type::upperCritical, Milliseconds(10).count(), 90 numeric::Direction::increasing, 90.2}}; 91 }; 92