QDaq  0.2.6
Qt-based Data Aqcuisition
 All Classes Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Slots | Protected Member Functions | Properties | List of all members
QDaqDataBuffer Class Reference

A class that provides storage of channel or other data. More...

#include <QDaqDataBuffer.h>

Inheritance diagram for QDaqDataBuffer:
Inheritance graph
[legend]
Collaboration diagram for QDaqDataBuffer:
Collaboration graph
[legend]

Public Slots

void clear ()
 Clear all data.
 
void push (const QDaqVector &v)
 Append a new row of values. More...
 
QDaqVector get (int i)
 Return the i-th QDaqBuffer.
 
- Public Slots inherited from QDaqObject
QString errorBacktrace (int maxItems=10) const
 Print a backtrace of recent errors in this QDaqObject.
 
QString path () const
 Return the object's path in the QDaq tree. More...
 
QString objectTree () const
 Output in a string the object hierarchy beneath this object.
 
QString listProperties () const
 List the objects properties.
 
QString listFunctions () const
 List the objects scriptable functions.
 
QDaqObjectparent () const
 
QDaqObjectList children () const
 Return a list of children of this object.
 
bool hasChildren () const
 Returns true if the object has children.
 
QDaqObjectappendChild (QDaqObject *obj)
 Adds a new child QDaqObject, as the last child and returns a pointer to it.
 
QDaqObjectinsertBefore (QDaqObject *newobj, QDaqObject *existingobj)
 Adds a new child QDaqObject, before an existing child and returns a pointer to it.
 
QDaqObjectclone ()
 Clone a QDaqObject with its child objects.
 
QDaqObjectremoveChild (QDaqObject *obj)
 Remove a child and return a pointer to it.
 
QDaqObjectreplaceChild (QDaqObject *newobj, QDaqObject *oldobj)
 Replace a child and return a pointer to the old child.
 
QDaqObjectfindChild (const QString &name) const
 Find the first child QDaqObject with objectName equal to name.
 

Protected Member Functions

virtual void writeh5 (H5::Group *h5g, QDaqH5File *f) const
 Write contents of the object to a H5 group. More...
 
virtual void readh5 (H5::Group *h5g, QDaqH5File *f)
 Read contents of the object from a H5 group. More...
 
virtual bool run ()
 Perform the QDaqDataBuffer tasks within a loop. More...
 
- Protected Member Functions inherited from QDaqJob
virtual bool arm_ ()
 Performs internal initialization for the job. More...
 
virtual void disarm_ ()
 Performs internal de-initialization. More...
 
bool setArmed (bool on)
 Arms or disarms a job. More...
 
virtual bool exec ()
 Called when the job is executed. More...
 
- Protected Member Functions inherited from QDaqObject
void pushError (const QString &type, const QString &descr=QString()) const
 Push an error in the error queue.
 
void throwScriptError (const QString &msg) const
 Throw a script error with message msg.
 
bool checkName (const QString &name) const
 Check if name is a legal name for an QDaqObject. More...
 

Properties

uint backBufferDepth
 Size of the back buffer in rows.
 
uint capacity
 Total capacity (allocated memory) of the data buffer in rows.
 
uint size
 Current size of the data buffer in rows.
 
uint columns
 Number of data columns.
 
bool circular
 True if buffer is circular.
 
QDaqObjectList channels
 A QList of the channels monitored by this object.
 
QStringList columnNames
 A list of column names.
 
- Properties inherited from QDaqJob
bool armed
 True if job is armed. More...
 
QString runCode
 Script code executed by the job at each repetition. More...
 
QString armCode
 Script code executed by the job in the arming face. More...
 
QString disarmCode
 Script code executed by the job in the dis-arming face. More...
 

Additional Inherited Members

- Signals inherited from QDaqObject
void propertiesChanged ()
 Fired when object properties have changed.
 
void updateWidgets ()
 Fired when widgets need update.
 
- Public Member Functions inherited from QDaqJob
Q_INVOKABLE QDaqJob (const QString &name)
 QDaqJob constructor. More...
 
virtual void attach ()
 Attach this QDaqObject to the QDaq tree. More...
 
virtual void detach ()
 Detach this QDaqObject from the QDaq tree. More...
 
QDaqLooptopLoop () const
 Returns the top level loop that this job belongs to.
 
QDaqLooploop () const
 Returns the loop that this job belongs to.
 
virtual QDaqScriptEngine * loopEngine () const
 Returns the QDaqScriptEngine of the top level loop.
 
- Public Member Functions inherited from QDaqObject
Q_INVOKABLE QDaqObject (const QString &name)
 Construct a QDaqObject with a name. More...
 
bool isAttached () const
 Returns true is this object is attached to the QDaq tree.
 
- Static Public Member Functions inherited from QDaqObject
static QDaqRootroot ()
 Obtain a pointer to the one-and-only QDaqRoot object.
 
static QDaqObjectfromPath (const QString &path)
 Return a pointer to an object given its full path in the QDaq tree. More...
 
- Public Attributes inherited from QDaqObject
QMutex comm_lock
 A recursive mutex for synching thread access to this object.
 

Detailed Description

A class that provides storage of channel or other data.

If QDaqDataBuffer is used within a QDaqLoop then at each repetition it will store the values of all channels that have been assigned to it. The data are stored internally as a matrix of QDaqBuffer objects, keeping one QDaqBuffer per channel. A new row of data is added at each loop repetition.

QDaqDataBuffer has an internal back buffer, where data generated in the loop thread are initially stored. The data is later transferred to the main buffer whenever possible and becomes available to the main application thread. The process is marshalled internally by a semaphore and the Qt signal/slot mechanism. Increasing the size of the back buffer can prevent data loss in fast loops.

The QDaqDataBuffer may be also used as a static object outside of a loop. Data may be appended by the push() function.

Definition at line 34 of file QDaqDataBuffer.h.

Member Function Documentation

void QDaqDataBuffer::push ( const QDaqVector v)
slot

Append a new row of values.

Parameters
vVector of data values. v.size() must be equal to size().

Definition at line 357 of file QDaqDataBuffer.cpp.

void QDaqDataBuffer::readh5 ( H5::Group *  g,
QDaqH5File *  f 
)
protectedvirtual

Read contents of the object from a H5 group.

The base class implementation reads all properties (static & dynamic) from corresponding datasets of the HDF5 file group.

Reimplement in QDaqObject descendants to read additional data.

Parameters
gHDF5 Group object

Reimplemented from QDaqObject.

Definition at line 46 of file QDaqH5Serialize.cpp.

bool QDaqDataBuffer::run ( )
protectedvirtual

Perform the QDaqDataBuffer tasks within a loop.

The following tasks are performed at each loop repetition

  • the object tries to acquire a free back buffer packet
  • If succesfull it fills the packet with data from the assigned channels and signals the main thread to collect the packet.
  • otherwise it pushes a QDaq error that data got lost
Returns
QDaqJob::run()

Reimplemented from QDaqJob.

Definition at line 251 of file QDaqDataBuffer.cpp.

void QDaqDataBuffer::writeh5 ( H5::Group *  g,
QDaqH5File *  f 
) const
protectedvirtual

Write contents of the object to a H5 group.

The base class implementation writes all properties (static & dynamic) as datasets of the HDF5 file group.

Reimplement in QDaqObject descendants to write additional data.

Parameters
gHDF5 Group object

Reimplemented from QDaqObject.

Definition at line 22 of file QDaqH5Serialize.cpp.


The documentation for this class was generated from the following files: