hipd/config/commands/commands.tcl
Added some of the procedures in extraconfig.tcl as "commands"

motors/sct_jogmotor_common.tcl
Added stop command.  Send SH, JG and BG commands on one line when jogging motor.

fakeDMC
dmc2280Server.tcl
mkSimAxes.tcl
simAxis.tcl
Added jog command.

exebuf.c
Batch file executor now sends a BATCHEND event when there is an AbortBatch interrupt.
This means we can now execute cleanup comands when a batch file terminates.

r2764 | ffr | 2009-01-23 16:06:03 +1100 (Fri, 23 Jan 2009) | 17 lines
This commit is contained in:
Ferdi Franceschini
2009-01-23 16:06:03 +11:00
committed by Douglas Clowes
parent fb817f2aa8
commit b134c901c5
6 changed files with 251 additions and 63 deletions

View File

@@ -224,6 +224,7 @@ int exeBufProcess(pExeBuf self, SicsInterp *pSics,
DeleteDynString(command);
if(SCGetInterrupt(pCon) >= eAbortBatch){
SCWrite(pCon,"ERROR: batch processing interrupted",eError);
InvokeCallBack(pCall,BATCHEND,self->name);
SetStatus(eEager);
return 0;
} else {

View File

@@ -1,5 +1,5 @@
# $Revision: 1.3 $
# $Date: 2007-10-31 06:10:30 $
# $Revision: 1.4 $
# $Date: 2009-01-23 05:06:03 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $
@@ -25,34 +25,36 @@ proc readLine {who channel} {
} else {
puts "RECEIVED: $line"
switch -glob $line {
foreach cmd [split $line ";"] {
switch -glob $cmd {
"" {puts -nonewline $channel ":"}
"kill" {exit}
"SH*" - "BG*" - "PA*" - "DP*" - "AT*" - "MO*" - "ST*" - "SP*" - "AC*" - "DC*" {
eval [parse $line]
"SH*" - "BG*" - "PA*" - "PR*" - "JG*" - "DP*" - "AT*" - "MO*" - "ST*" - "SP*" - "AC*" - "DC*" {
eval [parse $cmd]
puts -nonewline $channel ":"
}
"TP*" - "TD*" - "TI*" - "XQ*" {
set output [eval [parse $line]]
set output [eval [parse $cmd]]
puts $channel " $output"; puts -nonewline $channel ":"
}
"LV" {
set output [eval [parse $line]]
set output [eval [parse $cmd]]
puts $channel "$output"; puts -nonewline $channel ":"
}
"TS*" {
set output [eval [parse $line]]
set output [eval [parse $cmd]]
puts $channel " $output"; puts -nonewline $channel ":"
}
"TC 1" {
puts $channel " DMC2280 ERROR"; puts -nonewline $channel ":"
}
"MG *" {
set output [eval [parse $line]]
set output [eval [parse $cmd]]
puts $channel " $output"; puts -nonewline $channel ":"
}
}
flush $channel;
}
set didRead 1
}
return;

View File

@@ -1,9 +1,9 @@
#!/usr/bin/tclsh
# $Revision: 1.8 $
# $Date: 2008-05-12 01:08:15 $
# $Revision: 1.9 $
# $Date: 2009-01-23 05:06:03 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: dcl $
# Last revision by: $Author: ffr $
# Creates fake DMC configuration files based on the instrument
# configuration file.
@@ -63,14 +63,17 @@ proc mkSimAxes {instrument} {
set speed [expr $motor(stepsperx) * $motor(maxspeed)]
set acc [expr $motor(stepsperx) * $motor(maxaccel)]
set dec [expr $motor(stepsperx) * $motor(maxdecel)]
set lolim $motor(hardlowerlim)
set uplim $motor(hardupperlim)
if [ info exists motor(absenc) ] {
set enPos $motor(absenchome);
set enCnts $motor(cntsperx);
} else {
set enPos 0;
set enCnts 0;
set enCnts $motor(stepsperx);
}
puts $simFile($IPtoContName($motor(asyncqueue)-$instrument)) "array set $nm \[\list SC 1 TD 0 TP $enPos BG 0 ST 0 SP $speed AC $acc DC $dec cntsperx $enCnts stepsperx $motor(stepsperx) PA 0 TS 44 \]";
# MVTYPE = PA (move to target),PR (relative move), JG (move until limswitch or stop cmd)
puts $simFile($IPtoContName($motor(asyncqueue)-$instrument)) "array set $nm \[\list SC 1 TD 0 TP $enPos BG 0 ST 0 SP $speed AC $acc DC $dec cntsperx $enCnts stepsperx $motor(stepsperx) PA 0 TS 44 MVTYPE unknown LOLIM $lolim UPLIM $uplim ABSHOME $enPos ATLIM false\]";
# eval "lappend $IPtoContName($motor(host))_motors $m";
}

View File

@@ -1,8 +1,14 @@
# $Revision: 1.8 $
# $Date: 2008-05-30 00:26:54 $
# $Revision: 1.9 $
# $Date: 2009-01-23 05:06:03 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $
proc sleep {mstime} {
set x 0
after $mstime {set x 1}
vwait x
}
# Requires a configuration array for each axis that you want to simulate.
# eg
#array set B [list AC 25000 TP 7827107 TD 25000 PA 25000 stepsperx 25000 cntsperx 8192 DC 25000 SP 25000]
@@ -30,12 +36,25 @@ proc dmset {cmd axis args} {
} else {
set val [evaluate $args]
}
if {[string first $cmd "PA SP AC DC"] != -1} {
set inst [string range $cmd 0 1]
switch $inst {
"PA" - "PR" {
uplevel #0 set ${axis}(MVTYPE) $inst
uplevel #0 set ${axis}($cmd) $val;
} else {
}
"JG" {
uplevel #0 set ${axis}(MVTYPE) $inst
uplevel #0 set ${axis}($cmd) $val;
# uplevel #0 set ${axis}(SP) $val;
}
"SP" - "AC" - "DC" {
uplevel #0 set ${axis}($cmd) $val;
}
default {
uplevel #0 $cmd $axis $val;
}
}
}
proc dmget {cmd axis} {
uplevel #0 set ${axis}($cmd)
@@ -51,8 +70,12 @@ proc DP {axis val} {
proc TS {axis} {
uplevel #0 eval set ${axis}(TS)
}
proc ST {axis} {
uplevel #0 eval set ${axis}(ST) 1
proc ST {_axis} {
upvar #0 $_axis axis;
set axis(ST) 1
while {$axis(BG) == 1} {
sleep 1000
}
}
proc SH {args} {}
@@ -67,6 +90,9 @@ proc BG {_axis} {
set axis(BG) 1; # motor is moving
set axis(SC) 0; # motor is running
set timeStep 0.1; # seconds
set axis(ST) 0
switch $axis(MVTYPE) {
"PA" {
set target $axis(PA);
set diff [expr $target - $axis(TD)];
set sign [expr ($axis(PA) - $axis(TD)) < 0 ? -1 : 1];
@@ -75,7 +101,13 @@ proc BG {_axis} {
set step $diff;
set timeStep [expr abs($step / $axis(SP))];
}
every [expr round($timeStep * 1000)] "nextstep $_axis $step $target"
every [expr round($timeStep * 1000)] "nextstep $_axis $step target $_axis $target $step"
}
"JG" {
set step [expr $timeStep * $axis(JG) ];
every [expr round($timeStep * 1000)] "nextstep $_axis $step jogit"
}
}
# set diff [expr $target - $axis(TD)];
# set mult [expr $axis(cntsperx).0/$axis(stepsperx)];
@@ -107,29 +139,66 @@ proc every {ms body} {
return;
}
proc nextstep {paxis step target} {
proc nextstep {paxis step args} {
upvar #0 $paxis axis;
set finished false
if {($axis(ATLIM) == "upper") && ($step > 0)} {
return 0
} elseif {($axis(ATLIM) == "lower") && ($step < 0)} {
return 0
}
set mult [expr double($axis(cntsperx))/$axis(stepsperx)];
set axis(TP) [expr int($step * $mult + $axis(TP))];
set TD_POS [expr int($axis(TD) + $step)];
set axis(TD) [expr int($TD_POS)];
set currPos [expr ($axis(TP) - $axis(ABSHOME))/abs(double($axis(cntsperx)))]
if {$axis(ST) == 1} {
set axis(TS) 44; # Stopped, limit switches open
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 4; # motor stopped by stop command (ST)
return 0;
} elseif {[expr abs($target - $axis(TD)) < abs($step)]} {
set diff [expr $target - $axis(TD)];
set axis(TP) [expr int(round($diff*$mult + $axis(TP)))];
set axis(TD) [expr int($target)];
set axis(ATLIM) false
set finished true
} elseif {$currPos >= $axis(UPLIM)} {
set axis(TS) 36; # Stopped on forward limit switch
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 2; # motor stopped by limit switch
set axis(ATLIM) upper
set finished true
} elseif {$currPos <= $axis(LOLIM)} {
set axis(TS) 40; # Stopped on reverse limit switch
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 3; # motor stopped by limit switch
set axis(ATLIM) lower
set finished true
} elseif {[eval $args]} {
# Stop if condition specified in "args" is met
# set diff [expr $target - $axis(TD)];
# set axis(TP) [expr int(round($diff*$mult + $axis(TP)))];
# set axis(TD) [expr int($target)];
set axis(TS) 44; # Stopped, limit switches open
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 1; # motor stopped at commanded position
return 0;
set axis(ATLIM) false
set finished true
} else {
return 1;
set finished false
}
if {$finished} {
set axis(MVTYPE) "unknown"
return 0
} else {
return 1
}
}
proc target {paxis target step} {
upvar #0 $paxis axis;
return [expr abs($target - $axis(TD)) < abs($step)]
}
proc jogit {} {
return false
}

View File

@@ -58,16 +58,18 @@ namespace eval ::scobj::jogmotor {
set cmd DOWN
set dirn -1
}
"stop" {
$sct_controller send "ST${axis}"
return getACK
}
default {
set cmd UNKNOWN
}
}]
if {$cmd != "UNKNOWN"} {
set jogspeed [expr $dirn * [hval [hsibPath "speed"] ]]
$sct_controller send "JG${axis}=$jogspeed"
$sct_controller send "SH${axis}"
sct send "BG${axis}"
# set jogspeed [expr $dirn * [hval [hsibPath "speed"] ]]
set jogspeed [expr $dirn * [sct jogspeed]]
$sct_controller send "ST${axis};JG${axis}=$jogspeed;SH${axis};BG${axis}"
return getACK
} else {
return idle
@@ -125,7 +127,7 @@ proc updatestatus {} {
# middle n2 "inbetween"
# lower n3 "down"
#}
proc mk_sct_jogmotor {sct_controller axis jogmotor {initcmd_table {UP "up" DOWN "down"}}} {
proc mk_sct_jogmotor {sct_controller axis jogmotor jogspeed {initcmd_table {UP "up" DOWN "down"}}} {
variable cmd_table
foreach {cmd name} $initcmd_table {
set cmd_table($cmd) [string tolower $name]
@@ -145,6 +147,7 @@ proc updatestatus {} {
hfactory $jog_hpath/command plain user text
hsetprop $jog_hpath/command write ${ns}::jogCmd $sct_controller $axis
hsetprop $jog_hpath/command getACK ${ns}::getACK $sct_controller
hsetprop $jog_hpath/command jogspeed $jogspeed
hfactory $jog_hpath/status plain spy text
hsetprop $jog_hpath/status read ${ns}::status $axis

View File

@@ -5,6 +5,116 @@ namespace eval motor {
variable is_homing_list ""
}
namespace eval ajscmds {
# SetRadColl
command SetRadColl {
float time
float range
} {
set spd [expr 2.0*$range / $time]
oct softlowerlim [expr -abs($range/2.0) - 0.5]
oct softupperlim [expr abs($range/2.0) + 0.5]
oct maxretry 5
oct accel 0.25
oct speed 0.25
drive oct [expr abs($range/2.0)]
oct speed $spd
oct accel $spd
oct maxretry 0
}
# SimpleRun
command SimpleRun {
float=0:inf steptime
int=1:inf numsteps
} {
RadCollOff
histmem mode time
histmem preset $steptime
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
histmem start block
save $i
}
}
# SimpleScan
command SimpleScan {
text=drivable motor
float start
float step
int=1:inf numsteps
float=0:inf steptime
} {
RadCollOff
histmem mode time
histmem preset $steptime
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
drive $motor [expr $i*$step+$start]
histmem start block
save $i
}
}
# RadCollRun
command RadCollRun {
int=1:inf oscno
int=1:inf reps
} {
RadCollOn $oscno
histmem mode unlimited
newfile HISTOGRAM_XY
for {set i 0} {$i < $reps} {incr i} {
histmem start block
save $i
}
RadCollOff
}
# 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} {
histmem start block
save $i
incr i
set tim2 [expr [clock seconds] - $tim1]
if {$tim2 > $timsecs} {set bool 1}
}
RadCollOff
}
# RadCollScan
command RadCollScan {
text=drivable motor
float start
float step
int=1:inf numsteps
int=1:inf oscno
} {
RadCollOn $oscno
histmem mode unlimited
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
drive $motor [expr $i*$step+$start]
histmem start block
save $i
}
RadCollOff
}
}
proc ::commands::isc_initialize {} {
::commands::ic_initialize
}