libPaceventsWriter 2.0(r200)
Library for Writing .pacevents Files
|
Writes pacevents files. More...
#include <PaceventsWriter.h>
Signals | |
void | newChunkStarted () |
Public Member Functions | |
Constructors, destructor and methods for handling files | |
PaceventsWriter (QObject *parent=0) | |
PaceventsWriter (QFile *file, QObject *parent=0) | |
~PaceventsWriter () | |
void | useFile (QFile *file) |
void | finalize () |
Setters for header contents | |
void | setCompressionLevel (quint8 level) |
Sets the compression level used for measurement data. | |
void | setEventsPerChunk (quint64 events) |
Sets the number of events in each data chunk. | |
void | setStartOfMeasurement (const QDateTime &starttime) |
Sets the start time of a measurement. | |
void | setStopOfMeasurement (const QDateTime &stoptime) |
Sets the stop time of a measurement. | |
void | setColumnContents (const QList< Pac::DataFileColumns > &colcontents) |
Sets the type of content of each event's data 'columns'. | |
void | setColumnTypes (const QList< Pac::DataFileColumType > &coltypes) |
Sets the columns' data types. | |
void | setNodeIds (const QList< quint8 > &nodeids) |
Defines the index to node id mapping. | |
void | setNodeIdsToPhi (const QHash< quint8, float > &phi) |
Sets each node's phi angle. | |
void | setNodeIdsToTheta (const QHash< quint8, float > &theta) |
Sets each node's theta angle. | |
void | setSetupTree (const QMap< QString, QString > &setuptree) |
Sets the setup tree. | |
void | setFlags (Pac::DataFileFlags flags) |
Sets the flags that should be active in the resulting file. | |
void | setFinalComment (const QString &comment) |
Sets the Final comment appended to the file. | |
Event recording | |
void | writeEvent (const QByteArray &data) |
Writes pacevents files.
This class writes events in the pacevents format to disk. It first creates a format specific header, receives the serialized events, compresses them and writes them grouped in chunks to enable selective readout.
To be able to write the data this class expects a pointer to an already opened writeable QFile object.
The typical useage of this class is as follows:
The data files consist of a variable length (since version 3) header and a data part. The header contains a number of fixed and variable length fields beginning with a magic number (4 bytes), the file format version (4 bytes uint) and the 8 byte address of the data part's beginning. This pointer exists since file format version 3 and allows SpectraPac the skipping of extended header data that a newer version of PacMaster produced. After the data part pointer follws a 1-byte uint containing the used compressionlevel.
The data part consists of chunks of 'eventspercompressionchunk' compressed events. To overcome the missing random access to the compressed data the stream stops after 1E6 events and is followed by two 8-byte-pointers containing the address of the previous and next chunk's first byte. The sequence therefore looks like this:
* Magic number (4 bytes) * File format version (4 bytes) * Pointer to first byte of first chunk (8 bytes) * Pointer to last backpointer (8 bytes) * Compressionlevel (1 byte) * Events per compression-chunk (8 bytes) * Start timestamp (8 bytes) * Stop timestamp (8 bytes) * Number of records (8 bytes) * ****************************************** * ** PacEvent::getColumnHeader() ** * ****************************************** * Number of nodes (1 byte) * ****************************************** * **Node IDs and angles (9 bytes per node)** * ****************************************** * Setup tree length in bytes (4 bytes) * ****************************************** * ** Setup tree ** * ****************************************** * Status flags (1 byte) * ****************************************** * ** Place for future extensions ** * ****************************************** * Pointer to 1st byte of second chunk * ****************************************** * * Data of first chunk (1E6 events) * * ****************************************** * Pointer to 1st byte of first chunk * Pointer to 1st byte of third chunk * ****************************************** * * Data of second chunk * * ****************************************** * Pointer to 1st byte of second chunk * Pointer to 1st byte of fourth chunk * ****************************************** * * Data of third chunk * * ****************************************** * ... * ... * Pointer to 1st byte of the penultimate chunk * 0-Pointer * ****************************************** * * Data of last chunk * * ****************************************** * Pointer to 1st byte of last chunk * *EOF* *
PaceventsWriter::PaceventsWriter | ( | QObject * | parent = 0 | ) |
PaceventsWriter::PaceventsWriter | ( | QFile * | file, |
QObject * | parent = 0 |
||
) |
PaceventsWriter::~PaceventsWriter | ( | ) |
void PaceventsWriter::finalize | ( | ) |
Finalizes the file currently written and resets the internal pointer.
void PaceventsWriter::newChunkStarted | ( | ) | [signal] |
void PaceventsWriter::setColumnContents | ( | const QList< Pac::DataFileColumns > & | colcontents | ) |
Sets the type of content of each event's data 'columns'.
void PaceventsWriter::setColumnTypes | ( | const QList< Pac::DataFileColumType > & | coltypes | ) |
Sets the columns' data types.
void PaceventsWriter::setCompressionLevel | ( | quint8 | level | ) |
Sets the compression level used for measurement data.
void PaceventsWriter::setEventsPerChunk | ( | quint64 | events | ) |
Sets the number of events in each data chunk.
void PaceventsWriter::setFinalComment | ( | const QString & | comment | ) |
Sets the Final comment appended to the file.
void PaceventsWriter::setFlags | ( | Pac::DataFileFlags | flags | ) |
Sets the flags that should be active in the resulting file.
void PaceventsWriter::setNodeIds | ( | const QList< quint8 > & | nodeids | ) |
Defines the index to node id mapping.
void PaceventsWriter::setNodeIdsToPhi | ( | const QHash< quint8, float > & | phi | ) |
Sets each node's phi angle.
phi | node id => phi, phi must be in the interval between 0.0° and 360.0° (in degree)! |
void PaceventsWriter::setNodeIdsToTheta | ( | const QHash< quint8, float > & | theta | ) |
Sets each node's theta angle.
phi | node id => theta, theta must be in the interval between -90.0° and 90.0° (in degree)! |
void PaceventsWriter::setSetupTree | ( | const QMap< QString, QString > & | setuptree | ) |
Sets the setup tree.
void PaceventsWriter::setStartOfMeasurement | ( | const QDateTime & | starttime | ) |
Sets the start time of a measurement.
void PaceventsWriter::setStopOfMeasurement | ( | const QDateTime & | stoptime | ) |
Sets the stop time of a measurement.
void PaceventsWriter::useFile | ( | QFile * | file | ) |
Sets the file to be used for writing
void PaceventsWriter::writeEvent | ( | const QByteArray & | data | ) |