Node('ccr12',
     '''[sim] CCR12 box of MLZ Sample environment group
     
     Contains a Lakeshore 336 and an PLC controlling the compressor
     and some valves.
     
     This is how we use it now.''',
     interface='tcp://10767',
)

Mod('T_ccr12',
    'frappy.simulation.SimDrivable',
    description='Main temperature control node of CCR12.\n\nSwitches between regulation on stick and regulation on tube depending on temperature requested.\nMay also pump gas for higher temperatures, if configured.\n\nNote: in nicos this is handled by its own class which manages T_ccr12_stick and T_ccr12_tube.\nin this simulation this module is isolated.',
    extra_params=['ramp'],
    ramp=Param(
        datatype=FloatRange(unit='K/min', minval=0.0, maxval=60.0),
        default=60.0,
    ),
    value=Param(
        datatype=FloatRange(unit='K', minval=0.0, maxval=600.0),
        default=300.0,
    ),
    target=Param(
        datatype=FloatRange(unit='K', minval=0.0, maxval=600.0),
        default=300.0,
    ),
    meaning=('temperature_regulation', 20),
)

Mod('T_ccr12_stick',
    'frappy.simulation.SimDrivable',
    description='Temperature regulation for the sample stick in ccr12.',
    extra_params=['ramp'],
    ramp=Param(
        datatype=FloatRange(unit='K/min', minval=0.0, maxval=60.0),
        default=60.0,
    ),
    value=Param(
        datatype=FloatRange(unit='K', minval=0.0, maxval=600.0),
        default=300.0,
    ),
    target=Param(
        datatype=FloatRange(unit='K', minval=0.0, maxval=600.0),
        default=300.0,
    ),
    meaning=('temperature_regulation', 15),
)

Mod('T_ccr12_tube',
    'frappy.simulation.SimDrivable',
    description='Temperature regulation for the tube of ccr12.',
    extra_params=['ramp'],
    ramp=Param(
        datatype=FloatRange(unit='K/min', minval=0.0, maxval=60.0),
        default=60.0,
    ),
    value=Param(
        datatype=FloatRange(unit='K', minval=0.0, maxval=600.0),
        default=300.0,
    ),
    target=Param(
        datatype=FloatRange(unit='K', minval=0.0, maxval=600.0),
        default=300.0,
    ),
    meaning=('temperature_regulation', 10),
)

Mod('T_ccr12_A',
    'frappy.simulation.SimReadable',
    description='(optional) Sample temperature sensor.',
    value=Param(
        datatype=FloatRange(unit='K'),
        default=300.0,
    ),
    meaning=('temperature', 9),
)

Mod('T_ccr12_B',
    'frappy.simulation.SimReadable',
    description='(regulation) temperature sensor on stick.',
    value=Param(
        datatype=FloatRange(unit='K'),
        default=300.0,
    ),
    meaning=('temperature', 10),
)

Mod('T_ccr12_C',
    'frappy.simulation.SimReadable',
    description='Temperature at the coldhead.',
    value=Param(
        datatype=FloatRange(unit='K'),
        default=70.0,
    ),
    meaning=('temperature', 1),
)

Mod('T_ccr12_D',
    'frappy.simulation.SimReadable',
    description='(regulation) temperature at coupling to stick.',
    value=Param(
        datatype=FloatRange(unit='K'),
        default=80.0,
    ),
    meaning=('temperature', 2),
)

Mod('ccr12_pressure_regulate',
    'frappy.simulation.SimWritable',
    description='Selects on which Sensor the pressure regulation works, or switches it off.',
    visibility='expert',
    value=Param(
        datatype=EnumType('', off=0, p1=1, p2=2),
        default='off',
    ),
    target=Param(
        datatype=EnumType('', off=0, p1=1, p2=2),
        default='off',
    ),
)

Mod('ccr12_compressor',
    'frappy.simulation.SimDrivable',
    description='Switches the compressor for the cooling stage on or off.\n\nNote: This should always be on, except for fast heatup for sample change.',
    value=Param(
        datatype=EnumType('', off=0, on=1),
        default='on',
    ),
    target=Param(
        datatype=EnumType('', off=0, on=1),
        default='on',
    ),
)

Mod('ccr12_gas_switch',
    'frappy.simulation.SimWritable',
    description='Switches the gas inlet on or off.\n\nnote: in reality this switches itself off after 15min.\nnote: in reality this is interlocked with ccr12_vacuum_switch, only one can be on!\nnote: in this simulation this module is isolated.',
    value=Param(
        datatype=EnumType('', off=0, on=1),
        default='off',
    ),
    target=Param(
        datatype=EnumType('', off=0, on=1),
        default='off',
    ),
)

Mod('ccr12_vacuum_switch',
    'frappy.simulation.SimWritable',
    description='Switches the vacuum pumping valve on or off.\n\nnote: in reality this is interlocked with ccr12_gas_switch, only one can be on!\nnote: in this simulation this module is isolated.',
    value=Param(
        datatype=EnumType('', off=0, on=1),
        default='off',
    ),
    target=Param(
        datatype=EnumType('', off=0, on=1),
        default='off',
    ),
)

Mod('ccr12_p1',
    'frappy.simulation.SimReadable',
    description='Default pressure Sensor, linear scale 0..1000mbar',
    value=Param(
        datatype=FloatRange(unit='mbar'),
        default=999.0,
    ),
)

Mod('ccr12_p2',
    'frappy.simulation.SimReadable',
    description='Auxillary pressure Sensor.',
    value=Param(
        datatype=FloatRange(unit='mbar'),
        default=1e-06,
    ),
)

Mod('ccr12_curve_p2',
    'frappy.simulation.SimWritable',
    description='Curve for Aux pressure Sensor p2',
    visibility='expert',
    value=Param(
        default='TTR100',
        datatype=EnumType('', 0..10V=0, default=1, 0..9V=2, DI200=3, DI2000=4, TTR100=7, PTR90=8, PTR225/PTR237=9, ITR90=10, ITR100 curve D=11, ITR100 curve 2=12, ITR100 curve 3=13, ITR100 curve 4=14, ITR100 curve 5=15, ITR100 curve 6=16, ITR100 curve 7=17, ITR100 curve 8=18, ITR100 curve 9=19, ITR100 curve A=20, CMR361=21, CMR362=22, CMR363=23, CMR364=24, CMR365=25),
    ),
    target=Param(
        datatype=EnumType('', 0..10V=0, default=1, 0..9V=2, DI200=3, DI2000=4, TTR100=7, PTR90=8, PTR225/PTR237=9, ITR90=10, ITR100 curve D=11, ITR100 curve 2=12, ITR100 curve 3=13, ITR100 curve 4=14, ITR100 curve 5=15, ITR100 curve 6=16, ITR100 curve 7=17, ITR100 curve 8=18, ITR100 curve 9=19, ITR100 curve A=20, CMR361=21, CMR362=22, CMR363=23, CMR364=24, CMR365=25),
    ),
)

Mod('ccr12_p1_limits',
    'frappy.simulation.SimWritable',
    description='Limits for pressure regulation in P1.',
    visibility='expert',
    value=Param(
        datatype=TupleOf(FloatRange(unit='mbar', minval=0.0, maxval=1000.0), FloatRange(unit='mbar', minval=0.0, maxval=1000.0)),
        default=(0.0, 10.0),
    ),
    target=Param(
        datatype=TupleOf(FloatRange(unit='mbar', minval=0.0, maxval=1000.0), FloatRange(unit='mbar', minval=0.0, maxval=1000.0)),
        default=(0.0, 10.0),
    ),
)

Mod('ccr12_p2_limits',
    'frappy.simulation.SimWritable',
    description='Limits for pressure regulation in P2.',
    visibility='expert',
    value=Param(
        datatype=TupleOf(FloatRange(unit='mbar', minval=0.0, maxval=1000.0), FloatRange(unit='mbar', minval=0.0, maxval=1000.0)),
        default=(1e-05, 0.001),
    ),
    target=Param(
        datatype=TupleOf(FloatRange(unit='mbar', minval=0.0, maxval=1000.0), FloatRange(unit='mbar', minval=0.0, maxval=1000.0)),
        default=(1e-05, 0.001),
    ),
)
