added luft (air in He recovery) scripts

This commit is contained in:
l_samenv
2022-08-22 15:13:44 +02:00
parent 86c169a819
commit 99db0c6bb4
2 changed files with 118 additions and 0 deletions

99
tcl/luft.tclsh Executable file
View File

@ -0,0 +1,99 @@
#!/usr/bin/tclsh
foreach {adr obj} {
IKA-GAMA:Luft_S10 luft
IKA-GAMA:Luft_S2 luft_wlga
} {
set values($adr) -1
set objects($adr) $obj
}
proc readpipe {} {
global sea values
set line [gets $sea(pipe)]
if {$sea(debug)} {
puts stdout "> $line"
}
if {[eof $sea(pipe)]} {
exit
}
lassign $line adr date time value
set values($adr) $value
send_to_sea
}
proc seacom {line} {
global sea
puts $sea(sock) $line
flush $sea(sock)
if {$sea(debug)} {
puts stdout "> $line"
}
}
proc send_to_sea {} {
global sea values objects
foreach adr [array names values] {
if {$values($adr) >= 0} {
seacom "$objects($adr) confirm $sea(heartbeat) $values($adr)"
}
}
catch {after cancel $sea(afterid)}
set sea(afterid) [after [expr int(1000 * $sea(heartbeat))] send_to_sea]
}
proc readsea {} {
global sea values
set line [gets $sea(sock)]
if {[eof $sea(sock)]} {
exit
}
if {$sea(debug)} {
puts stdout "< $line"
}
# if {[scan $line {HEARTBEAT %d %s} sea(heartbeat) values($adr)]} {
# send_to_sea
# }
}
set env(EPICS_CA_ADDR_LIST) cryo-cagw:5062
set env(EPICS_CA_AUTO_ADDR_LIST) NO
set env(PATH) $env(PATH):/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/
set sea(debug) [lindex "$argv 0" 0]
set sea(heartbeat) 300
# connect to sea server prep0
set sea(sock) [socket samenv.psi.ch 8640]
fileevent $sea(sock) readable readsea
if {$sea(debug)} {
seacom "seauser seaser"
} else {
seacom "Spy 007"
}
set cmd "/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/camonitor [array names values]"
set ret [catch {set proc [exec ps ax -o pid,args | grep $cmd]} msg]
if {$ret == 0} {
foreach line [split $proc "\n"] {
set l [split [string trim $line]]
set c [lrange $l 1 end]
if {"$c" eq "$cmd"} {
# process was still running
if {$sea(debug)} {
puts stdout "kill $proc ($c)"
}
exec kill -9 [lindex $l 0]
}
}
}
set sea(pipe) [open "|$cmd" r]
fileevent $sea(pipe) readable readpipe
puts stdout [pid $sea(pipe)]
vwait forever

19
tcl/luft.tcsh Normal file
View File

@ -0,0 +1,19 @@
# just for testing whether luft works
setenv PATH ${PATH}:/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/
#setenv EPICS_CA_ADDR_LIST 129.129.130.255
setenv EPICS_CA_ADDR_LIST cryo-cagw:5062
setenv EPICS_CA_AUTO_ADDR_LIST NO
caget IKA-GAMA:Luft_S10
caget IKA-GAMA:Luft_S2
caget IKA-GAMA:Luft_S1
caget IKA-GAMA:Luft_S3
caget IKA-GAMA:Luft_S4
caget IKA-GAMA:Luft_S5
caget IKA-GAMA:Luft_S6
caget IKA-GAMA:Luft_S7
caget IKA-GAMA:Luft_S8
caget IKA-GAMA:Luft_S9
caget IKA-GAMA:Luft_S11
caget IKA-GAMA:Luft_S12