void DiagnosticPacket::addDataPoint(ChannelData& container, DataBuffer& payload, uint8 infoLength, uint8 infoId) const { switch(infoId) { //Current State case 0: container.emplace_back(WirelessChannel::channel_diag_state, 0, valueType_uint8, anyType(payload.read_uint8())); break; //Run Time case 1: //idle time container.emplace_back(WirelessChannel::channel_diag_runtime_idle, 0, valueType_uint32, anyType(payload.read_uint32())); //sleep time container.emplace_back(WirelessChannel::channel_diag_runtime_sleep, 0, valueType_uint32, anyType(payload.read_uint32())); //active run time container.emplace_back(WirelessChannel::channel_diag_runtime_activeRun, 0, valueType_uint32, anyType(payload.read_uint32())); //inactive run time container.emplace_back(WirelessChannel::channel_diag_runtime_inactiveRun, 0, valueType_uint32, anyType(payload.read_uint32())); break; //Reset Counter case 2: container.emplace_back(WirelessChannel::channel_diag_resetCounter, 0, valueType_uint16, anyType(payload.read_uint16())); break; //Battery flag case 3: container.emplace_back(WirelessChannel::channel_diag_lowBatteryFlag, 0, valueType_uint8, anyType(payload.read_uint8())); break; //Sample info case 4: //sweep index container.emplace_back(WirelessChannel::channel_diag_sweepIndex, 0, valueType_uint32, anyType(payload.read_uint32())); //bad sweep count container.emplace_back(WirelessChannel::channel_diag_badSweepCount, 0, valueType_uint32, anyType(payload.read_uint32())); break; //Transmit info case 5: //total transmissions container.emplace_back(WirelessChannel::channel_diag_totalTx, 0, valueType_uint32, anyType(payload.read_uint32())); //total retransmissions container.emplace_back(WirelessChannel::channel_diag_totalReTx, 0, valueType_uint32, anyType(payload.read_uint32())); //total dropped packets container.emplace_back(WirelessChannel::channel_diag_totalDroppedPackets, 0, valueType_uint32, anyType(payload.read_uint32())); break; //Built in Test result case 6: //BIT container.emplace_back(WirelessChannel::channel_diag_builtInTestResult, 0, valueType_uint32, anyType(payload.read_uint32())); break; //Unknown info default: { //read past the bytes we don't know about for(uint8 i = 0; i < infoLength; i++) { payload.read_uint8(); } } break; } }
void HclSmartBearing_RawPacket::parseSweeps_baseBoard() { typedef WirelessChannel WC; static const uint16 PAYLOAD_OFFSET_MAG_CONVERSION = 13; //read the values from the payload uint8 sensorErrorMask = m_payload.read_uint8(PAYLOAD_OFFSET_ERROR_MASK); uint8 sampleRate = m_payload.read_uint8(PAYLOAD_OFFSET_SAMPLE_RATE); uint16 tick = m_payload.read_uint16(PAYLOAD_OFFSET_TICK); uint64 timestampSeconds = m_payload.read_uint32(PAYLOAD_OFFSET_TS_SEC); //the timestamp (UTC) seconds part uint64 timestampNanos = m_payload.read_uint32(PAYLOAD_OFFSET_TS_NANOSEC); //the timestamp (UTC) nanoseconds part m_magConversionVal = static_cast<float>(m_payload.read_uint16(PAYLOAD_OFFSET_MAG_CONVERSION)); //build the full nanosecond resolution timestamp from the seconds and nanoseconds values read above uint64 realTimestamp = (timestampSeconds * TimeSpan::NANOSECONDS_PER_SECOND) + timestampNanos; //create a SampleRate object from the sampleRate byte SampleRate currentRate = SampleUtils::convertToSampleRate(sampleRate); //build the single sweep DataSweep sweep; sweep.samplingType(DataSweep::samplingType_SyncSampling); sweep.frequency(m_frequency); sweep.tick(tick); sweep.nodeAddress(m_nodeAddress); sweep.sampleRate(currentRate); sweep.timestamp(Timestamp(realTimestamp)); sweep.nodeRssi(m_nodeRSSI); sweep.baseRssi(m_baseRSSI); static const uint16 DATA_START = 15; ChannelData chData; chData.reserve(28); chData.emplace_back(WC::channel_error_code, 0, valueType_uint8, anyType(sensorErrorMask)); //Error Mask (not actually in payload) chData.emplace_back(WC::channel_hcl_rawBase_mag1_x, 1, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 0))); //Mag 1 - X chData.emplace_back(WC::channel_hcl_rawBase_mag1_y, 2, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 2))); //Mag 1 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag1_z, 3, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 4))); //Mag 1 - Z chData.emplace_back(WC::channel_hcl_rawBase_mag2_x, 4, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 6))); //Mag 2 - X chData.emplace_back(WC::channel_hcl_rawBase_mag2_y, 5, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 8))); //Mag 2 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag2_z, 6, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 10))); //Mag 2 - Z chData.emplace_back(WC::channel_hcl_rawBase_mag3_x, 7, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 12))); //Mag 3 - X chData.emplace_back(WC::channel_hcl_rawBase_mag3_y, 8, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 14))); //Mag 3 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag3_z, 9, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 16))); //Mag 3 - Z chData.emplace_back(WC::channel_hcl_rawBase_mag4_x, 10, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 18))); //Mag 4 - X chData.emplace_back(WC::channel_hcl_rawBase_mag4_y, 11, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 20))); //Mag 4 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag4_z, 12, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 22))); //Mag 4 - Z chData.emplace_back(WC::channel_hcl_rawBase_mag5_x, 13, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 24))); //Mag 5 - X chData.emplace_back(WC::channel_hcl_rawBase_mag5_y, 14, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 26))); //Mag 5 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag5_z, 15, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 28))); //Mag 5 - Z chData.emplace_back(WC::channel_hcl_rawBase_mag6_x, 16, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 30))); //Mag 6 - X chData.emplace_back(WC::channel_hcl_rawBase_mag6_y, 17, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 32))); //Mag 6 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag6_z, 18, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 34))); //Mag 6 - Z chData.emplace_back(WC::channel_hcl_rawBase_mag7_x, 19, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 36))); //Mag 7 - X chData.emplace_back(WC::channel_hcl_rawBase_mag7_y, 20, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 38))); //Mag 7 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag7_z, 21, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 40))); //Mag 7 - Z chData.emplace_back(WC::channel_hcl_rawBase_mag8_x, 22, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 42))); //Mag 8 - X chData.emplace_back(WC::channel_hcl_rawBase_mag8_y, 23, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 44))); //Mag 8 - Y chData.emplace_back(WC::channel_hcl_rawBase_mag8_z, 24, valueType_float, getMagChValue(m_payload.read_uint16(DATA_START + 46))); //Mag 8 - Z chData.emplace_back(WC::channel_hcl_rawBase_gyro_x, 25, valueType_float, anyType(m_payload.read_float(DATA_START + 48))); //Gyro - X chData.emplace_back(WC::channel_hcl_rawBase_gyro_y, 26, valueType_float, anyType(m_payload.read_float(DATA_START + 52))); //Gyro - Y chData.emplace_back(WC::channel_hcl_rawBase_gyro_z, 27, valueType_float, anyType(m_payload.read_float(DATA_START + 56))); //Gyro - Z //add all of the channel data to the sweep sweep.data(chData); //add the sweep to the container of sweeps addSweep(sweep); }
void HclSmartBearing_CalPacket::parseSweeps() { typedef WirelessChannel WC; //read the values from the payload uint8 sensorErrorMask = m_payload.read_uint8(PAYLOAD_OFFSET_ERROR_MASK); uint8 sampleRate = m_payload.read_uint8(PAYLOAD_OFFSET_SAMPLE_RATE); uint16 tick = m_payload.read_uint16(PAYLOAD_OFFSET_TICK); uint64 timestampSeconds = m_payload.read_uint32(PAYLOAD_OFFSET_TS_SEC); //the timestamp (UTC) seconds part uint64 timestampNanos = m_payload.read_uint32(PAYLOAD_OFFSET_TS_NANOSEC); //the timestamp (UTC) nanoseconds part //build the full nanosecond resolution timestamp from the seconds and nanoseconds values read above uint64 realTimestamp = (timestampSeconds * TimeSpan::NANOSECONDS_PER_SECOND) + timestampNanos; //create a SampleRate object from the sampleRate byte SampleRate currentRate = SampleUtils::convertToSampleRate(sampleRate); //build the single sweep DataSweep sweep; sweep.samplingType(DataSweep::samplingType_SyncSampling); sweep.frequency(m_frequency); sweep.tick(tick); sweep.nodeAddress(m_nodeAddress); sweep.sampleRate(currentRate); sweep.timestamp(Timestamp(realTimestamp)); sweep.nodeRssi(m_nodeRSSI); sweep.baseRssi(m_baseRSSI); sweep.calApplied(true); static const uint16 DATA_START = 13; ChannelData chData; chData.reserve(12); chData.emplace_back(WC::channel_error_code, 0, valueType_uint8, anyType(sensorErrorMask)); //Error Mask (not actually in payload) chData.emplace_back(WC::channel_hcl_axialLoadX, 1, valueType_int16, anyType(m_payload.read_int16(DATA_START + 0))); chData.emplace_back(WC::channel_hcl_axialLoadY, 2, valueType_int16, anyType(m_payload.read_int16(DATA_START + 2))); chData.emplace_back(WC::channel_hcl_axialLoadZ, 3, valueType_float, anyType(static_cast<float>(m_payload.read_int16(DATA_START + 4)) * 10)); chData.emplace_back(WC::channel_hcl_bendingMomentFlap, 4, valueType_int16, anyType(m_payload.read_int16(DATA_START + 6))); chData.emplace_back(WC::channel_hcl_bendingMomentLag, 5, valueType_int16, anyType(m_payload.read_int16(DATA_START + 8))); chData.emplace_back(WC::channel_hcl_bendingMomentPitch, 6, valueType_int16, anyType(m_payload.read_int16(DATA_START + 10))); chData.emplace_back(WC::channel_hcl_motionFlap_mag, 7, valueType_float, anyType(static_cast<float>(m_payload.read_int16(DATA_START + 12) / 1000.0))); chData.emplace_back(WC::channel_hcl_motionLag_mag, 8, valueType_float, anyType(static_cast<float>(m_payload.read_int16(DATA_START + 14) / 1000.0))); chData.emplace_back(WC::channel_hcl_motionPitch_mag, 9, valueType_float, anyType(static_cast<float>(m_payload.read_int16(DATA_START + 16) / 1000.0))); chData.emplace_back(WC::channel_hcl_motionFlap_inertial, 10, valueType_float, anyType(static_cast<float>(m_payload.read_int16(DATA_START + 18) / 1000.0))); chData.emplace_back(WC::channel_hcl_motionLag_inertial, 11, valueType_float, anyType(static_cast<float>(m_payload.read_int16(DATA_START + 20) / 1000.0))); chData.emplace_back(WC::channel_hcl_motionPitch_inertial, 12, valueType_float, anyType(static_cast<float>(m_payload.read_int16(DATA_START + 22) / 1000.0))); chData.emplace_back(WC::channel_hcl_cockingStiffness_mag, 13, valueType_int16, anyType(m_payload.read_int16(DATA_START + 24))); chData.emplace_back(WC::channel_hcl_cockingStiffness_inertial, 14, valueType_int16, anyType(m_payload.read_int16(DATA_START + 26))); chData.emplace_back(WC::channel_hcl_temperature, 15, valueType_int16, anyType(static_cast<int16>(m_payload.read_int8(DATA_START + 28)))); //add all of the channel data to the sweep sweep.data(chData); //add the sweep to the container of sweeps addSweep(sweep); }