blob: 95b19d213673b990c5f4b3713a91d1ebba7ff3ca [file] [log] [blame]
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01001#pragma once
2
3#include "interfaces/trigger_types.hpp"
4
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +00005#include <sdbusplus/message.hpp>
6
Wludzik, Jozef1477fe62021-01-02 11:56:10 +01007#include <chrono>
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01008#include <utility>
9
10class TriggerParams
11{
12 public:
13 TriggerParams& name(std::string val)
14 {
15 nameProperty = std::move(val);
16 return *this;
17 }
18
19 const std::string& name() const
20 {
21 return nameProperty;
22 }
23
Szymon Dompkef763c9e2021-03-12 09:19:22 +010024 TriggerParams& isDiscrete(bool val)
25 {
26 discreteProperty = val;
27 return *this;
28 }
29
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010030 bool isDiscrete() const
31 {
32 return discreteProperty;
33 }
34
35 bool logToJournal() const
36 {
37 return logToJournalProperty;
38 }
39
40 bool logToRedfish() const
41 {
42 return logToRedfishProperty;
43 }
44
45 bool updateReport() const
46 {
47 return updateReportProperty;
48 }
49
50 const std::vector<std::pair<sdbusplus::message::object_path, std::string>>&
51 sensors() const
52 {
53 return sensorsProperty;
54 }
55
56 const std::vector<std::string>& reportNames() const
57 {
58 return reportNamesProperty;
59 }
60
Szymon Dompkef763c9e2021-03-12 09:19:22 +010061 TriggerParams& thresholdParams(TriggerThresholdParams val)
62 {
63 thresholdsProperty = std::move(val);
64 return *this;
65 }
66
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010067 const TriggerThresholdParams& thresholdParams() const
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010068 {
69 return thresholdsProperty;
70 }
71
72 private:
73 std::string nameProperty = "Trigger1";
74 bool discreteProperty = false;
75 bool logToJournalProperty = false;
76 bool logToRedfishProperty = false;
77 bool updateReportProperty = false;
78 std::vector<std::pair<sdbusplus::message::object_path, std::string>>
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010079 sensorsProperty = {
80 {sdbusplus::message::object_path(
81 "/xyz/openbmc_project/sensors/temperature/BMC_Temp"),
82 ""}};
83 std::vector<std::string> reportNamesProperty = {"Report1"};
84 TriggerThresholdParams thresholdsProperty =
85 std::vector<numeric::ThresholdParam>{
Wludzik, Jozef9f145912021-02-11 08:54:10 +010086 {numeric::typeToString(numeric::Type::lowerCritical),
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010087 std::chrono::milliseconds(10).count(),
Wludzik, Jozef9f145912021-02-11 08:54:10 +010088 numeric::directionToString(numeric::Direction::decreasing), 0.0},
89 {numeric::typeToString(numeric::Type::upperCritical),
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010090 std::chrono::milliseconds(10).count(),
Wludzik, Jozef9f145912021-02-11 08:54:10 +010091 numeric::directionToString(numeric::Direction::increasing), 90.0}};
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010092};