Last active
February 21, 2019 14:22
-
-
Save kmadisa/3200436d42519d83f38a99dad517ff5f to your computer and use it in GitHub Desktop.
TANGO device interface change event bug test files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from tango import DeviceProxy, EventType | |
dp = DeviceProxy('tango://<host-name>:<port>/test/nodb/device1#dbase=no') | |
dp.ping() | |
def printx(data): | |
for att in data.att_list: | |
if att.name == 'ScalarDevEnum': | |
print "ScalarDevEnum enum-labels: ", att.enum_labels | |
print "*** Subscribing to an interface change event." | |
_id = dp.subscribe_event(EventType.INTERFACE_CHANGE_EVENT, printx) | |
print "Initial attribute list: ", dp.get_attribute_list() | |
# Trigger an interface change event by adding an attribute called current. | |
print "*** Adding a new attribute called 'current'." | |
dp.add_dyn_attr('current') | |
# Sleep a bit to wait for the interface change event. | |
time.sleep(2) | |
print "Final attribute list: ", dp.get_attribute_list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TangoTestDevice/test/DEVICE/TangoTestDevice: "test/nodb/device1" | |
############################################# | |
# CLASS TangoTestDevice | |
# CLASS TangoTestDevice attribute properties | |
# DEVICE test/nodb/device1 properties | |
test/nodb/device1->polled_attr: scalardevenum,\ | |
1000 | |
# DEVICE test/nodb/device1 attribute properties | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tango.server import Device, DeviceMeta, attribute, command, server_run | |
class TangoTestDevice(Device): | |
__metaclass__ = DeviceMeta | |
def init_device(self): | |
super(TangoTestDevice, self).init_device() | |
self._devenum = 0 | |
self._current = 0.0 | |
def read_current(self): | |
print ("read current method ", self._current) | |
return self._current | |
def write_current(self, curr): | |
self._current = curr | |
print ("set current to ", self._current) | |
@attribute(dtype='DevEnum', doc='An example scalar Enum attribute', | |
enum_labels=['ONLINE', 'OFFLINE', 'RESERVE'], | |
polling_period=1000, event_period=25) | |
def ScalarDevEnum(self): | |
return self._devenum | |
@command(dtype_in=str, doc_in='name of dynamic attribute to add') | |
def add_dyn_attr(self, name): | |
attr = attribute(name=name, dtype='float', | |
fget=self.read_current, fset=self.write_current) | |
self.add_attribute(attr) | |
if __name__ == "__main__": | |
server_run([TangoTestDevice]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment