from PyTango import *
import sys
import time
try :
t1 = DeviceProxy( "haso111n:10000/test/clipboard/1")
line1 = t1.read_attribute("Line1")
print "Line1: ", line1.value
line2 = t1.Line2
print "Line2: ", line2
t1.write_attribute("Line3","mytest")
except :
print "Failed with exception !"
print sys.exc_info()[0]
Example of how to subscribe to events for automatically detecting the changes in attributes. The attribute the subscription is made to, has to have defined change events and polling.
The function pus_event in the callback class defines what will be done when it ocurrs a change in the subscribed attribute.
from PyTango import *
import sys
import time
# The subscribe attributes have to have events and polling
class PyCallback:
def push_event(self,event):
if not event.err:
print event.attr_name, event.attr_value.value
else:
print event.errors
try :
t1 = DeviceProxy( "haso111n:10000/test/clipboard/1")
cb = PyCallback();
# We can only subscribe once
# t1.subscribe_event("UpdateId2", EventType.CHANGE_EVENT, cb, [])
att = AttributeProxy('test/clipboard/1/UpdateId2')
ev = att.subscribe_event(EventType.CHANGE_EVENT, cb, [])
while(1):
time.sleep(1)
except DevFailed, df:
Except.print_exception(df)