#----- IGH dil gas handling system ------

proc makeDil args {
  scanargs $args var -port 0
  makenv dil -driver igh -port $port
  Layout dil
#  appendVars dil.tmix/K/Mix_T/6 dil.tsorb/K/Sorb_T/10 dil.t1k/K/OneK_T/5
  appendVars dil.G1/mbar/G1/3 dil.G2/mbar/G2/5 dil.G3/mbar/G3/6 dil.P1/mbar/P1/7 dil.P2/mbar/IVC/8
  appendVars dil.V12a/%/V12a/3 dil.v6pos/%/V6/5 dil.psorb/mW/Sorb_P/10
}

proc dilLayout args {
  Group dil "dilution gas handling system"
}

proc dilGroup {} {
  showStatus dil
  if {[result dil tset] >= 0} {
    Tip set temperature \[K\]
    Input "set T" "run dil/[result dil tset]"
    Newline
  }
  Tip Still power \[mW\]
  Input "still power" "dil pstill"
  Tip power mixing chamber \[mW\]
  Input "power mixCh." "dil pmix"
  Newline
  Tip "heater range (0...5)"
  Input "heater range" "dil htrRange"
  Label "[dil enumText htrRange]"
  Newline
  Tip sorb set temperature \[K\]
  Input "sorb set T" "dil tsorbset"
  Tip sorb power \[W\]
  Input "sorb power" "dil psorb"
  Newline
  Group valves "gas handling valves and switches"
  if {[result dil extVersion] > 0} {
    Group trap "LN2 trap"
  }
}

proc valvesGroup {} {
  Tip entry cold trap 1
  CheckBox "V13A" "dil v13a"
  NoNewline
  Tip condenser line
  CheckBox "V1" "dil v1"
  NoNewline
  CheckBox "3He pump" "dil he3"
  NoNewline
  Tip IVC turbo pump
  CheckBox "V4A" "dil v4a"
  Newline
  Tip pump out dump
  CheckBox "V14" "dil v14"
  NoNewline
  Tip dump in (behind pump)
  CheckBox "V9" "dil v9"
  NoNewline
  Tip condenser to pump line short
  CheckBox "V3" "dil v3"
  Newline
  Tip cold trap 1 outlet
  Input "valve 12A" "dil v12a"
  Tip pumping line
  Input "valve 6" "dil v6"
  Newline
  foreach v [list V2 V4 V5 V7 V8 V10 V11A V11B V12B V13B V1A V2A V5A] {
    if {[result dil $v]} {
      NoNewline
      Style warning
      CheckBox $v "dil $v"
    }
  }
}

proc trapGroup {} {
  Value upperN2 "dil upperN2"
  Value lowerN2 "dil lowerN2"
}
