1 #pragma once 2 3 #include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp> 4 #include <xyz/openbmc_project/Sensor/Threshold/HardShutdown/server.hpp> 5 #include <xyz/openbmc_project/Sensor/Threshold/PerformanceLoss/server.hpp> 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 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>; 21 using PerformanceLossObject = ServerObject<threshold_ns::PerformanceLoss>; 22 23 template <typename T> 24 struct Threshold; 25 26 template <> 27 struct Threshold<WarningObject> : public WarningObject 28 { 29 static constexpr auto name = "Warning"; 30 using WarningObject::WarningObject; 31 32 auto high() 33 { 34 return warningHigh(); 35 } 36 auto low() 37 { 38 return warningLow(); 39 } 40 41 template <typename... Args> 42 auto alarmHigh(Args... args) 43 { 44 return warningAlarmHigh(std::forward<Args>(args)...); 45 } 46 47 template <typename... Args> 48 auto alarmLow(Args... args) 49 { 50 return warningAlarmLow(std::forward<Args>(args)...); 51 } 52 }; 53 54 template <> 55 struct Threshold<CriticalObject> : public CriticalObject 56 { 57 static constexpr auto name = "Critical"; 58 using CriticalObject::CriticalObject; 59 60 auto high() 61 { 62 return criticalHigh(); 63 } 64 auto low() 65 { 66 return criticalLow(); 67 } 68 69 template <typename... Args> 70 auto alarmHigh(Args... args) 71 { 72 return criticalAlarmHigh(std::forward<Args>(args)...); 73 } 74 75 template <typename... Args> 76 auto alarmLow(Args... args) 77 { 78 return criticalAlarmLow(std::forward<Args>(args)...); 79 } 80 }; 81 82 template <> 83 struct Threshold<SoftShutdownObject> : public SoftShutdownObject 84 { 85 static constexpr auto name = "SoftShutdown"; 86 using SoftShutdownObject::SoftShutdownObject; 87 88 auto high() 89 { 90 return softShutdownHigh(); 91 } 92 auto low() 93 { 94 return softShutdownLow(); 95 } 96 97 template <typename... Args> 98 auto alarmHigh(Args... args) 99 { 100 return softShutdownAlarmHigh(std::forward<Args>(args)...); 101 } 102 103 template <typename... Args> 104 auto alarmLow(Args... args) 105 { 106 return softShutdownAlarmLow(std::forward<Args>(args)...); 107 } 108 }; 109 110 template <> 111 struct Threshold<HardShutdownObject> : public HardShutdownObject 112 { 113 static constexpr auto name = "HardShutdown"; 114 using HardShutdownObject::HardShutdownObject; 115 116 auto high() 117 { 118 return hardShutdownHigh(); 119 } 120 auto low() 121 { 122 return hardShutdownLow(); 123 } 124 125 template <typename... Args> 126 auto alarmHigh(Args... args) 127 { 128 return hardShutdownAlarmHigh(std::forward<Args>(args)...); 129 } 130 131 template <typename... Args> 132 auto alarmLow(Args... args) 133 { 134 return hardShutdownAlarmLow(std::forward<Args>(args)...); 135 } 136 }; 137 138 template <> 139 struct Threshold<PerformanceLossObject> : public PerformanceLossObject 140 { 141 static constexpr auto name = "PerformanceLoss"; 142 using PerformanceLossObject::PerformanceLossObject; 143 144 auto high() 145 { 146 return performanceLossHigh(); 147 } 148 auto low() 149 { 150 return performanceLossLow(); 151 } 152 153 template <typename... Args> 154 auto alarmHigh(Args... args) 155 { 156 return performanceLossAlarmHigh(std::forward<Args>(args)...); 157 } 158 159 template <typename... Args> 160 auto alarmLow(Args... args) 161 { 162 return performanceLossAlarmLow(std::forward<Args>(args)...); 163 } 164 }; 165 166 } // namespace phosphor::virtualSensor 167