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

A class that represent a stream of numerical data, a signal. More...

#include <QDaqChannel.h>

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

Public Types

enum  ChannelType {
  Normal, Clock, Random, Inc,
  Dec
}
 Type of the channel. More...
 
enum  AveragingType {
  None, Running, Delta, ForgettingFactor,
  Median
}
 Type of channel averaging. More...
 
enum  NumberFormat { General, FixedPoint, Scientific, Time }
 Type of format for textual representation of channel data. More...
 

Public Slots

void push (double v)
 Insert a value into the channel. More...
 
void clear ()
 Clear internal channel memory. More...
 
double value () const
 Get the current channel value. More...
 
double std () const
 Get the current channel value standard deviation. More...
 
- 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.
 

Public Member Functions

virtual void detach ()
 Detach this QDaqObject from the QDaq tree. More...
 
virtual QString formatedValue ()
 Returns the channel value formatted according to format/digits.
 
- 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...
 
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.
 

Protected Member Functions

virtual bool arm_ ()
 Performs internal initialization for the job. More...
 
virtual bool run ()
 Perform channel tasks. More...
 
- Protected Member Functions inherited from QDaqJob
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...
 
virtual void writeh5 (H5::Group *g, QDaqH5File *f) const
 Write contents of the object to a H5 group. More...
 
virtual void readh5 (H5::Group *g, QDaqH5File *f)
 Read contents of the object from a H5 group. More...
 

Properties

ChannelType type
 Type of the channel.
 
QString signalName
 User supplied signal name. More...
 
QString unit
 User supplied unit of measurement. More...
 
NumberFormat format
 Option for formatting channel data for textual representation. More...
 
int digits
 Number of decimal digits to display. More...
 
QDaqVector range
 Signal range. More...
 
double offset
 Channel offset. More...
 
double multiplier
 Channel multiplier. More...
 
AveragingType averaging
 Type of on-line averaging.
 
double forgettingFactor
 Forgetting factor value. More...
 
uint depth
 Averaging depth. More...
 
uint memsize
 Channel memory used. More...
 
bool dataReady
 True if valid data exist on the channel. More...
 
QString parserExpression
 muParser Expression. More...
 
- 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.
 
- 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 represent a stream of numerical data, a signal.

Real time data is handeled in QDaq through the QDaqChannel class. E.g., an instrument provides measurement data through QDaqChannel objects.

QDaqChannel provides tools for displaying, transforming, averaging the data of the channel.

Definition at line 28 of file QDaqChannel.h.

Member Enumeration Documentation

Type of channel averaging.

Enumerator
None 

No averaging.

Running 

Running (box) averaging.

Delta 

Running average for signals of alternating sign.

ForgettingFactor 

Running average with forgetting (exponential weighting).

Median 

Running median filter.

Definition at line 104 of file QDaqChannel.h.

Type of the channel.

Enumerator
Normal 

Normal channel - nothing special.

Clock 

Records time in each repetition.

Can be used for time measurement.

Random 

Generates random samples.

Inc 

Starting from an initial value increments by 1 in each repetition.

Dec 

Starting from an initial value decrements by 1 in each repetition.

Definition at line 93 of file QDaqChannel.h.

Type of format for textual representation of channel data.

Enumerator
General 

No special formating.

FixedPoint 

No special formating.

Scientific 

No special formating.

Time 

No special formating.

Definition at line 115 of file QDaqChannel.h.

Member Function Documentation

bool QDaqChannel::arm_ ( )
protectedvirtual

Performs internal initialization for the job.

It is called by the setArmed() function.

This function can be reimplemented to perform specific initialization for a job. The parent class arm_() function should be called afterwards.

In the default implementation, if a loopEngine() exists the script code is checked against the script engine for errors.

If initialization is sucessfull it returns true, otherwise the function returns false.

Reimplemented from QDaqJob.

Definition at line 130 of file QDaqChannel.cpp.

void QDaqChannel::clear ( )
slot

Clear internal channel memory.

Definition at line 297 of file QDaqChannel.cpp.

void QDaqChannel::detach ( )
virtual

Detach this QDaqObject from the QDaq tree.

This function is called just before the object becomes detached from the QDaq tree.

In the base class implementation it first calls detach() for each child QDaqObject and then signal root that the object is removed from the qdaq tree.

Subclasses may reimplement this function to perform needed actions before detaching.

Reimplemented from QDaqJob.

Definition at line 32 of file QDaqChannel.cpp.

void QDaqChannel::push ( double  v)
inlineslot

Insert a value into the channel.

Definition at line 214 of file QDaqChannel.h.

bool QDaqChannel::run ( )
protectedvirtual

Perform channel tasks.

The tasks are performed in the following order:

  • If channel is of a special type, then its function is performed. E.g. if the type is Random a random number is generated.
  • averaging is performed
  • the mean value goes through muParser
  • the mean value is scaled and shifted (multiplier*v + offset)
  • the mean value is checked for under/over range

If new data is available the updateWidgets signal is emitted.

Returns
always return true.

Reimplemented from QDaqJob.

Definition at line 214 of file QDaqChannel.cpp.

double QDaqChannel::std ( ) const
inlineslot

Get the current channel value standard deviation.

Definition at line 220 of file QDaqChannel.h.

double QDaqChannel::value ( ) const
inlineslot

Get the current channel value.

Definition at line 218 of file QDaqChannel.h.

Property Documentation

bool QDaqChannel::dataReady
read

True if valid data exist on the channel.

If dataReady is true, then value() & std() return valid numbers.

Definition at line 83 of file QDaqChannel.h.

uint QDaqChannel::depth
readwrite

Averaging depth.

Number of past data values used in averaging.

Definition at line 75 of file QDaqChannel.h.

int QDaqChannel::digits
readwrite

Number of decimal digits to display.

Used when displaying the channel in fixed or scientific format.

Definition at line 50 of file QDaqChannel.h.

double QDaqChannel::forgettingFactor
readwrite

Forgetting factor value.

Only used when this type of averaging is active.

Definition at line 71 of file QDaqChannel.h.

NumberFormat QDaqChannel::format
readwrite

Option for formatting channel data for textual representation.

Used when displaying the channel.

Definition at line 46 of file QDaqChannel.h.

uint QDaqChannel::memsize
read

Channel memory used.

Number of values stored in internal channel memory.

Definition at line 79 of file QDaqChannel.h.

double QDaqChannel::multiplier
readwrite

Channel multiplier.

Applied imediately when data is inserted in the channel by the transformation y=a*x+b. b is the offset and a is the multiplier.

Definition at line 64 of file QDaqChannel.h.

double QDaqChannel::offset
readwrite

Channel offset.

Applied imediately when data is inserted in the channel by the transformation y=a*x+b. b is the offset and a is the multiplier.

Definition at line 59 of file QDaqChannel.h.

QString QDaqChannel::parserExpression
readwrite

muParser Expression.

If set the expression is executed on the channel data. Note that the data goes first through muParser and then they are scaled with multiplier and offset.

Definition at line 88 of file QDaqChannel.h.

QDaqVector QDaqChannel::range
readwrite

Signal range.

When the signal is outside the range an error is raised.

Definition at line 54 of file QDaqChannel.h.

QString QDaqChannel::signalName
readwrite

User supplied signal name.

Used when displaying the channel. It is different from the object name.

Definition at line 38 of file QDaqChannel.h.

QString QDaqChannel::unit
readwrite

User supplied unit of measurement.

Used when displaying the channel.

Definition at line 42 of file QDaqChannel.h.


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