blob: b17ea86e825939852f201f11096d51d8c282f64b [file] [log] [blame]
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01001#pragma once
2
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +01003#include "types/duration_types.hpp"
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00004#include "types/trigger_types.hpp"
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01005
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +00006#include <sdbusplus/message.hpp>
7
Wludzik, Jozef1477fe62021-01-02 11:56:10 +01008#include <chrono>
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01009#include <utility>
10
11class TriggerParams
12{
13 public:
Szymon Dompkee28aa532021-10-27 12:33:12 +020014 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
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010025 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
Szymon Dompke94f71c52021-12-10 07:16:33 +010036 TriggerParams& triggerActions(const std::vector<TriggerAction>& val)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010037 {
Szymon Dompke20013012021-07-23 09:54:20 +020038 triggerActionsProperty = val;
Szymon Dompkef763c9e2021-03-12 09:19:22 +010039 return *this;
40 }
41
Szymon Dompke94f71c52021-12-10 07:16:33 +010042 const std::vector<TriggerAction>& triggerActions() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010043 {
Szymon Dompke20013012021-07-23 09:54:20 +020044 return triggerActionsProperty;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010045 }
46
Cezary Zwolak4416fce2021-03-17 03:21:06 +010047 const std::vector<LabeledSensorInfo>& sensors() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010048 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010049 return labeledSensorsProperty;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010050 }
51
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010052 const std::vector<std::string>& reportIds() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010053 {
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010054 return reportIdsProperty;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010055 }
56
Szymon Dompkeb4ef22e2022-02-07 15:15:12 +010057 TriggerParams& reportIds(std::vector<std::string> val)
58 {
59 reportIdsProperty = std::move(val);
60 return *this;
61 }
62
Cezary Zwolak4416fce2021-03-17 03:21:06 +010063 TriggerParams& thresholdParams(LabeledTriggerThresholdParams val)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010064 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010065 labeledThresholdsProperty = std::move(val);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010066 return *this;
67 }
68
Cezary Zwolak4416fce2021-03-17 03:21:06 +010069 const LabeledTriggerThresholdParams& thresholdParams() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010070 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010071 return labeledThresholdsProperty;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010072 }
73
74 private:
Szymon Dompkee28aa532021-10-27 12:33:12 +020075 std::string idProperty = "Trigger1";
76 std::string nameProperty = "My Numeric Trigger";
Szymon Dompke94f71c52021-12-10 07:16:33 +010077 std::vector<TriggerAction> triggerActionsProperty = {
78 TriggerAction::UpdateReport};
Cezary Zwolak4416fce2021-03-17 03:21:06 +010079 std::vector<LabeledSensorInfo> labeledSensorsProperty = {
80 {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
81 "metadata1"}};
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010082 std::vector<std::string> reportIdsProperty = {"Report1"};
Cezary Zwolak4416fce2021-03-17 03:21:06 +010083 LabeledTriggerThresholdParams labeledThresholdsProperty =
84 std::vector<numeric::LabeledThresholdParam>{
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000085 numeric::LabeledThresholdParam{numeric::Type::lowerCritical,
86 Milliseconds(10).count(),
87 numeric::Direction::decreasing, 0.5},
Cezary Zwolak4416fce2021-03-17 03:21:06 +010088 numeric::LabeledThresholdParam{
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000089 numeric::Type::upperCritical, Milliseconds(10).count(),
Cezary Zwolak4416fce2021-03-17 03:21:06 +010090 numeric::Direction::increasing, 90.2}};
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010091};