MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / channelOffsetToJson

Method channelOffsetToJson

src/Hal/SensorDataProvider.cpp:410–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410void SensorDataProvider::channelOffsetToJson(JsonArray& jsonOffset, const ISensorChannel& channel) const
411{
412 switch (channel.getDataType())
413 {
414 case ISensorChannel::DataType::DATA_TYPE_INVALID:
415 (void)jsonOffset.add("NaN");
416 break;
417
418 case ISensorChannel::DataType::DATA_TYPE_UINT64: {
419 const SensorChannelUInt64* uint64Channel = reinterpret_cast<const SensorChannelUInt64*>(&channel);
420
421 (void)jsonOffset.add(uint64Channel->getOffset());
422 }
423 break;
424
425 case ISensorChannel::DataType::DATA_TYPE_UINT32: {
426 const SensorChannelUInt32* uint32Channel = reinterpret_cast<const SensorChannelUInt32*>(&channel);
427
428 (void)jsonOffset.add(uint32Channel->getOffset());
429 }
430 break;
431
432 case ISensorChannel::DataType::DATA_TYPE_INT32: {
433 const SensorChannelInt32* int32Channel = reinterpret_cast<const SensorChannelInt32*>(&channel);
434
435 (void)jsonOffset.add(int32Channel->getOffset());
436 }
437 break;
438
439 case ISensorChannel::DataType::DATA_TYPE_FLOAT32: {
440 const SensorChannelFloat32* float32Channel = reinterpret_cast<const SensorChannelFloat32*>(&channel);
441
442 (void)jsonOffset.add(float32Channel->getOffset());
443 }
444 break;
445
446 case ISensorChannel::DataType::DATA_TYPE_BOOL:
447 (void)jsonOffset.add("NaN");
448 break;
449
450 default:
451 (void)jsonOffset.add("NaN");
452 break;
453 }
454}
455
456void SensorDataProvider::channelOffsetFromJson(ISensorChannel& channel, JsonVariantConst jsonOffset) const
457{

Callers

nothing calls this directly

Calls 2

getDataTypeMethod · 0.45
getOffsetMethod · 0.45

Tested by

no test coverage detected