Terminition conditions when acquiring detector data are now controlled by the histogram server instead of the beam monitor. So more termination methods are now available and timed counts should be more precise.
hmm_configuration_common_1.tcl Map hmm dim0,1,2 to histogram server OAT dimensions. Added commands to set the histogram server count method, size and stop condition. scan_common_1.tcl hmscan is now controlled by the histogram server instead of the beam monitor. NOTE: the mode and preset parameters for hmscan run are now ignored in favour of the parameters set on the hmm object. r2189 | ffr | 2007-10-23 12:40:09 +1000 (Tue, 23 Oct 2007) | 10 lines
This commit is contained in:
committed by
Douglas Clowes
parent
8e6d4e4da6
commit
8b1996996a
@@ -1,48 +1,40 @@
|
||||
## \file Scan functionality and common high level commands are defined here.
|
||||
##
|
||||
# @file Scan functionality and common high level commands are defined here.
|
||||
#
|
||||
# namespace variables\n
|
||||
# ::scan::save_filetype data/scratch, controls if data will be saved to a scratch file.
|
||||
# ::scan::reset_position true/false, drive motor back to start position at end of scan
|
||||
# ::scan::reset_position true/false (default=true), drive motor back to start position at end of scan
|
||||
#TODO Get rid of duplication in bmonscan and hmscan code
|
||||
MakeScanCommand hmscan bm $cfPath(scan)/scan_common_1.hdd recover.bin
|
||||
MakeScanCommand bmonscan bm $cfPath(scan)/scan_common_1.hdd recover.bin
|
||||
MakeScanCommand scan2 bm $cfPath(scan)/scan_common_1.hdd recover.bin
|
||||
|
||||
namespace eval scan {
|
||||
variable event;
|
||||
# List of counts
|
||||
variable bmoncounts_array
|
||||
variable bmoncounts_axis
|
||||
variable save_filetype
|
||||
variable reset_position
|
||||
set save_filetype "data"
|
||||
set reset_position "false"
|
||||
|
||||
variable bmonscanvar_axis_hpath
|
||||
# hpath to values from bmoncounts_array
|
||||
# we use this to get auto-notification on update of bmonscancounts_array_hpath
|
||||
variable bmonscancounts_array_hpath
|
||||
variable scanVariable scan_var scanVarStart 0 scanVarStep 1
|
||||
proc scan_collect {sobj uobj point} {
|
||||
}
|
||||
|
||||
## \brief Aborts scan if a scan variable target position exeeds the limits.
|
||||
proc check_limit {scan_variable limit_name target} {
|
||||
}
|
||||
##
|
||||
# @brief Returns an error if a scan variable target position exceeds the limits.
|
||||
proc ::scan::check_limit {scan_variable limit_name target} {
|
||||
switch $limit_name {
|
||||
"hardlowerlim" - "softlowerlim" {
|
||||
set limit [SplitReply [$scan_variable $limit_name]]
|
||||
if { $target < $limit} {
|
||||
return -code error "ERROR Scan aborted. Final position of $target violates $limit_name $limit for $scan_variable"
|
||||
return -code error "Final position of $target violates $limit_name $limit for $scan_variable"
|
||||
}
|
||||
}
|
||||
"hardupperlim" - "softupperlim" {
|
||||
set limit [SplitReply [$scan_variable $limit_name]]
|
||||
if { $target > $limit} {
|
||||
return -code error "ERROR Scan aborted. Final position of $target violates $limit_name $limit for $scan_variable"
|
||||
return -code error "Final position of $target violates $limit_name $limit for $scan_variable"
|
||||
}
|
||||
}
|
||||
default {
|
||||
error_msg "Invalid limit name $limit_name"
|
||||
return -code error "Invalid limit name $limit_name"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +44,7 @@ proc check_limit {scan_variable limit_name target} {
|
||||
# so we don't have to.
|
||||
# TODO We can't check limits of virtual motors yet because the
|
||||
# configurablevirtualmotor doesn't set a checklimits function.
|
||||
proc check_scanvar {sobj uobj} {
|
||||
proc ::scan::check_scanvar {sobj uobj} {
|
||||
set vlist [split [$sobj getvarpar 0] = ];
|
||||
set NP [SplitReply [$sobj np]]
|
||||
set scan_variable [string trim [lindex [split [lindex $vlist 0] . ] 1]]
|
||||
@@ -60,21 +52,45 @@ proc check_limit {scan_variable limit_name target} {
|
||||
set scan_increment [lindex $vlist 2];
|
||||
if {[getatt $scan_variable type] == "motor"} {
|
||||
if {[SplitReply [$scan_variable fixed]] >= 0} {
|
||||
return -code error "Scan aborted. $scan_variable position is set to 'fixed'"
|
||||
return -code error "Can't drive scan variable, $scan_variable position is set to 'fixed'"
|
||||
}
|
||||
set target [expr $scan_start + $NP * $scan_increment]
|
||||
::scan::check_limit $scan_variable hardlowerlim $target
|
||||
::scan::check_limit $scan_variable hardupperlim $target
|
||||
::scan::check_limit $scan_variable softlowerlim $target
|
||||
::scan::check_limit $scan_variable softupperlim $target
|
||||
if [catch {
|
||||
::scan::check_limit $scan_variable hardlowerlim $target
|
||||
::scan::check_limit $scan_variable hardupperlim $target
|
||||
::scan::check_limit $scan_variable softlowerlim $target
|
||||
::scan::check_limit $scan_variable softupperlim $target
|
||||
}] {
|
||||
return -code error $::errorInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
proc hmm_scan_prepare {sobj uobj} {
|
||||
|
||||
##
|
||||
# @brief Instrument specific scan configurations can override this procedure to perform some setup
|
||||
# before running a scan, eg setting hmm frame frequency.
|
||||
#
|
||||
# NOTES\n
|
||||
# Returning an error will cause the scan to abort before it starts\n
|
||||
# eg\n
|
||||
# return -code error "error message"
|
||||
proc ::scan::pre_hmm_scan_prepare {} {}
|
||||
|
||||
##
|
||||
# @brief Do some pre-scan checks and prime the DAE
|
||||
proc ::scan::hmm_scan_prepare {sobj uobj} {
|
||||
variable scan_pt_start_time
|
||||
|
||||
::scan::check_scanvar $sobj $uobj
|
||||
if [catch {
|
||||
::scan::check_scanvar $sobj $uobj
|
||||
::scan::pre_hmm_scan_prepare
|
||||
}] {
|
||||
abortbatch
|
||||
return -code error "HMSCAN ABORTED: $::errorInfo"
|
||||
}
|
||||
# Prime DAE
|
||||
hmm pause
|
||||
|
||||
# stdscan prepare $sobj $uobj;
|
||||
::scan::hdb_hmscan -set NP [SplitReply [$sobj np]]
|
||||
set vlist [split [$sobj getvarpar 0] = ];
|
||||
::scan::hdb_hmscan -set scan_variable [string trim [lindex [split [lindex $vlist 0] . ] 1]]
|
||||
@@ -83,98 +99,84 @@ proc check_limit {scan_variable limit_name target} {
|
||||
|
||||
set scan_pt_start_time [sicstime]
|
||||
|
||||
#FIXME remove dependency on hdb path
|
||||
::scan::hdb_hmscan -set feedback status BUSY
|
||||
|
||||
::histogram_memory::prepare
|
||||
::nexus::newfile HISTOGRAM_XYT data
|
||||
data axis 1 [::scan::hdb_hmscan -set scan_variable]
|
||||
}
|
||||
|
||||
proc hmm_count {sobj uobj point mode preset} {
|
||||
proc ::scan::hmm_count {sobj uobj point mode preset} {
|
||||
::scan::hdb_hmscan -set mode $mode
|
||||
::scan::hdb_hmscan -set preset $preset;
|
||||
::scan::hdb_hmscan -set preset $preset
|
||||
::scan::hdb_hmscan -set feedback scanpoint $point
|
||||
::scan::hdb_hmscan -set feedback mode $mode;
|
||||
::scan::hdb_hmscan -set feedback preset $preset;
|
||||
::scan::hdb_hmscan -set feedback mode $mode
|
||||
::scan::hdb_hmscan -set feedback preset $preset
|
||||
::scan::hdb_hmscan -set feedback scan_variable_value [SplitReply [[::scan::hdb_hmscan -set scan_variable]]]
|
||||
::histogram_memory::count_bm_controlled $mode $preset;
|
||||
# Start histogram and block until count is complete
|
||||
::histogram_memory::start block
|
||||
}
|
||||
|
||||
proc hmm_scan_finish {sobj uobj} {
|
||||
proc ::scan::hmm_scan_finish {sobj uobj} {
|
||||
variable save_filetype
|
||||
variable reset_position
|
||||
set $save_filetype "data"
|
||||
::histogram_memory::finish;
|
||||
hmm pause
|
||||
hmm stop
|
||||
::scan::hdb_hmscan -set feedback status IDLE
|
||||
# Make sure that the next save command doesn't overwrite our scan data.
|
||||
# and clear any data links
|
||||
::nexus::newfile clear data
|
||||
if {$reset_position == "true"} {
|
||||
set reset_position "false"
|
||||
set svar [::scan::hdb_hmscan -get scan_variable]
|
||||
set svtype [getatt $svar type]
|
||||
if {$svtype == "motor" || $svtype == "configurablevirtualmotor"} {
|
||||
drive $svar [::scan::hdb_hmscan -get scan_start]
|
||||
}
|
||||
set reset_position "false"
|
||||
}
|
||||
::histogram_memory::configure_server Filler_defaults
|
||||
# ::histogram_memory::configure_server Filler_defaults
|
||||
}
|
||||
|
||||
proc bm_scan_finish {sobj uobj} {
|
||||
proc ::scan::bm_scan_finish {sobj uobj} {
|
||||
variable reset_position
|
||||
::scan::hdb_bmonscan -set feedback status IDLE
|
||||
# Make sure that the next save command doesn't overwrite our scan data.
|
||||
# and clear any data links
|
||||
::nexus::newfile clear data
|
||||
if {$reset_position == "true"} {
|
||||
set reset_position "false"
|
||||
set svar [::scan::hdb_bmonscan -get scan_variable]
|
||||
set svtype [getatt $svar type]
|
||||
if {$svtype == "motor" || $svtype == "configurablevirtualmotor"} {
|
||||
drive $svar [::scan::hdb_bmonscan -get scan_start]
|
||||
}
|
||||
set reset_position "false"
|
||||
}
|
||||
}
|
||||
#proc hmm_scan_finish {sobj uobj} {
|
||||
# nxclosefile;
|
||||
#}
|
||||
|
||||
# Add an nxentry for the current scan point
|
||||
#TODO Is this obsolete?
|
||||
proc write_nxentry {nxentryCmd point} {
|
||||
variable scanVarStart;
|
||||
variable scanVarStep;
|
||||
variable scanVariable;
|
||||
proc ::scan::write_nxentry {nxentryCmd point} {
|
||||
variable scan_pt_start_time;
|
||||
|
||||
set scanVarPos [expr {$scanVarStart + $point * $scanVarStep} ];
|
||||
save $point
|
||||
# nxreopenfile;
|
||||
# $nxentryCmd nxscript scan_[format "%05d" $point] $scanVariable $scanVarPos $scanVarStep $scan_pt_start_time;
|
||||
# $nxentryCmd nxscript entry1 $point $scanVariable $scanVarPos $scanVarStep $scan_pt_start_time;
|
||||
# nxclosefile;
|
||||
}
|
||||
|
||||
proc bm_writepoint {sobj uobj pt} {
|
||||
variable bmoncounts_array
|
||||
set bmoncounts_array [string map {\{ "" \} ""} [SplitReply [bmonscan getcounts]]];
|
||||
proc ::scan::bm_writepoint {sobj uobj pt} {
|
||||
::nexus::save $pt
|
||||
|
||||
::scan::hdb_bmonscan -set feedback counts [SplitReply [bm getcounts]];
|
||||
}
|
||||
|
||||
#TODO Feedback for Histogram memory scan
|
||||
proc hmm_writepoint {sobj uobj pt} {
|
||||
proc ::scan::hmm_writepoint {sobj uobj pt} {
|
||||
variable save_filetype
|
||||
# Write hdb tree
|
||||
::nexus::save $pt
|
||||
}
|
||||
|
||||
proc donothing {args} {}
|
||||
proc ::scan::donothing {args} {}
|
||||
|
||||
proc bm_count {sobj uobj point mode preset} {
|
||||
variable event;
|
||||
proc ::scan::bm_count {sobj uobj point mode preset} {
|
||||
::scan::hdb_bmonscan -set mode $mode
|
||||
::scan::hdb_bmonscan -set preset $preset
|
||||
::scan::hdb_bmonscan -set feedback scanpoint $point;
|
||||
@@ -184,30 +186,31 @@ proc check_limit {scan_variable limit_name target} {
|
||||
::monitor::count $mode $preset
|
||||
}
|
||||
|
||||
proc bm_scan_prepare {sobj uobj} {
|
||||
variable event;
|
||||
proc ::scan::bm_scan_prepare {sobj uobj} {
|
||||
|
||||
variable bmoncounts_array;
|
||||
variable bmoncounts_axis;
|
||||
variable scan_pt_start_time
|
||||
|
||||
set bmoncounts_array [list]
|
||||
if [catch {
|
||||
::scan::check_scanvar $sobj $uobj
|
||||
::scan::pre_hmm_scan_prepare
|
||||
}] {
|
||||
abortbatch
|
||||
return -code error "BMONSCAN ABORTED: $::errorInfo"
|
||||
}
|
||||
|
||||
#TODO Parameterise varindex in some way
|
||||
set varindex 0;
|
||||
|
||||
::scan::hdb_bmonscan -set feedback filename [SplitReply [dataFileName]]
|
||||
::scan::hdb_bmonscan -set NP [SplitReply [$sobj np]];
|
||||
# set event(hdb_bmonscan/graphics,dim) [::scan::hdb_bmonscan -set NP]
|
||||
set vlist [split [$sobj getvarpar $varindex] = ];
|
||||
::scan::hdb_bmonscan -set scan_variable [string trim [lindex [split [lindex $vlist 0] . ] 1]];
|
||||
::scan::hdb_bmonscan -set scan_start [lindex $vlist 1];
|
||||
::scan::hdb_bmonscan -set scan_increment [lindex $vlist 2];
|
||||
set scanvar_pts [SplitReply [$sobj getvardata $varindex]]
|
||||
set bmoncounts_axis [string map {\{ "" \} ""} $scanvar_pts]
|
||||
todo_msg "SET START TIME set event(hdb_bmonscan,scan_pt_start_time) [sicstime]"
|
||||
todo_msg "SET START TIME [sicstime]"
|
||||
|
||||
::scan::hdb_bmonscan -set feedback status BUSY
|
||||
#FIXME remove dependency on hdb path
|
||||
|
||||
array set bm_fb [::scan::hdb_bmonscan -list feedback]
|
||||
::nexus::newfile BEAM_MONITOR data
|
||||
@@ -216,18 +219,6 @@ proc check_limit {scan_variable limit_name target} {
|
||||
}
|
||||
|
||||
|
||||
# group=beam_monitor_scan
|
||||
proc hdb_bmonscan_graphics {process args} {
|
||||
set eid hdb_bmonscan/graphics
|
||||
$process $args path beam_monitor_scan prop_list {data false control true nxsave false klass @none type graphdata viewer default rank 1}
|
||||
$process $args kind event node beam_monitor_scan/dim dtype int priv user eventid $eid;
|
||||
$process $args kind event node beam_monitor_scan/point dtype int priv user eventid $eid;
|
||||
$process $args kind event node beam_monitor_scan/lastaxis dtype float priv user eventid $eid;
|
||||
$process $args kind event node beam_monitor_scan/lastdata dtype int priv user eventid $eid;
|
||||
$process $args kind script node beam_monitor_scan/axis dtype floatvarar dlen 100 priv user rscript "set ::scan::bmoncounts_axis" wscript hdbReadOnly prop_list {type axis}
|
||||
$process $args kind script node beam_monitor_scan/data dtype floatvarar dlen 100 priv user rscript "set ::scan::bmoncounts_array" wscript hdbReadOnly prop_list {type data}
|
||||
}
|
||||
}
|
||||
|
||||
Publish ::scan::scan_collect user
|
||||
Publish ::scan::write_nxentry user
|
||||
@@ -251,23 +242,6 @@ bmonscan function prepare ::scan::bm_scan_prepare
|
||||
bmonscan function finish ::scan::bm_scan_finish
|
||||
|
||||
|
||||
#scan2 function writeheader ::scan::donothing
|
||||
#scan2 function writepoint ::scan::nxaddpoint
|
||||
#scan2 function prepare ::scan::hmm_scan_prepare
|
||||
# Configure script mode, then we can configure all the scan callbacks.
|
||||
# The scan list command can be used to check that the callbacks
|
||||
# are properly defined.
|
||||
# A different count callback is defined in the two cases.
|
||||
#
|
||||
scan2 configure script
|
||||
|
||||
#scan2 function prepare ::histogram_memory::prepare
|
||||
scan2 function count ::histogram_memory::hs_count_hs_controlled
|
||||
#scan2 function collect ::histogram_memory::hs_collect
|
||||
scan2 function finish ::histogram_memory::hs_finish
|
||||
#
|
||||
# That's all, folks...
|
||||
|
||||
hmscan configure script
|
||||
#hmscan function prepare hdbprepare
|
||||
#hmscan function collect hdbcollect
|
||||
@@ -320,6 +294,5 @@ command hdb_hmscan { text:drivable scan_variable float: scan_start float: scan_i
|
||||
::scan::hdb_hmscan -addfb text filename text mode float preset float scan_variable_value int scanpoint int counts text status
|
||||
::scan::hdb_hmscan -set feedback status IDLE
|
||||
}
|
||||
publish ::scan::hdb_bmonscan_graphics user
|
||||
sicslist setatt ::scan::hdb_bmonscan long_name bmonscan
|
||||
sicslist setatt ::scan::hdb_hmscan long_name hmscan
|
||||
|
||||
Reference in New Issue
Block a user