cumbia-qtcontrols 1.x
Qt widgets on top of the cumbia C++ library
|
Manage readings of various type of objects in a different thread. More...
#include <quwatcher.h>
Public Slots | |
void | setSource (const QString &s) |
Connect the reader to the specified source. More... | |
void | unsetSource () |
Stop the watcher. More... | |
Public Member Functions | |
QuWatcher (QObject *parent, Cumbia *cumbia, const CuControlsReaderFactoryI &r_fac) | |
Constructs a reader with parent parent. More... | |
QuWatcher (QObject *parent, CumbiaPool *cumbia_pool, const CuControlsFactoryPool &fpool) | |
virtual | ~QuWatcher () |
CuContext * | getContext () const |
Return a reference to the CuContext in use. More... | |
void | onUpdate (const CuData &data) |
QuWatcher implementation of the onUpdate method. More... | |
QString | source () const |
returns the source of the watcher More... | |
Public Member Functions inherited from Qumbiaizer | |
Qumbiaizer (QObject *parent) | |
virtual | ~Qumbiaizer () |
bool | error () const |
QString | message () const |
virtual void | attach (QObject *object, const char *method, const char *setPointSlot=NULL, Qt::ConnectionType connType=Qt::AutoConnection) |
associate a QObject and one or two methods to be invoked by the class on new data arrival (QTWatcher) or on target execution (QTWriter). More... | |
void | attach (short *s) |
void | attach (double *d) |
void | attach (int *i) |
void | attach (unsigned int *u) |
void | attach (QString *qs) |
void | attach (bool *b) |
void | attach (QStringList *sl) |
void | attach (QVector< double > *v) |
void | attach (QVector< int > *vi) |
void | attach (QVector< bool > *vb) |
Type | type () const |
QString | slot () const |
QString | methodName () const |
returns the method name, without the full signature. More... | |
QString | setPointSlot () const |
QString | setPointMethodName () const |
void * | data () |
Qt::ConnectionType | connectionType () const |
void | setAutoConfSlot (AutoConfType act, const char *slot) |
when minimum and maximum values are available, these slots are invoked. More... | |
bool | inTypeOfMethod (const QString &method, QObject *obj, char *in_type) |
writes into the in_type parameter the type of the input argument of the given method of the object obj. More... | |
int | extractCode (QString &method) |
extracts the signal/slot code at the beginning of the method name More... | |
void | removeRefreshFilter (QuValueFilter *filter) |
removes filter from the object. More... | |
void | installRefreshFilter (QuValueFilter *filter) |
install the QTRefreshFilter filter into the QTangoizer. More... | |
QuValueFilter * | refreshFilter () const |
returns the currently installed refresh filter. More... | |
void | setSingleShot (bool singleShot) |
Call this one before setSource to ensure that only one read is performed. More... | |
void | setAutoDestroy (bool autoDestroy) |
set single shot and then destroy the object right after the execution More... | |
bool | autoDestroy () const |
returns true if the object auto destroys itself after first execution. More... | |
bool | singleShot () const |
returns the singleShot property. More... | |
void | setToolTipsDisabled (bool disable) |
bool | toolTipsDisabled () const |
const char * | type_str (Type t) const |
Public Member Functions inherited from CuContextI | |
virtual | ~CuContextI () |
virtual CuContext * | getContext () const =0 |
Return a reference to the CuContext in use. More... | |
Properties | |
QString | source |
Additional Inherited Members | |
Public Types inherited from Qumbiaizer | |
enum | Type { Invalid = -1 , Void , Int , Double , UInt , Short , String , Bool , BoolVector , DoubleVector , StringVector , IntVector } |
enum | AutoConfType { Min , Max , MinWarn , MaxWarn , MinErr , MaxErr , StdUnit , Unit , DisplayUnit , Description , Label } |
Supported auto configuration parameters with which you can invoke slots on the attached refreshee. More... | |
Signals inherited from Qumbiaizer | |
void | configured (const CuData &) |
auto configuration signal. More... | |
void | connectionOk (bool ok) |
emitted when the type of data received within onUpdate is set to property More... | |
void | connectionErrorMessage (const QString &msg) |
a signal that contains the error message related to setSource - or setTargets - failures. More... | |
void | refreshMessage (const QString &message) |
Emitted by the refresh method. The message is taken from the TVariant. More... | |
void | readOk (bool success) |
this signal is emitted by the QuWatcher::onUpdate method and the success parameter indicates whether the reading is successful or not. More... | |
void | newData (short s) |
newData for short data types More... | |
void | newData (int i) |
newData for int data types More... | |
void | newData (double d) |
newData for double data types More... | |
void | newData (const QString &s) |
newData for string data types More... | |
void | newData () |
void | newData (unsigned int ui) |
newData for unsigned int data types More... | |
void | newData (unsigned short us) |
newData for unsigned short data types More... | |
void | newData (bool b) |
newData for unsigned bool data types More... | |
void | newData (const QVector< double > &) |
newData for vector of double data types More... | |
void | newData (const QVector< int > &vi) |
newData for vector of int data types More... | |
void | newData (const QVector< bool > &bv) |
newData for vector of boolean More... | |
void | newData (const QStringList &slv) |
newData for string list More... | |
void | newData (const CuData &data) |
newData signal passing the whole data bundle More... | |
Protected Slots inherited from Qumbiaizer | |
virtual void | configure (const CuData &data) |
Configures the attached object, if any. More... | |
virtual void | updateValue (const CuData &v, bool read=true, const char *customMethod=NULL, QuValueFilter::State updateState=QuValueFilter::Update) |
updates the listener with the new value More... | |
Protected Attributes inherited from Qumbiaizer | |
QumbiaizerPrivate * | quizer_ptr |
Manage readings of various type of objects in a different thread.
QuWatcher is a special class that reads a tango variable using QTangoCore. Any QObject or base types (int, short, double, unsigned int, QString, bool) can be attached to this reader and obtain the new data when the attribute or command is refreshed. If a QObject is attached, then a slot must be provided together with the object so that the slot is invoked with a compatible input parameter in order to update the object itself on new data arrival. The data type that must be managed by the QuWatcher is guessed from the slot provided or detected according to one of the other attach methods available.
Call setSingleShot with a true parameter to make the QuWatcher perform a only single reading.
warning: singleShot property is read inside the refresh method. Reimplementing the refresh() method in your own subclass means taking care of correctly managing the singleShot property.
In single shot mode, newData, attributeAutoConfigured, connectionOk and connectionFailed signals are still emitted.
That's it! The QProgressBar will be updated via the setValue(int) slot whenever new data is available and even its maximum and minumum values are updated when available through the QTango auto configuration process.
See the qtango/test/watcher example inside the library distribution for an example
\chapter Supported data types \list
\endlist \endchapter
It is possible to setAutoDestroy to true to have your reader destroyed after the first reading. Note that the object will be destroyed even if the execution fails.
A convenience class, introduced in cumbia 1.2.4 is Qu1TWatcher, which is a single shot, auto destroying QuWatcher
You can call setSingleShot to let your reader perform only one reading from the source.
\chapter New data signals A variety of type specific signals are emitted after the value is successfully extracted from a reading. A newData signal containing the full CuData bundle is emitted as well.
Please note that only data["value"] is extracted, converted to the given type and sent through the newData signal. Control system engines supporting set point (or write) values will provide data["w_value"] when available. It is handled by QuWatcher for simple auto configuration tasks as aforementioned but the extracted value is not propagated through newData.
QuWatcher::QuWatcher | ( | QObject * | parent, |
Cumbia * | cumbia, | ||
const CuControlsReaderFactoryI & | r_fac | ||
) |
Constructs a reader with parent parent.
QuWatcher::QuWatcher | ( | QObject * | parent, |
CumbiaPool * | cumbia_pool, | ||
const CuControlsFactoryPool & | fpool | ||
) |
|
virtual |
|
virtual |
Return a reference to the CuContext in use.
Implements CuContextI.
void QuWatcher::onUpdate | ( | const CuData & | data | ) |
QuWatcher implementation of the onUpdate method.
data | the data received from the reader |
If data contains the property key, Qumbiaizer::configure is called and the configured signal is whence emitted. If data contains the value key and is not a property type, Qumbiaizer::updateValue is called. From there, type specific signals are emitted and the configure slots are invoked.
The following signals are always emitted at the end of this method:
Both the generic configure and newData signals carry the full data coming from the engine.
References Qumbiaizer::configure(), Qumbiaizer::data(), Qumbiaizer::newData(), Qumbiaizer::readOk(), Qumbiaizer::refreshMessage(), Qumbiaizer::singleShot(), unsetSource(), and Qumbiaizer::updateValue().
|
slot |
Connect the reader to the specified source.
If a reader with a different source is configured, it is deleted. If options have been set with QuContext::setOptions, they are used to set up the reader as desired.
References CuControlsReaderA::setSource(), and Qumbiaizer::singleShot().
QString QuWatcher::source | ( | ) | const |
returns the source of the watcher
|
slot |
Stop the watcher.
Disposes the reader.
References Qumbiaizer::autoDestroy().
Referenced by onUpdate().
|
readwrite |