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

SPEC config: add support for gasrig (wago + keller)

parent 9b689613
......@@ -182,6 +182,18 @@ SPEC_MULTIM_TEMPLATE = """\
multimsetup {name} type={type} trigger={trigger} integrate={integrate} scale={scale}
"""
SPEC_GASRIG_TEMPLATE = """\
##########################
# Gas rig
#########################
kellergaugesetup {serial_lines}
{add}
kellergaugecntsetup {counters}
gasrigsetup {wago}
"""
class WagoSetup:
def __init__(self, name, description=''):
......@@ -313,6 +325,7 @@ class Generator(object):
# spec configuration object
self.__spec_config = None
self.__spec_serial_count = 0
# spec aliases to config objects
self.__spec_aliases = OrderedDict()
# spec setup lines
......@@ -1178,9 +1191,16 @@ class Generator(object):
for item in items:
self.__add_lima_channel(session_name, item)
def add_serial(self, session_name, name):
def add_serial(self, session_name, name, config_name):
pass
def __add_serial(self, addr, baudrate):
nb = self.__spec_serial_count
ctrl = Device(ltype='SDEV_{0}'.format(nb) , addr=addr, num=baudrate, conf='raw')
self.spec_config.addDevice(ctrl)
self.__spec_serial_count += 1
return ctrl
def get_gpib_enet(self, session_name, url):
url_proto = 'enet'
head = '%s://' % url_proto
......@@ -1201,8 +1221,42 @@ class Generator(object):
gpibs[url] = unit
return unit
def add_gasrig(self, session_name, name):
pass
####################
# Gas rig
####################
def add_gasrig(self, session_name, name, config_name):
config = self.config.get_config(config_name)
wago_name = config['wago']
serial_lines, gauges, counters = [], [], []
for sensor in config['sensors']:
serial = sensor['serial']
url = serial['url']
if url.startswith('taco://'): url = 'TACO:' + url[7:]
elif url.startswith('tango://'): url = 'TACO:tango:' + url[8:]
gauges.append('kellergaugeadd 0 {0}'.format(sensor['serial_nb']))
baudrate = str(serial.get('baudrate', 9600))
pressure = sensor['pressure_name']
temperature = sensor['temperature_name']
counters.append([pressure, temperature])
spec_ctrl = self.__add_serial(url, baudrate)
serial_lines.append(str(spec_ctrl.indnum))
pressure_counter = Counter(ctrl='NONE', unit=0, chan=0,
mne=pressure, name=pressure)
self.spec_config.addCounter(pressure_counter)
temperature_counter = Counter(ctrl='NONE', unit=0, chan=0,
mne=temperature, name=temperature)
self.spec_config.addCounter(temperature_counter)
counters = ['{0} {1} {2}'.format(i+1, p, t)
for i,(p,t) in enumerate(counters)]
setup = SPEC_GASRIG_TEMPLATE.format(serial_lines=' '.join(serial_lines),
add='\n'.join(gauges),
counters=' '.join(counters),
wago=wago_name)
self.__spec_setup.append(setup)
self.__spec_macros.add('kellergauge.mac')
self.__spec_macros.add('gasrig2.mac')
def add_xia(self, session_name, name, config_name):
device_name = '{0}/xia/{1}'.format(self.beamline, name)
......
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