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 | |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 26 | struct Hysteresis |
| 27 | { |
| 28 | double highHysteresis; |
| 29 | double lowHysteresis; |
| 30 | auto getHighHysteresis() |
| 31 | { |
| 32 | return this->highHysteresis; |
| 33 | } |
| 34 | |
| 35 | auto getLowHysteresis() |
| 36 | { |
| 37 | return this->lowHysteresis; |
| 38 | } |
| 39 | |
| 40 | auto setHighHysteresis(double value) |
| 41 | { |
| 42 | this->highHysteresis = value; |
| 43 | } |
| 44 | |
| 45 | auto setLowHysteresis(double value) |
| 46 | { |
| 47 | this->lowHysteresis = value; |
| 48 | } |
| 49 | }; |
| 50 | |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 51 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 52 | struct Threshold<WarningObject> : public WarningObject, public Hysteresis |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 53 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 54 | static constexpr auto name = "Warning"; |
| 55 | using WarningObject::WarningObject; |
| 56 | |
| 57 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 58 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 59 | return warningHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 60 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 61 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 62 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 63 | return warningLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 64 | } |
| 65 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 66 | template <typename... Args> |
| 67 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 68 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 69 | return warningAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 70 | } |
| 71 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 72 | template <typename... Args> |
| 73 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 74 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 75 | return warningAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 76 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 77 | |
| 78 | template <typename... Args> |
| 79 | auto alarmHighSignalAsserted(Args... args) |
| 80 | { |
| 81 | return warningHighAlarmAsserted(std::forward<Args>(args)...); |
| 82 | } |
| 83 | |
| 84 | template <typename... Args> |
| 85 | auto alarmHighSignalDeasserted(Args... args) |
| 86 | { |
| 87 | return warningHighAlarmDeasserted(std::forward<Args>(args)...); |
| 88 | } |
| 89 | |
| 90 | template <typename... Args> |
| 91 | auto alarmLowSignalAsserted(Args... args) |
| 92 | { |
| 93 | return warningLowAlarmAsserted(std::forward<Args>(args)...); |
| 94 | } |
| 95 | |
| 96 | template <typename... Args> |
| 97 | auto alarmLowSignalDeasserted(Args... args) |
| 98 | { |
| 99 | return warningLowAlarmDeasserted(std::forward<Args>(args)...); |
| 100 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 104 | struct Threshold<CriticalObject> : public CriticalObject, public Hysteresis |
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 | static constexpr auto name = "Critical"; |
| 107 | using CriticalObject::CriticalObject; |
| 108 | |
| 109 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 110 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 111 | return criticalHigh(); |
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 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 114 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 115 | return criticalLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 116 | } |
| 117 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 118 | template <typename... Args> |
| 119 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 120 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 121 | return criticalAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 122 | } |
| 123 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 124 | template <typename... Args> |
| 125 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 126 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 127 | return criticalAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 128 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 129 | |
| 130 | template <typename... Args> |
| 131 | auto alarmHighSignalAsserted(Args... args) |
| 132 | { |
| 133 | return criticalHighAlarmAsserted(std::forward<Args>(args)...); |
| 134 | } |
| 135 | |
| 136 | template <typename... Args> |
| 137 | auto alarmHighSignalDeasserted(Args... args) |
| 138 | { |
| 139 | return criticalHighAlarmDeasserted(std::forward<Args>(args)...); |
| 140 | } |
| 141 | |
| 142 | template <typename... Args> |
| 143 | auto alarmLowSignalAsserted(Args... args) |
| 144 | { |
| 145 | return criticalLowAlarmAsserted(std::forward<Args>(args)...); |
| 146 | } |
| 147 | |
| 148 | template <typename... Args> |
| 149 | auto alarmLowSignalDeasserted(Args... args) |
| 150 | { |
| 151 | return criticalLowAlarmDeasserted(std::forward<Args>(args)...); |
| 152 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 156 | struct Threshold<SoftShutdownObject> : |
| 157 | public SoftShutdownObject, |
| 158 | public Hysteresis |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 159 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 160 | static constexpr auto name = "SoftShutdown"; |
| 161 | using SoftShutdownObject::SoftShutdownObject; |
| 162 | |
| 163 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 164 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 165 | return softShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 166 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 167 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 168 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 169 | return softShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 170 | } |
| 171 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 172 | template <typename... Args> |
| 173 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 174 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 175 | return softShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 176 | } |
| 177 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 178 | template <typename... Args> |
| 179 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 180 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 181 | return softShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 182 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 183 | |
| 184 | template <typename... Args> |
| 185 | auto alarmHighSignalAsserted(Args... args) |
| 186 | { |
| 187 | return softShutdownHighAlarmAsserted(std::forward<Args>(args)...); |
| 188 | } |
| 189 | |
| 190 | template <typename... Args> |
| 191 | auto alarmHighSignalDeasserted(Args... args) |
| 192 | { |
| 193 | return softShutdownHighAlarmDeasserted(std::forward<Args>(args)...); |
| 194 | } |
| 195 | |
| 196 | template <typename... Args> |
| 197 | auto alarmLowSignalAsserted(Args... args) |
| 198 | { |
| 199 | return softShutdownLowAlarmAsserted(std::forward<Args>(args)...); |
| 200 | } |
| 201 | |
| 202 | template <typename... Args> |
| 203 | auto alarmLowSignalDeasserted(Args... args) |
| 204 | { |
| 205 | return softShutdownLowAlarmDeasserted(std::forward<Args>(args)...); |
| 206 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 207 | }; |
| 208 | |
| 209 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 210 | struct Threshold<HardShutdownObject> : |
| 211 | public HardShutdownObject, |
| 212 | public Hysteresis |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 213 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 214 | static constexpr auto name = "HardShutdown"; |
| 215 | using HardShutdownObject::HardShutdownObject; |
| 216 | |
| 217 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 218 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 219 | return hardShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 220 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 221 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 222 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 223 | return hardShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 224 | } |
| 225 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 226 | template <typename... Args> |
| 227 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 228 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 229 | return hardShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 230 | } |
| 231 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 232 | template <typename... Args> |
| 233 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 234 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 235 | return hardShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 236 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 237 | |
| 238 | template <typename... Args> |
| 239 | auto alarmHighSignalAsserted(Args... args) |
| 240 | { |
| 241 | return hardShutdownHighAlarmAsserted(std::forward<Args>(args)...); |
| 242 | } |
| 243 | |
| 244 | template <typename... Args> |
| 245 | auto alarmHighSignalDeasserted(Args... args) |
| 246 | { |
| 247 | return hardShutdownHighAlarmDeasserted(std::forward<Args>(args)...); |
| 248 | } |
| 249 | |
| 250 | template <typename... Args> |
| 251 | auto alarmLowSignalAsserted(Args... args) |
| 252 | { |
| 253 | return hardShutdownLowAlarmAsserted(std::forward<Args>(args)...); |
| 254 | } |
| 255 | |
| 256 | template <typename... Args> |
| 257 | auto alarmLowSignalDeasserted(Args... args) |
| 258 | { |
| 259 | return hardShutdownLowAlarmDeasserted(std::forward<Args>(args)...); |
| 260 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 261 | }; |
| 262 | |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 263 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 264 | struct Threshold<PerformanceLossObject> : |
| 265 | public PerformanceLossObject, |
| 266 | public Hysteresis |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 267 | { |
| 268 | static constexpr auto name = "PerformanceLoss"; |
| 269 | using PerformanceLossObject::PerformanceLossObject; |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 270 | double performanceLossHighHysteresis; |
| 271 | double performanceLossLowHysteresis; |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 272 | |
| 273 | auto high() |
| 274 | { |
| 275 | return performanceLossHigh(); |
| 276 | } |
| 277 | auto low() |
| 278 | { |
| 279 | return performanceLossLow(); |
| 280 | } |
| 281 | |
| 282 | template <typename... Args> |
| 283 | auto alarmHigh(Args... args) |
| 284 | { |
| 285 | return performanceLossAlarmHigh(std::forward<Args>(args)...); |
| 286 | } |
| 287 | |
| 288 | template <typename... Args> |
| 289 | auto alarmLow(Args... args) |
| 290 | { |
| 291 | return performanceLossAlarmLow(std::forward<Args>(args)...); |
| 292 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 293 | |
| 294 | template <typename... Args> |
| 295 | auto alarmHighSignalAsserted(Args... args) |
| 296 | { |
| 297 | return performanceLossHighAlarmAsserted(std::forward<Args>(args)...); |
| 298 | } |
| 299 | |
| 300 | template <typename... Args> |
| 301 | auto alarmHighSignalDeasserted(Args... args) |
| 302 | { |
| 303 | return performanceLossHighAlarmDeasserted(std::forward<Args>(args)...); |
| 304 | } |
| 305 | |
| 306 | template <typename... Args> |
| 307 | auto alarmLowSignalAsserted(Args... args) |
| 308 | { |
| 309 | return performanceLossLowAlarmAsserted(std::forward<Args>(args)...); |
| 310 | } |
| 311 | |
| 312 | template <typename... Args> |
| 313 | auto alarmLowSignalDeasserted(Args... args) |
| 314 | { |
| 315 | return performanceLossLowAlarmDeasserted(std::forward<Args>(args)...); |
| 316 | } |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 317 | }; |
| 318 | |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 319 | } // namespace phosphor::virtualSensor |