blob: 62acd7a84fcc381359235285e8092ba05ba9e849 [file] [log] [blame]
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01001#pragma once
2
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00003#include "types/milliseconds.hpp"
4#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 Dompke20013012021-07-23 09:54:20 +020036 TriggerParams& triggerActions(const std::vector<std::string>& 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 Dompke20013012021-07-23 09:54:20 +020042 const std::vector<std::string>& 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
52 const std::vector<std::string>& reportNames() const
53 {
54 return reportNamesProperty;
55 }
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 Dompke20013012021-07-23 09:54:20 +020071 std::vector<std::string> triggerActionsProperty = {"UpdateReport"};
72
Cezary Zwolak4416fce2021-03-17 03:21:06 +010073 std::vector<LabeledSensorInfo> labeledSensorsProperty = {
74 {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
75 "metadata1"}};
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010076 std::vector<std::string> reportNamesProperty = {"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};