From 641ed5227e4a83d1d1e9be2310d9fb322419fe8f Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 8 Dec 2006 09:12:48 +1100 Subject: [PATCH] Integrated hmm with nexus data file writing. Now have hm and bm scans. r1354 | ffr | 2006-12-08 09:12:48 +1100 (Fri, 08 Dec 2006) | 3 lines --- site_ansto/instrument/hrpd/MANIFEST.TXT | 1 + site_ansto/instrument/hrpd/echidna.dic | 15 ++- .../instrument/hrpd/echidna_configuration.tcl | 7 +- site_ansto/instrument/hrpd/extraconfig.tcl | 2 + .../instrument/hrpd/hmm_configuration.tcl | 36 +++--- site_ansto/instrument/hrpd/nxscripts.tcl | 117 +++++++++++------- site_ansto/instrument/hrpd/scan.tcl | 111 +++++++++++------ 7 files changed, 185 insertions(+), 104 deletions(-) diff --git a/site_ansto/instrument/hrpd/MANIFEST.TXT b/site_ansto/instrument/hrpd/MANIFEST.TXT index b8e49c88..76c28cd1 100644 --- a/site_ansto/instrument/hrpd/MANIFEST.TXT +++ b/site_ansto/instrument/hrpd/MANIFEST.TXT @@ -12,3 +12,4 @@ hpaths.tcl InstXML.xml extraconfig.tcl sim_configuration.tcl +hmm/*.xml diff --git a/site_ansto/instrument/hrpd/echidna.dic b/site_ansto/instrument/hrpd/echidna.dic index e5d38774..2e778d69 100644 --- a/site_ansto/instrument/hrpd/echidna.dic +++ b/site_ansto/instrument/hrpd/echidna.dic @@ -12,7 +12,9 @@ entryName=entry1 dataName=histogram inst=HRPD detector=hrdetector +monochromator=monochromator thetadim=128 +scan_variable=scanvar #---------- NXentry level etitle=/$(entryName),NXentry/SDS title -type NX_CHAR estart=/$(entryName),NXentry/SDS start_time -type NX_CHAR @@ -26,6 +28,7 @@ iname=/$(entryName),NXentry/$(inst),NXinstrument/SDS name -type NX_CHAR \ mmode=/$(entryName),NXentry/monitor,NXmonitor/SDS mode -type NX_CHAR mpreset=/$(entryName),NXentry/monitor,NXmonitor/SDS preset -type NX_FLOAT32 mdata=/$(entryName),NXentry/monitor,NXmonitor/SDS data -type NX_INT32 +mdistance=/$(entryName),NXentry/monitor,NXmonitor/SDS distance -type NX_FLOAT32 -attr {units,metre} #----------------- NXsource sname=/$(entryName),NXentry/$(inst),NXinstrument/source,NXsource/SDS name \ @@ -34,8 +37,10 @@ stype=/$(entryName),NXentry/$(inst),NXinstrument/source,NXsource/SDS type -type sprobe=/$(entryName),NXentry/$(inst),NXinstrument/source,NXsource/SDS probe -type NX_CHAR -rank 1 #----------------- NXcrystal clambda=/$(entryName),NXentry/$(inst),NXinstrument/Ge113,NXcrystal/SDS wavelength -type NX_FLOAT32 -attr {units,Angstrom} +ctype=/$(entryName),NXentry/$(inst),NXinstrument/Ge113,NXcrystal/SDS type -type NX_CHAR #------------- counter -#-------------- histogram data +#-------------- Detector +# histogram data dradius=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS distance -type NX_FLOAT32 dtheta=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS polar_angle -type NX_FLOAT32 -LZW -rank 1 -dim {$(thetadim)} -attr {units,degree} @@ -50,9 +55,15 @@ ddesc=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS des dtype=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS type -type NX_CHAR dlayout=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS layout -type NX_CHAR +#--------------- NXmonochromator +mtth=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/mtth,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,mtth} #--------------- NXsample saname=/$(entryName),NXentry/sample,NXsample/SDS name -type NX_CHAR sarot=/$(entryName),NXentry/sample,NXsample/SDS rotation_angle -type NX_FLOAT32 -attr {units,degree} +stth=/$(entryName),NXentry/sample,NXsample/stth,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,stth} #----------------NXdata ------------------------------------------------ -dana=/$(entryName),NXentry/data,NXdata/NXVGROUP +scandata=/$(entryName),NXentry/scan_data,NXdata/NXVGROUP +scanvar=/$(entryName),NXentry/scan_variable,NXdata/NXVGROUP +#histogram=/$(entryName),NXentry/histogram,NXdata/NXVGROUP +#scanvar=/$(entryName),NXentry/$(scan_variable),NXdata/NXVGROUP diff --git a/site_ansto/instrument/hrpd/echidna_configuration.tcl b/site_ansto/instrument/hrpd/echidna_configuration.tcl index 2f6b6c16..e41919de 100644 --- a/site_ansto/instrument/hrpd/echidna_configuration.tcl +++ b/site_ansto/instrument/hrpd/echidna_configuration.tcl @@ -1,5 +1,5 @@ -# $Revision: 1.8 $ -# $Date: 2006-12-03 22:45:20 $ +# $Revision: 1.9 $ +# $Date: 2006-12-07 22:12:48 $ # Author: Ferdi Franceschini (ffr@ansto.gov.au) # Last revision by: $Author: ffr $ @@ -17,6 +17,7 @@ source server_config.tcl VarMake Instrument Text Internal Instrument Echidna Instrument lock +VarMake bm_distance Float User #MakeCounter simCtr SIM -1.0 #MakeScanCommand xxxscan simCtr echidna.hdd recover.bin @@ -37,7 +38,7 @@ publish nxcreatefile user ######## source gen_hipadaba.tcl -source counter.tcl +#source counter.tcl fileeval hmm_configuration.tcl fileeval scan.tcl fileeval nxscripts.tcl diff --git a/site_ansto/instrument/hrpd/extraconfig.tcl b/site_ansto/instrument/hrpd/extraconfig.tcl index b723bc49..ab9485a8 100644 --- a/site_ansto/instrument/hrpd/extraconfig.tcl +++ b/site_ansto/instrument/hrpd/extraconfig.tcl @@ -1,4 +1,6 @@ # Put extra config info here. +Motor nix ASIM 0 100 -1.0 0.01 + # It is useful during the testing stage to set # some axes as fixed. mom fixed 1 diff --git a/site_ansto/instrument/hrpd/hmm_configuration.tcl b/site_ansto/instrument/hrpd/hmm_configuration.tcl index 6c3760ba..05c429f3 100644 --- a/site_ansto/instrument/hrpd/hmm_configuration.tcl +++ b/site_ansto/instrument/hrpd/hmm_configuration.tcl @@ -1,14 +1,8 @@ -# $Revision: 1.1 $ -# $Date: 2006-12-03 22:44:35 $ +# $Revision: 1.2 $ +# $Date: 2006-12-07 22:12:48 $ # Author: Mark Lesha (mle@ansto.gov.au) # Last revision by: $Author: ffr $ -# Provides simulated motors for experimenting with scan and batch commands -#START SERVER CONFIGURATION SECTION -set sicsroot ../ -source echidna_configuration.tcl -#END SERVER CONFIGURATION SECTION - #------------------------------------------------------------------------- # System: Histogram Server (sample) #------------------------------------------------------------------------ @@ -21,7 +15,7 @@ source echidna_configuration.tcl # remote histogram server via http, and acquisition # of histogram period data. MakeHM hmm anstohttp -hmm configure hmaddress http://137.157.201.12:8080 +hmm configure hmaddress http://das1-echidna:8080 hmm configure username spy hmm configure password 007 @@ -107,7 +101,7 @@ hmm init ############################################## # Make and configure an ANSTO beam monitor counter. -MakeCounter bm anstomonitor [ params host "137.157.201.12" port "30000" ] +MakeCounter bm anstomonitor [ params host "das1-echidna" port "30000" ] bm SetExponent 0 # Make our special HMControl_ANSTO object with the bm controlling the hmm. @@ -126,7 +120,7 @@ MakeHMControl_ANSTO hmc bm hmm # # Define two scan objects which use the beam monitor counter. # -# For scan1, the hmc object uses the bm counter to control +# For hmscan, the hmc object uses the bm counter to control # acquisition duration. In other words, the acquisition duration # is controlled via SICS. This is fine if the duration doesn't # need to be controlled to an accuracy of less than one second. @@ -160,13 +154,13 @@ MakeHMControl_ANSTO hmc bm hmm # # 17/11/06 NOTE: The Beam Monitor is not yet interfaced directly to the # Histogram Server. This means that for BM-controlled acquisitions, -# SICS needs to use the BM counter (i.e. use scan1 not scan2). +# SICS needs to use the BM counter (i.e. use hmscan not scan2). # # EXAMPLES: For scan running over 5 stops and acquisition of 1 sec at each stop: -# scan1 run 5 timer 1 (termination controlled by the beam monitor) +# hmscan run 5 timer 1 (termination controlled by the beam monitor) # scan2_runb 5 TIME 100 IMMEDIATE (termination controlled by the histogram server) # -MakeScanCommand scan1 bm echidna.hdd recover.bin +MakeScanCommand hmscan bm echidna.hdd recover.bin MakeScanCommand scan2 bm echidna.hdd recover.bin # # Call is: scan2_runa @@ -205,7 +199,7 @@ blockctr SetPreset 0 # Later on we can add some motors to drive... #Motor som2 ASIM 0 100 -1.0 0.01 -#scan1 add som2 0 1 +#hmscan add som2 0 1 ############################################## # Support for using expanded histogram period @@ -388,14 +382,14 @@ Publish hs_finish User # are properly defined. # A different count callback is defined in the two cases. # -scan1 configure script -scan1 function prepare hs_prepare -scan1 function count hs_count_bm_controlled -scan1 function collect hs_collect -scan1 function finish hs_finish +hmscan configure script +#hmscan function prepare hs_prepare +hmscan function count hs_count_bm_controlled +hmscan function collect hs_collect +hmscan function finish hs_finish # scan2 configure script -scan2 function prepare hs_prepare +#scan2 function prepare hs_prepare scan2 function count hs_count_hs_controlled scan2 function collect hs_collect scan2 function finish hs_finish diff --git a/site_ansto/instrument/hrpd/nxscripts.tcl b/site_ansto/instrument/hrpd/nxscripts.tcl index 578545f7..c28e96ae 100644 --- a/site_ansto/instrument/hrpd/nxscripts.tcl +++ b/site_ansto/instrument/hrpd/nxscripts.tcl @@ -1,6 +1,8 @@ MakeNXScript #nxscript createxml junk4.xml echidna.dic - +proc getVal {msg} { + return [string trim [lindex [split $msg =] 1 ] ] +} proc nxreopenfile {} { global dataFileName; nxscript reopen $dataFileName echidna.dic; @@ -12,50 +14,79 @@ set tubedia 0.0254 set pi 3.1415926 #set angsep [expr $tubedia/$dradius *(180/$pi)] set angsep 1.25 -proc addnxentry {nxobj entryname ompos } { - global dradius ndect angsep; -# file_time shows +10 for UTC offset, should be +11 for local summer in NSW. -# sicstime doesn't show UTC offset -# ISO 8601 suggests that time and date are separated with 'T' in a time field. -#nxscript createxml junk.xml echidna.dic -$nxobj updatedictvar entryName $entryname -$nxobj puttext etitle [title] -$nxobj puttext estart [sicstime] -$nxobj puttext eend [sicstime] -$nxobj puttext iname [instrument] +# stthmin = (180 - (1.25*127))/2 +set stthmin 10.625 +proc addnxentry {nxobj entryname scanVariable scanVarPos } { + global dradius ndect angsep stthmin; +putcommon $nxobj $entryname $scanVariable +putcrystal $nxobj +putmonitor $nxobj +putsample $nxobj + set mtth_val [string trim [lindex [split [mtth] =] 1]] + $nxobj putfloat $scanVariable $mtth_val +# Add thetamin and stth to tharr(i) + set sampletwotheta [string trim [lindex [split [stth] =] 1]] + for {set i 0} {$i < $ndect} {incr i} { + set tharr($i) [expr ($i-63.5)*$angsep + $sampletwotheta] + } + $nxobj updatedictvar thetadim $ndect + $nxobj putarray dtheta tharr $ndect + $nxobj puttext dtype He-3 position sensitive detector, tube active length=335+/-5mm, tube diameter=25.4 +/- 0.8mm + $nxobj puttext ddesc 128 He-3 proportional counter detector tubes (GE Energy Reuter Stokes Inc. item=RS-P4-0814-217) + $nxobj putfloat dradius $dradius + $nxobj puttext dlayout area + $nxobj puthm dcounts hmm + $nxobj puthm deff hmm + $nxobj makelink scandata dcounts + $nxobj makelink scandata dtheta + $nxobj makelink scanvar $scanVariable + +} + +proc bm_addnxentry {nxobj entryname scanVariable scanVarPos } { + global dradius ndect angsep stthmin; +putcommon $nxobj $entryname $scanVariable +putcrystal $nxobj +putmonitor $nxobj +putsample $nxobj + set mtth_val [string trim [lindex [split [mtth] =] 1]] + $nxobj putfloat $scanVariable $mtth_val +# Add thetamin and stth to tharr(i) +# $nxobj puttext dtype He-3 position sensitive detector, tube active length=335+/-5mm, tube diameter=25.4 +/- 0.8mm +# $nxobj puttext ddesc 128 He-3 proportional counter detector tubes (GE Energy Reuter Stokes Inc. item=RS-P4-0814-217) +# $nxobj putfloat dradius $dradius + $nxobj puttext dlayout point + $nxobj makelink scandata mdata + $nxobj makelink scanvar $scanVariable + +} + +proc putmonitor {nxobj} { + $nxobj puttext mmode [string trim [lindex [split [bm getmode] =] 1]] + $nxobj putfloat mpreset [string trim [lindex [split [bm getpreset] =] 1]] + $nxobj putint mdata [string trim [lindex [split [bm getcounts] =] 1]] + $nxobj putfloat mdistance [getVal [bm_distance]] +} + +proc putsample {nxobj} { + $nxobj puttext saname [getVal [Sample]] +} +proc putcrystal {nxobj} { + $nxobj puttext ctype "Ge 113" +} +proc putcommon {nxobj entryName scanVariable} { + $nxobj updatedictvar entryName $entryName + $nxobj updatedictvar scan_variable $scanVariable + $nxobj puttext etitle [getVal [title]] + $nxobj puttext estart [sicstime] + $nxobj puttext eend [sicstime] + $nxobj puttext iname [getVal [instrument]] # NXsource -$nxobj puttext sname OPAL -$nxobj puttext stype Reactor Neutron Source -$nxobj puttext sprobe Neutron -# NXcrystal -$nxobj putfloat clambda 1.89 -# NXmonitor -$nxobj puttext mmode timer -$nxobj putfloat mpreset 1000 -$nxobj putint mdata 500 -#NXsample -$nxobj puttext saname Air -$nxobj putfloat sarot $ompos -#array set tharr [list 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 ] -#nxscript putarray dtheta tharr 10 -for {set i 0} {$i < $ndect} {incr i} { set tharr($i) [expr $i*$angsep] } -$nxobj updatedictvar thetadim $ndect -nxscript putarray dtheta tharr $ndect -$nxobj puttext dtype He-3 position sensitive detector, tube active length=335+/-5mm, tube diameter=25.4 +/- 0.8mm -$nxobj puttext ddesc 128 He-3 proportional counter detector tubes (GE Energy Reuter Stokes Inc. item=RS-P4-0814-217) -$nxobj putfloat dradius $dradius -$nxobj puttext dlayout area -$nxobj puthm dcounts hmc - ### TEST ### -# hmc initVal 1 - ### TEST ### -$nxobj puthm deff hmc -$nxobj makelink dana dcounts -$nxobj makelink dana dtheta -#nxscript close -} -proc addeff {} { + $nxobj puttext sname OPAL + $nxobj puttext stype Reactor Neutron Source + $nxobj puttext sprobe Neutron } publish addnxentry user +publish bm_addnxentry user diff --git a/site_ansto/instrument/hrpd/scan.tcl b/site_ansto/instrument/hrpd/scan.tcl index 71c59d61..ad0c917c 100644 --- a/site_ansto/instrument/hrpd/scan.tcl +++ b/site_ansto/instrument/hrpd/scan.tcl @@ -1,48 +1,89 @@ - +namespace eval scanCommand { #MakeScanCommand escan counter echidna.hdd recover.bin -proc scan_prepare {sobj uobj} { - global omstart omstep; - nxcreatefile -# stdscan prepare $sobj $uobj; - set vlist [split [$sobj getvarpar 0] = ]; - set omstart [lindex $vlist 1]; - set omstep [lindex $vlist 2]; - hs_prepare $sobj $uobj -# clientput [$sobj getvarpar 0] value; -# nxscript create5 junk5.nx5 echidna.dic; -} +variable scanVariable scan_var scanVarStart 0 scanVarStep 1 + proc scan_prepare {sobj uobj} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; -proc scan_finish {sobj uobj} { - nxscript close -} + nxcreatefile; +# stdscan prepare $sobj $uobj; + set vlist [split [$sobj getvarpar 0] = ]; + set scanVariable [string trim [lindex [split [lindex $vlist 0] . ] 1]]; + set scanVarStart [lindex $vlist 1]; + set scanVarStep [lindex $vlist 2]; + hs_prepare $sobj $uobj + } + + proc scan_finish {sobj uobj} { + nxscript close + } #proc scan_finish {sobj uobj} { # nxscript close; #} # Add an nxentry for the current scan point -proc nxaddpoint {sobj uobj pt} { - global omstart omstep; - set ompos [expr $omstart + $pt * $omstep]; - nxreopenfile; - addnxentry nxscript scan_$pt $ompos; - nxscript close + proc nxaddpoint {sobj uobj pt} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; + set scanVarPos [expr $scanVarStart + $pt * $scanVarStep]; + nxreopenfile; + addnxentry nxscript scan_$pt $scanVariable $scanVarPos; + nxscript close + } + + proc donothing {args} {} + +proc bmcount {sobj uobj pt mode preset} { + bm setmode $mode + bm count $preset; +} + proc bm_scan_prepare {sobj uobj} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; + nxcreatefile; + set vlist [split [$sobj getvarpar 0] = ]; + set scanVariable [string trim [lindex [split [lindex $vlist 0] . ] 1]]; + set scanVarStart [lindex $vlist 1]; + set scanVarStep [lindex $vlist 2]; + stdscan prepare $sobj $uobj; + } + proc bm_nxaddpoint {sobj uobj pt} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; + set scanVarPos [expr $scanVarStart + $pt * $scanVarStep]; + nxreopenfile; + bm_addnxentry nxscript scan_$pt $scanVariable $scanVarPos; + nxscript close + } } -proc donothing {args} {} +publish ::scanCommand::scan_prepare user +publish ::scanCommand::scan_finish user +publish ::scanCommand::nxaddpoint user +publish ::scanCommand::donothing user -#proc ecount {sobj uobj pt mode preset} { -# hmc count; -#} +publish ::scanCommand::bm_scan_prepare user +publish ::scanCommand::scan_finish user +publish ::scanCommand::bm_nxaddpoint user +publish ::scanCommand::donothing user +publish ::scanCommand::bmcount user -publish scan_prepare user -publish scan_finish user -publish nxaddpoint user -#publish ecount user -publish donothing user +hmscan function writeheader ::scanCommand::donothing +hmscan function writepoint ::scanCommand::nxaddpoint +hmscan function prepare ::scanCommand::scan_prepare -#scan2 configure script -scan2 function writeheader donothing -scan2 function writepoint nxaddpoint -#scan2 function prepare scan_prepare -#scan2 function count ecount +scan2 function writeheader ::scanCommand::donothing +scan2 function writepoint ::scanCommand::nxaddpoint +scan2 function prepare ::scanCommand::scan_prepare + +MakeScanCommand bmonscan bm echidna.hdd recover.bin +bmonscan configure script +bmonscan function writeheader ::scanCommand::donothing +bmonscan function writepoint ::scanCommand::bm_nxaddpoint +bmonscan function prepare ::scanCommand::bm_scan_prepare +bmonscan function count ::scanCommand::bmcount