Project is in beta test.
All basics methods are implemented.
An html file reference manual is included.
Here is a text copy.
QK8055 Class
The QK8055 class provides an interface to Velleman K8055 and VM100n boards.
In sources:
#include <QtK8055/QtK8055.h>
In project files:
LIBS += -lQtK8055
Inherits: QObject.
Public Functions
QK8055(QObject * parent = 0)
~QK8055()
int maxDevices()
const QList &openedDevicesPorts()
bool readDigitalInput(int port, int channel)
int readAllDigitalInput(int port)
int raedAnalog0(int port)
int raedAnalog1(int port)
int raedCounter0(int port)
int raedCounter1(int port)
SIGNALS
void InputChanged()
void errorK8055(int code)
void errorK8055(QString error)
void digitalChanged(int port, int bitmask)
void digitalActivated(int port, int channel)
void digitalUnactivated(int port, int channel)
void analog0Changed(int port, int value)
void analog1Changed(int port, int value)
void counter0Changed(int port, int value)
void counter1Changed(int port, int value)
void digitalOutputChanged(int port, int bitmask)
void digitalOutActivated(int port, int channel)
void digitalOutUnactivated(int port, int channel)
void analogOut0Changed(int port, int value)
void analogOut1Changed(int port, int value)
void debounce0Changed(int port, int value)
void debounce1Changed(int port, int value)
Public SLOTS
void openDevice(int port)
void closeDevice(int port)
void startTimingLoop(int msec)
void stopTimingLoop()
viod setQuickModeOn(bool status=true)
void setQuickModeOff(bool status=true)
void setAllDigital(int port, int bitmask)
void resetAllDigital(int port);
void setDigitalOn(int port, int channel, bool status=true)
void setDigitalOff(int port, int channel, bool status=true)
void setAllAnalog(int port, int analog0, int analog1)
void resetCounter(int port, int counter)
void setDebounceTime(int port,int counter, int msec)
void updateAllInputs()
void requestAllOutputs()
Detailed Description
This class allows, through the QT libraries, the command and control of the Velleman K8055 card or VM110n.
It is derived from the library libK8055 and, as it requires the libusb library.
In the specific request is the libusb 1.0, which allows porting across different operating systems. For the compilation are obviously also need the headers of that library.
Unlike libK8055 is not written in C, but in C + + and, through integration with the QT libraries, allows the use of the mechanism SIGNALS / SLOTS. By exchanging messages through this mechanism it is possible to assign the object to a separate thread QK8055 in total safety thanks to the method moveToThread (QThread *);
There is also direct access methods, but their use in multithreading is strongly discouraged.
The single instance of an object can handle all four cards per single system.
The object QK8055 has an internal timer that allows cyclic monitoring of the tabs and the issuance of the respective signals in case of changes. This timer should be started manually in case you wish to use the cards in this way.
Member Function Documentation
QK8055::QK8055(QObject * parent = 0)
Constructs the main object.
This object can handle one to “maxDevices()” devices.
QK8055::~QK8055()
Destructs the main object.
Also close all opened devices and free memory.
int QK8055::maxDevices()
Return max number of devices that system can handle.
const QList &QK8055::openedDevicesPorts()
Return reference to a QList containing all ports of opened devices.
bool QK8055::readDigitalInput(int port, int channel)
Return status of input channel of device at port.
Negative value indicate error.
This method can not be used in multithreadig, in case use SIGNALS and SLOTS!
int QK8055::readAllDigitalInput(int port)
Return status of inputs as bitmask of device at port.
Negative value indicate error.
This method can not be used in multithreadig, in case use SIGNALS and SLOTS!
int QK8055::readAnalog0(int port)
Return value of analog input 0 of device at port.
Negative value indicate error.
This method can not be used in multithreadig, in case use SIGNALS and SLOTS!
int QK8055::readAnalog1(int port)
Return value of analog input 1 of device at port.
Negative value indicate error.
This method can not be used in multithreadig, in case use SIGNALS and SLOTS!
int QK8055::readCounter0(int port)
Return value of analog counter 0 of device at port.
Negative value indicate error.
This method can not be used in multithreadig, in case use SIGNALS and SLOTS!
int QK8055::readCounter1(int port)
Return value of analog counter 1 of device at port.
Negative value indicate error.
This method can not be used in multithreadig, in case use SIGNALS and SLOTS!
void QK8055::inputChanged() [SIGNAL]
Signal emitted when an input is changed after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::errorK8055(int code) [SIGNAL]
Signal emitted when an error is encontred whith devices.
code is negative value.
void QK8055::errorK8055(QString error) [SIGNAL]
Signal emitted when an error is encontred whith devices.
Error is emitted as human readable description.
void QK8055::digitalChanged(int port, int bitmask) [SIGNAL]
Signal emitted when a digital input of device at port is changed after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::digitalActivated(int port, int channel) [SIGNAL]
Signal emitted when a digital input at channel of device at port is activated after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::digitalUnactivated(int port, int channel) [SIGNAL]
Signal emitted when a digital input at channel of device at port is unactivated after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::analog0Changed(int port, int value) [SIGNAL]
Signal emitted when input analog 0 of device at port change value after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::analog1Changed(int port, int value) [SIGNAL]
Signal emitted when input analog 1 of device at port change value after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::counter0Changed(int port, int value) [SIGNAL]
Signal emitted when counter 0 of device at port change value after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::counter1Changed(int port, int value) [SIGNAL]
Signal emitted when counter 1 of device at port change value after a manual or automatic ( see startTimingLoop(int msec) ) reading.
void QK8055::digitalOutChanged(int port, int bitmask) [SIGNAL]
Signal emitted when a digital output of device at port is changed after a request.
void QK8055::digitalOutActivated(int port, int channel) [SIGNAL]
Signal emitted when a digital output at channel of device at port is activated after a request.
void QK8055::digitalOutUnactivated(int port, int channel) [SIGNAL]
Signal emitted when a digital output at channel of device at port is unactivated after a request.
void QK8055::analogOut0Changed(int port, int value) [SIGNAL]
Signal emitted when output analog 0 of device at port change value after a request.
void QK8055::analogOut1Changed(int port, int value) [SIGNAL]
Signal emitted when output analog 1 of device at port change value after a request.
void QK8055::debounce0Changed(int port, int msec) [SIGNAL]
Signal emitted when debounce time of counter 0 of device at port change value after a request.
void QK8055::debounce1Changed(int port, int msec) [SIGNAL]
Signal emitted when debounce time of counter 1 of device at port change value after a request.
void QK8055::openDevice(int port) [PUBLIC SLOT]
This method try to open device at port. If device exists and could be opened, after opening port of this device is appended at devices list.
See openedDevicesPorts().
void QK8055::closeDevice(int port) [PUBLIC SLOT]
Close device at port and free it for another QK8055 istance or another application.
void QK8055::startTimingLoop(int msec) [PUBLIC SLOT]
Create a QTimer and connect timeout to device reading. Time msec is the interval between checks.
QTimer is istantiated here for multi threading. If you call QK8055::moveToThread(QThread *) method is safe call startTimingLoop only after moveToThread.
In singlethread applications startTimingLoop can used everywere.
If a Timing loop is started before moveToThread stop it whit QK8055::stopTimingLoop() and restart after.
void QK8055::startTimingLoop(int msec) [PUBLIC SLOT]
Stop timing loop and delete instantiated QTimer.
If you call QK8055::moveToThread(QThread *) method is safe call startTimingLoop only after moveToThread.
In singlethread applications startTimingLoop can used everywere.
If a Timing loop is started before moveToThread stop it whit QK8055::stopTimingLoop() and restart after.
void QK8055::setQuickModeOn(bool status=true) [PUBLIC SLOT]
Speed up reading from device. On other side, results may be inaccurate.
By default Quik Mode is disabled.
void QK8055::setQuickModeOff(bool status=true) [PUBLIC SLOT]
By default Quik Mode is disabled.
See QK8055::setQuickModeOn(bool status=true).
void QK8055::setAllDigital(int port, int bitmask) [PUBLIC SLOT]
Set outputs of device at to specified 8bit bitmask additional bits are ignored.
void QK8055::resetAllDigital(int port) [PUBLIC SLOT]
Set outputs of device at port to off.
Equivalent at QK8055::setAllDigital(port,0).
void QK8055::setDigitalOn(int port, int channel, bool status=true) [PUBLIC SLOT]
If status is true activate digital output at channel of board at port, else unactivate it.
void QK8055::setDigitalOff(int port, int channel, bool status=true) [PUBLIC SLOT]
If status is false activate digital output at channel of board at port, else unactivate it.
void QK8055::setAllAnalog(int port, int analog0, int analog1) [PUBLIC SLOT]
Set analog outputs to respective values analog0 and analog1.
void QK8055::resetCounter(int port, int counter) [PUBLIC SLOT]
If counter is 0 reset counter 0, if conter is 1 reset conter 1 of board at port.
void QK8055::setDebounceTime(int port, int counter, int msec) [PUBLIC SLOT]
Set debounce time of counter at msec in millisecods.
void QK8055::updateAllInputs() [PUBLIC SLOT]
In response of this slot QK8055 read devices and emit ALL inputs (also of unchanged inputs) SIGNALS.
Useful for updates.
void QK8055::requestAllOutputs() [PUBLIC SLOT]
In response of this slot QK8055 emit ALL outputs (also of unchanged output) SIGNALS.
Useful for updates.