From a121eaa0cfba7f9fd5bd239fd6e69c51102990ec Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 16 Mar 2007 17:20:33 +1100 Subject: [PATCH] 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 --- .../instrument/TEST_SICS/fakeDMC/simAxis.tcl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/site_ansto/instrument/TEST_SICS/fakeDMC/simAxis.tcl b/site_ansto/instrument/TEST_SICS/fakeDMC/simAxis.tcl index 78cce225..b12d5fdd 100644 --- a/site_ansto/instrument/TEST_SICS/fakeDMC/simAxis.tcl +++ b/site_ansto/instrument/TEST_SICS/fakeDMC/simAxis.tcl @@ -1,5 +1,5 @@ -# $Revision: 1.2 $ -# $Date: 2006-10-15 23:37:29 $ +# $Revision: 1.3 $ +# $Date: 2007-03-16 06:20:33 $ # Author: Ferdi Franceschini (ffr@ansto.gov.au) # Last revision by: $Author: ffr $ @@ -12,10 +12,17 @@ # then evaluates the expression. proc evaluate {args} { 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]; } +# 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} { set num [scan $args {%d} val]; if {$num == 1} { @@ -73,7 +80,7 @@ proc BG {_axis} { proc MG {msg} { # If msg starts with _ then return val for axis if {[string index $msg 0] == "_"} { - return [eval [parse $msg]]; + return [evalArgList $msg]; } else { return $msg; } @@ -89,10 +96,10 @@ proc every {ms body} { proc nextstep {paxis step target} { 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(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 return 0; } elseif {[expr abs($target - $axis(TD)) < abs($step)]} {