fix autofill with extrnal level meter
when no value is available, filling must be inhibited. this patch checks whether a value newer than 30 sec is available
This commit is contained in:
@ -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
|
||||||
|
@ -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"} {
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user