Files
sics/mcstas/dmc/mcsupport.tcl
2005-06-22 07:09:59 +00:00

67 lines
2.1 KiB
Tcl

#-------------------------------------------------------------------
# These are a couple of Tcl function which help with the interface
# between SICS and McStas
#
# Mark Koennecke, June 2005
#--------------------------------------------------------------------
# washsimfile fixes the evil NXsimulation name ="./dmc.xml" thing in
# the XML file. Path separators in name attributes throw off
# NXopenpath
#--------------------------------------------------------------------
proc washsimfile {name} {
set oriname $name
set in [open $name "r"]
set name [file tail $name]
set out [open /tmp/$name "w"]
while { [gets $in line] >= 0} {
if { [string first "NXsimulation name=" $line] > 0} {
puts $out "<NXsimulation name=\"$name\">"
} else {
puts $out $line
}
}
close $in
close $out
file copy -force /tmp/$name $oriname
file delete /tmp/$name
}
#---------------------------------------------------------------------
# When McStas dumps or is killed we need to give McStas some time to
# dump its data. Otherwise we observe that data reading fails.
# mcwaittime is used for this. Increase if you see problems
#--------------------------------------------------------------------
set mcwaittime 7
#----------------------------------------------------------------------
proc mcstasdump {pid} {
global mcwaittime
catch {eval exec /usr/bin/kill -USR2 $pid}
wait $mcwaittime
}
#-----------------------------------------------------------------------
proc mcstasisrunning {pid} {
set ret [catch {eval exec /bin/ps --pid $pid} msg]
if {$ret == 0} {
return 1
} else {
return 0;
}
}
#-----------------------------------------------------------------------
proc mcstaskill {pid} {
global mcwaittime
catch {eval exec /usr/bin/kill -TERM $pid}
wait $mcwaittime
}
#-----------------------------------------------------------------------
proc mcinstall {} {
allowexec /usr/bin/kill
allowexec /bin/ps
Publish mcstasdump User
Publish mcstasisrunning User
Publish mcstaskill User
mccontrol configure mcdump mcstasdump
mccontrol configure mckill mcstaskill
mccontrol configure mcisrunning mcstasisrunning
mccontrol configure update 300
}