Allow list expressions like MG _TDA,_TPA
Allow decimal numbers in expressions use double to ensure floating point in expressions. r1666 | ffr | 2007-03-16 17:20:33 +1100 (Fri, 16 Mar 2007) | 3 lines
This commit is contained in:
committed by
Douglas Clowes
parent
d1d5afc4df
commit
a121eaa0cf
@@ -1,5 +1,5 @@
|
|||||||
# $Revision: 1.2 $
|
# $Revision: 1.3 $
|
||||||
# $Date: 2006-10-15 23:37:29 $
|
# $Date: 2007-03-16 06:20:33 $
|
||||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||||
# Last revision by: $Author: ffr $
|
# Last revision by: $Author: ffr $
|
||||||
|
|
||||||
@@ -12,10 +12,17 @@
|
|||||||
# then evaluates the expression.
|
# then evaluates the expression.
|
||||||
proc evaluate {args} {
|
proc evaluate {args} {
|
||||||
regsub -all {_T[DP][ABCDEFGH]} $args {[eval [parse &]]} expression;
|
regsub -all {_T[DP][ABCDEFGH]} $args {[eval [parse &]]} expression;
|
||||||
regsub -all {\d+} $expression {&.0} expression;
|
regsub -all {\d+(?:\.\d*)?} $expression { double(&) } expression;
|
||||||
return [uplevel #0 expr $expression];
|
return [uplevel #0 expr $expression];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Evaluates a comma separated list of commands and
|
||||||
|
# returns a space separated list of values.
|
||||||
|
proc evalArgList {args} {
|
||||||
|
foreach cmd [split $args ,] {lappend values [eval [parse $cmd]]}
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
proc dmset {cmd axis args} {
|
proc dmset {cmd axis args} {
|
||||||
set num [scan $args {%d} val];
|
set num [scan $args {%d} val];
|
||||||
if {$num == 1} {
|
if {$num == 1} {
|
||||||
@@ -73,7 +80,7 @@ proc BG {_axis} {
|
|||||||
proc MG {msg} {
|
proc MG {msg} {
|
||||||
# If msg starts with _ then return val for axis
|
# If msg starts with _ then return val for axis
|
||||||
if {[string index $msg 0] == "_"} {
|
if {[string index $msg 0] == "_"} {
|
||||||
return [eval [parse $msg]];
|
return [evalArgList $msg];
|
||||||
} else {
|
} else {
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
@@ -89,10 +96,10 @@ proc every {ms body} {
|
|||||||
|
|
||||||
proc nextstep {paxis step target} {
|
proc nextstep {paxis step target} {
|
||||||
upvar #0 $paxis axis;
|
upvar #0 $paxis axis;
|
||||||
set mult [expr $axis(cntsperx).0/$axis(stepsperx)];
|
set mult [expr double($axis(cntsperx))/$axis(stepsperx)];
|
||||||
set axis(TP) [expr $step * $mult + $axis(TP)];
|
set axis(TP) [expr $step * $mult + $axis(TP)];
|
||||||
set axis(TD) [expr $axis(TD) + $step];
|
set axis(TD) [expr $axis(TD) + $step];
|
||||||
if {[expr abs($axis(TD) - $target.0)] < 0.5} {
|
if {[expr abs($axis(TD) - double($target))] < 0.5} {
|
||||||
set axis(TS) 44; # Stopped, limit switches open
|
set axis(TS) 44; # Stopped, limit switches open
|
||||||
return 0;
|
return 0;
|
||||||
} elseif {[expr abs($target - $axis(TD)) < abs($step)]} {
|
} elseif {[expr abs($target - $axis(TD)) < abs($step)]} {
|
||||||
|
|||||||
Reference in New Issue
Block a user