From bda5f46596cf83e9b94ba92fcb8b7cc6c74a9a37 Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Fri, 8 Apr 2011 15:44:27 +1000 Subject: [PATCH] r3096 | jgn | 2011-04-08 15:44:27 +1000 (Fri, 08 Apr 2011) | 1 line --- site_ansto/instrument/deploySICS.sh | 4 +- .../tas/config/commands/commands.tcl | 167 ------ .../tas/config/hmm/detector_ordela.tcl | 488 ------------------ .../tas/config/hmm/hmm_configuration.tcl | 1 + .../instrument/tas/taipan_configuration.tcl | 5 +- 5 files changed, 4 insertions(+), 661 deletions(-) delete mode 100644 site_ansto/instrument/tas/config/hmm/detector_ordela.tcl diff --git a/site_ansto/instrument/deploySICS.sh b/site_ansto/instrument/deploySICS.sh index 4aaf958c..12250b50 100755 --- a/site_ansto/instrument/deploySICS.sh +++ b/site_ansto/instrument/deploySICS.sh @@ -113,10 +113,10 @@ quokka|sans) INSTRUMENT=quokka DESTHOST=${2:-ics1-quokka.nbi.ansto.gov.au} INSTSRC=$SRCDIR/sans;; -pelican|pas) +pelican|pelican) INSTRUMENT=pelican DESTHOST=${2:-ics1-pelican.nbi.ansto.gov.au} -INSTSRC=$SRCDIR/pas;; +INSTSRC=$SRCDIR/pelican;; lyrebird|lyrebird) INSTRUMENT=lyrebird DESTHOST=${2:-ics1-taipan.nbi.ansto.gov.au} diff --git a/site_ansto/instrument/tas/config/commands/commands.tcl b/site_ansto/instrument/tas/config/commands/commands.tcl index 3d9bd1cd..5216c108 100644 --- a/site_ansto/instrument/tas/config/commands/commands.tcl +++ b/site_ansto/instrument/tas/config/commands/commands.tcl @@ -11,137 +11,6 @@ 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 -# Given -# (Xbf,Zbf) = beam pos in frame coords -# (Xbd,Zbd) = beam pos in detector coords -# (Xbbs, Zbbs) = beam pos in beamstop coords -# (Xdf,Zdf) = detector pos in frame coords -# (Xbsf,Zbsf) = beamstop pos in frame coords -# -# (Xbf,Zbf) = (Xdf+Xbd, Zdf+Zbd) = (Xbsf+Xbbs, Zbsf+Zbbs) -# Origin of detector coords = frame origin -# -# Detector and beamstop motor readings with beamstop disk centers -# overlapping over detector center mark. -# Xdf = 264.542 (7283813) Zdf = 0 -# Xbbs = 296.291 (8054270) -# Zbbs = 259.641 (13488244) -# Xbd = dethw, Zbd = (dethh) -# -# 264.542+dethw = Xbsf+296.291 -# 0+dethh = Zbsf+259.641 -# -# Xbsf = -31.749 + dethw, Zbsf = -259.641 + dethh -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 Xbsf [expr -31.749 + $dethw] - set Zbsf [expr -259.641 + $dethh] - array set bsl [subst { - 1 [SplitReply [bs1 softlowerlim]] - 2 [SplitReply [bs2 softlowerlim]] - 3 [SplitReply [bs3 softlowerlim]] - 4 [SplitReply [bs4 softlowerlim]] - 5 [SplitReply [bs5 softlowerlim]] - 6 [SplitReply [bs6 softlowerlim]] - }] - if [ catch { - switch $bs { - "1" { - set bsmot "bs1" - set bs_target 93.20 - set bs_diameter 110 - set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs4 $bsl(4) bs5 $bsl(5) bs6 $bsl(6)" - } - "2" { - set bsmot "bs2" - set bs_target 86.84 - set bs_diameter 88 - set bsdownCmd "drive bs1 $bsl(1) bs3 $bsl(3) bs4 $bsl(4) bs5 $bsl(5) bs6 $bsl(6)" - } - "3" { - set bsmot "bs3" - set bs_target 93.35 - set bs_diameter 66 - set bsdownCmd "drive bs2 $bsl(2) bs1 $bsl(1) bs4 $bsl(4) bs5 $bsl(5) bs6 $bsl(6)" - } - "4" { - set bsmot "bs4" - set bs_target 86.85 - set bs_diameter 44 - set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs1 $bsl(1) bs5 $bsl(5) bs6 $bsl(6)" - } - "5" { - set bsmot "bs5" - set bs_target 93.27 - set bs_diameter 22 - set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs4 $bsl(4) bs1 $bsl(1) bs6 $bsl(6)" - } - "6" { - set bsmot "bs6" - set bs_target 86.98 - set bs_diameter 11 - set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs4 $bsl(4) bs5 $bsl(5) bs1 $bsl(1)" - } - default { - error "beamstop selection must be an integer from 1 to 6" - } - } - - # comment out -- Jing - #set detoff_val [SplitReply [detoff]] - - if {$bx == "UNDEF" || $bz == "UNDEF"} { - statemon start selbs - if {[info level] > 1} {statemon start [lindex [info level -1] 0]} - set bsdriving true - BeamStop -1 - BSdiam -1 - drive $bsmot $bs_target - eval $bsdownCmd - BeamStop $bs - BSdiam $bs_diameter - set bsdriving false - statemon stop selbs - if {[info level] > 1} {statemon stop [lindex [info level -1] 0]} - } else { - if { [string is double $bx] == false } { - if { [string is double $bz] == false } { - error "beam coordinates must be floats" - } - } - # comment out -- Jing - #set bsx_target [expr {$bx-$Xbsf+$detoff_val}] - set bsz_target [expr {$bz-$Zbsf}] - - statemon start selbs - if {[info level] > 1} {statemon start [lindex [info level -1] 0]} - set bsdriving true - BeamStop -1 - BSdiam -1 - drive $bsmot $bs_target bsx $bsx_target bsz $bsz_target - eval $bsdownCmd - BeamStop $bs - BSdiam $bs_diameter - set bsdriving false - statemon stop selbs - if {[info level] > 1} {statemon stop [lindex [info level -1] 0]} - } - } msg ] { - if {$bsdriving} { - statemon stop selbs - if {[info level] > 1} {statemon stop [lindex [info level -1] 0]} - } - return -code error $msg - } -} -publish selbs user namespace eval beamstops { command selbsn {int=1,2,3,4,5,6 bs} { selbs $bs "UNDEF" "UNDEF" @@ -176,42 +45,6 @@ namespace eval optics { # 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"] - EApPosY $position - } - GuideConfig $configuration - } 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 diff --git a/site_ansto/instrument/tas/config/hmm/detector_ordela.tcl b/site_ansto/instrument/tas/config/hmm/detector_ordela.tcl deleted file mode 100644 index 8b9de19c..00000000 --- a/site_ansto/instrument/tas/config/hmm/detector_ordela.tcl +++ /dev/null @@ -1,488 +0,0 @@ -# Ordela 21000N detector calibration - -proc ord_get_pot { potxy potnumber } { - for { set rsp "Bad" } { $rsp == "Bad" } { } { - set potname [ format "%s%d" $potxy [expr $potnumber ^ 3] ] -# set rspall [ dhv1 cmd P $potname ] - set rspall [ sct_dhv1 transact "P $potname" ] - set rsp [lindex [split $rspall " "] 1] - } - return $rsp -} -Publish ord_get_pot User - -proc ord_set_pot { potxy potnumber potvalue } { - set potname [ format "%s%d" $potxy [expr $potnumber ^ 3] ] -# set rsp [ dhv1 cmd p $potname $potvalue ] - set rsp [ sct_dhv1 transact "p $potname $potvalue" ] - return $rsp -} -Publish ord_set_pot User - -set ord_pot_all_x "" -Publish ord_pot_all_x User -set ord_pot_all_y "" -Publish ord_pot_all_y User -set ord_pot_all_xy "" -Publish ord_pot_all_xy User - -proc ord_get_pot_all { } { - global ord_pot_all_x - global ord_pot_all_y - global ord_pot_all_xy - clientput " Reading Ordela 21000N pots, please wait..." - set ord_pot_all_x "" - set ord_pot_all_y "" - for { set ixy 0 } { $ixy <= 191 } { incr ixy } { - lappend ord_pot_all_x [ord_get_pot x $ixy] - lappend ord_pot_all_y [ord_get_pot y $ixy] - } - set ord_pot_all_xy [ format "%s\n%s\n" $ord_pot_all_x $ord_pot_all_y ] - clientput " All pots read. Current x and y pot settings are shown below:" - return $ord_pot_all_xy -} -Publish ord_get_pot_all User - -proc ord_set_pot_all { } { - global ord_pot_all_x - global ord_pot_all_y - clientput " Writing Ordela 21000N pots, please wait..." - set rspx "" - for { set ixy 0 } { $ixy <= 191 } { incr ixy } { - lappend rspx [ord_set_pot x $ixy [lindex $ord_pot_all_x $ixy] ] - } - set rspy "" - for { set ixy 0 } { $ixy <= 191 } { incr ixy } { - lappend rspy [ord_set_pot y $ixy [lindex $ord_pot_all_y $ixy] ] - } - clientput " All pots written. x and y pot setting responses are shown below:" - set rsp [ format "%s\n%s\n" $rspx $rspy ] - return $rsp -} -Publish ord_set_pot_all User - -proc ord_set_pot_all_const_range_x_y { xy ord_pot_all_x_y pot_l s_x_y pot_h } { - global $ord_pot_all_x_y - set $ord_pot_all_x_y "" - if { $s_x_y <= 0 } { - clientput " Applying constant value" $pot_h "to all" $xy "pots." - } elseif { $s_x_y >= 192 } { - clientput " Applying constant value" $pot_l "to all" $xy "pots." - } else { - clientput " Applying constant value" $pot_l "to" $xy "pots 0 to" [expr $s_x_y - 1] "and" $pot_h "to" $xy "pots" $s_x_y "to 191." - } - for { set ixy 0 } { $ixy <= 191 } { incr ixy } { - if { $ixy < $s_x_y } { - set pot_value_x_y $pot_l - } else { - set pot_value_x_y $pot_h - } - lappend $ord_pot_all_x_y $pot_value_x_y - } -} - -proc ord_set_pot_all_const_range_xy { pot_l_x s_x pot_h_x pot_l_y s_y pot_h_y } { - global ord_pot_all_x - global ord_pot_all_y - ord_set_pot_all_const_range_x_y x ord_pot_all_x $pot_l_x $s_x $pot_h_x - ord_set_pot_all_const_range_x_y y ord_pot_all_y $pot_l_y $s_y $pot_h_y - clientput $ord_pot_all_x - clientput $ord_pot_all_y -} -Publish ord_set_pot_all_const_range_xy User - -proc ord_set_pot_all_const_range { pot_l_x s_x pot_h_x pot_l_y s_y pot_h_y } { - ord_set_pot_all_const_range_xy $pot_l_x $s_x $pot_h_x $pot_l_y $s_y $pot_h_y - return [ord_set_pot_all] -} -Publish ord_set_pot_all_const_range User - -proc ord_set_pot_all_const_xy { pot_value_x pot_value_y } { - ord_set_pot_all_const_range_xy $pot_value_x 0 $pot_value_x $pot_value_y 0 $pot_value_y - return [ord_set_pot_all] -} -Publish ord_set_pot_all_const_xy User - -proc ord_set_pot_all_const { pot_value } { - ord_set_pot_all_const_range_xy $pot_value 0 $pot_value $pot_value 0 $pot_value - return [ord_set_pot_all] -} -Publish ord_set_pot_all_const User - -proc ord_save_pot_all { filename } { - global ord_pot_all_xy - set fh [ open $filename w ] - puts $fh $ord_pot_all_xy - close $fh - clientput " All pot settings saved to file." -} -Publish ord_save_pot_all User - -proc ord_load_pot_all { filename } { - global ord_pot_all_x - global ord_pot_all_y - global ord_pot_all_xy - set fh [ open $filename ] - gets $fh ord_pot_all_x - gets $fh ord_pot_all_y - set ord_pot_all_xy [ format "%s\n%s\n" $ord_pot_all_x $ord_pot_all_y ] - close $fh - clientput " All pot settings loaded from file." - clientput "x settings:" $ord_pot_all_x - clientput "y settings:" $ord_pot_all_y -} -Publish ord_load_pot_all User - -set histogram_xy "" -set histogram_x "" -set histogram_y "" - -# Calibration procedure should not include data from edges of the detector pattern in corresponding 2D histogram. -# The set values can be viewed/adjusted using the ord_get_cal_roi and ord_set_bs_pos functions provided below. -set roi_x_l 24 -set roi_x_h 167 -set roi_y_l 24 -set roi_y_h 167 - -proc ord_get_histogram_xy { bs_x_l bs_x_h bs_y_l bs_y_h roi_x_l roi_x_h roi_y_l roi_y_h } { -# Use data from within the x,y ROI (inclusive) to calculate 2D histograms. -# Excludes the beamstop region from the histogram calculations. -# Note the ROI and beamstop coords are in terms of histogram server coord system -# but the result x and y histograms are in detector coordinate system (match pot order). -# Also note that when calculating the x and y 1D histogram, it includes data from the y or x ROI respectively -# and excludes data from the BS region. (i.e. x histogram is computed by summing in y across the y ROI, -# but excludes the portion of y occupied by the beamstop). The calculation is done in this way so that -# the result is as uniform as possible in x and y. - global histogram_xy - global histogram_x - global histogram_y - clientput "Retrieving 2D xy histogram..." - set histogram_xy [ lreplace [ split [ hmm get 1 ] ] 0 1 ] - if { ($bs_x_l > $bs_x_h || $bs_y_l > $bs_y_h) && $roi_x_l == 0 && $roi_x_h == 191 && $roi_y_l == 0 && $roi_y_h == 191 } { - set get_full_histogram 1 - clientput "Calculating 2D histograms over full detector area..." - set bs_x_l 1 - set bs_x_h 0 - set bs_y_l 1 - set bs_y_h 0 - } else { - set get_full_histogram 0 - clientput "Calculating 2D histograms excluding beamstop area x =" $bs_x_l "to" $bs_x_h "and y =" $bs_y_l "to" $bs_y_h "..." - clientput "Histograms ROI is x =" $roi_x_l "to" $roi_x_h "(for y histogram) and y =" $roi_y_l "to" $roi_y_h "(for x histogram)." - } - set histogram_memory_x "" - set histogram_memory_y "" - for { set ia 0 } { $ia <= 191 } { incr ia } { - set sum_x 0 - set sum_y 0 -# NOTE: In the sum loops below, do NOT include the edges! Too unreliable. Sum in the ROI only instead. - for { set ib $roi_x_l } { $ib < $bs_x_l } { incr ib } { - set sum_x [expr $sum_x + [lindex $histogram_xy [expr $ib + $ia * 192] ]] - } - for { set ib [expr $bs_x_h + 1] } { $ib <= $roi_x_h } { incr ib } { - set sum_x [expr $sum_x + [lindex $histogram_xy [expr $ib + $ia * 192] ]] - } - for { set ib $roi_y_l } { $ib < $bs_y_l } { incr ib } { - set sum_y [expr $sum_y + [lindex $histogram_xy [expr $ia + $ib * 192] ]] - } - for { set ib [expr $bs_y_h + 1] } { $ib <= $roi_y_h } { incr ib } { - set sum_y [expr $sum_y + [lindex $histogram_xy [expr $ia + $ib * 192] ]] - } - lappend histogram_memory_x $sum_y - lappend histogram_memory_y $sum_x - } -# -# If x and y need to be swapped or reordered, do it in the loop below. -# (histo server raw data x,y order matches pot order) - set histogram_x "" - set histogram_y "" - for { set ixy 0 } { $ixy <= 191 } { incr ixy } { - lappend histogram_x [lindex $histogram_memory_y [expr $ixy]] - lappend histogram_y [lindex $histogram_memory_x [expr 191 - $ixy]] - } -# -# - if { $get_full_histogram == 1 } { - clientput "Calculated x and y histograms over entire detector area. Data:" - } else { - clientput "Calculated x and y histograms for ROI, excluding beamstop area. Data:" - } - set rsp [ format "%s\n%s\n" $histogram_x $histogram_y ] - return $rsp -} -Publish ord_get_histogram_xy User - -# Beamstop and spill nominally occupies the center 1/4 of the detector pattern. -# The set values can be viewed/adjusted using the ord_get_bs_pos and ord_set_bs_pos functions provided below. -set bss_x_l 72 -set bss_x_h 120 -set bss_y_l 72 -set bss_y_h 120 - -proc ord_get_bs_pos { } { - global bss_x_l - global bss_x_h - global bss_y_l - global bss_y_h - clientput "The current beamstop position settings (in histogram server xy coordinates) are: xl =" $bss_x_l "xh =" $bss_x_h$ -} -Publish ord_get_bs_pos User - -proc ord_set_bs_pos { bss_x_l_new bss_x_h_new bss_y_l_new bss_y_h_new } { - global bss_x_l - global bss_x_h - global bss_y_l - global bss_y_h - set bss_x_l $bss_x_l_new - set bss_x_h $bss_x_h_new - set bss_y_l $bss_y_l_new - set bss_y_h $bss_y_h_new - return [ord_get_bs_pos] -} -Publish ord_set_bs_pos User - -# Calibration procedure should not include data from edges of the detector pattern in corresponding 2D histogram. -# The set values can be viewed/adjusted using the ord_get_cal_roi and ord_set_bs_pos functions provided below. -set roi_x_l 24 -set roi_x_h 167 -set roi_y_l 24 -set roi_y_h 167 - -proc ord_get_roi_pos { } { - global roi_x_l - global roi_x_h - global roi_y_l - global roi_y_h - clientput "The current histogram ROI settings (in histogram server xy coordinates) are: xl =" $roi_x_l "xh =" $roi_x_h "yl =" $roi_y_l "yh =" $roi_y_h -} -Publish ord_get_roi_pos User - -proc ord_set_roi_pos { roi_x_l_new roi_x_h_new roi_y_l_new roi_y_h_new } { - global roi_x_l - global roi_x_h - global roi_y_l - global roi_y_h - set roi_x_l $roi_x_l_new - set roi_x_h $roi_x_h_new - set roi_y_l $roi_y_l_new - set roi_y_h $roi_y_h_new - return [ord_get_roi_pos] -} -Publish ord_set_roi_pos User - -proc ord_get_histogram_xy_bs { } { - global bss_x_l - global bss_x_h - global bss_y_l - global bss_y_h - global roi_x_l - global roi_x_h - global roi_y_l - global roi_y_h - return [ ord_get_histogram_xy $bss_x_l $bss_x_h $bss_y_l $bss_y_h $roi_x_l $roi_x_h $roi_y_l $roi_y_h ] -} -Publish ord_get_histogram_xy_bs User - -proc ord_get_histogram_xy_all { } { - return [ ord_get_histogram_xy 1 0 1 0 0 191 0 191 ] -} -Publish ord_get_histogram_xy_all User - -set histogram_min_x "" -set histogram_min_y "" -set histogram_max_x "" -set histogram_max_y "" -set histogram_mean_x "" -set histogram_mean_y "" - -proc ord_calc_hist_mmm_xy { } { -# Calculates min, max and mean of histogram values. -# NOTE: Because of edge effects in the detector, three of the edges return -# very high or low values. In order to stop these from dragging the mean -# high or low, they are excluded from the min/max/mean calculation entirely. - global histogram_x - global histogram_y - global histogram_min_x - global histogram_min_y - global histogram_max_x - global histogram_max_y - global histogram_mean_x - global histogram_mean_y - global bss_x_l - global bss_x_h - global bss_y_l - global bss_y_h -# NOTE: Ignore the edges entirely, as they are not reliable. - set histogram_mean_x 0 - set histogram_mean_y 0 - for { set ixy 1 } { $ixy <= 190 } { incr ixy } { - set histogram_x_val [lindex $histogram_x $ixy] - set histogram_y_val [lindex $histogram_y $ixy] - if { $ixy == 1 } { # NOTE edge at 0 is ignored - set histogram_min_x $histogram_x_val - set histogram_min_y $histogram_y_val - set histogram_max_x $histogram_x_val - set histogram_max_y $histogram_y_val - } else { - if {$histogram_x_val < $histogram_min_x } { - set histogram_min_x $histogram_x_val - } - if {$histogram_y_val < $histogram_min_y } { - set histogram_min_y $histogram_y_val - } - if {$histogram_x_val > $histogram_max_x } { - set histogram_max_x $histogram_x_val - } - if {$histogram_y_val > $histogram_max_y } { - set histogram_max_y $histogram_y_val - } - } - set histogram_mean_x [expr $histogram_mean_x + $histogram_x_val ] - set histogram_mean_y [expr $histogram_mean_y + $histogram_y_val ] - } -# NOTE beamstop region and edges are not included. -# ALSO NOTE we sum x histo over y, but x and y are transposed when the histo is retrieved, -# so we divide x histo values by span_x and y by span_y! -# set span_x [expr 190 - ( $bss_x_h - $bss_x_l ) ] -# set span_y [expr 190 - ( $bss_y_h - $bss_y_l ) ] -# if { $bss_x_l == 0 } { incr span_x } -# if { $bss_x_h == 191 } { incr span_x } -# if { $bss_y_l == 0 } { incr span_y } -# if { $bss_y_h == 191 } { incr span_y } - set span_x 190 - set span_y 190 - set histogram_mean_x [expr double($histogram_mean_x) / double($span_x) ] - set histogram_mean_y [expr double($histogram_mean_y) / double($span_y) ] - clientput "Calculated histogram means: mx =" $histogram_mean_x "and my =" $histogram_mean_y "(should be -roughly equal if bs window is square)." -} -Publish ord_calc_hist_mmm_xy User - -proc ord_calc_pot { pot_in histogram_value histogram_mean CP_divider add_deviation } { - set CP 0.25 - set histogram_deviation [expr double($histogram_value) / double($histogram_mean) - 1.] - set pot_out [ expr double($pot_in) - $histogram_deviation * $CP * 100. / $CP_divider ] - set pot_out [ expr int($pot_out + double($add_deviation) + 0.5) ] - if { $pot_out < 0 } { - set pot_out 0 - } elseif { $pot_out > 63 } { - set pot_out 63 - } - return $pot_out -} -Publish ord_calc_pot User - -proc ord_calc_pot_all_xy { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y } { - global histogram_x - global histogram_y - global histogram_mean_x - global histogram_mean_y - global ord_pot_all_x - global ord_pot_all_y - clientput "Calculating new pot settings based on old pot settings and histogram data..." - set ord_pot_all_x_new "" - set ord_pot_all_y_new "" - set ord_pot_dev_av_x 0 - set ord_pot_dev_av_y 0 - set ord_pot_dev_max_x 0 - set ord_pot_dev_max_y 0 -# Find current mean pot values. Do NOT include the edge pots. - set ord_pot_mean_x 0 - set ord_pot_mean_y 0 - for { set ixy 1 } { $ixy <= 190 } { incr ixy } { - set ord_pot_mean_x [expr $ord_pot_mean_x + [lindex $ord_pot_all_x $ixy]] - set ord_pot_mean_y [expr $ord_pot_mean_y + [lindex $ord_pot_all_y $ixy]] - } - set ord_pot_mean_x [expr double($ord_pot_mean_x) / 190.] - set ord_pot_mean_y [expr double($ord_pot_mean_y) / 190.] -# Calculate additional deviation to apply during new pot value calculation, -# to keep pot average close to desired mid range. - set ord_pot_add_dev_x [expr double($desiredpotsmidrange_x) - $ord_pot_mean_x] - set ord_pot_add_dev_y [expr double($desiredpotsmidrange_y) - $ord_pot_mean_y] -# Find all new pot values. - for { set ixy 0 } { $ixy <= 191 } { incr ixy } { -# clientput "Index" $ixy "x pot value" [lindex $ord_pot_all_x $ixy] -# clientput "Index" $ixy "histogram x value" [lindex $histogram_x $ixy] -# clientput "Index" $ixy "x pot value" $histogram_mean_x -# clientput "Index" $ixy "y pot value" [lindex $ord_pot_all_y $ixy] -# clientput "Index" $ixy "histogram y value" [lindex $histogram_y $ixy] -# clientput "Index" $ixy "y pot value" $histogram_mean_y - set ord_pot_old_x [lindex $ord_pot_all_x $ixy] - set ord_pot_old_y [lindex $ord_pot_all_y $ixy] - set ord_pot_new_x [ ord_calc_pot $ord_pot_old_x [lindex $histogram_x $ixy] $histogram_mean_x $CP_divider $ord_pot_add_dev_x ] - set ord_pot_new_y [ ord_calc_pot $ord_pot_old_y [lindex $histogram_y $ixy] $histogram_mean_y $CP_divider $ord_pot_add_dev_y ] - lappend ord_pot_all_x_new $ord_pot_new_x - lappend ord_pot_all_y_new $ord_pot_new_y -# Also get some stats on deviations (just take this as absolute) - set ord_pot_dev_x [ expr abs ( $ord_pot_new_x - $ord_pot_old_x ) ] - set ord_pot_dev_y [ expr abs ( $ord_pot_new_y - $ord_pot_old_y ) ] - set ord_pot_dev_av_x [ expr $ord_pot_dev_av_x + $ord_pot_dev_x ] - set ord_pot_dev_av_y [ expr $ord_pot_dev_av_y + $ord_pot_dev_y ] - if { $ord_pot_dev_x > $ord_pot_dev_max_x } { - set ord_pot_dev_max_x $ord_pot_dev_x - } - if { $ord_pot_dev_y > $ord_pot_dev_max_y } { - set ord_pot_dev_max_y $ord_pot_dev_y - } - } - set ord_pot_dev_av_x [ expr $ord_pot_dev_av_x / 192. ] - set ord_pot_dev_av_y [ expr $ord_pot_dev_av_y / 192. ] - clientput "Average deviations: x =" $ord_pot_dev_av_x "and y =" $ord_pot_dev_av_y - clientput "Maximum deviations: x =" $ord_pot_dev_max_x "and y =" $ord_pot_dev_max_y -# - set ord_pot_all_x $ord_pot_all_x_new - set ord_pot_all_y $ord_pot_all_y_new - set ord_pot_all_xy [ format "%s\n%s\n" $ord_pot_all_x $ord_pot_all_y ] - return $ord_pot_all_xy -} -Publish ord_calc_pot_all_xy User - -proc ord_calibrate_iterate { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y iteration } { -# For this to work we must first read pot values and the x and y histograms. -# Note the beamstop location is hard coded - position detector so that beamstop image is in the specified range - clientput [ord_get_histogram_xy_bs] - clientput [ord_calc_hist_mmm_xy] -# if { $iteration == 1 } { -# clientput [ord_get_pot_all] ## while iterating, the pot values are in the memory anyway so don't read -# } - clientput [ord_calc_pot_all_xy $CP_divider $desiredpotsmidrange_x $desiredpotsmidrange_y] - clientput [ord_set_pot_all] -} - -proc ord_calibrate { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y } { - clientput [ord_get_pot_all] - ord_calibrate_iterate $CP_divider $desiredpotsmidrange_x $desiredpotsmidrange_y 1 -} -Publish ord_calibrate User - -proc ord_calibrate_auto { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y resetallpotsmidrange iterations acqtime } { -# - if { $resetallpotsmidrange == 1 } { - clientput [ord_set_pot_all_const_xy $desiredpotsmidrange_x $desiredpotsmidrange_y ] - } else { - clientput [ord_get_pot_all] - } -# - for { set iteration 1 } { $iteration <= $iterations } { incr iteration } { - clientput "*** Commencing detector calibration iteration" $iteration -# NOTE: Assumes the histogram memory is set up in its DEFAULT state -# (that which SICS configures, but perhaps including HISTOGRAM_TRANSPOSE_RAW_XY=ENABLE). -# At 9/08 the configuration is HISTOGRAM_TRANSPOSE_RAW_XY=ENABLE, X OAT flipped, Y OAT non-flipped. -# Modify ordering in the ord_get_histogram_xy routine as needed. -# Alternately reconfigure transpose and OAT flipping here, so we get what we expect... -# (but this might not get put back by SICS so it's better not to) -# dhv1 cmd d # Diagnostic mode - CD turned off - histmem stop - histmem mode time - histmem preset $acqtime - histmem pause # NOTE - start in paused mode - server sends reset to Ordela first -# dhv1 cmd d # Place in diagnostic mode - will stay in this mode since reset won't occur on start, from paused - clientput [histmem start block] -# wait $acqtime # Can't figure out how to make histmem block, so just wait - clientput [histmem stop] -# dhv1 cmd n # Normal mode - CD turned back on - clientput [ord_calibrate_iterate $CP_divider $desiredpotsmidrange_x $desiredpotsmidrange_y $iteration ] - clientput "*** Detector calibration iteration" $iteration "completed." - } -} -Publish ord_calibrate_auto User diff --git a/site_ansto/instrument/tas/config/hmm/hmm_configuration.tcl b/site_ansto/instrument/tas/config/hmm/hmm_configuration.tcl index b5454aa0..2f2ac231 100644 --- a/site_ansto/instrument/tas/config/hmm/hmm_configuration.tcl +++ b/site_ansto/instrument/tas/config/hmm/hmm_configuration.tcl @@ -57,6 +57,7 @@ proc ::histogram_memory::isc_initialize {} { return -code error $message } } +publish isc_initialize user proc histmem {cmd args} { eval "_histmem $cmd $args" diff --git a/site_ansto/instrument/tas/taipan_configuration.tcl b/site_ansto/instrument/tas/taipan_configuration.tcl index 5170f94d..83477453 100644 --- a/site_ansto/instrument/tas/taipan_configuration.tcl +++ b/site_ansto/instrument/tas/taipan_configuration.tcl @@ -20,8 +20,6 @@ source $cfPath(hipadaba)/hipadaba_configuration.tcl fileeval $cfPath(motors)/motor_configuration.tcl fileeval $cfPath(motors)/spin_galil.tcl fileeval $cfPath(motors)/positmotor_configuration.tcl -#fileeval $cfPath(velsel)/velsel.tcl -#fileeval $cfPath(parameters)/parameters.tcl fileeval $cfPath(plc)/plc.tcl #fileeval $cfPath(optics)/optics.tcl fileeval $cfPath(counter)/counter.tcl @@ -29,7 +27,6 @@ fileeval $cfPath(counter)/counter.tcl #fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(nexus)/nxscripts.tcl -fileeval $cfPath(hmm)/detector.tcl fileeval $cfPath(scan)/scan.tcl fileeval $cfPath(commands)/commands.tcl fileeval $cfPath(anticollider)/anticollider.tcl @@ -39,8 +36,8 @@ fileeval $cfPath(anticollider)/anticollider.tcl #fileeval $cfPath(environment)/environment.tcl #fileeval $cfPath(environment)/sct_mcr500_rheometer.tcl #fileeval $cfPath(environment)/sct_protek_common.tcl -#fileeval $cfPath(beamline)/spin_flipper.tcl fileeval $cfPath(tasmad)/taspub_sics/tasscript.tcl +#fileeval $cfPath(tasmad)/taspub_sics/tasp.tcl source gumxml.tcl ::utility::mkVar ::anticollider::protect_detector text manager protect_detector false detector true false