How to push event on dynamic attribute?

Hi all,

My tango device server( C++ ) have few dynamic attributes.
At other end, client application is polling each attribute at regular period. Instead of polling, client shall be acknowledged if there is any change in the value of dynamic attribute. So each attribute of tango device server shall be configured to push event.

So is there any way to set polling and set push event by Tango API in C++?
Please provide necessary guidance. Thanks in advance.

Regards,
Pritesh Amrelia
Hi Pritesh,

check out the Tango::DeviceImpl interface which has methods for checking, starting and stopping polling:

http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/cpp_doc/classTango_1_1DeviceImpl.html

There are some hints on this howto page as well:

http://www.tango-controls.org/resources/howto/how-tune-polling-code-tango-class/

Andy
Thank you Andy for your prompt response.

I referred a link provided by you. polling dynamic attribute is possible through methods provided by class Tango::DeviceImpl. But I didn't find any method to push events on dynamic attribute.

I would be grateful if you please provide your guidance.

Thanks and Regards,
Pritesh Amrelia
Regards,
TCS_GMRT
Hi Pritesh,

It is not clear to me whether you want to push "manually" events from the server code or whether you want Tango to send events automatically when the attributes are read by the polling thread.

If you want Tango to send events when the attribute is read and according to the configuration of events as defined in jive (change event absolute criteria/relative change criteria/periodic…), the only thing you need to do is to configure your events in jive and to start the polling on your dynamic attributes.
Depending on the client you are using, you might need to change its code so that it subscribes to events instead of polling manually remotely your attributes.
Most of the standard clients are trying to subscribe to events and if this does not succeed, they will switch to remote polling. I don't know what is your client…

If you want to push events by code for your dynamic attributes, using one of the push_change_event() methods or push_archive_event() method for instance, you will need to warn the tango library that your dynamic attributes may push events manually.
You can do that using the Tango::Attribute::set_archive_event() and Tango::Attribute::set_change_event() methods.
In this case, after the creation of your dynamic attribute myAttr, you will need to call once:
myAttr->set_change_event(true,false)
if you want an event to be always sent every time you invoke push_change_event() method in your code.
OR you should call:
myAttr->set_change_event(true,true)
if you want the tango library to take into account the event configuration you have defined in jive before sending an attribute. Meaning that in this case, depending on your event configuration, sometimes an event will be sent (if the change is above the absolute change threshold defined in jive), sometimes not.

Hoping this helps,
Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new.
 
Register or login to create to post a reply.