Wombat
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:
committed by
Douglas Clowes
parent
fb817f2aa8
commit
b134c901c5
@@ -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 {
|
||||
"" {puts -nonewline $channel ":"}
|
||||
"kill" {exit}
|
||||
"SH*" - "BG*" - "PA*" - "DP*" - "AT*" - "MO*" - "ST*" - "SP*" - "AC*" - "DC*" {
|
||||
eval [parse $line]
|
||||
puts -nonewline $channel ":"
|
||||
}
|
||||
"TP*" - "TD*" - "TI*" - "XQ*" {
|
||||
set output [eval [parse $line]]
|
||||
puts $channel " $output"; puts -nonewline $channel ":"
|
||||
}
|
||||
"LV" {
|
||||
set output [eval [parse $line]]
|
||||
puts $channel "$output"; puts -nonewline $channel ":"
|
||||
}
|
||||
"TS*" {
|
||||
set output [eval [parse $line]]
|
||||
puts $channel " $output"; puts -nonewline $channel ":"
|
||||
}
|
||||
"TC 1" {
|
||||
puts $channel " DMC2280 ERROR"; puts -nonewline $channel ":"
|
||||
}
|
||||
"MG *" {
|
||||
set output [eval [parse $line]]
|
||||
puts $channel " $output"; puts -nonewline $channel ":"
|
||||
foreach cmd [split $line ";"] {
|
||||
switch -glob $cmd {
|
||||
"" {puts -nonewline $channel ":"}
|
||||
"kill" {exit}
|
||||
"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 $cmd]]
|
||||
puts $channel " $output"; puts -nonewline $channel ":"
|
||||
}
|
||||
"LV" {
|
||||
set output [eval [parse $cmd]]
|
||||
puts $channel "$output"; puts -nonewline $channel ":"
|
||||
}
|
||||
"TS*" {
|
||||
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 $cmd]]
|
||||
puts $channel " $output"; puts -nonewline $channel ":"
|
||||
}
|
||||
}
|
||||
flush $channel;
|
||||
}
|
||||
flush $channel;
|
||||
set didRead 1
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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,10 +36,23 @@ proc dmset {cmd axis args} {
|
||||
} else {
|
||||
set val [evaluate $args]
|
||||
}
|
||||
if {[string first $cmd "PA SP AC DC"] != -1} {
|
||||
uplevel #0 set ${axis}($cmd) $val;
|
||||
} else {
|
||||
uplevel #0 $cmd $axis $val;
|
||||
set inst [string range $cmd 0 1]
|
||||
switch $inst {
|
||||
"PA" - "PR" {
|
||||
uplevel #0 set ${axis}(MVTYPE) $inst
|
||||
uplevel #0 set ${axis}($cmd) $val;
|
||||
}
|
||||
"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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,15 +90,24 @@ proc BG {_axis} {
|
||||
set axis(BG) 1; # motor is moving
|
||||
set axis(SC) 0; # motor is running
|
||||
set timeStep 0.1; # seconds
|
||||
set target $axis(PA);
|
||||
set diff [expr $target - $axis(TD)];
|
||||
set sign [expr ($axis(PA) - $axis(TD)) < 0 ? -1 : 1];
|
||||
set step [expr $sign * $timeStep * $axis(SP) ];
|
||||
if {[expr abs($diff) < abs($step)]} {
|
||||
set step $diff;
|
||||
set timeStep [expr abs($step / $axis(SP))];
|
||||
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];
|
||||
set step [expr $sign * $timeStep * $axis(SP) ];
|
||||
if {[expr abs($diff) < abs($step)]} {
|
||||
set step $diff;
|
||||
set timeStep [expr abs($step / $axis(SP))];
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
||||
every [expr round($timeStep * 1000)] "nextstep $_axis $step $target"
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user