示例#1
0
void convertchan2beam( ifstream& datastrm) {
  ostringstream ossmsg;

	int pktSize = chanpkt1.getDataSize() + sizeof(beamHdr);

  for (;;) {
    datastrm.read((char *) &chanpkt1, pktSize);  
    if (datastrm.gcount() != pktSize) {
      if (datastrm.eof()) return;  // EOF should occur on this read 
      ossmsg << "(1) unexpected data file read count " <<
        dec << datastrm.gcount();
      mylog(ossmsg);
      exit(EXIT_FAILURE);
    }
    chanpkt1.marshall();
    memcpy( reinterpret_cast<void *>(&beamHdr), 
	reinterpret_cast<void *>(&chanpkt1), sizeof(beamHdr)) ;
    
    datastrm.read((char *) &chanpkt2, pktSize);  
    if (datastrm.gcount() != pktSize) {
      ossmsg << "(2) unexpected data file read count " <<
        dec << datastrm.gcount();
      mylog(ossmsg);
      exit(EXIT_FAILURE);
    }
    chanpkt2.marshall();
    short2char(reinterpret_cast<signed char *>(beampkt.getData()),
		reinterpret_cast <signed short *>(chanpkt1.getData()),
		reinterpret_cast <signed short *>(chanpkt2.getData()),
      		chanpkt1.getDataSize());


    // sanity check for 0xaabbccdd endian order value
    if (beamHdr.order != ATADataPacketHeader::CORRECT_ENDIAN) {
      mylog("output packet header does not contain 0xaabbccdd endian value");
      exit(EXIT_FAILURE);
    } 
    // fix some of the fields to make packets look like they came
    // from the beamformer
    beamHdr.src = ATADataPacketHeader::BEAM_104MHZ;  // not really 
    beamHdr.chan = 1;
    beamHdr.seq = sequence_num++;
    beamHdr.len = 2048;
    memcpy( reinterpret_cast<void *>(&beampkt), 
		reinterpret_cast<void *>(&beamHdr), sizeof(beamHdr));
    // write the SonATA channelizer compatible packet to stdout
    cout.write((char *) &beampkt, pktSize); 
  }
}
示例#2
0
void convertchan2beam( ifstream& datastrm) {
  ostringstream ossmsg;

	int pktSize = chanpkt1.getDataSize() + sizeof(beamHdr);

  for (;;) {
    datastrm.read((char *) &chanpkt1, pktSize);  
    if (datastrm.gcount() != pktSize) {
      if (datastrm.eof()) return;  // EOF should occur on this read 
      ossmsg << "(1) unexpected data file read count " <<
        dec << datastrm.gcount();
      mylog(ossmsg);
        ossmsg << "Packets: " << packetCount << endl
                << seqGaps << " gap(s) in sequence; " << totalMissedPackets
                << " Total Missed Packets" << endl;
	mylog(ossmsg);
      exit(EXIT_FAILURE);
    }
    chanpkt1.marshall();

// Copy the header into the output buffer

    memcpy( reinterpret_cast<void *>(&beamHdr), 
	reinterpret_cast<void *>(&chanpkt1), sizeof(beamHdr)) ;
    

	if (packetCount == 0)
	{
		expected[0] = expected[1] = beamHdr.seq;
	}

// Check for missing packets
	checkForMissingPackets(&beamHdr );
    datastrm.read((char *) &chanpkt2, pktSize);  
    if (datastrm.gcount() != pktSize) {
      ossmsg << "(2) unexpected data file read count " <<
        dec << datastrm.gcount();
      mylog(ossmsg);
        ossmsg << "Packets: " << packetCount << endl
                << seqGaps << " gap(s) in sequence; " << totalMissedPackets
                << " Total Missed Packets" << endl;
	mylog(ossmsg);
      exit(EXIT_FAILURE);
    }
// Read the next packet

    chanpkt2.marshall();
    memcpy( reinterpret_cast<void *>(&chanHdr), 
	reinterpret_cast<void *>(&chanpkt2), sizeof(chanHdr)) ;
// Check for missing packets
	checkForMissingPackets( &chanHdr );
// Convert both packets' data to 8 bit complex and store in 
// output buffer.

    short2char(reinterpret_cast<signed char *>(beampkt.getData()),
		reinterpret_cast <signed short *>(chanpkt1.getData()),
		reinterpret_cast <signed short *>(chanpkt2.getData()),
      		chanpkt1.getDataSize());


    // sanity check for 0xaabbccdd endian order value
    if (beamHdr.order != ATADataPacketHeader::CORRECT_ENDIAN) {
      mylog("output packet header does not contain 0xaabbccdd endian value");
        ossmsg << "Packets: " << packetCount << endl
                << seqGaps << " gap(s) in sequence; " << totalMissedPackets
                << " Total Missed Packets" << endl;
	mylog(ossmsg);
      exit(EXIT_FAILURE);
    } 
    // fix some of the fields to make packets look like they came
    // from the beamformer
    beamHdr.src = ATADataPacketHeader::BEAM_104MHZ;  // not really 
    beamHdr.chan = 1;
    beamHdr.seq = sequence_num++;
    beamHdr.len = 2048;
    memcpy( reinterpret_cast<void *>(&beampkt), 
		reinterpret_cast<void *>(&beamHdr), sizeof(beamHdr));
    // write the SonATA channelizer compatible packet to stdout
    cout.write((char *) &beampkt, pktSize); 
  }
}