Files
sea/tcl/drivers/bfgh.tcl

217 lines
4.8 KiB
Tcl

# BF dilution pressure readings pc9193 port 1234
namespace eval bfgh {} {
}
proc stdConfig::bfgh {} {
controller std "\n" 5
prop startcmd "names"
obj BlueForsPressureLog -none
kids "BF Gashandling Sensors" {
node pivc rd
prop readcmd "mgstatus 1"
prop readfmt "S05: %g"
node pstill rd
prop readcmd "mgstatus 2"
prop readfmt "S05: %g"
node pcond rd
prop readcmd "mgstatus 3"
prop readfmt "S05: %g"
node phep rd
prop readcmd "mgstatus 4"
prop readfmt "S05: %g"
node pdump rd
prop readcmd "mgstatus 5"
prop readfmt "S05: %g"
node paux rd
prop readcmd "mgstatus 6"
prop readfmt "S05: %g"
node flow rd
prop readcmd "fmstatus"
prop readfmt "S09: %g"
node v11 wr
prop help "Dump PumpOUT"
prop write bfgh::setrmt
prop enum 1
prop read bfgh::chanread
foreach {node help} {
v2 "Gate Bypass"
v1 "Gate Valve"
turbo1 "Still Turbo"
v12 "Dump slow PumpOUT"
v3 "Still-Condenser Short"
v10 "before He-3 Scroll"
turbo2 "Aux. Turbo"
v14 "common Vacuum 1"
v4 "Compressor Bypass"
v13 "Dump return"
compressor "condensation Compressor"
v15 " !!!Still-Aux Short!!!"
v5 "Compressor out"
hs-still "Heat switch 4K-Still"
v21 "Aux Turbo bypass"
v16 "common vacuum 2"
v6 "Compressor in"
scroll1 "He-3 Scroll"
v22 "Aux Turbo in"
v17 " !!!Condeser-Aux short!!!"
v7 "Ln2 Trap out"
scroll2 "Aux Scroll"
v23 "Aux Turbo out"
v18 " !!!Still-Aux short2!!!"
v8 "LN2 Trap bypass"
pulsetube "Pulse Tube"
v19 "Venting"
v20 "aux (Venting 2)"
v9 "LN2 Trap in"
hs-mc "Heat Switch Still-MC"
ext "Still Heater"
} {
node $node out
prop help $help
prop write bfgh::setrmt
prop enum 1
}
node ext_still_control par 1
prop help "control still with lakeshore 370 output from /bfgh/ext"
prop enum 1
node stillpower wr
default 0.01
prop help "when /bfgh/ext is on, stillpower is applied to /tbf/set/manualpower"
prop check bfgh::check_still
prop write stdSct::completeUpdate
prop read bfgh::read_still
node serial_turbo_control par 1
prop help "use serial instead of analog connection for switching turbo on/off"
prop enum 1
}
variable ctrl
variable path
$ctrl updatescript $path/ext bfgh::ext_update
$ctrl updatescript $path/turbo1 bfgh::turbo1_update
}
proc bfgh::ext_update {value} {
if {[hval [sct parent]/ext_still_control]} {
set old [hval /tbf/set/mode]
set oldp [hval /tbf/set/manualpower]
if {$value} {
set new 2
set newp [hval [sct parent]/stillpower]
} else {
set new 0
set newp 0
}
if {$new != $old} {
hset /tbf/set/mode $new
}
if {$newp != $oldp} {
hset /tbf/set/manualpower $newp
}
}
}
proc bfgh::read_still {} {
[sct controller] updatescript /tbf/set/manualpower "bfgh::update_still [sct]"
sct update [hvali [sct]]
return idle
}
proc bfgh::update_still {path value} {
if {$value} {
updateval $path $value
}
return idle
}
proc bfgh::check_still {} {
if {[sctval [sct parent]/ext_still_control]} {
tbf set/manualpower [sct target]
}
}
proc bfgh::turbo1_update {value} {
set ser [hval [sct parent]/serial_turbo_control]
if {$ser} {
if {$value} {
if {!([hval /turbo1a/on] && [hval /turbo1a/motor] && [hval /turbo1b/on] && [hval /turbo1b/motor])} {
turbo1a on 1
turbo1b on 1
turbo1a motor 1
turbo1b motor 1
}
} else {
if {[hval /turbo1a/on] || [hval /turbo1a/motor] || [hval /turbo1b/on] || [hval /turbo1b/motor]} {
turbo1a motor 0
turbo1b motor 0
turbo1a on 0
turbo1b on 0
}
}
}
}
proc bfgh::chanread {} {
sct send "status"
return bfgh::chanupd
}
proc bfgh::chanupd {} {
set response [string range [sct result] 5 end]
foreach chan [split $response ","] {
set c [split $chan "="]
hupdate [sct parent]/[lindex $c 0] [lindex $c 1]
}
hdelprop [sct] geterror
return idle
}
proc bfgh::setrmt {} {
sct send "control 1"
return bfgh::takectrl
}
proc bfgh::takectrl {} {
sct send "remote 1"
return bfgh::writechan
}
proc bfgh::writechan {} {
set node [lindex [split [sct] "/"] end]
if {$node == "v15"|| $node == "v17"|| $node == "v18"} {
hdelprop [sct parent]/$node requested
clientput "ERROR: you are not allowed to change these values"
# this are special valves they need confirmation
} else {
if {[sct target]} {
sct send "on $node"
} else {
sct send "off $node"
}
}
return bfgh::rtnctrl
}
proc bfgh::rtnctrl {} {
sct send "remote 0"
return bfgh::rtnrmt
}
proc bfgh::rtnrmt {} {
sct send "control 0"
return bfgh::chanread
}