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

SPEC config: add flowbus

parent b41ad7bf
......@@ -734,6 +734,97 @@ class Generator(object):
for item in items:
self.__add_eurotherm_channel(session_name, item)
####################
# Flowbus
####################
def add_flowbus(self, session_name, name, config_name):
config = self.config.get_config(config_name)
if 'spec' in config:
self.check_no_spec_alias('Flowbus controller', name, config_name)
return self.__add_flowbus_full(session_name, name)
# a flowbus counter or motor
return self.__add_flowbus_channel(session_name, config)
def __get_flowbus(self, name):
# 1. for now only support tango serial since it is a modbus tango device
config = self.config.get_config(name)
spec = config.get('spec', None)
tango_type = 'flowbusDS'
server = self.__tango_servers.get('{0}/{1}'.format(tango_type, name))
if server is None:
server_host = spec.get(SERVER_HOST_KEY)
nodes = config['nodes']
serial = config['serial_device']
search = config['search_from']
flowbus_dev = '{0}/flowbus/{1}'.format(self.beamline, name)
server = TServer(tango_type, name, server_host, [
TDevice('FlowbusDS', flowbus_dev, Nodes_address=nodes, Serial_device=serial,
search_from=search)])
# cheat a bit: put in tango server info needed by spec...
server.flowbus = flowbus_dev
server.motor_ctrl = None
server.counter_ctrl = None
self.__tango_servers[server['server']] = server
return server, '' # no setup
def __add_flowbus_channel(self, session_name, config):
# add the given flowbus channel to spec setup and add a motor/counter
# (if appropriate)
flowbus_name = config.parent.get_inherited('name')
flowbus_config = self.config.get_config(flowbus_name)
name = self.get_spec_object_name(session_name, config.get('name'))
if flowbus_config.plugin != 'flowbus':
raise ValueError('flowbus where channel {0!r} is must have a name'
.format(name))
server, _ = self.__get_flowbus(flowbus_name)
self._log.debug('adding flowbus channel %r to flowbus %r',
name, flowbus_name)
etype = config['type']
if etype == 'motor':
motor_ctrl = server.motor_ctrl
if motor_ctrl is None:
motor_ctrl = Device(ltype='PSE_MAC_MOT', addr='flowbus', num=0,
conf=server.flowbus)
self.spec_config.addDevice(motor_ctrl)
server.motor_ctrl = motor_ctrl
unit = motor_ctrl.getCtrlIndex()
chan = motor_ctrl.num
ctrl_addr = 'MAC_MOT:{0}/{1}'.format(unit, chan)
low_limit = float(config.get('low_limit', 0.))
high_limit = float(config.get('high_limit', 0.))
motor = Motor(ctrl=ctrl_addr, steps=1000, sign=1, slew=2000, base=200,
backl=0, accel=125, mne=name, name=name)
motor.addPar('MOTPAR:read_mode = 7')
motor.setSettings(0, 0., low_limit, high_limit)
self.spec_config.addMotor(motor)
motor_ctrl.addChannel(chan)
else: # must be a counter
counter_ctrl = server.counter_ctrl
if counter_ctrl is None:
counter_ctrl = Device(ltype='PSE_MAC_C', addr='flowbuscnt', num=0,
conf=server.flowbus)
self.spec_config.addDevice(counter_ctrl)
server.counter_ctrl = counter_ctrl
unit = counter_ctrl.getCtrlIndex()
counter = Counter(ctrl='MAC_CNT', unit=unit, chan=config['channel'],
mne=name, name=name)
self.spec_config.addCounter(counter)
counter_ctrl.addChannel(counter.chan)
self.__spec_macros.add('flowbus.mac')
def __add_flowbus_full(self, session_name, name):
self._log.debug('adding full flowbus %r from %s', name, session_name)
server, setup = self.__get_flowbus(name)
config = self.config.get_config(name)
spec = config.get('spec', None)
if spec:
items = spec.get('items', ())
for item in items:
self.__add_flowbus_channel(session_name, item)
####################
# Keithley
####################
......
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