libPaceventsWriter 2.0(r200)
Library for Writing .pacevents Files
Signals

PaceventsWriter Class Reference

Writes pacevents files. More...

#include <PaceventsWriter.h>

List of all members.

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)

Detailed Description

Writes pacevents files.

Author:
Matthias Nagl <mnagl@uni-goettingen.de>

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:

  1. Provide a file pointer
  2. Set all parameters that have to be set before the first call to writeEvent()
  3. write measurement data using writeEvent()
  4. Set remaining parameters
  5. Finalize the file using finalize()

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.

Warning:
Format versions >=3 are incompatible to version 1 and 2. Use the standalone conversion tool paceventsV2to3 to update older files!

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*
 * 

Constructor & Destructor Documentation

PaceventsWriter::PaceventsWriter ( QObject *  parent = 0)
PaceventsWriter::PaceventsWriter ( QFile *  file,
QObject *  parent = 0 
)
PaceventsWriter::~PaceventsWriter ( )

Member Function Documentation

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'.

Note:
Must be set before the first call to writeEvent()!
void PaceventsWriter::setColumnTypes ( const QList< Pac::DataFileColumType > &  coltypes)

Sets the columns' data types.

Note:
Must be set before the first call to writeEvent()!
void PaceventsWriter::setCompressionLevel ( quint8  level)

Sets the compression level used for measurement data.

Note:
Must be set before the first call to writeEvent()!
void PaceventsWriter::setEventsPerChunk ( quint64  events)

Sets the number of events in each data chunk.

Note:
Must be set before the first call to writeEvent()!
void PaceventsWriter::setFinalComment ( const QString &  comment)

Sets the Final comment appended to the file.

Note:
Can be called anytime before finalizing.
void PaceventsWriter::setFlags ( Pac::DataFileFlags  flags)

Sets the flags that should be active in the resulting file.

Note:
The flag Pac::Finalized is set automatically by finalize()!
Can be called anytime before finalizing.
void PaceventsWriter::setNodeIds ( const QList< quint8 > &  nodeids)

Defines the index to node id mapping.

Note:
Must be set before the first call to writeEvent()!
void PaceventsWriter::setNodeIdsToPhi ( const QHash< quint8, float > &  phi)

Sets each node's phi angle.

Note:
Must be set before the first call to writeEvent()!
Parameters:
phinode 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.

Note:
Must be set before the first call to writeEvent()!
Parameters:
phinode 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.

Note:
Must be set before the first call to writeEvent()!
void PaceventsWriter::setStartOfMeasurement ( const QDateTime &  starttime)

Sets the start time of a measurement.

Note:
If starttime.isValid() returns false while the header is written the current time while writing the header is used
Must be set before the first call to writeEvent() to have effect!
void PaceventsWriter::setStopOfMeasurement ( const QDateTime &  stoptime)

Sets the stop time of a measurement.

Note:
Can be called anytime before finalizing.
If stoptime.isValid() returns false the current time while finalizing is used
void PaceventsWriter::useFile ( QFile *  file)

Sets the file to be used for writing

void PaceventsWriter::writeEvent ( const QByteArray &  data)

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Properties Friends Defines