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

Base class of objects representing digital communications interfaces. More...

#include <QDaqInterface.h>

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

Public Slots

bool open ()
 Opens the interface and returns true if succesful.
 
void close ()
 Closes the interface.
 
void clear ()
 Clears the interface.
 
- 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

 QDaqInterface (const QString &name)
 Construct a QDaqInterface with object-name name.
 
virtual void detach ()
 When a QDaqInterface is detached it is also closed.
 
virtual bool open_port (uint i, QDaqDevice *d)
 Open communication port no. More...
 
virtual void close_port (uint i)
 Closes port i.
 
virtual void clear_port (uint i)
 Clear the communication channel with port i (interface specific).
 
virtual int read (uint port, char *buff, int len, int eos=0)
 Read data from a port. More...
 
virtual int write (uint port, const char *buff, int len, int eos=0)
 Write data to a port. More...
 
virtual bool isValidPort (uint i)
 Returns true is i is a valid port number.
 
virtual int readStatusByte (uint port)
 Returns a status byte for a port (interface specific).
 
virtual void trigger (uint port)
 Trigger a device connected to port (interface specific).
 
- Public Member Functions inherited from QDaqObject
Q_INVOKABLE QDaqObject (const QString &name)
 Construct a QDaqObject with a name. More...
 
virtual void attach ()
 Attach this QDaqObject to the QDaq tree. More...
 
bool isAttached () const
 Returns true is this object is attached to the QDaq tree.
 

Protected Member Functions

virtual bool open_ ()
 Implementation of interface open.
 
virtual void close_ ()
 Implementation of interface close.
 
virtual void clear_ ()
 Implementation of interface clear.
 
virtual void setTimeout_ (uint v)
 Implementation of setting the timeout.
 
bool throwIfOpen ()
 Throws a script error and a QDaqError if called on an open interface.
 
- 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

uint address
 Address of this interface. More...
 
uint timeout
 Communications timeout in ms.
 
bool isOpen
 Returns true if the interface is open.
 

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

Base class of objects representing digital communications interfaces.

QDaqInterface provides a common implementation for communication interfaces as, e.g., serial (RS232,RS485,USB), ethernet (TCP/IP), MODBUS and GPIB.

The QDaqInstrument class utilizes a descendant of QDaqInterface for performing the actual communications with the instrument.

A QDaqInterface has a number of communication "ports", which have different meaning depending on the specific interface implementation. On memory/register based interfaces like MODBUS, a port represents the register number to be read/written. On interfaces that support connection with multiple instruments (GPIB, RS485), the port is essentially the address of each instrument. On interfaces that support only one-to-one communication with an instrument (RS232, TCP/IP) the port is not used.

Definition at line 31 of file QDaqInterface.h.

Member Function Documentation

bool QDaqInterface::open_port ( uint  i,
QDaqDevice d 
)
virtual

Open communication port no.

i for QDaqDevice d

Returns true if the port was succesfully opened.

Definition at line 44 of file QDaqInterface.cpp.

int QDaqInterface::read ( uint  port,
char *  buff,
int  len,
int  eos = 0 
)
virtual

Read data from a port.

The meaning of the port parameter is different depending on the type of communication interface.

In message based communications (e.g. GPIB) the port is the instrument address.

In memory based interfaces (e.g. MODBUS) the port number represents the starting register address to access. The number of registers read/written depends on len, the size of the buffer in bytes. A MODBUS register is 16 bit, ie, occupies 2 bytes.

Parameters
portPort number.
buffPointer to memory buffer.
lenAllocated number of bytes.
eosEnd of string byte
Returns
Number of bytes read.

Definition at line 58 of file QDaqInterface.cpp.

int QDaqInterface::write ( uint  port,
const char *  buff,
int  len,
int  eos = 0 
)
virtual

Write data to a port.

The meaning of the port parameter is different depending on the type of communication interface.

In message based communications (e.g. GPIB) the port is the instrument address.

In memory based interfaces (e.g. MODBUS) the port number represents the starting register address to access. The number of registers read/written depends on len, the size of the buffer in bytes. A MODBUS register is 16 bit, ie, occupies 2 bytes.

Parameters
pPort number.
buffPointer to memory buffer.
lenNumber of bytes to write.
eosEnd of string byte
Returns
Number of bytes written.

Definition at line 67 of file QDaqInterface.cpp.

Property Documentation

uint QDaqInterface::address
readwrite

Address of this interface.

The meaning of address depends on the type of interface.

The address can be changed when the interface is closed.

Definition at line 42 of file QDaqInterface.h.


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