diff --git a/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl b/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl index 63b8251e..4c4625d7 100644 --- a/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl +++ b/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl @@ -155,6 +155,10 @@ proc newFileName {idNum postfix} { proc ::nexus::ic_initialize {} { } + proc getBaseName {fileName} { + set baseName [lindex [split [file tail $fileName] "."] 0] + return $baseName + } ## # @brief Create a nexus file # This first generates a nexus dictionary file from the hdb tree and then creates a new @@ -175,8 +179,7 @@ proc newFileName {idNum postfix} { } } - set baseName [lindex [split [file tail $FileName] "."] 0] - set nxdict_path [::nexus::gen_nxdict $baseName $nexusdic] + set nxdict_path [::nexus::gen_nxdict $nexusdic] if {$state(file,incr_datnum) == true} { sicsdatanumber incr } @@ -399,6 +402,7 @@ proc ::nexus::save {{point 0}} { set valid_options [list "-index" "-label"] set required_options [list "-index"] if [ catch { + set caught_exception false ::utility::check_valid_options $args $valid_options ::utility::check_required_options $args $required_options array set param $args @@ -424,6 +428,7 @@ proc ::nexus::save {{point 0}} { set data_label @singlefile } if {$isNewFile($data_label)} { + set isNewFile($data_label) "false" ::nexus::createfile $currFilename($data_label) dataFileName $currFilename($data_label) estart [sicstime] @@ -435,13 +440,10 @@ proc ::nexus::save {{point 0}} { file_status $file_states(O) ::nexus::nxreopenfile $currFilename($data_label) file_status $file_states(S) + set baseName [getBaseName $currFilename($data_label)] + set entryName [gen_NXentry_name $baseName] + nxscript updatedictvar pa_entryName $entryName ::nexus::save_data $point newfile - ::nexus::nxclosefile $currFilename($data_label) - file_status $file_states(C) - incr save_count_arr($data_label) - save_count $save_count_arr($data_label) - currpoint $point - set isNewFile($data_label) "false" } else { eend [sicstime] # timestamp [expr {[clock seconds] - $start_seconds_array($data_label)}] @@ -450,20 +452,28 @@ proc ::nexus::save {{point 0}} { file_status $file_states(O) ::nexus::nxreopenfile $currFilename($data_label) file_status $file_states(S) + set baseName [getBaseName $currFilename($data_label)] + set entryName [gen_NXentry_name $baseName] + nxscript updatedictvar pa_entryName $entryName ::nexus::save_data $point oldfile - ::nexus::nxclosefile $currFilename($data_label) - file_status $file_states(C) - incr save_count_arr($data_label) - currpoint $point - save_count $save_count_arr($data_label) } } message ] { - if {[info exists data_label] && [info exists currFilename($data_label)]} { - ::nexus::nxclosefile $currFilename($data_label) - } - return -code error "([info level 0]) $message" + set caught_exception true } - return + if {[info exists data_label] && [info exists currFilename($data_label)]} { + ::nexus::nxclosefile $currFilename($data_label) + file_status $file_states(C) + incr save_count_arr($data_label) + save_count $save_count_arr($data_label) + currpoint $point + } else { + set message "$message !! FAILED ASSERTION: data_lable and/or currFilename undefined !!" + } + if {$caught_exception} { + return -code error "([info level 0]) $message" + } else { + return + } } ## @@ -746,10 +756,10 @@ proc ::nexus::gen_NXentry_name {baseName} { set nm_conv $NXentry_nm_convention([instname]) switch $nm_conv { "simple" { - return "/entry1" + return "entry1" } "fname" { - return "/${baseName}" + return "${baseName}" } default { return -code error "ERROR: Unknown NXentry naming convention $nm_conv" @@ -765,21 +775,21 @@ proc ::nexus::gen_NXentry_name {baseName} { # @param baseName The base name of the file without suffix # @param nexusdic Name of the nexus dictionary that will be created. # @return Full path to the nexus dictionary. -proc ::nexus::gen_nxdict {baseName nexusdic} { +proc ::nexus::gen_nxdict {nexusdic} { global cfPath variable nxdictionary if [ catch { set nxdict_path $cfPath(nexus)/$nexusdic array unset nxdictionary - set entryName [gen_NXentry_name $baseName] foreach hp [hlist /] { if {[hgetpropval /$hp data] == true} { set nxclass [hgetpropval /$hp klass] - ::nexus::_gen_nxdict $hp $entryName,NXentry $hp $nxclass + ::nexus::_gen_nxdict $hp /\$(pa_entryName),NXentry $hp $nxclass } } set fh [open $nxdict_path w] puts $fh "##NXDICT-1.0" + puts $fh pa_entryName=entry1 puts $fh pa_hmmdimstr=-1,0 puts $fh pa_hmmrank=1 puts $fh pa_hmmdatname=hmm @@ -1310,7 +1320,7 @@ foreach expt $::nexus::exports { set tmpstr [string map {"$" ""} {$Name: not supported by cvs2svn $}] set nx_content_release_tag [lindex $tmpstr [expr [llength $tmpstr] - 1]] -set tmpstr [string map {"$" ""} {$Revision: 1.48 $}] +set tmpstr [string map {"$" ""} {$Revision: 1.49 $}] set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]] #namespace eval data { diff --git a/site_ansto/instrument/sans/config/commands/commands.tcl b/site_ansto/instrument/sans/config/commands/commands.tcl index 102923c3..8a6b657c 100644 --- a/site_ansto/instrument/sans/config/commands/commands.tcl +++ b/site_ansto/instrument/sans/config/commands/commands.tcl @@ -11,6 +11,112 @@ namespace eval motor { # } #} +## +# @brief Beamstop select command +# @param bs beamstop, 1,2,3,4,5 or 6 +# @param bx beam position in detector coordinates +# @param bz beam position in detector coordinates +# Origin of beamstop coordinate system is (bsxo, bszo) relative to frame +# Origin of detector coordinate system is (0, 0) relative to frame +# Given +# (Xb,Zb) = beam position in frame coordinates +# bx = beam x pos in detector coordinates +# bz = beam z pos in detector coordinates +# detoff = detector x pos in detector coordinates +# bsx = beamstop x pos in beamstop coordinates +# bsz = beamstop z pos in beamstop coordinates +# bszo = beamstop z origin relative to frame +# (bx+detoff, bz) = (Xb,Zb) +# (bsx, bsz+bszo) = (Xb,Zb) +proc selbs {bs {bx "UNDEF"} {bz "UNDEF"}} { + set bsdriving false + set dethw [expr {[SplitReply detector_active_height_mm]/2.0}] + set dethh [expr {[SplitReply detector_active_width_mm]/2.0}] + set bsxo -33.112 + $dethw + set bszo -329.440 + $dethh + if [ catch { + switch $bs { + "1" { + set bsmot "bs1" + set bs_target 92.79 + set bsdownCmd "drive bs2 0 bs3 0 bs4 0 bs5 0 bs6 0" + } + "2" { + set bsmot "bs2" + set bs_target 86.20 + set bsdownCmd "drive bs1 0 bs3 0 bs4 0 bs5 0 bs6 0" + } + "3" { + set bsmot "bs3" + set bs_target 92.54 + set bsdownCmd "drive bs2 0 bs1 0 bs4 0 bs5 0 bs6 0" + } + "4" { + set bsmot "bs4" + set bs_target 86.66 + set bsdownCmd "drive bs2 0 bs3 0 bs1 0 bs5 0 bs6 0" + } + "5" { + set bsmot "bs5" + set bs_target 92.50 + set bsdownCmd "drive bs2 0 bs3 0 bs4 0 bs1 0 bs6 0" + } + "6" { + set bsmot "bs6" + set bs_target 85.87 + set bsdownCmd "drive bs2 0 bs3 0 bs4 0 bs5 0 bs1 0" + } + default { + error "beamstop selection must be an integer from 1 to 6" + } + } + + set detoff_val [SplitReply [detoff]] + + if {$bx == "UNDEF" || $bz == "UNDEF"} { + statemon start selbs + set bsdriving true + drive $bsmot $bs_target + BeamStop -1 + eval $bsdownCmd + BeamStop $bs + set bsdriving false + statemon stop selbs + } else { + if { [string is double $bx] == false } { + if { [string is double $bz] == false } { + error "beam coordinates must be floats" + } + } + set bsx_target [expr {$bx-$bsxo+$detoff_val}] + set bsz_target [expr {$bz-$bszo}] + + statemon start selbs + set bsdriving true + drive $bsmot $bs_target bsx $bsx_target bsz $bsz_target + BeamStop -1 + eval $bsdownCmd + BeamStop $bs + set bsdriving false + statemon stop selbs + } + } msg ] { + if {$bsdriving} { + statemon stop selbs + } + return -code error $msg + } +} +publish selbs user +namespace eval beamstops { + command selbsn {int=1,2,3,4,5,6 bs} { + selbs $bs "UNDEF" "UNDEF" + } + command selbsxz {int=1,2,3,4,5,6 bs float bx float bz} { + selbs $bs $bx $bz + } +} + namespace eval optics { VarMake ::optics::select::section text user VarMake ::optics::polarizer::in text user diff --git a/site_ansto/instrument/sans/config/motors/motor_configuration.tcl b/site_ansto/instrument/sans/config/motors/motor_configuration.tcl index 86beafa2..e351f867 100644 --- a/site_ansto/instrument/sans/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/sans/config/motors/motor_configuration.tcl @@ -1,5 +1,5 @@ -# $Revision: 1.28 $ -# $Date: 2009-11-24 22:56:48 $ +# $Revision: 1.29 $ +# $Date: 2009-12-03 02:04:57 $ # Author: Ferdi Franceschini (ffr@ansto.gov.au) # Last revision by: $Author: ffr $ @@ -58,7 +58,8 @@ set samy_Home 7101486 set samz_Home 9944901 set samthet_Home 23004075 set det_Home 7055209 -set detoff_Home 6932100 +#set detoff_Home 6932100 +set detoff_Home 6857213 set pent_Home 8123563 #set srce_Home 7868762 @@ -71,14 +72,16 @@ set apx_Home 12965422 set apz_Home 7500000 set att_Home 24782942 -set bsx_Home 7831707 -set bsz_Home 10143000 -set bs1_Home 19027 -set bs2_Home 5721 -set bs3_Home 15844 -set bs4_Home 23089 -set bs5_Home 2293 -set bs6_Home 12597 +#set bsx_Home 7831707 +set bsx_Home 7578346 +#set bsz_Home 10143000 +set bsz_Home 10568857 +set bs1_Home 13219 +set bs2_Home 2506 +set bs3_Home 22391 +set bs4_Home 15287 +set bs5_Home 6283 +set bs6_Home 19123 set bs_cntsPerX [expr 32768.0/360.0] set bs_stepsPerX [expr -25000.0*160.0/360.0] set pol_Home 7500000 @@ -404,7 +407,7 @@ Motor detoff $motor_driver_type [params \ axis H\ units mm\ hardlowerlim -50\ - hardupperlim 420\ + hardupperlim 500\ maxSpeed 10\ maxAccel 1\ maxDecel 10\ @@ -415,7 +418,7 @@ Motor detoff $motor_driver_type [params \ detoff part detector detoff long_name detector_x detoff softlowerlim -50 -detoff softupperlim 410 +detoff softupperlim 500 detoff home 0 ############################ @@ -830,8 +833,8 @@ Motor bsx $motor_driver_type [params \ port pmc4-quokka\ axis A\ units mm\ - hardlowerlim -200\ - hardupperlim 200\ + hardlowerlim 0\ + hardupperlim 500\ maxSpeed 5\ maxAccel 2\ maxDecel 5\ @@ -841,8 +844,8 @@ Motor bsx $motor_driver_type [params \ cntsPerX [expr 8192.0/5.0/1.02]] bsx part detector bsx long_name bsx -bsx softlowerlim -200 -bsx softupperlim 200 +bsx softlowerlim 0 +bsx softupperlim 500 bsx speed 5 bsx home 0 @@ -853,9 +856,9 @@ Motor bsz $motor_driver_type [params \ port pmc4-quokka\ axis B\ units mm\ - hardlowerlim -240\ - hardupperlim 85\ - maxSpeed 1\ + hardlowerlim 0\ + hardupperlim 400\ + maxSpeed 5\ maxAccel 1\ maxDecel 5\ stepsPerX [expr (25000.0*7.0)/5.0/1.02]\ @@ -864,8 +867,8 @@ Motor bsz $motor_driver_type [params \ cntsPerX [expr (8192.0*7.0)/5.0/1.02]] bsz part detector bsz long_name bsz -bsz softlowerlim -240 -bsz softupperlim 80 +bsz softlowerlim 0 +bsz softupperlim 400 bsz home 0 # Largest beamstop @@ -874,8 +877,8 @@ Motor bs1 $motor_driver_type [params \ axis C\ units degrees\ hardlowerlim 0\ - hardupperlim 90\ - maxSpeed 1\ + hardupperlim 100\ + maxSpeed 2\ maxAccel 1\ maxDecel 1\ stepsPerX $bs_stepsPerX\ @@ -885,8 +888,9 @@ Motor bs1 $motor_driver_type [params \ bs1 part detector bs1 long_name bs1 bs1 softlowerlim 0 -bs1 softupperlim 90 +bs1 softupperlim 100 bs1 home 0 +bs1 precision 0.05 sicslist setatt bs1 link parameters_group Motor bs2 $motor_driver_type [params \ @@ -894,8 +898,8 @@ Motor bs2 $motor_driver_type [params \ axis D\ units degrees\ hardlowerlim 0\ - hardupperlim 90\ - maxSpeed 1\ + hardupperlim 100\ + maxSpeed 2\ maxAccel 1\ maxDecel 1\ stepsPerX $bs_stepsPerX\ @@ -905,8 +909,9 @@ Motor bs2 $motor_driver_type [params \ bs2 part detector bs2 long_name bs2 bs2 softlowerlim 0 -bs2 softupperlim 90 +bs2 softupperlim 100 bs2 home 0 +bs2 precision 0.05 sicslist setatt bs2 link parameters_group Motor bs3 $motor_driver_type [params \ @@ -914,8 +919,8 @@ Motor bs3 $motor_driver_type [params \ axis E\ units degrees\ hardlowerlim 0\ - hardupperlim 90\ - maxSpeed 1\ + hardupperlim 100\ + maxSpeed 2\ maxAccel 1\ maxDecel 1\ stepsPerX $bs_stepsPerX\ @@ -925,8 +930,9 @@ Motor bs3 $motor_driver_type [params \ bs3 part detector bs3 long_name bs3 bs3 softlowerlim 0 -bs3 softupperlim 90 +bs3 softupperlim 100 bs3 home 0 +bs3 precision 0.05 sicslist setatt bs3 link parameters_group Motor bs4 $motor_driver_type [params \ @@ -934,8 +940,8 @@ Motor bs4 $motor_driver_type [params \ axis F\ units degrees\ hardlowerlim 0\ - hardupperlim 90\ - maxSpeed 1\ + hardupperlim 100\ + maxSpeed 2\ maxAccel 1\ maxDecel 1\ stepsPerX $bs_stepsPerX\ @@ -945,8 +951,9 @@ Motor bs4 $motor_driver_type [params \ bs4 part detector bs4 long_name bs4 bs4 softlowerlim 0 -bs4 softupperlim 90 +bs4 softupperlim 100 bs4 home 0 +bs4 precision 0.05 sicslist setatt bs4 link parameters_group Motor bs5 $motor_driver_type [params \ @@ -954,8 +961,8 @@ Motor bs5 $motor_driver_type [params \ axis G\ units degrees\ hardlowerlim 0\ - hardupperlim 90\ - maxSpeed 1\ + hardupperlim 100\ + maxSpeed 2\ maxAccel 1\ maxDecel 1\ stepsPerX $bs_stepsPerX\ @@ -965,8 +972,9 @@ Motor bs5 $motor_driver_type [params \ bs5 part detector bs5 long_name bs5 bs5 softlowerlim 0 -bs5 softupperlim 90 +bs5 softupperlim 100 bs5 home 0 +bs5 precision 0.05 sicslist setatt bs5 link parameters_group Motor bs6 $motor_driver_type [params \ @@ -974,8 +982,8 @@ Motor bs6 $motor_driver_type [params \ axis H\ units degrees\ hardlowerlim 0\ - hardupperlim 90\ - maxSpeed 1\ + hardupperlim 100\ + maxSpeed 2\ maxAccel 1\ maxDecel 1\ stepsPerX $bs_stepsPerX\ @@ -985,8 +993,9 @@ Motor bs6 $motor_driver_type [params \ bs6 part detector bs6 long_name bs6 bs6 softlowerlim 0 -bs6 softupperlim 90 +bs6 softupperlim 100 bs6 home 0 +bs6 precision 0.05 sicslist setatt bs6 link parameters_group # Polarizer Rotation diff --git a/site_ansto/instrument/sans/config/parameters/parameters.tcl b/site_ansto/instrument/sans/config/parameters/parameters.tcl index 02d1e567..b96b08e7 100644 --- a/site_ansto/instrument/sans/config/parameters/parameters.tcl +++ b/site_ansto/instrument/sans/config/parameters/parameters.tcl @@ -20,6 +20,7 @@ foreach {var lname nxname} { foreach {var lname type priv units klass} { SApShape SApShape text user none parameter BSShape BSShape text user none parameter + BeamStop BeamStop int user none parameter SampleThickness thickness float user mm sample TransmissionFlag transmission_flag int user none sample magnetic_field magnetic_field float user T sample diff --git a/site_ansto/instrument/sans/config/velsel/sct_velsel.tcl b/site_ansto/instrument/sans/config/velsel/sct_velsel.tcl index 18e18665..15f378ce 100644 --- a/site_ansto/instrument/sans/config/velsel/sct_velsel.tcl +++ b/site_ansto/instrument/sans/config/velsel/sct_velsel.tcl @@ -1,5 +1,5 @@ # TODO Check if requested tilt-angle is within range - +# TODO What should be reported for the wavelength if the tilt angle is 999.99 ## # @file # The velocity selector control is split into two objects,