xref: /openbmc/telemetry/tests/src/params/trigger_params.hpp (revision 2001301a0f2ce71797cf171305a1d0eb0d288fe6)
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& triggerActions(const std::vector<std::string>& val)
26     {
27         triggerActionsProperty = val;
28         return *this;
29     }
30 
31     const std::vector<std::string>& triggerActions() const
32     {
33         return triggerActionsProperty;
34     }
35 
36     const std::vector<LabeledSensorInfo>& sensors() const
37     {
38         return labeledSensorsProperty;
39     }
40 
41     const std::vector<std::string>& reportNames() const
42     {
43         return reportNamesProperty;
44     }
45 
46     TriggerParams& thresholdParams(LabeledTriggerThresholdParams val)
47     {
48         labeledThresholdsProperty = std::move(val);
49         return *this;
50     }
51 
52     const LabeledTriggerThresholdParams& thresholdParams() const
53     {
54         return labeledThresholdsProperty;
55     }
56 
57   private:
58     std::string nameProperty = "Trigger1";
59     std::vector<std::string> triggerActionsProperty = {"UpdateReport"};
60 
61     std::vector<LabeledSensorInfo> labeledSensorsProperty = {
62         {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
63          "metadata1"}};
64     std::vector<std::string> reportNamesProperty = {"Report1"};
65     LabeledTriggerThresholdParams labeledThresholdsProperty =
66         std::vector<numeric::LabeledThresholdParam>{
67             numeric::LabeledThresholdParam{numeric::Type::lowerCritical,
68                                            Milliseconds(10).count(),
69                                            numeric::Direction::decreasing, 0.5},
70             numeric::LabeledThresholdParam{
71                 numeric::Type::upperCritical, Milliseconds(10).count(),
72                 numeric::Direction::increasing, 90.2}};
73 };
74