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

Conflicts:
	tcl/drivers/hepump.tcl
This commit is contained in:
2023-10-24 13:21:16 +02:00
21 changed files with 229 additions and 167 deletions

View File

@ -160,29 +160,33 @@ proc hepump::set_calib {} {
hsetprop /nv off_reason "pump mode changed"
sct print "pump mode change: suspend needle valve control for 20 sec."
}
return idle
return idle
}
proc hepump::read {} {
set p [expr [silent 0 result cc f] * [silent 0.6 hvali /nv/calib/ln_per_min_per_mbar]]
set f [silent 0 result nvflow]
if {[hvali [sct]/eco] == 0 && $p > 1 && $f > 0.5 && $f < 25} {
set health [expr 100 * $f / ($p / 1.2 - 0.5)]
set health [expr [silent $health sct health] * 0.95 + 0.05 * $health]
sct health $health
if {abs($health - [silent 0 hval [sct]/health]) > 1} {
sct health_cnt 0
hupdate [sct]/health [format %.1f $health]
} else {
sct health_cnt [expr [sct health_cnt] + 1]
if {[sct health_cnt] == 10} {
if {$health > 100} {set health 100}
catch {prep0 / pump_health_update [result instrument] [format %.0f $health]} msg
}
set p [silent 0 result nv flowp]
set f [silent 0 result nv flow]
set p_buf [silent 0 sct p_buf]
set f_buf [silent 0 sct f_buf]
lappend p_buf $p
lappend f_buf $f
sct p_buf [lrange $p_buf end-30 end]
sct f_buf [lrange $f_buf end-30 end]
set pmin [tcl::mathfunc::min {*}$p_buf]
set pmax [tcl::mathfunc::max {*}$p_buf]
set fmin [tcl::mathfunc::min {*}$f_buf]
set fmax [tcl::mathfunc::max {*}$f_buf]
if {[silent 0 hval [sct]/eco] == 0 && $pmin >= 1 && $fmin >= 0.5 && $fmin < 25} {
set hmax [expr round(100 * $fmax / ($pmin - 0.4))]
set hmin [expr round(100 * $fmin / ($pmax - 0.4))]
set health [silent 100 hval [sct]/health]
if {$hmax < $health} {
set health $hmax
} elseif {$hmin > $health} {
set health $hmin
}
} else {
# reset filter
hdelprop [sct] health
hupdate [sct]/health $health
catch {prep0 / pump_health_update [result instrument] [expr min($health, 100)]} msg
}
return [hepump::set_calib]
}
@ -401,7 +405,9 @@ proc hepump::get_auto {} {
set eco [sctval [sct parent]/eco]
set lim [sctval [sct parent]/eco_t_lim 7]
set target [silent [silent $lim hval /tt/target] hval /tt/set/reg]
if {$target < $lim && [silent $lim hval /tt] < 2 * $lim} {
if {[silent 0 result nv use_pressure]} {
set ecoset 0
} elseif {$target < $lim && [silent $lim hval /tt] < 2 * $lim} {
set ecoset 0
} elseif {$target > $lim || [silent $lim hval /tt] > 3 * $lim} {
set ecoset 1