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