#pragma once #include #include #include #include #include namespace phosphor::virtualSensor { template using ServerObject = typename sdbusplus::server::object_t; namespace threshold_ns = sdbusplus::xyz::openbmc_project::Sensor::Threshold::server; using CriticalObject = ServerObject; using WarningObject = ServerObject; using SoftShutdownObject = ServerObject; using HardShutdownObject = ServerObject; using PerformanceLossObject = ServerObject; template struct Threshold; struct Hysteresis { double highHysteresis; double lowHysteresis; auto getHighHysteresis() { return this->highHysteresis; } auto getLowHysteresis() { return this->lowHysteresis; } auto setHighHysteresis(double value) { this->highHysteresis = value; } auto setLowHysteresis(double value) { this->lowHysteresis = value; } }; template <> struct Threshold : public WarningObject, public Hysteresis { static constexpr auto name = "Warning"; using WarningObject::WarningObject; auto high() { return warningHigh(); } auto low() { return warningLow(); } template auto alarmHigh(Args... args) { return warningAlarmHigh(std::forward(args)...); } template auto alarmLow(Args... args) { return warningAlarmLow(std::forward(args)...); } template auto alarmHighSignalAsserted(Args... args) { return warningHighAlarmAsserted(std::forward(args)...); } template auto alarmHighSignalDeasserted(Args... args) { return warningHighAlarmDeasserted(std::forward(args)...); } template auto alarmLowSignalAsserted(Args... args) { return warningLowAlarmAsserted(std::forward(args)...); } template auto alarmLowSignalDeasserted(Args... args) { return warningLowAlarmDeasserted(std::forward(args)...); } }; template <> struct Threshold : public CriticalObject, public Hysteresis { static constexpr auto name = "Critical"; using CriticalObject::CriticalObject; auto high() { return criticalHigh(); } auto low() { return criticalLow(); } template auto alarmHigh(Args... args) { return criticalAlarmHigh(std::forward(args)...); } template auto alarmLow(Args... args) { return criticalAlarmLow(std::forward(args)...); } template auto alarmHighSignalAsserted(Args... args) { return criticalHighAlarmAsserted(std::forward(args)...); } template auto alarmHighSignalDeasserted(Args... args) { return criticalHighAlarmDeasserted(std::forward(args)...); } template auto alarmLowSignalAsserted(Args... args) { return criticalLowAlarmAsserted(std::forward(args)...); } template auto alarmLowSignalDeasserted(Args... args) { return criticalLowAlarmDeasserted(std::forward(args)...); } }; template <> struct Threshold : public SoftShutdownObject, public Hysteresis { static constexpr auto name = "SoftShutdown"; using SoftShutdownObject::SoftShutdownObject; auto high() { return softShutdownHigh(); } auto low() { return softShutdownLow(); } template auto alarmHigh(Args... args) { return softShutdownAlarmHigh(std::forward(args)...); } template auto alarmLow(Args... args) { return softShutdownAlarmLow(std::forward(args)...); } template auto alarmHighSignalAsserted(Args... args) { return softShutdownHighAlarmAsserted(std::forward(args)...); } template auto alarmHighSignalDeasserted(Args... args) { return softShutdownHighAlarmDeasserted(std::forward(args)...); } template auto alarmLowSignalAsserted(Args... args) { return softShutdownLowAlarmAsserted(std::forward(args)...); } template auto alarmLowSignalDeasserted(Args... args) { return softShutdownLowAlarmDeasserted(std::forward(args)...); } }; template <> struct Threshold : public HardShutdownObject, public Hysteresis { static constexpr auto name = "HardShutdown"; using HardShutdownObject::HardShutdownObject; auto high() { return hardShutdownHigh(); } auto low() { return hardShutdownLow(); } template auto alarmHigh(Args... args) { return hardShutdownAlarmHigh(std::forward(args)...); } template auto alarmLow(Args... args) { return hardShutdownAlarmLow(std::forward(args)...); } template auto alarmHighSignalAsserted(Args... args) { return hardShutdownHighAlarmAsserted(std::forward(args)...); } template auto alarmHighSignalDeasserted(Args... args) { return hardShutdownHighAlarmDeasserted(std::forward(args)...); } template auto alarmLowSignalAsserted(Args... args) { return hardShutdownLowAlarmAsserted(std::forward(args)...); } template auto alarmLowSignalDeasserted(Args... args) { return hardShutdownLowAlarmDeasserted(std::forward(args)...); } }; template <> struct Threshold : public PerformanceLossObject, public Hysteresis { static constexpr auto name = "PerformanceLoss"; using PerformanceLossObject::PerformanceLossObject; double performanceLossHighHysteresis; double performanceLossLowHysteresis; auto high() { return performanceLossHigh(); } auto low() { return performanceLossLow(); } template auto alarmHigh(Args... args) { return performanceLossAlarmHigh(std::forward(args)...); } template auto alarmLow(Args... args) { return performanceLossAlarmLow(std::forward(args)...); } template auto alarmHighSignalAsserted(Args... args) { return performanceLossHighAlarmAsserted(std::forward(args)...); } template auto alarmHighSignalDeasserted(Args... args) { return performanceLossHighAlarmDeasserted(std::forward(args)...); } template auto alarmLowSignalAsserted(Args... args) { return performanceLossLowAlarmAsserted(std::forward(args)...); } template auto alarmLowSignalDeasserted(Args... args) { return performanceLossLowAlarmDeasserted(std::forward(args)...); } }; } // namespace phosphor::virtualSensor