change event for Pytango device server and Taurus client

Hi all,

I have a pytango device server running on Raspberry Pi2 and a Taurus GUI on a windows client. I am trying to find a way to configure change event for the state attribute, but i can not find the necessary steps to do so in the documentation.
On the server side do i just need to put that line of code in the init_device method?

self.set_change_event('State',True,True)

On the client side, how can i subscribe to that event using taurus libraries ?

Thank you !


Hi Raphael,

Taurus subscribes to Tango events (ATTR_CONF_EVENT and CHANGE_EVENT) and translates them into the Taurus events of types Config and Change (see taurus.TaurusEventType).

You can subscribe to Taurus events using the addListener method of the TaurusAttribute class. You have two options to do that, using either a python function or a python object of a class defining eventReceived method.


import taurus

ATTR_NAME = 'motor/motctrl01/1/state'

def myListener(evt_src, evt_type, evt_value):
    print 'myListener: entering…'
    print 'evt_src = ', evt_src
    print 'evt_type = ', evt_type
    print 'evt_value = ', evt_value
    print '\n'

class MyListener(object):

    def eventReceived(self, evt_src, evt_type, evt_value):
        print 'MyListener.eventReceived: entering…'
        print 'evt_src = ', evt_src
        print 'evt_type = ', evt_type
        print 'evt_value = ', evt_value
        print '\n'

attr = taurus.Attribute(ATTR_NAME)

attr.addListener(myListener)
attr.addListener(MyListener())

But since you are talking about a Taurus GUI, you may be interested in the Taurus QT signals?
In this case your widgets would need to inherit from the TaurusBaseComponent class and each of the Taurus events would be translated into the QT signal.
Please see the following thread where a similar issue was raised:
https://sourceforge.net/p/sardana/mailman/message/34071656/

Hope it helps,
Zibi

PS. You may be also interested in subscribing to the Taurus project mailing lists:

https://lists.sf.net/lists/listinfo/tauruslib-users
https://lists.sf.net/lists/listinfo/tauruslib-devel
Hi zreszela,

Thank you very much for your response!
The issue is much more clear now, i will make change to my code and i'll keep you informed.



 
Register or login to create to post a reply.