xref: /openbmc/telemetry/tests/src/params/trigger_params.hpp (revision dcc4e1936173a93251a02066432bc2bcbc386240)
1 #pragma once
2 
3 #include "types/milliseconds.hpp"
4 #include "types/trigger_types.hpp"
5 
6 #include <sdbusplus/message.hpp>
7 
8 #include <chrono>
9 #include <utility>
10 
11 class 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 
25     TriggerParams& isDiscrete(bool val)
26     {
27         discreteProperty = val;
28         return *this;
29     }
30 
31     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 
46     TriggerParams& updateReport(bool updateReport)
47     {
48         updateReportProperty = updateReport;
49         return *this;
50     }
51 
52     bool updateReport() const
53     {
54         return updateReportProperty;
55     }
56 
57     const std::vector<LabeledSensorInfo>& sensors() const
58     {
59         return labeledSensorsProperty;
60     }
61 
62     const std::vector<std::string>& reportNames() const
63     {
64         return reportNamesProperty;
65     }
66 
67     TriggerParams& thresholdParams(LabeledTriggerThresholdParams val)
68     {
69         labeledThresholdsProperty = std::move(val);
70         return *this;
71     }
72 
73     const LabeledTriggerThresholdParams& thresholdParams() const
74     {
75         return labeledThresholdsProperty;
76     }
77 
78   private:
79     std::string nameProperty = "Trigger1";
80     bool discreteProperty = false;
81     bool logToJournalProperty = false;
82     bool logToRedfishProperty = false;
83     bool updateReportProperty = true;
84     std::vector<LabeledSensorInfo> labeledSensorsProperty = {
85         {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
86          "metadata1"}};
87 
88     std::vector<std::string> reportNamesProperty = {"Report1"};
89 
90     LabeledTriggerThresholdParams labeledThresholdsProperty =
91         std::vector<numeric::LabeledThresholdParam>{
92             numeric::LabeledThresholdParam{numeric::Type::lowerCritical,
93                                            Milliseconds(10).count(),
94                                            numeric::Direction::decreasing, 0.5},
95             numeric::LabeledThresholdParam{
96                 numeric::Type::upperCritical, Milliseconds(10).count(),
97                 numeric::Direction::increasing, 90.2}};
98 };
99