Files
sics/site_ansto/instrument/sans/config/commands/commands.tcl
Ferdi Franceschini 746f495d69 SICS-354 nxscripts_common_1.tcl
Now using a nexus dictionary variable to set the entry name in data files to prevent duplicate or wrong entry names.
Make sure that the isNewFile flag is reset on the first "save" call to prevent file number being incremented multiple times

SICS-394 sans commands.tcl
Added "selbs", "selbsn", and "selbsxz" commands to select and position a beamstop in a safe manner.

SICS-394 sans motor_configuration.tcl
Added new beamstop motor drivers.

SICS-394 sans parameters.tcl
Added BeamStop parameter to record which beamstop has been selected.

r2832 | ffr | 2009-12-03 13:04:57 +1100 (Thu, 03 Dec 2009) | 13 lines
2012-11-15 16:57:31 +11:00

184 lines
4.8 KiB
Tcl

source $cfPath(commands)/commands_common.tcl
namespace eval motor {
# is_homing_list = comma separated list of motors which are safe to send "home"
variable is_homing_list ""
}
#namespace eval sample {
# command select {int=0:8 sampid} {
# SampleNum $sampid
# }
#}
##
# @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
VarMake ::optics::lens::selection text user
command rotary_attenuator {int=0,15,45,90,180 angle} {
AttRotDeg $angle
}
command entrance_aperture {
int=0,45,90,135,180,270 angle
text=circ,squ,open,rect shape
} {
RotApDeg $angle
RotApShape $shape
}
command sample_aperture {
int=25,50 size
text=circ,squ,open,rect shape
} {
SApXmm $size
SApZmm $size
SApShape $shape
}
##############################
##
# @brief The "guide" command uses a lookup table to setup the collimation system
# @param row, selects a row from the guide configuration table
#
# eg\n
# guide ga
command guide "
text=[join [array names ::optics::guide_configuration] , ] configuration
" {
variable guide_configuration
variable guide_configuration_columns
if [ catch {
foreach {compselection position} $guide_configuration($configuration) {
foreach el $compselection guide $guide_configuration_columns {
lappend to_config $guide
lappend to_config [set ::optics::${guide}_map($el)]
}
::optics::guide -set feedback status BUSY
set msg [eval "drive $to_config"]
EApPosYmm $position
}
} message ] {
::optics::guide -set feedback status IDLE
if {$::errorCode=="NONE"} {return $message}
return -code error $message
}
::optics::guide -set feedback status IDLE
}
::optics::guide -addfb text status
::optics::guide -set feedback status IDLE
}
proc ::commands::isc_initialize {} {
::commands::ic_initialize
}