server_config.tcl
server_init now calls ::counter::isc_initialize, ::histogram_memory::isc_initialize and ::scan::isc_initialize scan.c SICS-158 Restrict bmonscan and hmscan to only one scan variable count_common.tcl Create a mulicounter which uses the available monitors as channels. The multicounter is used in bmonscans hipadaba_configuration_common.tcl Use _link as the suffix for the nxvgroup name when making nexus file links. hmm_configuration_common.tcl SICS-190 Create hdb entries for bm_counts, bm_event_rate, bm_status SICS-164 Allow running histmem in simulated mode. hmm_cylindrical_detector_configuration.tcl Only refer to detector SICSVariables when necessary, otherwise we get dependency problems. nxscripts_common_1.tcl Separate histmem_filtype_spec from bmon_filetype_spec so that we can use the histem_filetyp_spec names to restrict the histmem scan filetypes. Close the data file on error in proc ::nexus::save Allow int and text types when saving macro data scan_common_1.tcl SICS-173 Allow users to force a scan when the instrument isn't ready Added ic_initialize proc so we can make dependencies explicit in the init_server proc SICS-186 Allow monitor modes for histmem scans Allow selection of histmem file policies from runscan command echidna, wombat, kowari, quokka and platypus component and server configurations Added instrument specific configuration initialisation functions in the component configuration files. Add a catch block to the top-level instrument server configuration file and printout the errorContext and callStack r2641 | ffr | 2008-07-01 17:02:26 +1000 (Tue, 01 Jul 2008) | 34 lines
This commit is contained in:
committed by
Douglas Clowes
parent
c2186b037e
commit
0f96e4f82f
@@ -2,21 +2,88 @@
|
||||
# @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 (default=true), drive motor back to start position at end of scan
|
||||
# ::scan::save_filetype data/scratch, controls if data will be saved to a
|
||||
# scratch file.\n
|
||||
# ::scan::reset_position true/false (default=true), drive motor back to start
|
||||
# position at end of scan\n
|
||||
# ::scan::force_scan true/false, (default=false), Will force a scan if the
|
||||
# instrument isn't ready, eg shutters closed. Note: The scan will still fail if
|
||||
# you are scanning against a motor and motion control is disabled.\n
|
||||
# If force_scan is true it is immediately reset to false after it is checked.
|
||||
#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
|
||||
|
||||
namespace eval scan {
|
||||
variable ic_runscanpar
|
||||
|
||||
variable hmm_filetype
|
||||
variable save_filetype
|
||||
variable reset_position
|
||||
variable check_thread0
|
||||
variable check_instrument_ready
|
||||
variable force_scan
|
||||
|
||||
set check_thread0 true
|
||||
set check_instrument_ready true
|
||||
set force_scan false
|
||||
set save_filetype "data"
|
||||
set reset_position "false"
|
||||
|
||||
if {[SplitReply [motor_simulation]] == "true"} {
|
||||
set check_thread0 false
|
||||
}
|
||||
|
||||
proc scan_collect {sobj uobj point} {
|
||||
}
|
||||
}
|
||||
|
||||
proc ::scan::ic_initialize {} {
|
||||
if [ catch {
|
||||
variable ic_runscanpar
|
||||
variable hmm_filetype
|
||||
|
||||
set hmm_filetype HISTOGRAM_XYT
|
||||
|
||||
MakeScanCommand hmscan bm $::cfPath(scan)/scan_common_1.hdd recover.bin
|
||||
MakeScanCommand bmonscan bm $::cfPath(scan)/scan_common_1.hdd recover.bin
|
||||
|
||||
bmonscan configure script
|
||||
bmonscan function writeheader ::scan::donothing
|
||||
bmonscan function writepoint ::scan::bm_writepoint
|
||||
bmonscan function count ::scan::bm_count
|
||||
#bmonscan function collect ::scan::scan_collect
|
||||
bmonscan function prepare ::scan::bm_scan_prepare
|
||||
bmonscan function finish ::scan::bm_scan_finish
|
||||
|
||||
|
||||
hmscan configure script
|
||||
#hmscan function prepare hdbprepare
|
||||
#hmscan function collect hdbcollect
|
||||
hmscan function writeheader ::scan::donothing
|
||||
hmscan function writepoint ::scan::hmm_writepoint
|
||||
hmscan function count ::scan::hmm_count
|
||||
#hmscan function collect ::scan::scan_collect
|
||||
hmscan function prepare ::scan::hmm_scan_prepare
|
||||
hmscan function finish ::scan::hmm_scan_finish
|
||||
|
||||
# TODO Use ic_runscanpar to create the ::scan::runscan command and
|
||||
# to validate the "runscan" proc parameters.
|
||||
array set ic_runscanpar [subst {
|
||||
scanvar text=drivable
|
||||
start float
|
||||
stop float
|
||||
numpoints int=0,inf
|
||||
mode text=[join [concat [list time unlimited period count frame] $::counter::isc_beam_monitor_list ] , ]
|
||||
preset float=0,inf
|
||||
filetype text=[join [array names ::nexus::histmem_filetype_spec] , ]
|
||||
savetype text=save,nosave
|
||||
force boolean
|
||||
}]
|
||||
} message ] {
|
||||
if {$::errorCode=="NONE"} {return $message}
|
||||
return -code error $message
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Returns an error if a scan variable target position exceeds the limits.
|
||||
proc ::scan::check_limit {scan_variable limit_name target} {
|
||||
@@ -45,6 +112,7 @@ proc ::scan::check_limit {scan_variable limit_name target} {
|
||||
# TODO We can't check limits of virtual motors yet because the
|
||||
# configurablevirtualmotor doesn't set a checklimits function.
|
||||
proc ::scan::check_scanvar {sobj uobj} {
|
||||
variable check_thread0
|
||||
set vlist [split [$sobj getvarpar 0] = ];
|
||||
set NP [SplitReply [$sobj np]]
|
||||
set scan_variable [string trim [lindex [split [lindex $vlist 0] . ] 1]]
|
||||
@@ -53,7 +121,7 @@ proc ::scan::check_scanvar {sobj uobj} {
|
||||
if {[getatt $scan_variable type] == "motor"} {
|
||||
if {[SplitReply [$scan_variable fixed]] >= 0} {
|
||||
return -code error "ERROR: Can't drive scan variable, $scan_variable position is set to 'fixed'"
|
||||
} elseif {[SplitReply [$scan_variable thread0]] == -1} {
|
||||
} elseif {$check_thread0 && [SplitReply [$scan_variable thread0]] == -1} {
|
||||
return -code error "ERROR: Can't scan ${scan_variable}. Thread zero has stopped running on the motion controller"
|
||||
}
|
||||
set target [expr $scan_start + ($NP-1) * $scan_increment]
|
||||
@@ -83,42 +151,47 @@ proc ::scan::pre_hmm_scan_prepare {} {}
|
||||
proc ::scan::hmm_scan_prepare {sobj uobj} {
|
||||
variable scan_pt_start_time
|
||||
variable save_filetype
|
||||
variable hmm_filetype
|
||||
variable check_instrument_ready
|
||||
variable force_scan
|
||||
|
||||
if {[::plc::inst_ready] != 1} {
|
||||
if {$force_scan || $check_instrument_ready && [::plc::inst_ready]} {
|
||||
set force_scan false
|
||||
if [catch {
|
||||
::scan::check_scanvar $sobj $uobj
|
||||
::scan::pre_hmm_scan_prepare
|
||||
}] {
|
||||
abortbatch
|
||||
return -code error "HMSCAN ABORTED: $::errorInfo"
|
||||
}
|
||||
|
||||
if [catch {
|
||||
set numpoints [SplitReply [$sobj np]]
|
||||
set vlist [split [$sobj getvarpar 0] = ]
|
||||
set scanstart [lindex $vlist 1]
|
||||
set scanstep [lindex $vlist 2]
|
||||
::scan::hdb_hmscan -set NP $numpoints
|
||||
::scan::hdb_hmscan -set scan_variable [string trim [lindex [split [lindex $vlist 0] . ] 1]]
|
||||
::scan::hdb_hmscan -set scan_start $scanstart
|
||||
::scan::hdb_hmscan -set scan_increment $scanstep
|
||||
|
||||
set scan_pt_start_time [sicstime]
|
||||
|
||||
::scan::hdb_hmscan -set feedback status BUSY
|
||||
|
||||
::nexus::newfile $hmm_filetype $save_filetype
|
||||
data axis 1 [::scan::hdb_hmscan -set scan_variable]
|
||||
|
||||
clientput "Scan start: $scanstart, Scan step: $scanstep, Number of points: $numpoints"
|
||||
clientput "Filetype: $hmm_filetype"
|
||||
# Prime DAE
|
||||
hmm pause
|
||||
}] {
|
||||
return -code error $::errorInfo
|
||||
}
|
||||
} else {
|
||||
return -code error "HMSCAN ABORTED: Instrument not ready"
|
||||
}
|
||||
if [catch {
|
||||
::scan::check_scanvar $sobj $uobj
|
||||
::scan::pre_hmm_scan_prepare
|
||||
}] {
|
||||
abortbatch
|
||||
return -code error "HMSCAN ABORTED: $::errorInfo"
|
||||
}
|
||||
|
||||
if [catch {
|
||||
set numpoints [SplitReply [$sobj np]]
|
||||
set vlist [split [$sobj getvarpar 0] = ]
|
||||
set scanstart [lindex $vlist 1]
|
||||
set scanstep [lindex $vlist 2]
|
||||
::scan::hdb_hmscan -set NP $numpoints
|
||||
::scan::hdb_hmscan -set scan_variable [string trim [lindex [split [lindex $vlist 0] . ] 1]]
|
||||
::scan::hdb_hmscan -set scan_start $scanstart
|
||||
::scan::hdb_hmscan -set scan_increment $scanstep
|
||||
|
||||
set scan_pt_start_time [sicstime]
|
||||
|
||||
::scan::hdb_hmscan -set feedback status BUSY
|
||||
|
||||
::nexus::newfile HISTOGRAM_XYT $save_filetype
|
||||
data axis 1 [::scan::hdb_hmscan -set scan_variable]
|
||||
|
||||
clientput "Scan start: $scanstart, Scan step: $scanstep, Number of points: $numpoints"
|
||||
clientput "Filetype: HISTOGRAM_XYT"
|
||||
# Prime DAE
|
||||
hmm pause
|
||||
}] {
|
||||
return -code error $::errorInfo
|
||||
}
|
||||
}
|
||||
|
||||
proc ::scan::hmm_count {sobj uobj point mode preset} {
|
||||
@@ -257,32 +330,31 @@ Publish ::scan::bm_scan_finish user
|
||||
Publish ::scan::bm_writepoint user
|
||||
Publish ::scan::bm_count user
|
||||
|
||||
bmonscan configure script
|
||||
bmonscan function writeheader ::scan::donothing
|
||||
bmonscan function writepoint ::scan::bm_writepoint
|
||||
bmonscan function count ::scan::bm_count
|
||||
#bmonscan function collect ::scan::scan_collect
|
||||
bmonscan function prepare ::scan::bm_scan_prepare
|
||||
bmonscan function finish ::scan::bm_scan_finish
|
||||
|
||||
|
||||
hmscan configure script
|
||||
#hmscan function prepare hdbprepare
|
||||
#hmscan function collect hdbcollect
|
||||
hmscan function writeheader ::scan::donothing
|
||||
hmscan function writepoint ::scan::hmm_writepoint
|
||||
hmscan function count ::scan::hmm_count
|
||||
#hmscan function collect ::scan::scan_collect
|
||||
hmscan function prepare ::scan::hmm_scan_prepare
|
||||
hmscan function finish ::scan::hmm_scan_finish
|
||||
|
||||
namespace eval scan {
|
||||
namespace export runscan
|
||||
VarMake ::scan::runscan_reset_position Text internal
|
||||
::scan::runscan_reset_position false
|
||||
proc runscan {scanvar start stop numpoints mode preset {savetype "save"} } {
|
||||
#TODO Add counter (monitor_1 monitor_2 ... histmem) and filetype BEAM_MONITOR HISTMEM_?
|
||||
##
|
||||
# @brief Run a histogram memory scan
|
||||
# @param filetype one of the histogram filetypes (default=HISTOGRAM_XYT)
|
||||
# @param savetype save/nosave (default=save)
|
||||
# @param force true/false (default=false)
|
||||
|
||||
proc runscan {scanvar start stop numpoints mode preset args} {
|
||||
variable hmm_filetype
|
||||
variable save_filetype
|
||||
variable reset_position
|
||||
variable force_scan
|
||||
|
||||
set force_scan false
|
||||
|
||||
set hm_ft_names [array names ::nexus::histmem_filetype_spec]
|
||||
|
||||
# Default filetype for histogram memory scans
|
||||
set hmm_filetype "HISTOGRAM_XYT"
|
||||
# Default save uniquely numbered files
|
||||
set savetype "save"
|
||||
set reset_position [SplitReply [::scan::runscan_reset_position]]
|
||||
if {[is_drivable $scanvar] == 0} {
|
||||
return -code error "The scan variable <$scanvar> must be drivable"
|
||||
@@ -306,15 +378,38 @@ namespace eval scan {
|
||||
set numpoints 1
|
||||
}
|
||||
|
||||
switch $savetype {
|
||||
"save" {
|
||||
set save_filetype data
|
||||
}
|
||||
"nosave" {
|
||||
set save_filetype scratch
|
||||
}
|
||||
default {
|
||||
return -code error "$savetype should be 'save' or 'nosave'"
|
||||
foreach {arg val} $args {
|
||||
switch $arg {
|
||||
"force" {
|
||||
if [string is boolean $val] {
|
||||
set force_scan $val
|
||||
} else {
|
||||
error "ERROR: force must be true or false"
|
||||
}
|
||||
}
|
||||
"filetype" {
|
||||
if {[lsearch $hm_ft_names $val] == -1} {
|
||||
error "ERROR: filetype should be one of $hm_ft_names"
|
||||
} else {
|
||||
set hmm_filetype $val
|
||||
}
|
||||
}
|
||||
"savetype" {
|
||||
switch $val {
|
||||
"save" {
|
||||
set save_filetype data
|
||||
}
|
||||
"nosave" {
|
||||
set save_filetype scratch
|
||||
}
|
||||
default {
|
||||
return -code error "ERROR: $arg $val, valid values for $arg are 'save' or 'nosave'"
|
||||
}
|
||||
}
|
||||
}
|
||||
default {
|
||||
error "ERROR: $arg should be 'filetype' 'savetype' or 'force'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +417,7 @@ namespace eval scan {
|
||||
hmscan add $scanvar $start $step
|
||||
# hmscan ignores mode and preset, we use FAT_COUNT_METHOD and FAT_COUNT_STOP
|
||||
set status [catch {hmscan run $numpoints timer 0} msg]
|
||||
set force_scan false
|
||||
|
||||
if {$status == 0} {
|
||||
return $msg
|
||||
|
||||
Reference in New Issue
Block a user