Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp> |
| 4 | #include <xyz/openbmc_project/Sensor/Threshold/HardShutdown/server.hpp> |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame^] | 5 | #include <xyz/openbmc_project/Sensor/Threshold/PerformanceLoss/server.hpp> |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 6 | #include <xyz/openbmc_project/Sensor/Threshold/SoftShutdown/server.hpp> |
| 7 | #include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp> |
| 8 | |
| 9 | namespace phosphor::virtualSensor |
| 10 | { |
| 11 | |
| 12 | template <typename... T> |
| 13 | using ServerObject = typename sdbusplus::server::object::object<T...>; |
| 14 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 15 | namespace threshold_ns = |
| 16 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server; |
| 17 | using CriticalObject = ServerObject<threshold_ns::Critical>; |
| 18 | using WarningObject = ServerObject<threshold_ns::Warning>; |
| 19 | using SoftShutdownObject = ServerObject<threshold_ns::SoftShutdown>; |
| 20 | using HardShutdownObject = ServerObject<threshold_ns::HardShutdown>; |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame^] | 21 | using PerformanceLossObject = ServerObject<threshold_ns::PerformanceLoss>; |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 22 | |
| 23 | template <typename T> |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 24 | struct Threshold; |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 25 | |
| 26 | template <> |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 27 | struct Threshold<WarningObject> : public WarningObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 28 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 29 | static constexpr auto name = "Warning"; |
| 30 | using WarningObject::WarningObject; |
| 31 | |
| 32 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 33 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 34 | return warningHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 35 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 36 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 37 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 38 | return warningLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 39 | } |
| 40 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 41 | template <typename... Args> |
| 42 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 43 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 44 | return warningAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 45 | } |
| 46 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 47 | template <typename... Args> |
| 48 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 49 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 50 | return warningAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 51 | } |
| 52 | }; |
| 53 | |
| 54 | template <> |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 55 | struct Threshold<CriticalObject> : public CriticalObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 56 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 57 | static constexpr auto name = "Critical"; |
| 58 | using CriticalObject::CriticalObject; |
| 59 | |
| 60 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 61 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 62 | return criticalHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 63 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 64 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 65 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 66 | return criticalLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 67 | } |
| 68 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 69 | template <typename... Args> |
| 70 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 71 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 72 | return criticalAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 73 | } |
| 74 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 75 | template <typename... Args> |
| 76 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 77 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 78 | return criticalAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 79 | } |
| 80 | }; |
| 81 | |
| 82 | template <> |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 83 | struct Threshold<SoftShutdownObject> : public SoftShutdownObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 84 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 85 | static constexpr auto name = "SoftShutdown"; |
| 86 | using SoftShutdownObject::SoftShutdownObject; |
| 87 | |
| 88 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 89 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 90 | return softShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 91 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 92 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 93 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 94 | return softShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 95 | } |
| 96 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 97 | template <typename... Args> |
| 98 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 99 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 100 | return softShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 101 | } |
| 102 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 103 | template <typename... Args> |
| 104 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 105 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 106 | return softShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 107 | } |
| 108 | }; |
| 109 | |
| 110 | template <> |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 111 | struct Threshold<HardShutdownObject> : public HardShutdownObject |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 112 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 113 | static constexpr auto name = "HardShutdown"; |
| 114 | using HardShutdownObject::HardShutdownObject; |
| 115 | |
| 116 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 117 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 118 | return hardShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 119 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 120 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 121 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 122 | return hardShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 123 | } |
| 124 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 125 | template <typename... Args> |
| 126 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 127 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 128 | return hardShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 129 | } |
| 130 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 131 | template <typename... Args> |
| 132 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 133 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 134 | return hardShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 135 | } |
| 136 | }; |
| 137 | |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame^] | 138 | template <> |
| 139 | struct Threshold<PerformanceLossObject> : public PerformanceLossObject |
| 140 | { |
| 141 | static constexpr auto name = "PerformanceLoss"; |
| 142 | using PerformanceLossObject::PerformanceLossObject; |
| 143 | |
| 144 | auto high() |
| 145 | { |
| 146 | return performanceLossHigh(); |
| 147 | } |
| 148 | auto low() |
| 149 | { |
| 150 | return performanceLossLow(); |
| 151 | } |
| 152 | |
| 153 | template <typename... Args> |
| 154 | auto alarmHigh(Args... args) |
| 155 | { |
| 156 | return performanceLossAlarmHigh(std::forward<Args>(args)...); |
| 157 | } |
| 158 | |
| 159 | template <typename... Args> |
| 160 | auto alarmLow(Args... args) |
| 161 | { |
| 162 | return performanceLossAlarmLow(std::forward<Args>(args)...); |
| 163 | } |
| 164 | }; |
| 165 | |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 166 | } // namespace phosphor::virtualSensor |