diff --git a/tcl/17tf.config b/tcl/17tf.config index 195505e..8dde30d 100644 --- a/tcl/17tf.config +++ b/tcl/17tf.config @@ -28,7 +28,7 @@ GraphAdd 17tf.nlevel % N2_lev black #makeCCU4 blank nv #GraphAdd nv.flow mbar nv_flow red -makenv ln2fill -driver ccu4ext n2 "17tf nlevel" +makenv ln2fill -driver ccu4ext n2 /17tf/nlevel #make17tfNv diff --git a/tcl/drivers/ccu4ext.tcl b/tcl/drivers/ccu4ext.tcl index 4292795..c3b15d9 100644 --- a/tcl/drivers/ccu4ext.tcl +++ b/tcl/drivers/ccu4ext.tcl @@ -3,7 +3,7 @@ namespace eval ccu4ext { } # automatic fill with level reading from external source -proc stdConfig::ccu4ext {type {readlevel 0}} { +proc stdConfig::ccu4ext {type {readpath 0}} { variable node variable ctrl @@ -27,13 +27,14 @@ proc stdConfig::ccu4ext {type {readlevel 0}} { node state upd -text - node readlevel -text par $readlevel + node readpath -text par $readpath prop visible false node lowlevel par 10 node highlevel par 100 node smooth upd prop fmt %.7g + prop geterror undefined default -1 node minfillminutes par 3.0 @@ -89,7 +90,7 @@ proc ccu4ext::changestate {type state} { proc ccu4ext::calcsmooth {level minspeed maxspeed} { if {![string is double $level]} { - return 999.9 + return 199 } set now [clock seconds] set lasttime [silent 0 sct lasttime] @@ -98,10 +99,7 @@ proc ccu4ext::calcsmooth {level minspeed maxspeed} { } set delta [expr $now - $lasttime] sct lasttime $now - set smooth [hvali [sct]/smooth] - if {$smooth < 0} { - set smooth $level - } + set smooth [silent $level hvali [sct]/smooth] set gs [expr $smooth + $delta * $maxspeed] if {$level > $gs} { set smooth $gs @@ -126,6 +124,7 @@ proc ccu4ext::calcsmooth {level minspeed maxspeed} { } } hupdate [sct]/smooth $smooth + hdelprop [sct]/smooth geterror return $smooth } @@ -148,7 +147,8 @@ proc ccu4ext::fillExt {type} { } } set errtxt "" - set sm [expr [DoubleTime] > [silent 0 sct change_time] + 10] + set now [DoubleTime] + set sm [expr $now > [silent 0 sct change_time] + 10] switch -- $valve { 0 { set txt "fill valve off" @@ -178,6 +178,12 @@ proc ccu4ext::fillExt {type} { set errtxt "unknown error" } } + set rdpath [hvali [sct]/readpath] + set level [hvali $rdpath] + set levelerror [silent "" hgetpropval $rdpath geterror] + if {$levelerror ne "" && $errtxt eq ""} { + set errtxt "$txt ($rdpath $levelerror)" + } if {$errtxt eq ""} { updateval [sct]/state $txt hupdate [sct]/status "" @@ -189,11 +195,6 @@ proc ccu4ext::fillExt {type} { changestate $type fill return idle } - set level [silent invalid result [hvali [sct]/readlevel]] - if {! [string is double $level]} { - hsetprop [sct]/readlevel geterror "illegal $type level reading" - return idle - } set state [sctval [sct]] set now [clock seconds] set lowlevel [hvali [sct]/lowlevel] @@ -219,6 +220,7 @@ proc ccu4ext::fillExt {type} { return idle } 0 { # watching + validated_level set minspeed [expr - 100.0 / [hvali [sct]/minholdhours] / 3600.] set maxspeed [expr - 100.0 / [hvali [sct]/maxholdhours] / 3600.] set s [calcsmooth $level $minspeed $maxspeed] @@ -231,13 +233,18 @@ proc ccu4ext::fillExt {type} { } # start fill hset [sct] 1 - clientput "$type level low - start fill" + clientput "$type level low ($level smooth $s) - start fill" } else { changestate $type stop } return idle } - 1 { + 1 { # filling + if {[validated_level] eq ""} { + hset [sct] 2 + changestate $type off + return idle + } set vcmd [silent 0 sct vessel_cmd] # check that vessel command works if {$vcmd ne "0" && [catch {[result $vcmd]}]} { @@ -246,7 +253,7 @@ proc ccu4ext::fillExt {type} { set vmd 0 } set now [clock seconds] - set s [hvali [sct]/smooth] + set s [silent $level hval [sct]/smooth] sct minlevel [silent 999 sct minlevel] if {$s < [sct minlevel]} { sct minlevel $s @@ -321,12 +328,30 @@ proc ccu4ext::fillExt {type} { return idle } +proc ccu4ext::validated_level {} { + set rdpath [hval [sct]/readpath] + if {[DoubleTime] < [silent 0 hgetpropval $rdpath read_time] + 30} { + return [hval $rdpath] + } + if {[silent "" hgetpropval $rdpath geterror] eq ""} { + clientlog "ERROR: no reading of $rdpath within 30 sec" + } + hsetprop $rdpath geterror not_available + return "" +} + proc ccu4ext::writeExt {type {activate 1}} { sct update [sct target] - hupdate [sct]/smooth [silent 0 result [hvali [sct]/readlevel]] switch -- [sct target] { # watching 0 { + set level [validated_level] + if {$level eq ""} { + changestate $type off + sct update 2 + return idle + } + hupdate [sct]/smooth $level catch {logsetup [sct]/vext clear} hupdate [sct]/status "" eval [silent "expr 0" sct slow_cmd] @@ -350,6 +375,13 @@ proc ccu4ext::writeExt {type {activate 1}} { } # fill 1 { + set level [validated_level] + if {$level eq ""} { + changestate $type off + sct update 2 + return idle + } + hupdate [sct]/smooth $level hupdate [sct]/status "" set vcmd [silent 0 sct vessel_cmd] if {$vcmd ne "0"} { diff --git a/tcl/drivers/dil12.tcl b/tcl/drivers/dil12.tcl index baef43a..4aa078e 100644 --- a/tcl/drivers/dil12.tcl +++ b/tcl/drivers/dil12.tcl @@ -821,8 +821,8 @@ proc dil12::autostep {phase init} { dil12::msg "pump for 15 more seconds" } } - } elseif {[sct pumptime] != 0} { - dil12::msg "there might be some mixure in TRAP A, please check" + # } elseif {[sct pumptime] != 0} { + # dil12::msg "there might be some mixure in TRAP A, please check" } } init_pipes_ready { diff --git a/tcl/mb11.config b/tcl/mb11.config index bef6fac..9478384 100644 --- a/tcl/mb11.config +++ b/tcl/mb11.config @@ -1,4 +1,4 @@ -deviceDesc = FRAPPY history recorder, with stick +deviceDesc = MB11 Frappy history recorder set ::secop_version 4 @@ -11,6 +11,5 @@ if {[string match "prep*" $ins]} { error "runs on instruments or prep0-9 only" } else { makenv frappy_main -driver secop -port localhost:15101 - makenv frappy_stick -driver secop -port localhost:15201 makeHePump } diff --git a/tcl/mb11.stick b/tcl/mb11.stick new file mode 100644 index 0000000..613f28f --- /dev/null +++ b/tcl/mb11.stick @@ -0,0 +1,13 @@ +deviceDesc = MB11 stick Frappy history recorder + +set ::secop_version 4 + +set ins [result instrument] +if {[string match "prep*" $ins]} { + set nr [string range $ins end end] + makenv frappy_stick -driver secop -port localhost:1521$nr +} elseif {[lindex [split [info hostname] .] 0] ne $ins} { + error "runs on instruments or prep0-9 only" +} else { + makenv frappy_stick -driver secop -port localhost:15201 +} diff --git a/tcl/startup/autofill.tcl b/tcl/startup/autofill.tcl index ebb203a..6cbbf6c 100644 --- a/tcl/startup/autofill.tcl +++ b/tcl/startup/autofill.tcl @@ -19,7 +19,7 @@ proc makeHeFill {levcmd} { if {$levcmd eq "ccu"} { makenv hefill he_ext_ccu ccu } elseif {$levcmd eq "ccu4ilm"} { - makenv hefill -driver ccu4ext he lev + makenv hefill -driver ccu4ext he /lev lappend fast_cmd {lev mode 1} lappend slow_cmd {lev mode 0} } else { @@ -90,7 +90,7 @@ proc makeN2Fill {{option ccu} {code 0}} { GraphAdd n2.upper K_2 N2_Upper red GraphAdd n2.lower K_2 N2_Lower green } elseif {$option eq "ccu4ilm"} { - makenv ln2fill -driver ccu4ext n2 "lev n2" + makenv ln2fill -driver ccu4ext n2 /lev/n2 GraphAdd lev.n2 % "N2_level" black if {! $c} { # switch silently to inactive diff --git a/tcl/startup/dilpars.tcl b/tcl/startup/dilpars.tcl new file mode 100644 index 0000000..6d97a17 --- /dev/null +++ b/tcl/startup/dilpars.tcl @@ -0,0 +1,8 @@ +proc apply_dilpars {} { + catch { + ts auto/condenseflow [hval dilpars/condenseflow] + } + catch { + ts auto/circulateflow [hval dilpars/circulateflow] + } +} diff --git a/tcl/startup/frappy.tcl b/tcl/startup/frappy.tcl index 748a3b5..4621fa6 100644 --- a/tcl/startup/frappy.tcl +++ b/tcl/startup/frappy.tcl @@ -177,7 +177,7 @@ proc get_param_values {hp} { } proc check_or_do {doit service cfgs} { - # result: 1: no change needed, 0: change needed, 2: failure + # result: 1: no change needed, 0: change needed, "ERROR:...": failure set result 1 set config "" set stick "" @@ -199,7 +199,7 @@ proc check_or_do {doit service cfgs} { if {$doit} { if {[hval /device/confirmed] eq [hval /device/name]} { set msg "do not allow frappy to change from [hval /device/name] to $config" - clientlog $msg + clientlog ERROR:$msg return $msg } clientlog 0