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