Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Krzysztof Grobelny | 51f0fd5 | 2021-12-28 16:32:08 +0100 | [diff] [blame] | 3 | #include "types/duration_types.hpp" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 4 | #include "types/trigger_types.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 5 | |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 6 | #include <sdbusplus/message.hpp> |
| 7 | |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 8 | #include <chrono> |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 9 | #include <utility> |
| 10 | |
| 11 | class TriggerParams |
| 12 | { |
| 13 | public: |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 14 | TriggerParams& id(std::string val) |
| 15 | { |
| 16 | idProperty = std::move(val); |
| 17 | return *this; |
| 18 | } |
| 19 | |
| 20 | const std::string& id() const |
| 21 | { |
| 22 | return idProperty; |
| 23 | } |
| 24 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 25 | TriggerParams& name(std::string val) |
| 26 | { |
| 27 | nameProperty = std::move(val); |
| 28 | return *this; |
| 29 | } |
| 30 | |
| 31 | const std::string& name() const |
| 32 | { |
| 33 | return nameProperty; |
| 34 | } |
| 35 | |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame^] | 36 | TriggerParams& triggerActions(const std::vector<TriggerAction>& val) |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 37 | { |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 38 | triggerActionsProperty = val; |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 39 | return *this; |
| 40 | } |
| 41 | |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame^] | 42 | const std::vector<TriggerAction>& triggerActions() const |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 43 | { |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 44 | return triggerActionsProperty; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 45 | } |
| 46 | |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 47 | const std::vector<LabeledSensorInfo>& sensors() const |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 48 | { |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 49 | return labeledSensorsProperty; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 50 | } |
| 51 | |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 52 | const std::vector<std::string>& reportIds() const |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 53 | { |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 54 | return reportIdsProperty; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 57 | TriggerParams& thresholdParams(LabeledTriggerThresholdParams val) |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 58 | { |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 59 | labeledThresholdsProperty = std::move(val); |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 60 | return *this; |
| 61 | } |
| 62 | |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 63 | const LabeledTriggerThresholdParams& thresholdParams() const |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 64 | { |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 65 | return labeledThresholdsProperty; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | private: |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 69 | std::string idProperty = "Trigger1"; |
| 70 | std::string nameProperty = "My Numeric Trigger"; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame^] | 71 | std::vector<TriggerAction> triggerActionsProperty = { |
| 72 | TriggerAction::UpdateReport}; |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 73 | std::vector<LabeledSensorInfo> labeledSensorsProperty = { |
| 74 | {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp", |
| 75 | "metadata1"}}; |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 76 | std::vector<std::string> reportIdsProperty = {"Report1"}; |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 77 | LabeledTriggerThresholdParams labeledThresholdsProperty = |
| 78 | std::vector<numeric::LabeledThresholdParam>{ |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 79 | numeric::LabeledThresholdParam{numeric::Type::lowerCritical, |
| 80 | Milliseconds(10).count(), |
| 81 | numeric::Direction::decreasing, 0.5}, |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 82 | numeric::LabeledThresholdParam{ |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 83 | numeric::Type::upperCritical, Milliseconds(10).count(), |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 84 | numeric::Direction::increasing, 90.2}}; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 85 | }; |