pelican/examples/example-2/emulator/StreamEmulator.cpp
// Function called to obtain packet data.
// This function is called each time a new packet is required and is responsible
// for setting the data into the packet to be send.
//
// The function first updates the packet header and then sets the packet data
// (currently disabled for performance reasons).
//
// The data pointer of returned by this function is then written to the TCP
// socket by the emulator driver.
Function called to obtain packet data.
This function is called each time a new packet is required and is responsible
for setting the data into the packet to be send.

The function first updates the packet header and then sets the packet data
(currently disabled for performance reasons).

The data pointer of returned by this function is then written to the TCP
socket by the emulator driver.
Function called to obtain packet data . This function is called each time a new packet is required and is responsible for setting the data into the packet to be send . The function first updates the packet header and then sets the packet data ( currently disabled for performance reasons ) . The data pointer of returned by this function is then written to the TCP socket by the emulator driver .
void StreamEmulator::getPacketData(char*& data, unsigned long& bytes)
{
    if (packetCounter_ == 0)
        timer_.start();
    data = packet_.data();
    bytes = packetSize_;
    quint32* header1 = reinterpret_cast<quint32*>(data);
    header1[0] = packetSize_;
    header1[1] = packetCounter_;
    header1[2] = timer_.elapsed();
    qint32* header2 = reinterpret_cast<qint32*>(data + 3*sizeof(quint32));
    header2[0] = numPackets_;
    header2[1] = reportInterval_;
#if 0
    quint32* values = reinterpret_cast<quint32*>(data + headerSize_);
    for (size_t i = 0; i < numSamples_; ++i) {
        values[i] = (packetCounter_ * numSamples_) + i;
    }
#endif
    if (packetCounter_ > 0 && packetCounter_%reportInterval_ == 0) {
        printReport();
        timer_.restart();
    }
    ++packetCounter_; 
}
void StreamEmulator :: getPacketData ( char * & data , unsigned long & bytes ) { if ( packetCounter_ == 0 ) timer_ . start ( ) ; data = packet_ . data ( ) ; bytes = packetSize_ ; quint32 * header1 = reinterpret_cast < quint32 * > ( data ) ; header1 [ 0 ] = packetSize_ ; header1 [ 1 ] = packetCounter_ ; header1 [ 2 ] = timer_ . elapsed ( ) ; qint32 * header2 = reinterpret_cast < qint32 * > ( data + 3 * sizeof ( quint32 ) ) ; header2 [ 0 ] = numPackets_ ; header2 [ 1 ] = reportInterval_ ; #if 0 quint32 * values = reinterpret_cast < quint32 * > ( data + headerSize_ ) ; for ( size_t i = 0 ; i < numSamples_ ; ++ i ) { values [ i ] = ( packetCounter_ * numSamples_ ) + i ; } #endif if ( packetCounter_ > 0 && packetCounter_ % reportInterval_ == 0 ) { printReport ( ) ; timer_ . restart ( ) ; } ++ packetCounter_ ; }
Function called to obtain packet data.
Function called to obtain packet data .
// Update the packet header. // Fill data section. // (Note: this is a major bottleneck therefore disabled for benchmark) // Increment the packet counter.