Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 3 | #include "utils/conversion.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 4 | |
| 5 | #include <string> |
| 6 | #include <tuple> |
| 7 | #include <utility> |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 8 | #include <variant> |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
| 11 | namespace discrete |
| 12 | { |
| 13 | |
| 14 | enum class Severity |
| 15 | { |
| 16 | ok = 0, |
| 17 | warning, |
| 18 | critical |
| 19 | }; |
| 20 | |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 21 | inline Severity toSeverity(int x) |
| 22 | { |
| 23 | return utils::toEnum<Severity, Severity::ok, Severity::critical>(x); |
| 24 | } |
| 25 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 26 | using ThresholdParam = std::tuple<std::string, std::underlying_type_t<Severity>, |
| 27 | std::variant<double>, uint64_t>; |
| 28 | } // namespace discrete |
| 29 | |
| 30 | namespace numeric |
| 31 | { |
| 32 | |
| 33 | enum class Type |
| 34 | { |
| 35 | lowerCritical = 0, |
| 36 | lowerWarning, |
| 37 | upperWarning, |
| 38 | upperCritical |
| 39 | }; |
| 40 | |
| 41 | enum class Direction |
| 42 | { |
| 43 | either = 0, |
| 44 | decreasing, |
| 45 | increasing |
| 46 | }; |
| 47 | |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 48 | inline Type toType(int x) |
| 49 | { |
| 50 | return utils::toEnum<Type, Type::lowerCritical, Type::upperCritical>(x); |
| 51 | } |
| 52 | |
| 53 | inline Direction toDirection(int x) |
| 54 | { |
| 55 | return utils::toEnum<Direction, Direction::either, Direction::increasing>( |
| 56 | x); |
| 57 | } |
| 58 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 59 | using ThresholdParam = std::tuple<std::underlying_type_t<Type>, uint64_t, |
| 60 | std::underlying_type_t<Direction>, double>; |
| 61 | } // namespace numeric |
| 62 | |
| 63 | using TriggerThresholdParams = |
| 64 | std::variant<std::vector<numeric::ThresholdParam>, |
| 65 | std::vector<discrete::ThresholdParam>>; |