QDaq
0.2.6
Qt-based Data Aqcuisition
|
Base class for objects that perform a specific task reqursively. More...
#include <QDaqJob.h>
Public Member Functions | |
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 | 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... | |
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 | |
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 | |
![]() | |
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. | |
![]() | |
void | propertiesChanged () |
Fired when object properties have changed. | |
void | updateWidgets () |
Fired when widgets need update. | |
![]() | |
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. | |
Base class for objects that perform a specific task reqursively.
Jobs can be organized as children of a parent-job or children of the super-class QDaqLoop.
When a QDaqLoop runs all its child jobs are executed by calling their exec() function. The exec() function first calls run() to perform the actual processing of this job (if there is any) and then calls exec() of each child job.
To give an example of the order that jobs are executed, the following job tree:
job0 |--job1 | |--job11 | |--job12 |--job2 |--job3
will be executed with the following order: job0-job1-job11-job12-job2-job3
Before the job can perform its task it must be "armed". Arming does all the necessary initialization and is implemented in the function setArmed().
|
explicit |
|
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 in QDaqLoop, QDaqChannel, and QDaqDevice.
Definition at line 55 of file QDaqJob.cpp.
|
virtual |
Attach this QDaqObject to the QDaq tree.
This function is called when the object becomes part of the QDaq tree.
In the base class implementation this function signals the root object that a new QDaqObject has been inserted in the tree and then calls attach() for each child QDaqObject.
Subclasses may reimplement this function to perform specific initialization.
Reimplemented from QDaqObject.
Definition at line 12 of file QDaqJob.cpp.
|
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 QDaqObject.
Reimplemented in QDaqChannel, and QDaqDevice.
Definition at line 16 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 in QDaqLoop.
Definition at line 91 of file QDaqJob.cpp.
|
protectedvirtual |
Called when the job is executed.
If armed is false, the function does nothing.
If armed is true, then this job's run() is called and then the exec() of all sub-jobs.
The function is called by the parent loop's QDaqLoop::exec() function.
Reimplemented in QDaqLoop.
Definition at line 26 of file QDaqJob.cpp.
|
protectedvirtual |
This function performs the actual task of this QDaqJob.
It can be reimplemented in subclasses to define the specific job that must be performed.
In the base implementation, it executes the script code if available.
Reimplemented in QDaqChannel, and QDaqDataBuffer.
Definition at line 38 of file QDaqJob.cpp.
|
protected |
Arms or disarms a job.
If on is true then setArmed() is called for each child-QDaqJob (not QDaqLoop) and finally arm_() is called to initialize this job. If any of those calls return false the arming is aborted and false is returned.
If on is false then disarm_() is called first and then setArmed() with parameter false is called for each child job.
This funtion is protected so that it cannot be called directly. QDaqJob objects are armed by their parent QDaqLoop, when calling QDaqLoop::arm().
on | If true the job is armed otherwise it is disarmed. |
Definition at line 129 of file QDaqJob.cpp.
|
readwrite |
|
read |
|
readwrite |
|
readwrite |
Script code executed by the job at each repetition.
If code is empty then nothing will be executed.
The script code is executed by the top loop script engine, which is obtained by loopEngine(). This script engine lives in the top-loop thread.