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: |
| 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 | |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 25 | TriggerParams& isDiscrete(bool val) |
| 26 | { |
| 27 | discreteProperty = val; |
| 28 | return *this; |
| 29 | } |
| 30 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 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 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 46 | TriggerParams& updateReport(bool updateReport) |
| 47 | { |
| 48 | updateReportProperty = updateReport; |
| 49 | return *this; |
| 50 | } |
| 51 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 52 | bool updateReport() const |
| 53 | { |
| 54 | return updateReportProperty; |
| 55 | } |
| 56 | |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 57 | const std::vector<LabeledSensorInfo>& sensors() const |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 58 | { |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 59 | return labeledSensorsProperty; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | const std::vector<std::string>& reportNames() const |
| 63 | { |
| 64 | return reportNamesProperty; |
| 65 | } |
| 66 | |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 67 | TriggerParams& thresholdParams(LabeledTriggerThresholdParams val) |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 68 | { |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 69 | labeledThresholdsProperty = std::move(val); |
Szymon Dompke | f763c9e | 2021-03-12 09:19:22 +0100 | [diff] [blame] | 70 | return *this; |
| 71 | } |
| 72 | |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 73 | const LabeledTriggerThresholdParams& thresholdParams() const |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 74 | { |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 75 | return labeledThresholdsProperty; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | private: |
| 79 | std::string nameProperty = "Trigger1"; |
| 80 | bool discreteProperty = false; |
| 81 | bool logToJournalProperty = false; |
| 82 | bool logToRedfishProperty = false; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 83 | bool updateReportProperty = true; |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 84 | std::vector<LabeledSensorInfo> labeledSensorsProperty = { |
| 85 | {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp", |
| 86 | "metadata1"}}; |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 87 | std::vector<std::string> reportNamesProperty = {"Report1"}; |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 88 | LabeledTriggerThresholdParams labeledThresholdsProperty = |
| 89 | std::vector<numeric::LabeledThresholdParam>{ |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 90 | numeric::LabeledThresholdParam{numeric::Type::lowerCritical, |
| 91 | Milliseconds(10).count(), |
| 92 | numeric::Direction::decreasing, 0.5}, |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 93 | numeric::LabeledThresholdParam{ |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 94 | numeric::Type::upperCritical, Milliseconds(10).count(), |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 95 | numeric::Direction::increasing, 90.2}}; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 96 | }; |