blob: ea7f7dc6bc8ed7e2dc02cfdfa7676f0b23175f5e [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
Cezary Zwolak4416fce2021-03-17 03:21:06 +010057 TriggerParams& thresholdParams(LabeledTriggerThresholdParams val)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010058 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010059 labeledThresholdsProperty = std::move(val);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010060 return *this;
61 }
62
Cezary Zwolak4416fce2021-03-17 03:21:06 +010063 const LabeledTriggerThresholdParams& thresholdParams() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010064 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010065 return labeledThresholdsProperty;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010066 }
67
68 private:
Szymon Dompkee28aa532021-10-27 12:33:12 +020069 std::string idProperty = "Trigger1";
70 std::string nameProperty = "My Numeric Trigger";
Szymon Dompke94f71c52021-12-10 07:16:33 +010071 std::vector<TriggerAction> triggerActionsProperty = {
72 TriggerAction::UpdateReport};
Cezary Zwolak4416fce2021-03-17 03:21:06 +010073 std::vector<LabeledSensorInfo> labeledSensorsProperty = {
74 {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
75 "metadata1"}};
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010076 std::vector<std::string> reportIdsProperty = {"Report1"};
Cezary Zwolak4416fce2021-03-17 03:21:06 +010077 LabeledTriggerThresholdParams labeledThresholdsProperty =
78 std::vector<numeric::LabeledThresholdParam>{
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000079 numeric::LabeledThresholdParam{numeric::Type::lowerCritical,
80 Milliseconds(10).count(),
81 numeric::Direction::decreasing, 0.5},
Cezary Zwolak4416fce2021-03-17 03:21:06 +010082 numeric::LabeledThresholdParam{
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000083 numeric::Type::upperCritical, Milliseconds(10).count(),
Cezary Zwolak4416fce2021-03-17 03:21:06 +010084 numeric::Direction::increasing, 90.2}};
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010085};