#---------------------------------------------------------------------------- # VDMC instrument special scripted commands # # Mark Koennecke, June 2005 #--------------------------------------------------------------------------- source $home/mcsupport.tcl if { [info exists vdmcinit] == 0 } { set vdmcinit 1 Publish LogBook Spy Publish count User Publish Repeat User Publish storedmcdata User Publish rundmcsim User Publish copydmcdata User mcinstall } source $home/log.tcl source $home/nxsupport.tcl source $home/nxdmc.tcl #------------------------------------------------------------------------ proc SplitReply { text } { set l [split $text =] return [lindex $l 1] } #----------------------------------------------------------------------- # Scripts required for controlling McStas simulations #----------------------------------------------------------------------- proc rundmcsim {mode preset} { global home append command $home/dmc_sics01 " -f $home/dmc.xml --format=\"XML\"" append command " -n 9e15 " append command " lambda=[string trim [SplitReply [lambda]]]" append command " TKOFF=[string trim [SplitReply [TwoThetaM]]]" append command " samplefile=$home/[string trim [SplitReply [sample]]].q" append command " monfile=$home/monfile " append command " >& $home/dmc.log &" clientput "Starting McStas.. " set ret [catch {eval exec $command} msg] if {$ret != 0} { error $msg } else { return $msg } } #------------------------------------------------------------------------ proc copydmcdata { } { global home set mcversion "McStas 1.8 - Mar. 05, 2004" washsimfile $home/dmc.xml mcreader open $home/dmc.xml mcreader insertmon \ "/$mcversion/DMC_diff/dmc.xml/PSD_sample/PSD_sample.dat/values" \ counter 1 mcreader inserthm \ "/$mcversion/DMC_diff/dmc.xml/Det9/det9.dat/data" banana mcreader close } #-------------------------------------------------------------------------- mccontrol configure mcstart rundmcsim mccontrol configure mccopydata copydmcdata mccontrol configure update 60 mccontrol configure mcmonfile $home/monfile #-------------------------------------------------------------------------- # A count command for VDMC # All arguments are optional. The current values will be used if not # specified # Dr. Mark Koennecke, Juli 1997 #-------------------------------------------------------------------------- proc count { {mode NULL } { preset NULL } } { starttime [sicstime] catch {temperature log clear} msg #----- deal with mode set mode2 [string toupper $mode] set mode3 [string trim $mode2] set mc [string index $mode2 0] if { [string compare $mc T] == 0 } { banana CountMode Timer } elseif { [string compare $mc M] == 0 } { banana CountMode Monitor } #------ deal with preset if { [string compare $preset NULL] != 0 } { banana preset $preset } #------ prepare a count message set a [banana preset] set aa [SplitReply $a] set b [banana CountMode] set bb [SplitReply $b] ClientPut [format " Starting counting in %s mode with a preset of %s" \ $bb $aa] #------- count banana InitVal 0 wait 1 banana count set ret [catch {Success} msg] #------- StoreData storedata if { $ret != 0 } { error [format "Counting ended with error"] } } #---------------- Repeat ----------------------------------------------- proc repeat { num {mode NULL} {preset NULL} } { for { set i 0 } { $i < $num } { incr i } { set ret [catch {count $mode $preset} msg] if {$ret != 0} { error "Counting ended with error" } } } #------------------------------------------------------------------------ # This implements the wwwsics command which generates a listing of # important experiment parameters in html format for the SICS WWW Status # application. This version is for the powder diffractometers DMC and # HRPT. # # Mark Koennecke, March 2000 #------------------------------------------------------------------------ proc wwwsics {} { #----- get all the data we need set user [GetNum [user]] set sample [GetNum [sample]] set tit [GetNum [title]] set ret [catch {lambda} msg] if {$ret != 0 } { set lam Undetermined } else { set lam [GetNum $msg] } set ret [catch {temperature} msg] if {$ret != 0 } { set tem Undetermined } else { set tem [GetNum $msg] } set run [GetNum [sicsdatanumber]] catch {incr run} msg set stat [GetNum [status]] #------- html format the reply append result "" append result append result append result append result append result append result append result append result
Run Number $run
Title $tit
User $user
Sample $sample
wavelength $lam
Sample Temperature $tem
Status $stat
return $result } #------------ install command catch {Publish wwwsics Spy} msg