Accessing Tango from your macros
Created by: dschick
This is a rather general question about the "correct" way to access Tango devices in Sardana macros.
We do have the generic case of module that holds serveral macro functions which all interact with the same tango.DeviceProxy
.
Currently we create that proxy within every function, e.g.
from sardana.macroserver.macro import Macro, macro, Type
from tango import DeviceProxy
@macro()
def laser_on(self):
"""Macro laser_on"""
proxy = DeviceProxy('laser/ThorlabsShutter/0')
proxy.Open()
self.output("Laser shutter open!")
@macro()
def laser_off(self):
"""Macro laser_off"""
proxy = DeviceProxy('laser/ThorlabsShutter/0')
proxy.Close()
self.output("Laser shutter closed!")
...
Is this a smart way of doing it? Or could I open the proxy ones and use the same proxy object by all macro functions?