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