bool Analysis_Impl::addDataPoint(const std::vector<Measure>& measures) { OptionalDataPoint dataPoint = problem().createDataPoint(measures); if (dataPoint) { return addDataPoint(*dataPoint); } LOG(Error,"Cannot add DataPoint to Analysis '" << name() << "', because the provided " "measures were invalid for Problem '" << problem().name() << "'."); return false; }
void DiagnosticPacket::parseSweeps() { DataBuffer payload(m_payload); m_numSweeps = 1; //build the 1 sweep that we need to add DataSweep sweep; sweep.samplingType(DataSweep::samplingType_Diagnostic); sweep.frequency(m_frequency); sweep.nodeAddress(m_nodeAddress); //the data itself is the beacon timestamp. //use this for the current PC time sweep.timestamp(Timestamp::timeNow()); //get this sweep's node and base rssi values sweep.nodeRssi(m_nodeRSSI); sweep.baseRssi(m_baseRSSI); sweep.calApplied(true); //get the packet interval (in seconds) uint16 packetInterval = payload.read_uint16(); sweep.tick(payload.read_uint16()); sweep.sampleRate(SampleRate::Seconds(packetInterval)); size_t numInfoItemBytes = payload.size() - 4; size_t infoByteCounter = 0; ChannelData chData; //iterate over all of the info bytes while(infoByteCounter < numInfoItemBytes) { uint8 infoLen = payload.read_uint8(); uint8 infoId = payload.read_uint8(); addDataPoint(chData, payload, infoLen - 1, infoId); infoByteCounter += (infoLen + 1); } //add the channel data to the sweep sweep.data(chData); //add the sweep to the container of sweeps addSweep(sweep); }
void BufferedLdcPacket::parseSweeps() { //read the values from the payload uint8 channelMask = m_payload.read_uint8(PAYLOAD_OFFSET_CHANNEL_MASK); uint8 sampleRate = m_payload.read_uint8(PAYLOAD_OFFSET_SAMPLE_RATE); uint8 dataType = m_payload.read_uint8(PAYLOAD_OFFSET_DATA_TYPE); uint16 tick = m_payload.read_uint16(PAYLOAD_OFFSET_TICK); //set the data type of the packet m_dataType = static_cast<WirelessTypes::DataType>(dataType); //build the ChannelMask from the channel mask ChannelMask channels(channelMask); //calculate the size of a single sweep m_sweepSize = channels.count() * WirelessTypes::dataTypeSize(m_dataType); //if the sweep size is 0 (no channels active) if(m_sweepSize == 0) { //we only want to insert 1 sweep m_numSweeps = 1; } else { //calculate the number of sweeps in this packet m_numSweeps = (m_payload.size() - PAYLOAD_OFFSET_CHANNEL_DATA) / m_sweepSize; } //if we still have no sweeps, there was an error in the packet if(m_numSweeps == 0) { throw Error("Invalid Packet"); } //build the full nanosecond resolution timestamp from the seconds and nanoseconds values read above uint64 receivedTime = Timestamp::timeNow().nanoseconds(); //create a SampleRate object from the sampleRate byte SampleRate currentRate = SampleUtils::convertToSampleRate(sampleRate); //get the value to increment the timestamp by for each sweep (the timestamp from the packet only applies to the first sweep) const uint64 TS_INCREMENT = currentRate.samplePeriod().getNanoseconds(); //there are multiple sweeps in this packet (buffered) for(uint32 sweepItr = 0; sweepItr < m_numSweeps; sweepItr++) { //build a sweep to add DataSweep sweep; sweep.samplingType(DataSweep::samplingType_NonSync_Buffered); sweep.frequency(m_frequency); sweep.tick(tick++); sweep.nodeAddress(m_nodeAddress); sweep.sampleRate(currentRate); //calculate the timestamp to use for this sweep (last sweep gets PC timestamp, count backwards for the other sweeps) sweep.timestamp(Timestamp(receivedTime - (TS_INCREMENT * (m_numSweeps - (sweepItr + 1))))); //get this sweep's node and base rssi values sweep.nodeRssi(m_nodeRSSI); sweep.baseRssi(m_baseRSSI); //cals applied if the data type is float sweep.calApplied(m_dataType == WirelessTypes::dataType_float32); ChannelData chData; //the index of the channel data int chDataIndex = 0; uint8 lastActiveCh = channels.lastChEnabled(); //loop through all the channels for(uint8 chItr = 1; chItr <= lastActiveCh; ++chItr) { //if the current channel is enabled if(channels.enabled(chItr)) { //insert the data point into the ChannelData object for the wireless channel addDataPoint(chData, (chItr), chDataIndex, sweepItr, wirelessChannelFromChNum(chItr)); chDataIndex++; } } //add the channel data to the sweep sweep.data(chData); //add the sweep to the container of sweeps addSweep(sweep); } }