Node('fs.psi.ch',
     'small vacuum furnace',
     'tcp://5000',
)

Mod('T',
    'frappy_psi.furnace.PI2',
    'controlled Temperature on sample (2nd loop)',
    value = Param(unit='degC'),
    meaning = ['temperature', 30],
    input_module = 'T_sam',
    output_module = 'T_reg',
    p = 1.2,
    i = 0.005,
   )

Mod('T_reg',
    'frappy_psi.furnace.PIctrl',
    'controlled Temperature on heater',
    value = Param(unit='degC'),
    input_module = 'T_htr',
    output_module = 't_out',
    output_min = 0,
    output_max = 100,
    p = 1,
    i = 0.003,
   )

#Mod('p_reg',
#    'frappy_psi.furnace.PI',
#    'controlled pressure',
#    input_module = 'p',
#    output_module = 't_out',
#    p = 1,
#    i = 0.005,
#   )

Mod('T_htr',
    'frappy_psi.furnace.PRtransmitter',
    'heater temperature',
    addr = 'ai4',
    valuerange = (0, 1372),
    value = Param(unit='degC'),
   )


Mod('T_sam',
    'frappy_psi.furnace.PRtransmitter',
    'sample temperature',
    addr = 'ai2',
    valuerange = (0, 1372),
    value = Param(unit='degC'),

   )

Mod('T_extra',
    'frappy_psi.furnace.PRtransmitter',
    'extra temperature',
    addr = 'ai3',
    valuerange = (0, 1372),
    value = Param(unit='degC'),
   )

Mod('T_wall',
    'frappy_psi.ionopimax.VoltageInput',
    'furnace wall temperature',
    addr = 'av2',
    rawrange = (0, 1.5),
    valuerange = (0, 150),
    value = Param(unit='degC'),
   )

Mod('htr_io',
    'frappy_psi.bkpower.IO',
    'powersupply communicator',
    uri = 'serial:///dev/ttyUSBupper',
   )

Mod('htr',
    'frappy_psi.bkpower.Power',
    'heater power',
    io= 'htr_io',
   )

Mod('t_out',
    'frappy_psi.bkpower.Output',
    'heater output',
    # p_value = 'p_out',
    io = 'htr_io',
    maxvolt = 50,
    maxcurrent = 2,
   )

Mod('relay',
    'frappy_psi.ionopimax.DigitalOutput',
    'relais for power output',
    addr = 'o2',
   )

Mod('interlock',
    'frappy_psi.furnace.Interlocks',
    'interlock parameters',
    input = 'T_htr',
    wall_T = 'T_wall',
    htr_T = 'T_htr',
    main_T = 'T_sam',
    reg_T = 'T_reg',
    extra_T = 'T_extra',
    htr = 't_out',
    vacuum = 'p',
    relay = 'relay',
    control = 'T',
    wall_limit = 60,
    vacuum_limit = 0.001,
    disabled_checks = 'T_extra',
   )

Mod('p',
    'frappy_psi.furnace.PKRgauge',
    'pressure reading',
    addr = 'av1',
    rawrange = (1.82, 8.6),
    valuerange = (5e-9, 1000),
    value = Param(unit='mbar'),
   )

Mod('vso',
    'frappy_psi.ionopimax.VoltagePower',
    'voltage power output',
    target = 24,
    export = False,
   )
