From 99db0c6bb487e18876de515339301f090b9ac495 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Mon, 22 Aug 2022 15:13:44 +0200 Subject: [PATCH] added luft (air in He recovery) scripts --- tcl/luft.tclsh | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ tcl/luft.tcsh | 19 ++++++++++ 2 files changed, 118 insertions(+) create mode 100755 tcl/luft.tclsh create mode 100644 tcl/luft.tcsh diff --git a/tcl/luft.tclsh b/tcl/luft.tclsh new file mode 100755 index 0000000..1aa17c6 --- /dev/null +++ b/tcl/luft.tclsh @@ -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 diff --git a/tcl/luft.tcsh b/tcl/luft.tcsh new file mode 100644 index 0000000..ed3f11b --- /dev/null +++ b/tcl/luft.tcsh @@ -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