blob: 31c30e87dbd510271ab0f140eb390dc42aa633f8 [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>
5#include <xyz/openbmc_project/Sensor/Threshold/SoftShutdown/server.hpp>
6#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
7
8namespace phosphor::virtualSensor
9{
10
11template <typename... T>
12using ServerObject = typename sdbusplus::server::object::object<T...>;
13
14using CriticalIface =
15 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Critical;
16using CriticalObject = ServerObject<CriticalIface>;
17
18using WarningIface =
19 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning;
20using WarningObject = ServerObject<WarningIface>;
21
22using SoftShutdownIface =
23 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::SoftShutdown;
24using SoftShutdownObject = ServerObject<SoftShutdownIface>;
25
26using HardShutdownIface =
27 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::HardShutdown;
28using HardShutdownObject = ServerObject<HardShutdownIface>;
29
30template <typename T>
31struct Threshold
32{};
33
34template <>
35struct Threshold<WarningObject>
36{
37 public:
38 static double high(WarningObject* iface)
39 {
40 return iface->warningHigh();
41 }
42 static double low(WarningObject* iface)
43 {
44 return iface->warningLow();
45 }
46
47 static bool alarmHigh(WarningObject* iface)
48 {
49 return iface->warningAlarmHigh();
50 }
51
52 static bool alarmLow(WarningObject* iface)
53 {
54 return iface->warningAlarmLow();
55 }
56
57 static void alarmHigh(WarningObject* iface, bool value)
58 {
59 iface->warningAlarmHigh(value);
60 }
61
62 static void alarmLow(WarningObject* iface, bool value)
63 {
64 iface->warningAlarmLow(value);
65 }
66
67 static const char* name()
68 {
69 return "Warning";
70 }
71};
72
73template <>
74struct Threshold<CriticalObject>
75{
76 public:
77 static double high(CriticalObject* iface)
78 {
79 return iface->criticalHigh();
80 }
81 static double low(CriticalObject* iface)
82 {
83 return iface->criticalLow();
84 }
85
86 static bool alarmHigh(CriticalObject* iface)
87 {
88 return iface->criticalAlarmHigh();
89 }
90
91 static bool alarmLow(CriticalObject* iface)
92 {
93 return iface->criticalAlarmLow();
94 }
95
96 static void alarmHigh(CriticalObject* iface, bool value)
97 {
98 iface->criticalAlarmHigh(value);
99 }
100
101 static void alarmLow(CriticalObject* iface, bool value)
102 {
103 iface->criticalAlarmLow(value);
104 }
105
106 static const char* name()
107 {
108 return "Critical";
109 }
110};
111
112template <>
113struct Threshold<SoftShutdownObject>
114{
115 public:
116 static double high(SoftShutdownObject* iface)
117 {
118 return iface->softShutdownHigh();
119 }
120 static double low(SoftShutdownObject* iface)
121 {
122 return iface->softShutdownLow();
123 }
124
125 static bool alarmHigh(SoftShutdownObject* iface)
126 {
127 return iface->softShutdownAlarmHigh();
128 }
129
130 static bool alarmLow(SoftShutdownObject* iface)
131 {
132 return iface->softShutdownAlarmLow();
133 }
134
135 static void alarmHigh(SoftShutdownObject* iface, bool value)
136 {
137 iface->softShutdownAlarmHigh(value);
138 }
139
140 static void alarmLow(SoftShutdownObject* iface, bool value)
141 {
142 iface->softShutdownAlarmLow(value);
143 }
144
145 static const char* name()
146 {
147 return "SoftShutdown";
148 }
149};
150
151template <>
152struct Threshold<HardShutdownObject>
153{
154 public:
155 static double high(HardShutdownObject* iface)
156 {
157 return iface->hardShutdownHigh();
158 }
159 static double low(HardShutdownObject* iface)
160 {
161 return iface->hardShutdownLow();
162 }
163
164 static bool alarmHigh(HardShutdownObject* iface)
165 {
166 return iface->hardShutdownAlarmHigh();
167 }
168
169 static bool alarmLow(HardShutdownObject* iface)
170 {
171 return iface->hardShutdownAlarmLow();
172 }
173
174 static void alarmHigh(HardShutdownObject* iface, bool value)
175 {
176 iface->hardShutdownAlarmHigh(value);
177 }
178
179 static void alarmLow(HardShutdownObject* iface, bool value)
180 {
181 iface->hardShutdownAlarmLow(value);
182 }
183
184 static const char* name()
185 {
186 return "HardShutdown";
187 }
188};
189
190} // namespace phosphor::virtualSensor