QDaq
0.2.6
Qt-based Data Aqcuisition
|
A class representing a DAQ device. More...
#include <QDaqDevice.h>
Public Slots | |
bool | on () |
Try to bring the device online and return true if succesfull. | |
void | off () |
Bring the device offline. | |
void | clear () |
Call QDaqInterface::clear_port(). Depends on type of interface. | |
int | statusByte () |
Call QDaqInterface::readStatusByte(). Return value depends on type of interface. | |
void | trigger () |
Trigger the device (Must be supported by the interface, e.g. GPIB) | |
Functions for message based communication. | |
int | write (const QString &msg) |
Write a string message to the device. Return number of characters written. | |
bool | write (const QStringList &msgs) |
Write a list of string message to the device. Return true if succesfull. | |
int | writeBytes (const QByteArray &msg) |
Write a byte array to the device. Return number of bytes written. | |
QString | read () |
Read a string from the device. On error return empty string and emit QDaqError. | |
QByteArray | readBytes () |
Read bytes from the device. On error return empty array and emit QDaqError. | |
QString | query (const QString &msg) |
Send message and return the answer, ie, read and write in one command. | |
Functions for register based communication (eg, MODBUS). | |
A register holds a 16-bit unsigned integer. | |
int | write (int reg, int val) |
Write a value at a device register. More... | |
int | write (int start_reg, int n, const QByteArray &msg) |
Write to a number of consecutive device registers. More... | |
int | read (int reg) |
Return the value of the device register at address reg. | |
QByteArray | read (int reg, int n) |
Read a number of consecutive device registers. 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. | |
Public Member Functions | |
Q_INVOKABLE | QDaqDevice (const QString &name) |
QDaqDevice constructor. More... | |
virtual void | detach () |
Detach this QDaqObject from the QDaq tree. More... | |
int | write (const char *msg, int len) |
Write a C-string message to the device, returns the number of characters written. | |
int | write (const char *msg) |
Write a zero terminated C-string message to the device, returns the number of characters written. | |
int | write (const QByteArray &msg) |
Write a byte array to the device, returns the number of bytes written. | |
bool | write (const QList< QByteArray > &msglist) |
Write a list byte arrays to the device, returns true if succesfull. | |
![]() | |
Q_INVOKABLE | QDaqJob (const QString &name) |
QDaqJob constructor. More... | |
virtual void | attach () |
Attach this QDaqObject to 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... | |
bool | throwIfOffline () |
Thow QDaqError and script error if called with device offline. | |
bool | throwIfOnline () |
Thow QDaqError and script error if called with device online. | |
virtual bool | setOnline_ (bool on) |
Implements specific procedures for bringing device on- or offline. 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 | |
uint | bufferSize |
Size of the internal communication buffer. | |
int | address |
Device address (depends on type of interface). | |
bool | online |
True when device is online. | |
int | eot |
End of transmition code. | |
int | eos |
End of string code. | |
QDaqObject | interface |
The underlying QDaqInterface used for communication. | |
![]() | |
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 | |
![]() | |
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. | |
A class representing a DAQ device.
It is used in combination with a QDaqInterface in order to communicate with the device.
In order to start communications with a device, first instantiate the interface and device objects, asign the interface to the device and then open() the interface and bring the device online with on().
After the device is online the communication functions can be used either for message based or register based communication.
Definition at line 44 of file QDaqDevice.h.
|
explicit |
QDaqDevice constructor.
name | The QDaqObject name. |
Definition at line 3 of file QDaqDevice.cpp.
|
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 127 of file QDaqDevice.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 QDaqJob.
Definition at line 16 of file QDaqDevice.cpp.
|
slot |
Read a number of consecutive device registers.
reg | Starting register address. |
n | Number of registers. |
Definition at line 230 of file QDaqDevice.cpp.
|
protectedvirtual |
Implements specific procedures for bringing device on- or offline.
This function is called to change the online property.
Reimplement this function to define additional procedures needed in devices classes that inherit QDaqDevice.
In the base class implementation, QDaqInterface::open_port() is called with the address passed as the port number. If this returns true, then QDaqInterface::clear_port() is also called.
on | True for making device online, false for offline. |
Definition at line 41 of file QDaqDevice.cpp.
|
slot |
Write a value at a device register.
reg | Register address. |
val | Value to write. Will be truncated to 16-bit (max 0xFFFF). |
Definition at line 179 of file QDaqDevice.cpp.
|
slot |
Write to a number of consecutive device registers.
start_reg | Starting register address. |
n | Number of registers. |
msg | Buffer containing data to write. Must hold at least 2*n bytes. |
Definition at line 187 of file QDaqDevice.cpp.