Files
sics/site_ansto/instrument/TEST_SICS/fakeDMC/dmcParse.tcl
2014-05-16 17:23:58 +10:00

40 lines
1.2 KiB
Tcl

# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Parses a subset of DMC2280 commands and returns the corresponding command
# which is defined in dmc2280Server.tcl
# dmc2280 has two letter commands <CM> as follows
#parses CM exp, _CM<axis,num>, {TP,TD}<axis>, CM<axis>=exp, CM<axis>, CM
# axis=ABCDEFGH, num=01234567
proc parse {cmdst args} {
# CM exp, handles MG
if {[string length $args] > 0} {return "$cmdst $args"}
# _CM<axis,num>, {TP,TD}<axis> get an axis property or position
set num [scan $cmdst {_%2s%1[ABCDEFGH]} cmd an];
if {$num == 2} {return "dmget $cmd $an"}
set num [scan $cmdst {%2s%1[ABCDEFGH]} cmd axis];
if {$num == 2 && [string first $cmd "TD TP"] != -1} {
return "dmget $cmd $axis";
}
# CM<axis>=exp
# Try
# set line "DPB=(_TPB - 7818915)*(25000/8192) + 0"
# parse $line
set cmdlst [split $cmdst =];
if {[llength $cmdlst] == 2} {
set num [scan [lindex $cmdlst 0] {%2s%1[ABCDEFGH0-7]} cmd axis];
return "dmset $cmd $axis [lindex $cmdlst 1]";
}
# CM<par>
set num [scan $cmdst {%2s%1[ABCDEFGH0-7]} cmd par];
if {$num == 2} {return "dmcall $cmd $par"}
set num [scan $cmdst {_%2s%1[ABCDEFGH0-7]} cmd par];
if {$num == 2} {return "dmcall $cmd $par"}
return $cmdst;
}