blob: 96486d31f2f1d352b6fa3189d67b212d45f5cde3 [file] [log] [blame]
Matt Spinler8f5e6112021-01-15 10:44:32 -06001#pragma once
2
3#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
4#include <xyz/openbmc_project/Sensor/Threshold/HardShutdown/server.hpp>
Matt Spinlerb306b032021-02-01 10:05:46 -06005#include <xyz/openbmc_project/Sensor/Threshold/PerformanceLoss/server.hpp>
Matt Spinler8f5e6112021-01-15 10:44:32 -06006#include <xyz/openbmc_project/Sensor/Threshold/SoftShutdown/server.hpp>
7#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
8
9namespace phosphor::virtualSensor
10{
11
12template <typename... T>
13using ServerObject = typename sdbusplus::server::object::object<T...>;
14
Patrick Williamsfdb826d2021-01-20 14:37:53 -060015namespace threshold_ns =
16 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server;
17using CriticalObject = ServerObject<threshold_ns::Critical>;
18using WarningObject = ServerObject<threshold_ns::Warning>;
19using SoftShutdownObject = ServerObject<threshold_ns::SoftShutdown>;
20using HardShutdownObject = ServerObject<threshold_ns::HardShutdown>;
Matt Spinlerb306b032021-02-01 10:05:46 -060021using PerformanceLossObject = ServerObject<threshold_ns::PerformanceLoss>;
Matt Spinler8f5e6112021-01-15 10:44:32 -060022
23template <typename T>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060024struct Threshold;
Matt Spinler8f5e6112021-01-15 10:44:32 -060025
Rashmica Gupta1dff7dc2021-07-27 19:43:31 +100026struct 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 Spinler8f5e6112021-01-15 10:44:32 -060051template <>
Rashmica Gupta1dff7dc2021-07-27 19:43:31 +100052struct Threshold<WarningObject> : public WarningObject, public Hysteresis
Matt Spinler8f5e6112021-01-15 10:44:32 -060053{
Patrick Williamsfdb826d2021-01-20 14:37:53 -060054 static constexpr auto name = "Warning";
55 using WarningObject::WarningObject;
56
57 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -060058 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060059 return warningHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -060060 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -060061 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -060062 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060063 return warningLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -060064 }
65
Patrick Williamsfdb826d2021-01-20 14:37:53 -060066 template <typename... Args>
67 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060068 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060069 return warningAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060070 }
71
Patrick Williamsfdb826d2021-01-20 14:37:53 -060072 template <typename... Args>
73 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060074 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060075 return warningAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060076 }
George Hung4294e6d2021-04-14 20:58:21 +080077
78 template <typename... Args>
79 auto alarmHighSignalAsserted(Args... args)
80 {
81 return warningHighAlarmAsserted(std::forward<Args>(args)...);
82 }
83
84 template <typename... Args>
85 auto alarmHighSignalDeasserted(Args... args)
86 {
87 return warningHighAlarmDeasserted(std::forward<Args>(args)...);
88 }
89
90 template <typename... Args>
91 auto alarmLowSignalAsserted(Args... args)
92 {
93 return warningLowAlarmAsserted(std::forward<Args>(args)...);
94 }
95
96 template <typename... Args>
97 auto alarmLowSignalDeasserted(Args... args)
98 {
99 return warningLowAlarmDeasserted(std::forward<Args>(args)...);
100 }
Matt Spinler8f5e6112021-01-15 10:44:32 -0600101};
102
103template <>
Rashmica Gupta1dff7dc2021-07-27 19:43:31 +1000104struct Threshold<CriticalObject> : public CriticalObject, public Hysteresis
Matt Spinler8f5e6112021-01-15 10:44:32 -0600105{
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600106 static constexpr auto name = "Critical";
107 using CriticalObject::CriticalObject;
108
109 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600110 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600111 return criticalHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600112 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600113 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600114 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600115 return criticalLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600116 }
117
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600118 template <typename... Args>
119 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600120 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600121 return criticalAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600122 }
123
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600124 template <typename... Args>
125 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600126 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600127 return criticalAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600128 }
George Hung4294e6d2021-04-14 20:58:21 +0800129
130 template <typename... Args>
131 auto alarmHighSignalAsserted(Args... args)
132 {
133 return criticalHighAlarmAsserted(std::forward<Args>(args)...);
134 }
135
136 template <typename... Args>
137 auto alarmHighSignalDeasserted(Args... args)
138 {
139 return criticalHighAlarmDeasserted(std::forward<Args>(args)...);
140 }
141
142 template <typename... Args>
143 auto alarmLowSignalAsserted(Args... args)
144 {
145 return criticalLowAlarmAsserted(std::forward<Args>(args)...);
146 }
147
148 template <typename... Args>
149 auto alarmLowSignalDeasserted(Args... args)
150 {
151 return criticalLowAlarmDeasserted(std::forward<Args>(args)...);
152 }
Matt Spinler8f5e6112021-01-15 10:44:32 -0600153};
154
155template <>
Rashmica Gupta1dff7dc2021-07-27 19:43:31 +1000156struct Threshold<SoftShutdownObject> :
157 public SoftShutdownObject,
158 public Hysteresis
Matt Spinler8f5e6112021-01-15 10:44:32 -0600159{
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600160 static constexpr auto name = "SoftShutdown";
161 using SoftShutdownObject::SoftShutdownObject;
162
163 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600164 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600165 return softShutdownHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600166 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600167 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600168 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600169 return softShutdownLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600170 }
171
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600172 template <typename... Args>
173 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600174 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600175 return softShutdownAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600176 }
177
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600178 template <typename... Args>
179 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600180 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600181 return softShutdownAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600182 }
George Hung4294e6d2021-04-14 20:58:21 +0800183
184 template <typename... Args>
185 auto alarmHighSignalAsserted(Args... args)
186 {
187 return softShutdownHighAlarmAsserted(std::forward<Args>(args)...);
188 }
189
190 template <typename... Args>
191 auto alarmHighSignalDeasserted(Args... args)
192 {
193 return softShutdownHighAlarmDeasserted(std::forward<Args>(args)...);
194 }
195
196 template <typename... Args>
197 auto alarmLowSignalAsserted(Args... args)
198 {
199 return softShutdownLowAlarmAsserted(std::forward<Args>(args)...);
200 }
201
202 template <typename... Args>
203 auto alarmLowSignalDeasserted(Args... args)
204 {
205 return softShutdownLowAlarmDeasserted(std::forward<Args>(args)...);
206 }
Matt Spinler8f5e6112021-01-15 10:44:32 -0600207};
208
209template <>
Rashmica Gupta1dff7dc2021-07-27 19:43:31 +1000210struct Threshold<HardShutdownObject> :
211 public HardShutdownObject,
212 public Hysteresis
Matt Spinler8f5e6112021-01-15 10:44:32 -0600213{
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600214 static constexpr auto name = "HardShutdown";
215 using HardShutdownObject::HardShutdownObject;
216
217 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600218 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600219 return hardShutdownHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600220 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600221 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600222 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600223 return hardShutdownLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600224 }
225
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600226 template <typename... Args>
227 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600228 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600229 return hardShutdownAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600230 }
231
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600232 template <typename... Args>
233 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600234 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600235 return hardShutdownAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600236 }
George Hung4294e6d2021-04-14 20:58:21 +0800237
238 template <typename... Args>
239 auto alarmHighSignalAsserted(Args... args)
240 {
241 return hardShutdownHighAlarmAsserted(std::forward<Args>(args)...);
242 }
243
244 template <typename... Args>
245 auto alarmHighSignalDeasserted(Args... args)
246 {
247 return hardShutdownHighAlarmDeasserted(std::forward<Args>(args)...);
248 }
249
250 template <typename... Args>
251 auto alarmLowSignalAsserted(Args... args)
252 {
253 return hardShutdownLowAlarmAsserted(std::forward<Args>(args)...);
254 }
255
256 template <typename... Args>
257 auto alarmLowSignalDeasserted(Args... args)
258 {
259 return hardShutdownLowAlarmDeasserted(std::forward<Args>(args)...);
260 }
Matt Spinler8f5e6112021-01-15 10:44:32 -0600261};
262
Matt Spinlerb306b032021-02-01 10:05:46 -0600263template <>
Rashmica Gupta1dff7dc2021-07-27 19:43:31 +1000264struct Threshold<PerformanceLossObject> :
265 public PerformanceLossObject,
266 public Hysteresis
Matt Spinlerb306b032021-02-01 10:05:46 -0600267{
268 static constexpr auto name = "PerformanceLoss";
269 using PerformanceLossObject::PerformanceLossObject;
Rashmica Gupta1dff7dc2021-07-27 19:43:31 +1000270 double performanceLossHighHysteresis;
271 double performanceLossLowHysteresis;
Matt Spinlerb306b032021-02-01 10:05:46 -0600272
273 auto high()
274 {
275 return performanceLossHigh();
276 }
277 auto low()
278 {
279 return performanceLossLow();
280 }
281
282 template <typename... Args>
283 auto alarmHigh(Args... args)
284 {
285 return performanceLossAlarmHigh(std::forward<Args>(args)...);
286 }
287
288 template <typename... Args>
289 auto alarmLow(Args... args)
290 {
291 return performanceLossAlarmLow(std::forward<Args>(args)...);
292 }
George Hung4294e6d2021-04-14 20:58:21 +0800293
294 template <typename... Args>
295 auto alarmHighSignalAsserted(Args... args)
296 {
297 return performanceLossHighAlarmAsserted(std::forward<Args>(args)...);
298 }
299
300 template <typename... Args>
301 auto alarmHighSignalDeasserted(Args... args)
302 {
303 return performanceLossHighAlarmDeasserted(std::forward<Args>(args)...);
304 }
305
306 template <typename... Args>
307 auto alarmLowSignalAsserted(Args... args)
308 {
309 return performanceLossLowAlarmAsserted(std::forward<Args>(args)...);
310 }
311
312 template <typename... Args>
313 auto alarmLowSignalDeasserted(Args... args)
314 {
315 return performanceLossLowAlarmDeasserted(std::forward<Args>(args)...);
316 }
Matt Spinlerb306b032021-02-01 10:05:46 -0600317};
318
Matt Spinler8f5e6112021-01-15 10:44:32 -0600319} // namespace phosphor::virtualSensor