Merge branch 'master' of gitlab.psi.ch-samenv:samenv/sea

This commit is contained in:
2023-09-25 13:21:26 +02:00
8 changed files with 78 additions and 26 deletions

View File

@ -28,7 +28,7 @@ GraphAdd 17tf.nlevel % N2_lev black
#makeCCU4 blank nv #makeCCU4 blank nv
#GraphAdd nv.flow mbar nv_flow red #GraphAdd nv.flow mbar nv_flow red
makenv ln2fill -driver ccu4ext n2 "17tf nlevel" makenv ln2fill -driver ccu4ext n2 /17tf/nlevel
#make17tfNv #make17tfNv

View File

@ -3,7 +3,7 @@ namespace eval ccu4ext {
} }
# automatic fill with level reading from external source # automatic fill with level reading from external source
proc stdConfig::ccu4ext {type {readlevel 0}} { proc stdConfig::ccu4ext {type {readpath 0}} {
variable node variable node
variable ctrl variable ctrl
@ -27,13 +27,14 @@ proc stdConfig::ccu4ext {type {readlevel 0}} {
node state upd -text node state upd -text
node readlevel -text par $readlevel node readpath -text par $readpath
prop visible false prop visible false
node lowlevel par 10 node lowlevel par 10
node highlevel par 100 node highlevel par 100
node smooth upd node smooth upd
prop fmt %.7g prop fmt %.7g
prop geterror undefined
default -1 default -1
node minfillminutes par 3.0 node minfillminutes par 3.0
@ -89,7 +90,7 @@ proc ccu4ext::changestate {type state} {
proc ccu4ext::calcsmooth {level minspeed maxspeed} { proc ccu4ext::calcsmooth {level minspeed maxspeed} {
if {![string is double $level]} { if {![string is double $level]} {
return 999.9 return 199
} }
set now [clock seconds] set now [clock seconds]
set lasttime [silent 0 sct lasttime] set lasttime [silent 0 sct lasttime]
@ -98,10 +99,7 @@ proc ccu4ext::calcsmooth {level minspeed maxspeed} {
} }
set delta [expr $now - $lasttime] set delta [expr $now - $lasttime]
sct lasttime $now sct lasttime $now
set smooth [hvali [sct]/smooth] set smooth [silent $level hvali [sct]/smooth]
if {$smooth < 0} {
set smooth $level
}
set gs [expr $smooth + $delta * $maxspeed] set gs [expr $smooth + $delta * $maxspeed]
if {$level > $gs} { if {$level > $gs} {
set smooth $gs set smooth $gs
@ -126,6 +124,7 @@ proc ccu4ext::calcsmooth {level minspeed maxspeed} {
} }
} }
hupdate [sct]/smooth $smooth hupdate [sct]/smooth $smooth
hdelprop [sct]/smooth geterror
return $smooth return $smooth
} }
@ -148,7 +147,8 @@ proc ccu4ext::fillExt {type} {
} }
} }
set errtxt "" 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 { switch -- $valve {
0 { 0 {
set txt "fill valve off" set txt "fill valve off"
@ -178,6 +178,12 @@ proc ccu4ext::fillExt {type} {
set errtxt "unknown error" 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 ""} { if {$errtxt eq ""} {
updateval [sct]/state $txt updateval [sct]/state $txt
hupdate [sct]/status "" hupdate [sct]/status ""
@ -189,11 +195,6 @@ proc ccu4ext::fillExt {type} {
changestate $type fill changestate $type fill
return idle 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 state [sctval [sct]]
set now [clock seconds] set now [clock seconds]
set lowlevel [hvali [sct]/lowlevel] set lowlevel [hvali [sct]/lowlevel]
@ -219,6 +220,7 @@ proc ccu4ext::fillExt {type} {
return idle return idle
} }
0 { # watching 0 { # watching
validated_level
set minspeed [expr - 100.0 / [hvali [sct]/minholdhours] / 3600.] set minspeed [expr - 100.0 / [hvali [sct]/minholdhours] / 3600.]
set maxspeed [expr - 100.0 / [hvali [sct]/maxholdhours] / 3600.] set maxspeed [expr - 100.0 / [hvali [sct]/maxholdhours] / 3600.]
set s [calcsmooth $level $minspeed $maxspeed] set s [calcsmooth $level $minspeed $maxspeed]
@ -231,13 +233,18 @@ proc ccu4ext::fillExt {type} {
} }
# start fill # start fill
hset [sct] 1 hset [sct] 1
clientput "$type level low - start fill" clientput "$type level low ($level smooth $s) - start fill"
} else { } else {
changestate $type stop changestate $type stop
} }
return idle return idle
} }
1 { 1 { # filling
if {[validated_level] eq ""} {
hset [sct] 2
changestate $type off
return idle
}
set vcmd [silent 0 sct vessel_cmd] set vcmd [silent 0 sct vessel_cmd]
# check that vessel command works # check that vessel command works
if {$vcmd ne "0" && [catch {[result $vcmd]}]} { if {$vcmd ne "0" && [catch {[result $vcmd]}]} {
@ -246,7 +253,7 @@ proc ccu4ext::fillExt {type} {
set vmd 0 set vmd 0
} }
set now [clock seconds] set now [clock seconds]
set s [hvali [sct]/smooth] set s [silent $level hval [sct]/smooth]
sct minlevel [silent 999 sct minlevel] sct minlevel [silent 999 sct minlevel]
if {$s < [sct minlevel]} { if {$s < [sct minlevel]} {
sct minlevel $s sct minlevel $s
@ -321,12 +328,30 @@ proc ccu4ext::fillExt {type} {
return idle 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}} { proc ccu4ext::writeExt {type {activate 1}} {
sct update [sct target] sct update [sct target]
hupdate [sct]/smooth [silent 0 result [hvali [sct]/readlevel]]
switch -- [sct target] { switch -- [sct target] {
# watching # watching
0 { 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} catch {logsetup [sct]/vext clear}
hupdate [sct]/status "" hupdate [sct]/status ""
eval [silent "expr 0" sct slow_cmd] eval [silent "expr 0" sct slow_cmd]
@ -350,6 +375,13 @@ proc ccu4ext::writeExt {type {activate 1}} {
} }
# fill # fill
1 { 1 {
set level [validated_level]
if {$level eq ""} {
changestate $type off
sct update 2
return idle
}
hupdate [sct]/smooth $level
hupdate [sct]/status "" hupdate [sct]/status ""
set vcmd [silent 0 sct vessel_cmd] set vcmd [silent 0 sct vessel_cmd]
if {$vcmd ne "0"} { if {$vcmd ne "0"} {

View File

@ -821,8 +821,8 @@ proc dil12::autostep {phase init} {
dil12::msg "pump for 15 more seconds" dil12::msg "pump for 15 more seconds"
} }
} }
} elseif {[sct pumptime] != 0} { # } elseif {[sct pumptime] != 0} {
dil12::msg "there might be some mixure in TRAP A, please check" # dil12::msg "there might be some mixure in TRAP A, please check"
} }
} }
init_pipes_ready { init_pipes_ready {

View File

@ -1,4 +1,4 @@
deviceDesc = FRAPPY history recorder, with stick deviceDesc = MB11 Frappy history recorder
set ::secop_version 4 set ::secop_version 4
@ -11,6 +11,5 @@ if {[string match "prep*" $ins]} {
error "runs on instruments or prep0-9 only" error "runs on instruments or prep0-9 only"
} else { } else {
makenv frappy_main -driver secop -port localhost:15101 makenv frappy_main -driver secop -port localhost:15101
makenv frappy_stick -driver secop -port localhost:15201
makeHePump makeHePump
} }

13
tcl/mb11.stick Normal file
View File

@ -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
}

View File

@ -19,7 +19,7 @@ proc makeHeFill {levcmd} {
if {$levcmd eq "ccu"} { if {$levcmd eq "ccu"} {
makenv hefill he_ext_ccu ccu makenv hefill he_ext_ccu ccu
} elseif {$levcmd eq "ccu4ilm"} { } elseif {$levcmd eq "ccu4ilm"} {
makenv hefill -driver ccu4ext he lev makenv hefill -driver ccu4ext he /lev
lappend fast_cmd {lev mode 1} lappend fast_cmd {lev mode 1}
lappend slow_cmd {lev mode 0} lappend slow_cmd {lev mode 0}
} else { } else {
@ -90,7 +90,7 @@ proc makeN2Fill {{option ccu} {code 0}} {
GraphAdd n2.upper K_2 N2_Upper red GraphAdd n2.upper K_2 N2_Upper red
GraphAdd n2.lower K_2 N2_Lower green GraphAdd n2.lower K_2 N2_Lower green
} elseif {$option eq "ccu4ilm"} { } elseif {$option eq "ccu4ilm"} {
makenv ln2fill -driver ccu4ext n2 "lev n2" makenv ln2fill -driver ccu4ext n2 /lev/n2
GraphAdd lev.n2 % "N2_level" black GraphAdd lev.n2 % "N2_level" black
if {! $c} { if {! $c} {
# switch silently to inactive # switch silently to inactive

8
tcl/startup/dilpars.tcl Normal file
View File

@ -0,0 +1,8 @@
proc apply_dilpars {} {
catch {
ts auto/condenseflow [hval dilpars/condenseflow]
}
catch {
ts auto/circulateflow [hval dilpars/circulateflow]
}
}

View File

@ -177,7 +177,7 @@ proc get_param_values {hp} {
} }
proc check_or_do {doit service cfgs} { 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 result 1
set config "" set config ""
set stick "" set stick ""
@ -199,7 +199,7 @@ proc check_or_do {doit service cfgs} {
if {$doit} { if {$doit} {
if {[hval /device/confirmed] eq [hval /device/name]} { if {[hval /device/confirmed] eq [hval /device/name]} {
set msg "do not allow frappy to change from [hval /device/name] to $config" set msg "do not allow frappy to change from [hval /device/name] to $config"
clientlog $msg clientlog ERROR:$msg
return $msg return $msg
} }
clientlog 0 clientlog 0