127 lines
4.4 KiB
Tcl
127 lines
4.4 KiB
Tcl
#----------------------------------------------------------------------------
|
|
# center scan. A convenience scan for the one and only Daniel Clemens
|
|
# at TOPSI. Scans around a given ceter point. Requires the scan command
|
|
# for TOPSI to work.
|
|
#
|
|
# another convenience scan:
|
|
# sscan var1 start end var1 start end .... np preset
|
|
# scans var1, var2 from start to end with np steps and a preset of preset
|
|
#
|
|
# Mark Koennecke, August, 22, 1997
|
|
#-----------------------------------------------------------------------------
|
|
proc cscan { var center delta np preset } {
|
|
#------ start with some argument checking
|
|
set t [SICSType $var]
|
|
if { [string compare $t DRIV] != 0 } {
|
|
ClientPut [format "ERROR: %s is NOT drivable!" $var]
|
|
return
|
|
}
|
|
set t [SICSType $center]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: %s is no number!" $center]
|
|
return
|
|
}
|
|
set t [SICSType $delta]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: %s is no number!" $delta]
|
|
return
|
|
}
|
|
set t [SICSType $np]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: %s is no number!" $np]
|
|
return
|
|
}
|
|
set t [SICSType $preset]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: %s is no number!" $preset]
|
|
return
|
|
}
|
|
#-------- store command in lastscancommand
|
|
set txt [format "cscan %s %s %s %s %s" $var $center \
|
|
$delta $np $preset]
|
|
catch {lastscancommand $txt}
|
|
#-------- set standard parameters
|
|
scan clear
|
|
scan preset $preset
|
|
scan np [expr $np*2 + 1]
|
|
#--------- calculate start
|
|
set start [expr $center - $np * $delta]
|
|
set ret [catch {scan var $var $start $delta} msg]
|
|
if { $ret != 0} {
|
|
ClientPut $msg
|
|
return
|
|
}
|
|
#---------- start scan
|
|
set ret [catch {scan run} msg]
|
|
if {$ret != 0} {
|
|
error $msg
|
|
}
|
|
}
|
|
#---------------------------------------------------------------------------
|
|
proc sscan args {
|
|
scan clear
|
|
#------- check arguments: the last two must be preset and np!
|
|
set l [llength $args]
|
|
if { $l < 5} {
|
|
ClientPut "ERROR: Insufficient number of arguments to sscan"
|
|
return
|
|
}
|
|
set preset [lindex $args [expr $l - 1]]
|
|
set np [lindex $args [expr $l - 2]]
|
|
set t [SICSType $preset]
|
|
ClientPut $t
|
|
ClientPut [string first $t "NUM"]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: expected number for preset, got %s" \
|
|
$preset]
|
|
return
|
|
}
|
|
set t [SICSType $np]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: expected number for np, got %s" \
|
|
$np]
|
|
return
|
|
}
|
|
scan preset $preset
|
|
scan np $np
|
|
#--------- do variables
|
|
set nvar [expr ($l - 2) / 3]
|
|
for { set i 0 } { $i < $nvar} { incr i } {
|
|
set var [lindex $args [expr $i * 3]]
|
|
set t [SICSType $var]
|
|
if {[string compare $t DRIV] != 0} {
|
|
ClientPut [format "ERROR: %s is not drivable" $var]
|
|
return
|
|
}
|
|
set start [lindex $args [expr ($i * 3) + 1]]
|
|
set t [SICSType $start]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: expected number for start, got %s" \
|
|
$start]
|
|
return
|
|
}
|
|
set end [lindex $args [expr ($i * 3) + 2]]
|
|
set t [SICSType $end]
|
|
if { [string compare $t NUM] != 0 } {
|
|
ClientPut [format "ERROR: expected number for end, got %s" \
|
|
$end]
|
|
return
|
|
}
|
|
#--------- do scan parameters
|
|
set step [expr double($end - $start)/double($np)]
|
|
set ret [catch {scan var $var $start $step} msg]
|
|
if { $ret != 0} {
|
|
ClientPut $msg
|
|
return
|
|
}
|
|
}
|
|
#------------- set lastcommand text
|
|
set txt [format "sscan %s" [join $args]]
|
|
catch {lastscancommand $txt}
|
|
#------------- start scan
|
|
set ret [catch {scan run} msg]
|
|
if {$ret != 0} {
|
|
error $msg
|
|
}
|
|
}
|