Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 3 | #include "types/milliseconds.hpp" |
| 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 | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 36 | TriggerParams& triggerActions(const std::vector<std::string>& 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 | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 42 | const std::vector<std::string>& 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 | |
| 52 | const std::vector<std::string>& reportNames() const |
| 53 | { |
| 54 | return reportNamesProperty; |
| 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 | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 71 | std::vector<std::string> triggerActionsProperty = {"UpdateReport"}; |
| 72 | |
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"}}; |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 76 | std::vector<std::string> reportNamesProperty = {"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 | }; |