Event channel not responding inside QT application
|
|
---|---|
Dear all, I write you to ask help on a error I am getting when subscribing device proxies to Tango events inside a Qt application. I try to describe what I am doing. I have a QWidget in which I create a class (derived from QObject) that creates Tango device proxies and subscribes to events defined in given Tango servers with callback model. Proxy creation and event subscription is not done in the main GUI widget thread but in a QThread. The error I get in the callback is the following:
I have seen from other posts that this error could be caused by a wrong TANGO_HOST or by a blocking callback preventing event heartbeat. I provide below some simplified code sketch and details to help you.
I am using Tango version 9.2.5a (zmq 4.0.8, omniorb 4.2.1) on Ubuntu 16.04 LTS. TANGO_HOST is set to my laptop hostname (i.e. TANGO_HOST=riggi-tpt460:10000). I have 4 proxies with ~50 subscribed attributes in total. Polling periods ranges from 100 ms (few attributes) to 1000/3000 ms (the majority). I am subscribing to CHANGE events only. I have performed some tests to understand more. For example, if I move the proxy creation and subscription part in a standalone Tango server for testing I do not get the error. I do not notice the error if I significantly reduce the number of attributes. I suspect I am doing something wrong, probably inconsistent with the QT event loop. Do you have any hints on what I can try to do to understand the error? Many thanks for your help, Cheers, Simone
****************************************************************
Simone Riggi INAF, Osservatorio Astrofisico di Catania Via S. Sofia 78 95123, Catania - Italy phone: +39 095 7332 extension 282 e-mail: simone.riggi@gmail.com, sriggi@oact.inaf.it skype: simone.riggi **************************************************************** |
|
|
---|---|
Hello Simone. It has been a Tango flaw for a long time. Within your Run method, be sure to place this line of code omni_thread::ensure_self se; This will probably address your issue. If your need to integrate Tango and Qt is not sporadic, consider using the QTango library (or, better, the forthcoming cumbia library), that provides a multi threaded framework to work with Tango and Qt. Best regards. Giacomo. |
|
|
---|---|
Hi Giacomo, many thanks. I have tried your solution and it seems that the errors went away. I will have a look at QTango & cumbia library to go beyond these QT+Tango tests. Many thanks! Simone
****************************************************************
Simone Riggi INAF, Osservatorio Astrofisico di Catania Via S. Sofia 78 95123, Catania - Italy phone: +39 095 7332 extension 282 e-mail: simone.riggi@gmail.com, sriggi@oact.inaf.it skype: simone.riggi **************************************************************** |
|
|
---|---|
Dear all, just to add that the errors was documented in this ticket https://sourceforge.net/p/tango-cs/bugs/833/. I missed that, so thanks again Giacomo. For people seeing the post in the future, at the end I did the following in the QT example reported above: 1) Subclass QThread and override QThread::run() method in this way:
2) Use MyThread in place of QThread in the example reported above. Seems it is working now. Cheers, Simone
****************************************************************
Simone Riggi INAF, Osservatorio Astrofisico di Catania Via S. Sofia 78 95123, Catania - Italy phone: +39 095 7332 extension 282 e-mail: simone.riggi@gmail.com, sriggi@oact.inaf.it skype: simone.riggi **************************************************************** |
|
|
---|---|
Hi, it's just came to my mind. What about pytango and pyqt (or taurus). Do we have a similar workaround for the python case? In principle it should be the same. Do we have a similar pytango `omni_thread::ensure_self se;` variable. In python I haven't seen this error (except from taurus but I hope it was missing tangohost definition problem ). Best regards, Jan |