blob: 755174d3105082d8af529619a216f73ad7c03a5e [file] [log] [blame]
Brad Bishop43b6ba72017-01-05 21:45:28 -05001#include <algorithm>
2#include <sdbusplus/server.hpp>
3#include <sdbusplus/exception.hpp>
4#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
5
6namespace sdbusplus
7{
8namespace xyz
9{
10namespace openbmc_project
11{
12namespace Sensor
13{
14namespace Threshold
15{
16namespace server
17{
18
19Critical::Critical(bus::bus& bus, const char* path)
20 : _xyz_openbmc_project_Sensor_Threshold_Critical_interface(
21 bus, path, _interface, _vtable, this)
22{
23}
24
25
26
27auto Critical::criticalHigh() const ->
28 int64_t
29{
30 return _criticalHigh;
31}
32
33int Critical::_callback_get_CriticalHigh(
34 sd_bus* bus, const char* path, const char* interface,
35 const char* property, sd_bus_message* reply, void* context,
36 sd_bus_error* error)
37{
38 using sdbusplus::server::binding::details::convertForMessage;
39
40 try
41 {
42 auto m = message::message(sd_bus_message_ref(reply));
43
44 auto o = static_cast<Critical*>(context);
45 m.append(convertForMessage(o->criticalHigh()));
46 }
47 catch(sdbusplus::internal_exception_t& e)
48 {
49 sd_bus_error_set_const(error, e.name(), e.description());
50 return -EINVAL;
51 }
52
53 return true;
54}
55
56auto Critical::criticalHigh(int64_t value) ->
57 int64_t
58{
59 if (_criticalHigh != value)
60 {
61 _criticalHigh = value;
62 _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalHigh");
63 }
64
65 return _criticalHigh;
66}
67
68int Critical::_callback_set_CriticalHigh(
69 sd_bus* bus, const char* path, const char* interface,
70 const char* property, sd_bus_message* value, void* context,
71 sd_bus_error* error)
72{
73 try
74 {
75 auto m = message::message(sd_bus_message_ref(value));
76
77 auto o = static_cast<Critical*>(context);
78
79 int64_t v{};
80 m.read(v);
81 o->criticalHigh(v);
82 }
83 catch(sdbusplus::internal_exception_t& e)
84 {
85 sd_bus_error_set_const(error, e.name(), e.description());
86 return -EINVAL;
87 }
88
89 return true;
90}
91
92namespace details
93{
94namespace Critical
95{
96static const auto _property_CriticalHigh =
97 utility::tuple_to_array(message::types::type_id<
98 int64_t>());
99}
100}
101auto Critical::criticalLow() const ->
102 int64_t
103{
104 return _criticalLow;
105}
106
107int Critical::_callback_get_CriticalLow(
108 sd_bus* bus, const char* path, const char* interface,
109 const char* property, sd_bus_message* reply, void* context,
110 sd_bus_error* error)
111{
112 using sdbusplus::server::binding::details::convertForMessage;
113
114 try
115 {
116 auto m = message::message(sd_bus_message_ref(reply));
117
118 auto o = static_cast<Critical*>(context);
119 m.append(convertForMessage(o->criticalLow()));
120 }
121 catch(sdbusplus::internal_exception_t& e)
122 {
123 sd_bus_error_set_const(error, e.name(), e.description());
124 return -EINVAL;
125 }
126
127 return true;
128}
129
130auto Critical::criticalLow(int64_t value) ->
131 int64_t
132{
133 if (_criticalLow != value)
134 {
135 _criticalLow = value;
136 _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalLow");
137 }
138
139 return _criticalLow;
140}
141
142int Critical::_callback_set_CriticalLow(
143 sd_bus* bus, const char* path, const char* interface,
144 const char* property, sd_bus_message* value, void* context,
145 sd_bus_error* error)
146{
147 try
148 {
149 auto m = message::message(sd_bus_message_ref(value));
150
151 auto o = static_cast<Critical*>(context);
152
153 int64_t v{};
154 m.read(v);
155 o->criticalLow(v);
156 }
157 catch(sdbusplus::internal_exception_t& e)
158 {
159 sd_bus_error_set_const(error, e.name(), e.description());
160 return -EINVAL;
161 }
162
163 return true;
164}
165
166namespace details
167{
168namespace Critical
169{
170static const auto _property_CriticalLow =
171 utility::tuple_to_array(message::types::type_id<
172 int64_t>());
173}
174}
175auto Critical::criticalAlarmHigh() const ->
176 bool
177{
178 return _criticalAlarmHigh;
179}
180
181int Critical::_callback_get_CriticalAlarmHigh(
182 sd_bus* bus, const char* path, const char* interface,
183 const char* property, sd_bus_message* reply, void* context,
184 sd_bus_error* error)
185{
186 using sdbusplus::server::binding::details::convertForMessage;
187
188 try
189 {
190 auto m = message::message(sd_bus_message_ref(reply));
191
192 auto o = static_cast<Critical*>(context);
193 m.append(convertForMessage(o->criticalAlarmHigh()));
194 }
195 catch(sdbusplus::internal_exception_t& e)
196 {
197 sd_bus_error_set_const(error, e.name(), e.description());
198 return -EINVAL;
199 }
200
201 return true;
202}
203
204auto Critical::criticalAlarmHigh(bool value) ->
205 bool
206{
207 if (_criticalAlarmHigh != value)
208 {
209 _criticalAlarmHigh = value;
210 _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalAlarmHigh");
211 }
212
213 return _criticalAlarmHigh;
214}
215
216int Critical::_callback_set_CriticalAlarmHigh(
217 sd_bus* bus, const char* path, const char* interface,
218 const char* property, sd_bus_message* value, void* context,
219 sd_bus_error* error)
220{
221 try
222 {
223 auto m = message::message(sd_bus_message_ref(value));
224
225 auto o = static_cast<Critical*>(context);
226
227 bool v{};
228 m.read(v);
229 o->criticalAlarmHigh(v);
230 }
231 catch(sdbusplus::internal_exception_t& e)
232 {
233 sd_bus_error_set_const(error, e.name(), e.description());
234 return -EINVAL;
235 }
236
237 return true;
238}
239
240namespace details
241{
242namespace Critical
243{
244static const auto _property_CriticalAlarmHigh =
245 utility::tuple_to_array(message::types::type_id<
246 bool>());
247}
248}
249auto Critical::criticalAlarmLow() const ->
250 bool
251{
252 return _criticalAlarmLow;
253}
254
255int Critical::_callback_get_CriticalAlarmLow(
256 sd_bus* bus, const char* path, const char* interface,
257 const char* property, sd_bus_message* reply, void* context,
258 sd_bus_error* error)
259{
260 using sdbusplus::server::binding::details::convertForMessage;
261
262 try
263 {
264 auto m = message::message(sd_bus_message_ref(reply));
265
266 auto o = static_cast<Critical*>(context);
267 m.append(convertForMessage(o->criticalAlarmLow()));
268 }
269 catch(sdbusplus::internal_exception_t& e)
270 {
271 sd_bus_error_set_const(error, e.name(), e.description());
272 return -EINVAL;
273 }
274
275 return true;
276}
277
278auto Critical::criticalAlarmLow(bool value) ->
279 bool
280{
281 if (_criticalAlarmLow != value)
282 {
283 _criticalAlarmLow = value;
284 _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalAlarmLow");
285 }
286
287 return _criticalAlarmLow;
288}
289
290int Critical::_callback_set_CriticalAlarmLow(
291 sd_bus* bus, const char* path, const char* interface,
292 const char* property, sd_bus_message* value, void* context,
293 sd_bus_error* error)
294{
295 try
296 {
297 auto m = message::message(sd_bus_message_ref(value));
298
299 auto o = static_cast<Critical*>(context);
300
301 bool v{};
302 m.read(v);
303 o->criticalAlarmLow(v);
304 }
305 catch(sdbusplus::internal_exception_t& e)
306 {
307 sd_bus_error_set_const(error, e.name(), e.description());
308 return -EINVAL;
309 }
310
311 return true;
312}
313
314namespace details
315{
316namespace Critical
317{
318static const auto _property_CriticalAlarmLow =
319 utility::tuple_to_array(message::types::type_id<
320 bool>());
321}
322}
323
324
325const vtable::vtable_t Critical::_vtable[] = {
326 vtable::start(),
327 vtable::property("CriticalHigh",
328 details::Critical::_property_CriticalHigh
329 .data(),
330 _callback_get_CriticalHigh,
331 _callback_set_CriticalHigh,
332 vtable::property_::emits_change),
333 vtable::property("CriticalLow",
334 details::Critical::_property_CriticalLow
335 .data(),
336 _callback_get_CriticalLow,
337 _callback_set_CriticalLow,
338 vtable::property_::emits_change),
339 vtable::property("CriticalAlarmHigh",
340 details::Critical::_property_CriticalAlarmHigh
341 .data(),
342 _callback_get_CriticalAlarmHigh,
343 _callback_set_CriticalAlarmHigh,
344 vtable::property_::emits_change),
345 vtable::property("CriticalAlarmLow",
346 details::Critical::_property_CriticalAlarmLow
347 .data(),
348 _callback_get_CriticalAlarmLow,
349 _callback_set_CriticalAlarmLow,
350 vtable::property_::emits_change),
351 vtable::end()
352};
353
354} // namespace server
355} // namespace Threshold
356} // namespace Sensor
357} // namespace openbmc_project
358} // namespace xyz
359} // namespace sdbusplus
360