QDaq
0.2.6
Qt-based Data Aqcuisition
|
A class encapsulating a software loop. More...
#include <QDaqJob.h>
Public Slots | |
bool | arm () |
Arm the loop. More... | |
void | disarm () |
Disarm the loop. | |
QString | stat () |
Print loop statistics. | |
void | createLoopEngine () |
Create a dedicated QDaqScriptEngine. More... | |
![]() | |
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. | |
QDaqObject * | parent () const |
QDaqObjectList | children () const |
Return a list of children of this object. | |
bool | hasChildren () const |
Returns true if the object has children. | |
QDaqObject * | appendChild (QDaqObject *obj) |
Adds a new child QDaqObject, as the last child and returns a pointer to it. | |
QDaqObject * | insertBefore (QDaqObject *newobj, QDaqObject *existingobj) |
Adds a new child QDaqObject, before an existing child and returns a pointer to it. | |
QDaqObject * | clone () |
Clone a QDaqObject with its child objects. | |
QDaqObject * | removeChild (QDaqObject *obj) |
Remove a child and return a pointer to it. | |
QDaqObject * | replaceChild (QDaqObject *newobj, QDaqObject *oldobj) |
Replace a child and return a pointer to the old child. | |
QDaqObject * | findChild (const QString &name) const |
Find the first child QDaqObject with objectName equal to name. | |
Signals | |
void | abort () |
This is emitted if the loop aborts due to an error. | |
![]() | |
void | propertiesChanged () |
Fired when object properties have changed. | |
void | updateWidgets () |
Fired when widgets need update. | |
Public Member Functions | |
bool | isTop () const |
Return true if this is a top level loop. | |
QDaqLoop * | parentLoop () const |
Return the parent loop of this loop. | |
![]() | |
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... | |
QDaqLoop * | topLoop () const |
Returns the top level loop that this job belongs to. | |
QDaqLoop * | loop () const |
Returns the loop that this job belongs to. | |
virtual QDaqScriptEngine * | loopEngine () const |
Returns the QDaqScriptEngine of the top level loop. | |
![]() | |
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 | exec () |
Called when a loop is executed. More... | |
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 | run () |
This function performs the actual task of this QDaqJob. More... | |
![]() | |
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 | |
uint | count |
Number of executed loop cycles (read-only). More... | |
uint | limit |
Total number of cycles to be executed. More... | |
uint | delay |
Number of parent loop cycles before this loop is called. More... | |
uint | preload |
Preload the internal counter. More... | |
uint | period |
The repetition period in ms. More... | |
![]() | |
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 | |
![]() | |
static QDaqRoot * | root () |
Obtain a pointer to the one-and-only QDaqRoot object. | |
static QDaqObject * | fromPath (const QString &path) |
Return a pointer to an object given its full path in the QDaq tree. More... | |
![]() | |
QMutex | comm_lock |
A recursive mutex for synching thread access to this object. | |
A class encapsulating a software loop.
QDaqLoop is used to execute a number of child-jobs and/or child-loops.
By setting the class properties we can arrange for a number of different execution scenarios: repetitive with given period repeat for ever or for a given number of cycles skip execution every delay cycles single shot
A QDaqLoop that has no QDaqLoop ancestor is considered a "top level loop" (isTop() returns true). Otherwise the loop is a child-loop.
When arm() is called on a top level loop, a new QTimerThread is spawned that calls exec() at each timer repetition.
If arm() is called on a child loop, then it simply arms all child jobs. The exec() function of a child loop is called from the top level loop thread.
To use QDaqLoop, create the object and build underneath it a tree of child-jobs and child-loops that perform the required tasks in the correct order. Then attach the loop to the QDaq tree either as a child of the root object ("qdaq") or under another object that does not have a QDaqLoop anchestor. Thus the loop becomes top level.
|
inlineslot |
|
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 288 of file QDaqJob.cpp.
|
slot |
Create a dedicated QDaqScriptEngine.
The created script engine will be used for running script code of child jobs.
The created script engine lives executes code within the loop timer thread.
All child jobs can obtain a pointer to this engine with loopEngine().
Definition at line 378 of file QDaqJob.cpp.
|
protectedvirtual |
Performs internal de-initialization.
It is called by the setArmed() function.
Can be reimplemented to define special behavior during dis-arming. The parent class disarm_() should be called.
Reimplemented from QDaqJob.
Definition at line 306 of file QDaqJob.cpp.
|
protectedvirtual |
Called when a loop is executed.
In a top level loop this function is called at each repetition of the timer thread.
In a child-loop exec() is called from the parent loop according to the order of the child-loop in the tree structure.
This function first locks the mutexes of all child jobs to prevent access from other threads. Then it calls QDaqJob::exec() which runs all child jobs. Finally it unlocks the mutexes in the reverse order as they were locked.
The signals updateWidgets() and propertiesChanged() are emitted at each valid repetition.
Reimplemented from QDaqJob.
Definition at line 242 of file QDaqJob.cpp.
|
read |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |