Check that the instrument is ready before starting a scan.
Added "runscan" command using syntax requested by Andy Nelson for platypus. r2205 | ffr | 2007-10-31 16:51:16 +1100 (Wed, 31 Oct 2007) | 3 lines
This commit is contained in:
committed by
Douglas Clowes
parent
f8c64b55a0
commit
c661cf16a7
@@ -80,7 +80,11 @@ 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
|
||||
variable save_filetype
|
||||
|
||||
if {[::plc::inst_ready] != 1} {
|
||||
return -code error "HMSCAN ABORTED: Instrument not ready"
|
||||
}
|
||||
if [catch {
|
||||
::scan::check_scanvar $sobj $uobj
|
||||
::scan::pre_hmm_scan_prepare
|
||||
@@ -88,21 +92,31 @@ proc ::scan::hmm_scan_prepare {sobj uobj} {
|
||||
abortbatch
|
||||
return -code error "HMSCAN ABORTED: $::errorInfo"
|
||||
}
|
||||
# Prime DAE
|
||||
hmm pause
|
||||
|
||||
::scan::hdb_hmscan -set NP [SplitReply [$sobj np]]
|
||||
set vlist [split [$sobj getvarpar 0] = ];
|
||||
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 [lindex $vlist 1];
|
||||
::scan::hdb_hmscan -set scan_increment [lindex $vlist 2];
|
||||
::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 data
|
||||
::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} {
|
||||
@@ -120,8 +134,7 @@ proc ::scan::hmm_scan_finish {sobj uobj} {
|
||||
variable save_filetype
|
||||
variable reset_position
|
||||
set $save_filetype "data"
|
||||
hmm pause
|
||||
hmm stop
|
||||
::histogram_memory::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
|
||||
@@ -190,6 +203,9 @@ proc ::scan::bm_scan_prepare {sobj uobj} {
|
||||
|
||||
variable scan_pt_start_time
|
||||
|
||||
if {[::plc::inst_ready] != 1} {
|
||||
return -code error "HMSCAN ABORTED: Instrument not ready"
|
||||
}
|
||||
if [catch {
|
||||
::scan::check_scanvar $sobj $uobj
|
||||
::scan::pre_hmm_scan_prepare
|
||||
@@ -201,12 +217,15 @@ proc ::scan::bm_scan_prepare {sobj uobj} {
|
||||
#TODO Parameterise varindex in some way
|
||||
set varindex 0;
|
||||
|
||||
set numpoints [SplitReply [$sobj np]]
|
||||
set vlist [split [$sobj getvarpar $varindex] = ]
|
||||
set scanstart [lindex $vlist 1]
|
||||
set scanstep [lindex $vlist 2]
|
||||
::scan::hdb_bmonscan -set feedback filename [SplitReply [dataFileName]]
|
||||
::scan::hdb_bmonscan -set NP [SplitReply [$sobj np]];
|
||||
set vlist [split [$sobj getvarpar $varindex] = ];
|
||||
::scan::hdb_bmonscan -set NP $numpoints
|
||||
::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];
|
||||
::scan::hdb_bmonscan -set scan_start $scanstart
|
||||
::scan::hdb_bmonscan -set scan_increment $scanstep
|
||||
set scanvar_pts [SplitReply [$sobj getvardata $varindex]]
|
||||
todo_msg "SET START TIME [sicstime]"
|
||||
|
||||
@@ -216,6 +235,8 @@ proc ::scan::bm_scan_prepare {sobj uobj} {
|
||||
::nexus::newfile BEAM_MONITOR data
|
||||
::nexus::data axis 1 [::scan::hdb_bmonscan -set scan_variable]
|
||||
#stdscan prepare $sobj $uobj;
|
||||
clientput "Scan start: $scanstart, Scan step: $scanstep, Number of points: $numpoints"
|
||||
clientput "Filetype: BEAM_MONITOR"
|
||||
}
|
||||
|
||||
|
||||
@@ -296,3 +317,58 @@ command hdb_hmscan { text:drivable scan_variable float: scan_start float: scan_i
|
||||
}
|
||||
sicslist setatt ::scan::hdb_bmonscan long_name bmonscan
|
||||
sicslist setatt ::scan::hdb_hmscan long_name hmscan
|
||||
namespace eval scan {
|
||||
namespace export runscan
|
||||
proc runscan {scanvar start stop numpoints mode preset {savetype "save"} } {
|
||||
variable save_filetype
|
||||
variable reset_position
|
||||
set reset_position "true"
|
||||
if {[is_drivable $scanvar] == 0} {
|
||||
return -code error "The scan variable <$scanvar> must be drivable"
|
||||
}
|
||||
if {[string is integer $numpoints] != 1} {
|
||||
return -code error "Number of points <$numpoints> must be an integer"
|
||||
}
|
||||
if { $numpoints < 1 } {
|
||||
return -code error "Number of points <$numpoints> must not be less than one"
|
||||
}
|
||||
::histogram_memory::count_method $mode
|
||||
::histogram_memory::count_size $preset
|
||||
|
||||
if {$numpoints == 1} {
|
||||
set step 0
|
||||
} else {
|
||||
set step [expr double($stop - $start)/($numpoints - 1.0)]
|
||||
}
|
||||
if {$step == 0 && $numpoints > 1} {
|
||||
clientput "WARNING:Scan step is zero and number of points > 1. Adjusting numpoints to one"
|
||||
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'"
|
||||
}
|
||||
}
|
||||
|
||||
hmscan clear
|
||||
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]
|
||||
|
||||
if {$status == 0} {
|
||||
return $msg
|
||||
} else {
|
||||
return -code error "ERROR [info level 0]\n$msg"
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace import ::scan::runscan
|
||||
publish runscan user
|
||||
sicslist setatt ::scan::runscan privilege internal
|
||||
|
||||
Reference in New Issue
Block a user