Download Pelican User Guide

Transcript
56
Pelican Reference
throw QString("EmulatorExample: "
"Packet size must be a whole number of doubles.");
// Check that the packet size is not empty.
if (_packetSize == 0)
throw QString("EmulatorExample: Packet size must be > 0.");
// Initialise the packet.
_packet.resize(_packetSize);
}
void EmulatorExample::getPacketData(char*& ptr, unsigned long& size)
{
// Set the output data.
ptr = _packet.data();
size = _packetSize;
// Fill the packet.
unsigned nDoubles = _packet.size() / sizeof(double);
for (unsigned i = 0; i < nDoubles; ++i)
reinterpret_cast<double*>(ptr)[i] = _initialValue + _counter;
// Increment counter for next time.
_counter++;
}
} // namespace pelican
To use the emulator, invoke the emulator driver as follows:
ConfigNode emulatorConfig(xmlString);
EmulatorDriver emulator(new EmulatorExample(emulatorConfig));
Generated on Tue Jan 22 2013 11:07:31 for Pelican User Guide by Doxygen