Node('leiden.psi.ch',
     'Leiden Dilution, basic config',
     'tcp://5000',
     secondary = ['ws://8051']
)

IO('io_tcs', 'linse-leiden-ts:3005')
IO('io_htr', 'linse-leiden-ts:3007')
IO('io_ghs', 'linse-521e-ts:3001')
IO('io_pfeiffer', 'linse-521e-ts:3002')
IO('io_ccr', 'linse-521e-ts:3003')

# ah2700: linse-leiden-ts:3002, see leidenexp_cfg.py)
# ls370: 'linse-leiden-ts:3004, see  ~/sea/tcl/leiden.config
# nanovolt: linse-leiden-ts:3006, see ~/sea/tcl/leiden.config
# k2601b: linse-leiden-ts:3006, see leidenexp_cfg.py ( used for HC experiment as heater)
# SR bridge: linse-leiden-ts:3008, see leidenexp_cfg.py

Mod('sea_conn',  # do not use sea_main, as this is used in addons/leidenexp_cfg.py
    'frappy_psi.sea.SeaClient',
    'main sea connection for leiden.config',
    config = 'leiden.config',
    service = 'main',
    uri = 'localhost:8648',  # for prep8. TODO: check why this is not taken automatically
)

Mod('T_mix',
    'frappy_psi.sea.SeaReadable', '',
    io='sea_conn',
    sea_object='tt',
    rel_paths=['Tmix'],
    value=Param(unit='K'),
    extra_modules = ['raw'],
    meaning = ['temperature', 20],
)

Mod('R_mix',
    'frappy_psi.sea.SeaReadable', '',
    io='sea_conn',
    value=Param(unit='Ohm'),
    single_module='T_mix.raw'
)

Mod('still_htr',
    'frappy_psi.tcs.Heater',
    'still heater',
    io='io_tcs',
    channel=2,
    )

Mod('mix_htr',
    'frappy_psi.dilhtr.WrappedHeater',
    'mixing chamber heater',
    io='io_htr',
    )

Mod('drive_mix',
    'frappy_psi.picontrol.PIctrl',
    'controlled mix ch. temperature',
    input_module = 'T_mix',
    output_module = 'mix_htr',
    output_min = 0,
    output_max = 0.02,
    p = 5,
    itime = 60,
   )

for name in [
  'A0', 'A1', 'A10', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9',
  'AUX1', 'He3', 'He4', 'S1', 'S2', 'S3', 'S4', 'S5',
  'V0', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9',
  'V10', 'V11', 'V12', 'V13', 'V14', 'V15', 'V16', 'V17',
  'auto', 'bypass', 'circulation', 'gate18', 'ledtest', 'mixcompr', 'recovery', 'reset', 'start']:
    Mod(name,
       'frappy_psi.leidenghs.Valve',
       f'switch or valve {name}',
       io='io_ghs',
       key=name,
    )

Mod('p0',
    'frappy_psi.leidenghs.Pressure',
    'test pressure p0',
    io='io_ghs',
    addr='p0',
    scale=2**12 / 1e4,
    )

for pname in ['p2', 'p3', 'p4', 'p5']:
    Mod(pname,
        'frappy_psi.leidenghs.Pressure',
        'pressure {pname}',
        io='io_ghs',
        addr=pname,
    )

Mod('p6',
    'frappy_psi.leidenghs.PressureLimit',
    'test pressure with limits p6',
    io='io_ghs',
    addr='p6',
    offset=0,
    )

Mod('p7',
    'frappy_psi.leidenghs.PressureLimit',
    'test pressure with limits p7',
    io='io_ghs',
    addr='p7',
    offset=0,
    )

Mod('flow',
    'frappy_psi.leidenghs.PressureLimit',
    'condense flow',
    io='io_ghs',
    addr='flow',
    offset=0,
    value=Param(unit='ln/min'),
    scale = 2**15 / 1e2,
    )

for pname, addr in [('p8', 4), ('p9', 3), ('p10', 2)]:
    Mod(pname,
        'frappy_psi.pfeiffer.Pressure',
        f'pressure reading {pname}',
        io = 'io_pfeiffer',
        channel = addr,
    )

#Mod('ccr_compressor',
#    'frappy_psi.cp2800.CP2800',
#    'cryocooler compressor',
#    io='io_ccr',
#)
