diff --git a/frappy_psi/ccracks.py b/frappy_psi/ccracks.py index d16d5616..a8eab23c 100644 --- a/frappy_psi/ccracks.py +++ b/frappy_psi/ccracks.py @@ -3,6 +3,7 @@ from glob import glob from pathlib import Path from configparser import ConfigParser from frappy.errors import ConfigError +from frappy.config import Param class Rack: @@ -14,6 +15,7 @@ class Rack: sections = {} self.config = {} files = glob(str(instpath / '*.ini')) + # TODO: why may we accept several rack configs? for filename in files: parser = ConfigParser() parser.optionxform = str @@ -24,7 +26,7 @@ class Rack: raise ConfigError(f'duplicate {section} section in {filename} and {prev}') sections[section] = filename self.config.update(parser.items(section)) - if 'rack' not in sections: + if 'config' not in sections: raise ConfigError(f'no rack found in {instpath}') self.props = {} # dict (, ) of value self.mods = {} # dict (, ) of list of @@ -39,7 +41,7 @@ class Rack: else: # set prop in current module if not mod.get(prop): # do not override given and not empty property - mod[prop] = value + mod[prop] = Param(value) def fix_props(self, method, **kwds): for prop, value in kwds.items(): @@ -48,12 +50,12 @@ class Rack: self.props[prop, method] = value # set property in modules to be fixed for mod in self.mods.get((prop, method), ()): - mod[prop] = value + mod[prop] = Param(value) def lakeshore(self, ls_uri=None, io='ls_io', dev='ls', model='336', **kwds): Mod = self.modfactory self.fix_props('lakeshore', io=io, device=dev) - self.ls_model = model + self.ls_model = self.config.get('ls_model', model) self.ls_dev = dev ls_uri = ls_uri or self.config.get('ls_uri') Mod(io, cls=f'frappy_psi.lakeshore.IO{self.ls_model}', @@ -129,7 +131,7 @@ class Rack: Mod = self.modfactory hepump_type = hepump_type or self.config.get('hepump_type', 'no') Mod(nv, 'frappy_psi.ccu4.NeedleValveFlow', 'flow from flow sensor or pump pressure', - flow_sensor=flow_sensor, pressure=pump_pressure, io=ccu_io, **kwds) + flow_sensor=flow_sensor, pressure=pump_pressure, io=ccu_io, pump_type=hepump_type, **kwds) Mod(pump_pressure, 'frappy_psi.ccu4.Pressure', 'He pump pressure', io=ccu_io) if hepump_type == 'no': print('no pump, no flow meter - using flow from pressure alone') @@ -137,7 +139,7 @@ class Rack: hepump_uri = hepump_uri or self.config['hepump_uri'] Mod(hepump_io, 'frappy.io.BytesIO', 'He pump connection', uri=hepump_uri) Mod(hepump, 'frappy_psi.hepump.HePump', 'He pump', pump_type=hepump_type, - valvemotor=hepump_mot, valve=hepump_valve, flow=nv) + valvemotor=hepump_mot, valve=hepump_valve) Mod(hepump_mot, 'frappy_psi.hepump.Motor', 'He pump valve motor', io=hepump_io, maxcurrent=2.8) Mod(hepump_valve, 'frappy_psi.butterflyvalve.Valve', 'He pump valve', motor=hepump_mot) Mod(flow_sensor, 'frappy_psi.sensirion.FlowSensor', 'Flow Sensor', io=hepump_io, nsamples=160)