blob: 753cbb1bb421ee8271085c8252e92d899324862d [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:
14 TriggerParams& name(std::string val)
15 {
16 nameProperty = std::move(val);
17 return *this;
18 }
19
20 const std::string& name() const
21 {
22 return nameProperty;
23 }
24
Szymon Dompkef763c9e2021-03-12 09:19:22 +010025 TriggerParams& isDiscrete(bool val)
26 {
27 discreteProperty = val;
28 return *this;
29 }
30
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010031 bool isDiscrete() const
32 {
33 return discreteProperty;
34 }
35
36 bool logToJournal() const
37 {
38 return logToJournalProperty;
39 }
40
41 bool logToRedfish() const
42 {
43 return logToRedfishProperty;
44 }
45
Cezary Zwolaka4e67612021-02-18 13:16:16 +010046 TriggerParams& updateReport(bool updateReport)
47 {
48 updateReportProperty = updateReport;
49 return *this;
50 }
51
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010052 bool updateReport() const
53 {
54 return updateReportProperty;
55 }
56
Cezary Zwolak4416fce2021-03-17 03:21:06 +010057 const std::vector<LabeledSensorInfo>& sensors() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010058 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010059 return labeledSensorsProperty;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010060 }
61
62 const std::vector<std::string>& reportNames() const
63 {
64 return reportNamesProperty;
65 }
66
Cezary Zwolak4416fce2021-03-17 03:21:06 +010067 TriggerParams& thresholdParams(LabeledTriggerThresholdParams val)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010068 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010069 labeledThresholdsProperty = std::move(val);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010070 return *this;
71 }
72
Cezary Zwolak4416fce2021-03-17 03:21:06 +010073 const LabeledTriggerThresholdParams& thresholdParams() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010074 {
Cezary Zwolak4416fce2021-03-17 03:21:06 +010075 return labeledThresholdsProperty;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010076 }
77
78 private:
79 std::string nameProperty = "Trigger1";
80 bool discreteProperty = false;
81 bool logToJournalProperty = false;
82 bool logToRedfishProperty = false;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010083 bool updateReportProperty = true;
Cezary Zwolak4416fce2021-03-17 03:21:06 +010084 std::vector<LabeledSensorInfo> labeledSensorsProperty = {
85 {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
86 "metadata1"}};
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010087 std::vector<std::string> reportNamesProperty = {"Report1"};
Cezary Zwolak4416fce2021-03-17 03:21:06 +010088 LabeledTriggerThresholdParams labeledThresholdsProperty =
89 std::vector<numeric::LabeledThresholdParam>{
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000090 numeric::LabeledThresholdParam{numeric::Type::lowerCritical,
91 Milliseconds(10).count(),
92 numeric::Direction::decreasing, 0.5},
Cezary Zwolak4416fce2021-03-17 03:21:06 +010093 numeric::LabeledThresholdParam{
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000094 numeric::Type::upperCritical, Milliseconds(10).count(),
Cezary Zwolak4416fce2021-03-17 03:21:06 +010095 numeric::Direction::increasing, 90.2}};
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010096};