Tango coherence
Tango code in the bliss project is a bit of a mess. This RFC proposes some guidelines to write tango code in the bliss project.
One of the deliverables of this RFC should be a wiki page / doc on how to write bliss tango servers.
tango server executables:
- should be placed in the tango/ directory
- preferably a python executable without extension (using python shebang:
#!/usr/bin/env python
) - see CT2 example
tango server code
- should be placed in
bliss/tango/servers
- logic should be implemented in bliss; tango classes should have a minimum of logic
- if tango class is developed to provide access to spec:
- provide minimum attributes & commands to make it happen
- write a macro in
spec/
- see BlissAxisManager example
- if tango class is developed to provide bliss with remote access to bliss class (ex: PCI card):
Example
write a device class Potentiostat exposing bliss biologic potentiostat. Also provide an executable capable of running a DS with class Potentiostat
bliss/controllers/potentiostat/biologic.py
class Potentiostat:
def is_channel_plugged(self, channel):
...
def start_channel(self, channel):
...
bliss/tango/servers/potentiostat/biologic.py module
from PyTango.server import (Device, DeviceMeta,
command, attribute)
from bliss.controllers.potentiostat import biologic
class Potentiostat(Device):
__metaclass__ = DeviceMeta
def init_device(self):
Device.init_device(self)
self.__potentiostat = biologic.Potentiostat()
@command(dtype_in=int, dtype_out=bool)
def is_channel_plugged(self, channel):
return self.__potentiostat.is_channel_plugged()
@command(dtype_in=int)
def start_channel(self, channel):
self.__potentiostat.start_channel(channel)
def main():
from PyTango import GreenMode
from PyTango.server import run
run([Potentiostat,], green_mode=GreenMode.Gevent)
if __name__ == "__main__":
main()
tango/Potentiostat executable
#!/usr/bin/env python
from bliss.tango.servers.biologic.potentiostat import main()
main()
With this approach it becomes simple to create a new server with multiple classes. Example:
my_server
#!/usr/bin/env python
from bliss.tango.servers.biologic.potentiostat import Potentiostat
from bliss.tango.servers.musst import Musst
from PyTango import GreenMode
from PyTango.server import run
run([Potentiostat, Musst], green_mode=GreenMode.Gevent)
We can even invent a Bliss server which can expose all known bliss classes :-)