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:
reason=API_EventTimeout
desc=Event channel is not responding anymore, maybe the server or event system is down
origin=EventConsumer::KeepAliveThread()
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.
=== MyClass class ===
class MyClass : public QObject {
Q_OBJECT
MyClass(EventCB* cb)
: m_eventCB(cb)
{
//...
}
public slots:
void Run()
{
//Init dev proxies and subscribe to events
//... proxy->subscribe_event(attr_name,evt_type,m_eventCB)
}
protected:
std::vector<Tango::DeviceProxy*> m_proxies;//list of proxies
std::vector<std::vector<std::string>> m_subscribed_attrs;//list of subscribed attrs per proxy
EventCB* m_eventCB;//event callback
};
=== MyWidget class ===
class MyWidget : public QWidget {
QObject
MyWidget(QWidget *parent = 0)
{
//Create widget objects
m_eventCB= new EventCB;
m_myClass= new MyClass(m_eventCB);
m_thread= new QThread;
//Connect thread start with object action
connect(m_thread, SIGNAL(started()), m_myClass, SLOT(Run()), Qt::QueuedConnection);
//Start thread
m_myClass->moveToThread(m_thread);
m_thread->start();
}
protected:
EventCB* m_eventCB;
MyClass* m_myClass;
QThread* m_thread;
};
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