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> |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 13 | using ServerObject = typename sdbusplus::server::object_t<T...>; |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 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; |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 56 | /** @brief sdbusplus bus client connection. */ |
Patrick Williams | 83e3ac3 | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 57 | sdbusplus::bus_t& bus; |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 58 | std::string objPath; |
| 59 | |
| 60 | /** @brief Virtual sensor path/interface in entityManagerDbus. |
| 61 | * This 3 value is used to set thresholds |
| 62 | */ |
| 63 | std::string entityPath; |
| 64 | std::string entityInterfaceHigh; |
| 65 | std::string entityInterfaceLow; |
| 66 | |
| 67 | /** @brief Constructor to put object onto bus at a dbus path. |
| 68 | * @param[in] bus - Bus to attach to. |
| 69 | * @param[in] path - Path to attach at. |
| 70 | */ |
Patrick Williams | 83e3ac3 | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 71 | Threshold(sdbusplus::bus_t& bus, const char* path) : |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 72 | WarningObject(bus, path), bus(bus), objPath(std::string(path)) |
| 73 | {} |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 74 | |
| 75 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 76 | { |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 77 | return WarningObject::warningHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 78 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 79 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 80 | { |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 81 | return WarningObject::warningLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 82 | } |
| 83 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 84 | template <typename... Args> |
| 85 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 86 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 87 | return warningAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 88 | } |
| 89 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 90 | template <typename... Args> |
| 91 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 92 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 93 | return warningAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 94 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 95 | |
| 96 | template <typename... Args> |
| 97 | auto alarmHighSignalAsserted(Args... args) |
| 98 | { |
| 99 | return warningHighAlarmAsserted(std::forward<Args>(args)...); |
| 100 | } |
| 101 | |
| 102 | template <typename... Args> |
| 103 | auto alarmHighSignalDeasserted(Args... args) |
| 104 | { |
| 105 | return warningHighAlarmDeasserted(std::forward<Args>(args)...); |
| 106 | } |
| 107 | |
| 108 | template <typename... Args> |
| 109 | auto alarmLowSignalAsserted(Args... args) |
| 110 | { |
| 111 | return warningLowAlarmAsserted(std::forward<Args>(args)...); |
| 112 | } |
| 113 | |
| 114 | template <typename... Args> |
| 115 | auto alarmLowSignalDeasserted(Args... args) |
| 116 | { |
| 117 | return warningLowAlarmDeasserted(std::forward<Args>(args)...); |
| 118 | } |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 119 | |
| 120 | /** @brief Set value of WarningHigh */ |
| 121 | virtual double warningHigh(double value) |
| 122 | { |
Matt Spinler | a291ce1 | 2023-02-06 15:12:44 -0600 | [diff] [blame] | 123 | if (!entityPath.empty() && !entityInterfaceHigh.empty()) |
| 124 | { |
| 125 | // persistThreshold |
| 126 | setDbusProperty(bus, entityManagerBusName, entityPath, |
| 127 | entityInterfaceHigh, "Value", value); |
| 128 | } |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 129 | return WarningObject::warningHigh(value); |
| 130 | } |
| 131 | |
| 132 | /** @brief Set value of WarningLow */ |
| 133 | virtual double warningLow(double value) |
| 134 | { |
Matt Spinler | a291ce1 | 2023-02-06 15:12:44 -0600 | [diff] [blame] | 135 | if (!entityPath.empty() && !entityInterfaceLow.empty()) |
| 136 | { |
| 137 | // persistThreshold |
| 138 | setDbusProperty(bus, entityManagerBusName, entityPath, |
| 139 | entityInterfaceLow, "Value", value); |
| 140 | } |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 141 | return WarningObject::warningLow(value); |
| 142 | } |
| 143 | |
| 144 | /** @brief Set the entitymanager interface corresponding to virtualsensor |
| 145 | * warningLow |
| 146 | */ |
| 147 | void setEntityInterfaceLow(const std::string& interfaceLow) |
| 148 | { |
| 149 | entityInterfaceLow = interfaceLow; |
| 150 | } |
| 151 | |
| 152 | /** @brief Set the entitymanager interface corresponding to virtualsensor |
| 153 | * warningHigh |
| 154 | */ |
| 155 | void setEntityInterfaceHigh(const std::string& interfaceHigh) |
| 156 | { |
| 157 | entityInterfaceHigh = interfaceHigh; |
| 158 | } |
| 159 | |
| 160 | /** @brief Set the entitymanager path corresponding to virtualsensor warning |
| 161 | */ |
| 162 | void setEntityPath(const std::string& path) |
| 163 | { |
| 164 | entityPath = path; |
| 165 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 169 | struct Threshold<CriticalObject> : public CriticalObject, public Hysteresis |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 170 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 171 | static constexpr auto name = "Critical"; |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 172 | |
| 173 | /** @brief sdbusplus bus client connection. */ |
Patrick Williams | 83e3ac3 | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 174 | sdbusplus::bus_t& bus; |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 175 | std::string objPath; |
| 176 | |
| 177 | /** @brief Virtual sensor path/interface in entityManagerDbus. |
| 178 | * This 3 value is used to set thresholds |
| 179 | */ |
| 180 | std::string entityPath; |
| 181 | std::string entityInterfaceHigh; |
| 182 | std::string entityInterfaceLow; |
| 183 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 184 | using CriticalObject::CriticalObject; |
| 185 | |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 186 | /** @brief Constructor to put object onto bus at a dbus path. |
| 187 | * @param[in] bus - Bus to attach to. |
| 188 | * @param[in] path - Path to attach at. |
| 189 | */ |
Patrick Williams | 83e3ac3 | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 190 | Threshold(sdbusplus::bus_t& bus, const char* path) : |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 191 | CriticalObject(bus, path), bus(bus), objPath(std::string(path)) |
| 192 | {} |
| 193 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 194 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 195 | { |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 196 | return CriticalObject::criticalHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 197 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 198 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 199 | { |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 200 | return CriticalObject::criticalLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 201 | } |
| 202 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 203 | template <typename... Args> |
| 204 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 205 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 206 | return criticalAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 207 | } |
| 208 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 209 | template <typename... Args> |
| 210 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 211 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 212 | return criticalAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 213 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 214 | |
| 215 | template <typename... Args> |
| 216 | auto alarmHighSignalAsserted(Args... args) |
| 217 | { |
| 218 | return criticalHighAlarmAsserted(std::forward<Args>(args)...); |
| 219 | } |
| 220 | |
| 221 | template <typename... Args> |
| 222 | auto alarmHighSignalDeasserted(Args... args) |
| 223 | { |
| 224 | return criticalHighAlarmDeasserted(std::forward<Args>(args)...); |
| 225 | } |
| 226 | |
| 227 | template <typename... Args> |
| 228 | auto alarmLowSignalAsserted(Args... args) |
| 229 | { |
| 230 | return criticalLowAlarmAsserted(std::forward<Args>(args)...); |
| 231 | } |
| 232 | |
| 233 | template <typename... Args> |
| 234 | auto alarmLowSignalDeasserted(Args... args) |
| 235 | { |
| 236 | return criticalLowAlarmDeasserted(std::forward<Args>(args)...); |
| 237 | } |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 238 | |
| 239 | /** @brief Set value of CriticalHigh */ |
| 240 | virtual double criticalHigh(double value) |
| 241 | { |
| 242 | // persistThreshold |
Matt Spinler | a291ce1 | 2023-02-06 15:12:44 -0600 | [diff] [blame] | 243 | if (!entityPath.empty() && !entityInterfaceHigh.empty()) |
| 244 | { |
| 245 | setDbusProperty(bus, entityManagerBusName, entityPath, |
| 246 | entityInterfaceHigh, "Value", value); |
| 247 | } |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 248 | return CriticalObject::criticalHigh(value); |
| 249 | } |
| 250 | |
| 251 | /** @brief Set value of CriticalLow */ |
| 252 | virtual double criticalLow(double value) |
| 253 | { |
Matt Spinler | a291ce1 | 2023-02-06 15:12:44 -0600 | [diff] [blame] | 254 | if (!entityPath.empty() && !entityInterfaceLow.empty()) |
| 255 | { |
| 256 | setDbusProperty(bus, entityManagerBusName, entityPath, |
| 257 | entityInterfaceLow, "Value", value); |
| 258 | } |
Tao Lin | 91799db | 2022-07-27 21:02:20 +0800 | [diff] [blame] | 259 | return CriticalObject::criticalLow(value); |
| 260 | } |
| 261 | |
| 262 | /** @brief Set the entitymanager interface corresponding to virtualsensor |
| 263 | * criticalLow |
| 264 | */ |
| 265 | void setEntityInterfaceLow(const std::string& interfaceLow) |
| 266 | { |
| 267 | entityInterfaceLow = interfaceLow; |
| 268 | } |
| 269 | |
| 270 | /** @brief Set the entitymanager interface corresponding to virtualsensor |
| 271 | * criticalLow |
| 272 | */ |
| 273 | void setEntityInterfaceHigh(const std::string& interfaceHigh) |
| 274 | { |
| 275 | entityInterfaceHigh = interfaceHigh; |
| 276 | } |
| 277 | |
| 278 | /** @brief Set the entitymanager path corresponding to virtualsensor warning |
| 279 | */ |
| 280 | void setEntityPath(const std::string& path) |
| 281 | { |
| 282 | entityPath = path; |
| 283 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 287 | struct Threshold<SoftShutdownObject> : |
| 288 | public SoftShutdownObject, |
| 289 | public Hysteresis |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 290 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 291 | static constexpr auto name = "SoftShutdown"; |
| 292 | using SoftShutdownObject::SoftShutdownObject; |
| 293 | |
| 294 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 295 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 296 | return softShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 297 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 298 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 299 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 300 | return softShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 301 | } |
| 302 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 303 | template <typename... Args> |
| 304 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 305 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 306 | return softShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 307 | } |
| 308 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 309 | template <typename... Args> |
| 310 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 311 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 312 | return softShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 313 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 314 | |
| 315 | template <typename... Args> |
| 316 | auto alarmHighSignalAsserted(Args... args) |
| 317 | { |
| 318 | return softShutdownHighAlarmAsserted(std::forward<Args>(args)...); |
| 319 | } |
| 320 | |
| 321 | template <typename... Args> |
| 322 | auto alarmHighSignalDeasserted(Args... args) |
| 323 | { |
| 324 | return softShutdownHighAlarmDeasserted(std::forward<Args>(args)...); |
| 325 | } |
| 326 | |
| 327 | template <typename... Args> |
| 328 | auto alarmLowSignalAsserted(Args... args) |
| 329 | { |
| 330 | return softShutdownLowAlarmAsserted(std::forward<Args>(args)...); |
| 331 | } |
| 332 | |
| 333 | template <typename... Args> |
| 334 | auto alarmLowSignalDeasserted(Args... args) |
| 335 | { |
| 336 | return softShutdownLowAlarmDeasserted(std::forward<Args>(args)...); |
| 337 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 338 | }; |
| 339 | |
| 340 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 341 | struct Threshold<HardShutdownObject> : |
| 342 | public HardShutdownObject, |
| 343 | public Hysteresis |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 344 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 345 | static constexpr auto name = "HardShutdown"; |
| 346 | using HardShutdownObject::HardShutdownObject; |
| 347 | |
| 348 | auto high() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 349 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 350 | return hardShutdownHigh(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 351 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 352 | auto low() |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 353 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 354 | return hardShutdownLow(); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 355 | } |
| 356 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 357 | template <typename... Args> |
| 358 | auto alarmHigh(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 359 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 360 | return hardShutdownAlarmHigh(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 361 | } |
| 362 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 363 | template <typename... Args> |
| 364 | auto alarmLow(Args... args) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 365 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 366 | return hardShutdownAlarmLow(std::forward<Args>(args)...); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 367 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 368 | |
| 369 | template <typename... Args> |
| 370 | auto alarmHighSignalAsserted(Args... args) |
| 371 | { |
| 372 | return hardShutdownHighAlarmAsserted(std::forward<Args>(args)...); |
| 373 | } |
| 374 | |
| 375 | template <typename... Args> |
| 376 | auto alarmHighSignalDeasserted(Args... args) |
| 377 | { |
| 378 | return hardShutdownHighAlarmDeasserted(std::forward<Args>(args)...); |
| 379 | } |
| 380 | |
| 381 | template <typename... Args> |
| 382 | auto alarmLowSignalAsserted(Args... args) |
| 383 | { |
| 384 | return hardShutdownLowAlarmAsserted(std::forward<Args>(args)...); |
| 385 | } |
| 386 | |
| 387 | template <typename... Args> |
| 388 | auto alarmLowSignalDeasserted(Args... args) |
| 389 | { |
| 390 | return hardShutdownLowAlarmDeasserted(std::forward<Args>(args)...); |
| 391 | } |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 392 | }; |
| 393 | |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 394 | template <> |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 395 | struct Threshold<PerformanceLossObject> : |
| 396 | public PerformanceLossObject, |
| 397 | public Hysteresis |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 398 | { |
| 399 | static constexpr auto name = "PerformanceLoss"; |
| 400 | using PerformanceLossObject::PerformanceLossObject; |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 401 | double performanceLossHighHysteresis; |
| 402 | double performanceLossLowHysteresis; |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 403 | |
| 404 | auto high() |
| 405 | { |
| 406 | return performanceLossHigh(); |
| 407 | } |
| 408 | auto low() |
| 409 | { |
| 410 | return performanceLossLow(); |
| 411 | } |
| 412 | |
| 413 | template <typename... Args> |
| 414 | auto alarmHigh(Args... args) |
| 415 | { |
| 416 | return performanceLossAlarmHigh(std::forward<Args>(args)...); |
| 417 | } |
| 418 | |
| 419 | template <typename... Args> |
| 420 | auto alarmLow(Args... args) |
| 421 | { |
| 422 | return performanceLossAlarmLow(std::forward<Args>(args)...); |
| 423 | } |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 424 | |
| 425 | template <typename... Args> |
| 426 | auto alarmHighSignalAsserted(Args... args) |
| 427 | { |
| 428 | return performanceLossHighAlarmAsserted(std::forward<Args>(args)...); |
| 429 | } |
| 430 | |
| 431 | template <typename... Args> |
| 432 | auto alarmHighSignalDeasserted(Args... args) |
| 433 | { |
| 434 | return performanceLossHighAlarmDeasserted(std::forward<Args>(args)...); |
| 435 | } |
| 436 | |
| 437 | template <typename... Args> |
| 438 | auto alarmLowSignalAsserted(Args... args) |
| 439 | { |
| 440 | return performanceLossLowAlarmAsserted(std::forward<Args>(args)...); |
| 441 | } |
| 442 | |
| 443 | template <typename... Args> |
| 444 | auto alarmLowSignalDeasserted(Args... args) |
| 445 | { |
| 446 | return performanceLossLowAlarmDeasserted(std::forward<Args>(args)...); |
| 447 | } |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 448 | }; |
| 449 | |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 450 | } // namespace phosphor::virtualSensor |