Commit 7685a397 authored by Jose Tiago Macara Coutinho's avatar Jose Tiago Macara Coutinho Committed by blissadm_ID31@bibhelm
Browse files

bliss tango: add compatibility with BlissAxisManager (generator part)

parent 58307af8
......@@ -223,6 +223,7 @@ def _is_tango_server_running(server_instance):
SERVER_HOST_KEY = 'server_host'
TANGO_SERVER_KEY = 'tango_server'
def TServer(type, name, host, devices):
......@@ -275,6 +276,8 @@ class Generator(object):
self.__tango_servers = OrderedDict()
# map of tango bliss servers <session name: server info (TServer)>
self.__tango_bliss_servers = OrderedDict()
# map of tango BlissAxisManager servers <server full name (str): server info (TServer)>
self.__tango_axis_manager_servers = OrderedDict()
# map of tango lima servers <server full name (str): server info (TServer)>
self.__tango_lima_servers = OrderedDict()
......@@ -291,6 +294,7 @@ class Generator(object):
self.__spec_setup = [unique_setup, lima_setup]
# spec <-> bliss controllers
self.__spec_mot_ctrl_tango_bliss_servers = OrderedDict()
self.__spec_mot_ctrl_axis_manager_servers = OrderedDict()
# necessary macros to be imported
self.__spec_macros = set(['spec_utils.mac'])
......@@ -333,6 +337,18 @@ class Generator(object):
self.__spec_macros.add('bliss.mac')
return tango_bliss
def get_tango_axis_manager(self, tango_server):
axis_manager = self.__tango_axis_manager_servers.get(tango_server)
if axis_manager is None:
dev_name = '{0}/emotion/{1}'.format(self.beamline, tango_server)
axis_manager = TServer('BlissAxisManager', tango_server, None,
[TDevice('BlissAxisManager', dev_name)])
# Don't put it in the list of tango servers. We assume they were
# manually created
#self.__tango_servers[axis_manager['server']] = axis_manager
self.__tango_axis_manager_servers[tango_server] = axis_manager
return axis_manager
@property
def spec_config(self):
spec_config = self.__spec_config
......@@ -345,17 +361,30 @@ class Generator(object):
self.spec_config.addMotor(dmot)
return spec_config
def __add_emotion_ctrl_to_spec(self, dev_name):
ctrl = Device(ltype='PSE_MAC_MOT', addr='tango_mot', num=0, conf=dev_name)
self.spec_config.addDevice(ctrl)
self.__spec_macros.add('tango_mot.mac')
return ctrl
def get_spec_mot_ctrl_bliss_tango(self, session_name):
ctrl = self.__spec_mot_ctrl_tango_bliss_servers.get(session_name)
if ctrl is None:
tango_bliss =self.get_tango_bliss(session_name)
bliss_dev_name = tango_bliss['device_types']['Bliss'][0]['name']
ctrl = Device(ltype='PSE_MAC_MOT', addr='tango_mot', num=0,
conf=bliss_dev_name)
self.spec_config.addDevice(ctrl)
dev_name = tango_bliss['device_types']['Bliss'][0]['name']
ctrl = self.__add_emotion_ctrl_to_spec(dev_name)
self.__spec_mot_ctrl_tango_bliss_servers[session_name] = ctrl
return ctrl
def get_spec_mot_ctrl_axis_manager(self, tango_server):
ctrl = self.__spec_mot_ctrl_axis_manager_servers.get(tango_server)
if ctrl is None:
tango_bliss = self.get_tango_axis_manager(tango_server)
dev_name = tango_bliss['device_types']['BlissAxisManager'][0]['name']
ctrl = self.__add_emotion_ctrl_to_spec(dev_name)
self.__spec_mot_ctrl_axis_manager_servers[tango_server] = ctrl
return ctrl
def add_session(self, session_name):
session_config = self.config.get_config(session_name)
if session_config is None or \
......@@ -407,10 +436,11 @@ class Generator(object):
# Emotion
####################
def add_emotion(self, session_name, name, config_name):
ctrl = self.get_spec_mot_ctrl_bliss_tango(session_name)
ctrl_addr = 'MAC_MOT:{0}/{1}'.format(ctrl.getCtrlIndex(), ctrl.num)
def __add_emotion_axis_to_spec_controller(self, name, config_name, ctrl):
mot_config = self.config.get_config(config_name)
ctrl_addr = 'MAC_MOT:{0}/{1}'.format(ctrl.getCtrlIndex(), ctrl.num)
sign = mot_config.get('sign') or 1
spec_motor = Motor(ctrl=ctrl_addr, steps=int(1E6), mne=name,
name=name, sign=sign, backl=0)
......@@ -420,9 +450,25 @@ class Generator(object):
self.spec_config.addMotor(spec_motor)
ctrl.num += 1
self.__spec_macros.add('tango_mot.mac')
def add_emotion(self, session_name, name, config_name):
mot_config = self.config.get_config(config_name)
if 'tango_server' in mot_config:
return self.__add_emotion_as_axis_manager(session_name, name, config_name)
ctrl = self.get_spec_mot_ctrl_bliss_tango(session_name)
self.__add_emotion_axis_to_spec_controller(name, config_name, ctrl)
# bliss tango will add all axes when it starts-up so nothing to do
# on the tango side
def __add_emotion_as_axis_manager(self, session_name, name, config_name):
# use old BlissAxisManager
mot_config = self.config.get_config(config_name)
tango_server = mot_config['tango_server']
ctrl = self.get_spec_mot_ctrl_axis_manager(tango_server)
self.__add_emotion_axis_to_spec_controller(name, config_name, ctrl)
####################
# Icepap
####################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment