Brad Bishop | 43b6ba7 | 2017-01-05 21:45:28 -0500 | [diff] [blame] | 1 | #include <algorithm> |
| 2 | #include <sdbusplus/server.hpp> |
| 3 | #include <sdbusplus/exception.hpp> |
| 4 | #include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp> |
| 5 | |
| 6 | namespace sdbusplus |
| 7 | { |
| 8 | namespace xyz |
| 9 | { |
| 10 | namespace openbmc_project |
| 11 | { |
| 12 | namespace Sensor |
| 13 | { |
| 14 | namespace Threshold |
| 15 | { |
| 16 | namespace server |
| 17 | { |
| 18 | |
| 19 | Warning::Warning(bus::bus& bus, const char* path) |
| 20 | : _xyz_openbmc_project_Sensor_Threshold_Warning_interface( |
| 21 | bus, path, _interface, _vtable, this) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | |
| 26 | |
| 27 | auto Warning::warningHigh() const -> |
| 28 | int64_t |
| 29 | { |
| 30 | return _warningHigh; |
| 31 | } |
| 32 | |
| 33 | int Warning::_callback_get_WarningHigh( |
| 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<Warning*>(context); |
| 45 | m.append(convertForMessage(o->warningHigh())); |
| 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 | |
| 56 | auto Warning::warningHigh(int64_t value) -> |
| 57 | int64_t |
| 58 | { |
| 59 | if (_warningHigh != value) |
| 60 | { |
| 61 | _warningHigh = value; |
| 62 | _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningHigh"); |
| 63 | } |
| 64 | |
| 65 | return _warningHigh; |
| 66 | } |
| 67 | |
| 68 | int Warning::_callback_set_WarningHigh( |
| 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<Warning*>(context); |
| 78 | |
| 79 | int64_t v{}; |
| 80 | m.read(v); |
| 81 | o->warningHigh(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 | |
| 92 | namespace details |
| 93 | { |
| 94 | namespace Warning |
| 95 | { |
| 96 | static const auto _property_WarningHigh = |
| 97 | utility::tuple_to_array(message::types::type_id< |
| 98 | int64_t>()); |
| 99 | } |
| 100 | } |
| 101 | auto Warning::warningLow() const -> |
| 102 | int64_t |
| 103 | { |
| 104 | return _warningLow; |
| 105 | } |
| 106 | |
| 107 | int Warning::_callback_get_WarningLow( |
| 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<Warning*>(context); |
| 119 | m.append(convertForMessage(o->warningLow())); |
| 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 | |
| 130 | auto Warning::warningLow(int64_t value) -> |
| 131 | int64_t |
| 132 | { |
| 133 | if (_warningLow != value) |
| 134 | { |
| 135 | _warningLow = value; |
| 136 | _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningLow"); |
| 137 | } |
| 138 | |
| 139 | return _warningLow; |
| 140 | } |
| 141 | |
| 142 | int Warning::_callback_set_WarningLow( |
| 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<Warning*>(context); |
| 152 | |
| 153 | int64_t v{}; |
| 154 | m.read(v); |
| 155 | o->warningLow(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 | |
| 166 | namespace details |
| 167 | { |
| 168 | namespace Warning |
| 169 | { |
| 170 | static const auto _property_WarningLow = |
| 171 | utility::tuple_to_array(message::types::type_id< |
| 172 | int64_t>()); |
| 173 | } |
| 174 | } |
| 175 | auto Warning::warningAlarmHigh() const -> |
| 176 | bool |
| 177 | { |
| 178 | return _warningAlarmHigh; |
| 179 | } |
| 180 | |
| 181 | int Warning::_callback_get_WarningAlarmHigh( |
| 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<Warning*>(context); |
| 193 | m.append(convertForMessage(o->warningAlarmHigh())); |
| 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 | |
| 204 | auto Warning::warningAlarmHigh(bool value) -> |
| 205 | bool |
| 206 | { |
| 207 | if (_warningAlarmHigh != value) |
| 208 | { |
| 209 | _warningAlarmHigh = value; |
| 210 | _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningAlarmHigh"); |
| 211 | } |
| 212 | |
| 213 | return _warningAlarmHigh; |
| 214 | } |
| 215 | |
| 216 | int Warning::_callback_set_WarningAlarmHigh( |
| 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<Warning*>(context); |
| 226 | |
| 227 | bool v{}; |
| 228 | m.read(v); |
| 229 | o->warningAlarmHigh(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 | |
| 240 | namespace details |
| 241 | { |
| 242 | namespace Warning |
| 243 | { |
| 244 | static const auto _property_WarningAlarmHigh = |
| 245 | utility::tuple_to_array(message::types::type_id< |
| 246 | bool>()); |
| 247 | } |
| 248 | } |
| 249 | auto Warning::warningAlarmLow() const -> |
| 250 | bool |
| 251 | { |
| 252 | return _warningAlarmLow; |
| 253 | } |
| 254 | |
| 255 | int Warning::_callback_get_WarningAlarmLow( |
| 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<Warning*>(context); |
| 267 | m.append(convertForMessage(o->warningAlarmLow())); |
| 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 | |
| 278 | auto Warning::warningAlarmLow(bool value) -> |
| 279 | bool |
| 280 | { |
| 281 | if (_warningAlarmLow != value) |
| 282 | { |
| 283 | _warningAlarmLow = value; |
| 284 | _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningAlarmLow"); |
| 285 | } |
| 286 | |
| 287 | return _warningAlarmLow; |
| 288 | } |
| 289 | |
| 290 | int Warning::_callback_set_WarningAlarmLow( |
| 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<Warning*>(context); |
| 300 | |
| 301 | bool v{}; |
| 302 | m.read(v); |
| 303 | o->warningAlarmLow(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 | |
| 314 | namespace details |
| 315 | { |
| 316 | namespace Warning |
| 317 | { |
| 318 | static const auto _property_WarningAlarmLow = |
| 319 | utility::tuple_to_array(message::types::type_id< |
| 320 | bool>()); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | |
| 325 | const vtable::vtable_t Warning::_vtable[] = { |
| 326 | vtable::start(), |
| 327 | vtable::property("WarningHigh", |
| 328 | details::Warning::_property_WarningHigh |
| 329 | .data(), |
| 330 | _callback_get_WarningHigh, |
| 331 | _callback_set_WarningHigh, |
| 332 | vtable::property_::emits_change), |
| 333 | vtable::property("WarningLow", |
| 334 | details::Warning::_property_WarningLow |
| 335 | .data(), |
| 336 | _callback_get_WarningLow, |
| 337 | _callback_set_WarningLow, |
| 338 | vtable::property_::emits_change), |
| 339 | vtable::property("WarningAlarmHigh", |
| 340 | details::Warning::_property_WarningAlarmHigh |
| 341 | .data(), |
| 342 | _callback_get_WarningAlarmHigh, |
| 343 | _callback_set_WarningAlarmHigh, |
| 344 | vtable::property_::emits_change), |
| 345 | vtable::property("WarningAlarmLow", |
| 346 | details::Warning::_property_WarningAlarmLow |
| 347 | .data(), |
| 348 | _callback_get_WarningAlarmLow, |
| 349 | _callback_set_WarningAlarmLow, |
| 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 | |