86 lines
1.9 KiB
Tcl
Executable File
86 lines
1.9 KiB
Tcl
Executable File
#!/usr/bin/tclsh
|
|
|
|
# $Revision: 1.2 $
|
|
# $Date: 2006-10-15 23:38:34 $
|
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
|
# Last revision by: $Author: ffr $
|
|
|
|
# Creates fake DMC configuration files based on the instrument
|
|
# configuration file.
|
|
|
|
proc usage {} {
|
|
puts "mkSimAxes.tcl INSTNAME";
|
|
puts "INSTNAME is the instrument name (eg wombat, echidna)"
|
|
}
|
|
|
|
source loadConfig.tcl
|
|
|
|
# This implementation of the "Motor" command stores the
|
|
# configured motor parameters in an array named
|
|
# after the motor.
|
|
proc Motor {name type par} {
|
|
global motors;
|
|
upvar #0 $par arr
|
|
upvar #0 $name param_arr
|
|
upvar #0 ${name}_status status
|
|
array set param_arr [array get arr]
|
|
|
|
|
|
array set status [list position "" home "" upperLim "" lowerLim "" homeTest NOTDONE limitTest NOTDONE]
|
|
lappend motors $name
|
|
}
|
|
|
|
proc mkSimMotor {args} {
|
|
foreach m $args {
|
|
upvar #0 $m axis;
|
|
puts $axis(host);
|
|
}
|
|
}
|
|
|
|
proc mkSimAxes {} {
|
|
global IPtoContName motors ContList simConts;
|
|
array get IPtoContName;
|
|
puts $motors;
|
|
|
|
foreach c $ContList {
|
|
set simFile($c) [open ${c}_sim.tcl w];
|
|
}
|
|
|
|
foreach m $motors {
|
|
upvar #0 $m motor;
|
|
|
|
set nm $motor(axis);
|
|
set ${nm}Pos 0;
|
|
set ${nm}stepsperx 20125;
|
|
set speed [expr $motor(stepsperx) * $motor(maxspeed)]
|
|
set acc [expr $motor(stepsperx) * $motor(maxaccel)]
|
|
set dec [expr $motor(stepsperx) * $motor(maxdecel)]
|
|
if [ info exists motor(absenc) ] {
|
|
set enPos $motor(absenchome);
|
|
set enCnts $motor(cntsperx);
|
|
} else {
|
|
set enPos 0;
|
|
set enCnts 0;
|
|
}
|
|
puts $simFile($IPtoContName($motor(host))) "array set $nm \[\list TD 0 TP $enPos SP $speed AC $acc DC $dec cntsperx $enCnts stepsperx $motor(stepsperx) PA 0 TS 44 \]";
|
|
|
|
# eval "lappend $IPtoContName($motor(host))_motors $m";
|
|
}
|
|
|
|
foreach c $ContList {
|
|
close $simFile($c);
|
|
}
|
|
}
|
|
|
|
proc main {args} {
|
|
cd ../sics/server;
|
|
loadConfig $args;
|
|
cd ../../fakeDMC;
|
|
mkSimAxes;
|
|
}
|
|
|
|
if {$tcl_interactive==0} {
|
|
main ${argv}_configuration.tcl;
|
|
}
|
|
|