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