Skip to content

Instantly share code, notes, and snippets.

@vxgmichel
Created May 11, 2016 08:53
Show Gist options
  • Save vxgmichel/128314bda87adb43cdc6305954e01e48 to your computer and use it in GitHub Desktop.
Save vxgmichel/128314bda87adb43cdc6305954e01e48 to your computer and use it in GitHub Desktop.
Test file for using events with devicetest
from time import sleep
from devicetest import TangoTestContext
from PyTango import utils, EventType, DevState
from PyTango.server import Device, DeviceMeta, command, run
class Dummy(Device):
__metaclass__ = DeviceMeta
def init_device(self):
self.set_change_event('State', True, True)
@command
def On(self):
self.set_state(DevState.ON)
@command
def Off(self):
self.set_state(DevState.OFF)
if __name__ == '__main__':
with TangoTestContext(Dummy) as proxy:
cb = utils.EventCallBack()
proxy.subscribe_event('State', EventType.CHANGE_EVENT, cb)
while True:
proxy.On()
sleep(3)
proxy.Off()
sleep(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment