blob: b01d86da07b706c2d94940667cbed6efefc7c67d [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
26template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060027struct Threshold<WarningObject> : public WarningObject
Matt Spinler8f5e6112021-01-15 10:44:32 -060028{
Patrick Williamsfdb826d2021-01-20 14:37:53 -060029 static constexpr auto name = "Warning";
30 using WarningObject::WarningObject;
31
32 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -060033 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060034 return warningHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -060035 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -060036 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -060037 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060038 return warningLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -060039 }
40
Patrick Williamsfdb826d2021-01-20 14:37:53 -060041 template <typename... Args>
42 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060043 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060044 return warningAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060045 }
46
Patrick Williamsfdb826d2021-01-20 14:37:53 -060047 template <typename... Args>
48 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060049 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060050 return warningAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060051 }
52};
53
54template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060055struct Threshold<CriticalObject> : public CriticalObject
Matt Spinler8f5e6112021-01-15 10:44:32 -060056{
Patrick Williamsfdb826d2021-01-20 14:37:53 -060057 static constexpr auto name = "Critical";
58 using CriticalObject::CriticalObject;
59
60 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -060061 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060062 return criticalHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -060063 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -060064 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -060065 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060066 return criticalLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -060067 }
68
Patrick Williamsfdb826d2021-01-20 14:37:53 -060069 template <typename... Args>
70 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060071 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060072 return criticalAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060073 }
74
Patrick Williamsfdb826d2021-01-20 14:37:53 -060075 template <typename... Args>
76 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060077 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060078 return criticalAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -060079 }
80};
81
82template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -060083struct Threshold<SoftShutdownObject> : public SoftShutdownObject
Matt Spinler8f5e6112021-01-15 10:44:32 -060084{
Patrick Williamsfdb826d2021-01-20 14:37:53 -060085 static constexpr auto name = "SoftShutdown";
86 using SoftShutdownObject::SoftShutdownObject;
87
88 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -060089 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060090 return softShutdownHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -060091 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -060092 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -060093 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -060094 return softShutdownLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -060095 }
96
Patrick Williamsfdb826d2021-01-20 14:37:53 -060097 template <typename... Args>
98 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -060099 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600100 return softShutdownAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600101 }
102
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600103 template <typename... Args>
104 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600105 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600106 return softShutdownAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600107 }
108};
109
110template <>
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600111struct Threshold<HardShutdownObject> : public HardShutdownObject
Matt Spinler8f5e6112021-01-15 10:44:32 -0600112{
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600113 static constexpr auto name = "HardShutdown";
114 using HardShutdownObject::HardShutdownObject;
115
116 auto high()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600117 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600118 return hardShutdownHigh();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600119 }
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600120 auto low()
Matt Spinler8f5e6112021-01-15 10:44:32 -0600121 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600122 return hardShutdownLow();
Matt Spinler8f5e6112021-01-15 10:44:32 -0600123 }
124
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600125 template <typename... Args>
126 auto alarmHigh(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600127 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600128 return hardShutdownAlarmHigh(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600129 }
130
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600131 template <typename... Args>
132 auto alarmLow(Args... args)
Matt Spinler8f5e6112021-01-15 10:44:32 -0600133 {
Patrick Williamsfdb826d2021-01-20 14:37:53 -0600134 return hardShutdownAlarmLow(std::forward<Args>(args)...);
Matt Spinler8f5e6112021-01-15 10:44:32 -0600135 }
136};
137
Matt Spinlerb306b032021-02-01 10:05:46 -0600138template <>
139struct 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
Matt Spinler8f5e6112021-01-15 10:44:32 -0600166} // namespace phosphor::virtualSensor