Files
sics/site_ansto/instrument/TEST_SICS/fakeDMC/mkSimAxes.tcl
Ferdi Franceschini 14a244d014 Use new dir structure.
r1515 | ffr | 2007-02-20 08:03:21 +1100 (Tue, 20 Feb 2007) | 2 lines
2012-11-15 13:00:19 +11:00

94 lines
2.1 KiB
Tcl
Executable File

#!/usr/bin/tclsh
# $Revision: 1.4 $
# $Date: 2007-02-19 20:58:19 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $
# Creates fake DMC configuration files based on the instrument
# configuration file.
# Use this to create an array of named parameters to initialise motors.
proc params {args} {
upvar 1 "" x;
if [info exists x] {unset x}
foreach {k v} $args {set x([string tolower $k]) $v}
}
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 config/motors/motor_configuration.tcl;
}