112 lines
2.9 KiB
Tcl
Executable File
112 lines
2.9 KiB
Tcl
Executable File
#!/usr/bin/tclsh
|
|
|
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
|
|
|
# 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
|
|
proc fileeval {args} {
|
|
if [catch {uplevel #0 source $args} errMsg] {
|
|
error $errMsg
|
|
}
|
|
}
|
|
# This implementation of the "Motor" command stores the
|
|
# configured motor parameters in an array named
|
|
# after the motor.
|
|
proc Motor {name type par} {
|
|
if {$type != "DMC2280"} {
|
|
return
|
|
}
|
|
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 {instrument} {
|
|
global IPtoContName motors ContList simConts;
|
|
puts [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)]
|
|
set lolim $motor(hardlowerlim)
|
|
set uplim $motor(hardupperlim)
|
|
if [ info exists motor(absenc) ] {
|
|
set enPos $motor(absenchome);
|
|
set enCnts $motor(cntsperx);
|
|
} else {
|
|
set enPos 0;
|
|
set enCnts $motor(stepsperx);
|
|
}
|
|
# MVTYPE = PA (move to target),PR (relative move), JG (move until limswitch or stop cmd)
|
|
puts $simFile($IPtoContName($motor(asyncqueue)-$instrument)) "array set $nm \[\list SC 1 TD 0 TP $enPos BG 0 ST 0 SP $speed AC $acc DC $dec cntsperx $enCnts stepsperx $motor(stepsperx) PA 0 TS 44 MVTYPE unknown LOLIM $lolim UPLIM $uplim ABSHOME $enPos ATLIM false\]";
|
|
|
|
# eval "lappend $IPtoContName($motor(host))_motors $m";
|
|
}
|
|
|
|
foreach c $ContList {
|
|
close $simFile($c);
|
|
}
|
|
}
|
|
|
|
proc main {instrument sicspath args} {
|
|
set currDir [pwd]
|
|
cd $sicspath;
|
|
loadConfig $args;
|
|
cd $currDir;
|
|
mkSimAxes $instrument;
|
|
}
|
|
|
|
if {$tcl_interactive==0} {
|
|
puts "arguments($argc) = $argv"
|
|
set cfPath(motors) "config/motors"
|
|
switch $argc {
|
|
1 { main $argv ../sics/server config/motors/motor_configuration.tcl }
|
|
2 { main [lindex $argv 0] [lindex $argv 1] config/motors/motor_configuration.tcl }
|
|
default {
|
|
puts "Usage: ./mkSimAxes.tcl <instrument>"
|
|
puts "or : ./mkSimAxes.tcl <instrument> <sics server path>"
|
|
puts "eg : ./mkSimAxes.tcl platypus ../sics/newserver"
|
|
}
|
|
}
|
|
}
|
|
|