Files
sics/site_ansto/instrument/hipd/config/commands/commands.tcl
2015-02-19 11:51:51 +11:00

230 lines
4.5 KiB
Tcl

source $cfPath(commands)/commands_common.tcl
namespace eval motor {
# is_homing_list = comma separated list of motors which are safe to send "home"
variable is_homing_list ""
}
namespace eval ajscmds {
namespace export SetRadColl SimpleRun SimpleScan RadCollRun RadCollTimed RadCollScan RadCollBiScan
# SetRadColl
command SetRadColl {
float time
float range
} {
catch {
#ffr Changed 0.5 to 0.2 on 30/06/2014 because
# oct hits upper limit switch at about 1.27 degrees
# with new "oct oscillate" command.
#dcl Removed 0.2 because old osc limits it to +/-1.0
oct oscillate_low [expr -abs($range/2.0)]
oct oscillate_high [expr abs($range/2.0)]
set spd [expr 2.0*$range / $time]
oct maxretry 5
oct accel 0.25
oct speed 0.25
oct decel 0.25
drive oct [expr abs($range/2.0)]
oct speed $spd
oct accel [expr $spd*5]
oct decel [expr $spd*5]
oct maxretry 0
} msg
clientput $msg
}
# SimpleRun
command SimpleRun {
float=0:inf steptime
int=1:inf numsteps
} {
histmem mode time
histmem preset $steptime
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
hmm countblock
save $i
}
}
# SimpleScan
command SimpleScan {
text=drivable motor
float start
float step
int=1:inf numsteps
float=0:inf steptime
} {
histmem mode time
histmem preset $steptime
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
drive $motor [expr $i*$step+$start]
hmm countblock
save $i
}
}
# RadCollRun
command RadCollRun {
int=1:inf oscno
int=1:inf reps
} {
histmem mode unlimited
newfile HISTOGRAM_XY
for {set i 0} {$i < $reps} {incr i} {
oct oscillate_count $oscno
oct oscillate start
hmm countblock
save $i
}
}
# RadCollTimed
command RadCollTimed {
int=1:inf oscno
float=0:inf time
} {
RadCollOn $oscno
set tim1 [clock seconds]
histmem mode unlimited
newfile HISTOGRAM_XY
set bool 0
set i 0
set timsecs [expr $time*60]
while {$bool == 0} {
oct oscillate_count $oscno
oct oscillate start
histmem start block
save $i
incr i
set tim2 [expr [clock seconds] - $tim1]
if {$tim2 > $timsecs} {set bool 1}
}
}
# RadCollScan
command RadCollScan {
text=drivable motor
float start
float step
int=1:inf numsteps
int=1:inf oscno
} {
histmem mode unlimited
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
drive $motor [expr $i*$step+$start]
oct oscillate_count $oscno
oct oscillate start
hmm countblock
save $i
}
}
}
namespace import ::ajscmds::*
publish SetRadColl user
publish SimpleRun user
publish SimpleScan user
publish RadCollRun user
publish RadCollTimed user
publish RadCollScan user
proc ::commands::isc_initialize {} {
::commands::ic_initialize
}
# RadCollScanRange
proc RadCollScanRange {motor start step fin oscno} {
if {$step==0} {break}
if {($start > $fin) && ($step > 0)} {break}
if {($start < $fin) && ($step < 0)} {break}
set i_bool 0
histmem mode unlimited
set currentmot $start
set i 0
newfile HISTOGRAM_XY
while {$i_bool==0} {
drive $motor $currentmot
$motor send SH`
oct oscillate_count $oscno
oct oscillate start
hmm countblock
set currentmot [expr {$currentmot + $step}]
if {($step > 0) && ($currentmot > $fin)} {set i_bool 1}
if {($step < 0) && ($currentmot < $fin)} {set i_bool 1}
if {($i_bool == 0)} {run $motor $currentmot}
save $i
incr i
}
}
publish RadCollScanRange user
#RadCollScanBi
proc RadCollScanBi {motor start step fin oscno motdir} {
set i_bool 0
set spx -12500
set spstep [expr {$spx * $step * $motdir}]
histmem stop
histmem mode unlimited
if {$motdir == 1} {
set currentmot $start
set i 0
} else {
set currentmot $fin
set i [expr {int(($fin-$start)/$step)}]
}
drive $motor $currentmot
newfile HISTOGRAM_XY
while {$i_bool==0} {
oct oscillate_count $oscno
oct oscillate start
hmm countblock
if {($motdir > 0)} {
set currentmot [expr {$currentmot + $step}]
if {$currentmot > $fin} {set i_bool 1}
} else {
set currentmot [expr {$currentmot - $step}]
if {$currentmot < $start} {set i_bool 1}
}
if {($i_bool == 0)} {run $motor $currentmot}
save $i
if {($motdir > 0)} {incr i 1} else {incr i -1}
# if {($i_bool == 0)} {
# $motor send SH`
# $motor send PR` $spstep
# $motor send BG`
#
# }
# save $i
}
}
publish RadCollScanBi user