Common SICS configuration and some utility functions
r1080 | ffr | 2006-08-25 12:44:09 +1000 (Fri, 25 Aug 2006) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
e1dc2842d0
commit
d10c726ccf
53
site_ansto/instrument/utility.tcl
Normal file
53
site_ansto/instrument/utility.tcl
Normal file
@@ -0,0 +1,53 @@
|
||||
# Some useful functions for SICS configuration.
|
||||
|
||||
# $Revision: 1.1 $
|
||||
# $Date: 2006-08-25 02:44:09 $
|
||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||
# Last revision by $Author: ffr $
|
||||
|
||||
# Utility fucntion for setting the home and upper and lower
|
||||
# limits for a motor
|
||||
proc setHomeandRange {args} {
|
||||
set usage "
|
||||
Usage: setHomeandRange -motor motName -home homeVal -lowrange low -uprange high
|
||||
eg
|
||||
setHomeandRange -motor mchi -home 90 -lowrange 5 -uprange 7
|
||||
this sets the home position to 90 degreess for motor mchi
|
||||
with the lower limit at 85 and the upper limit at 97
|
||||
"
|
||||
if {$args == ""} {clientput $usage; return}
|
||||
array set params $args
|
||||
set motor $params(-motor)
|
||||
set home $params(-home)
|
||||
set lowlim [expr $home - $params(-lowrange)]
|
||||
set uplim [expr $home + $params(-uprange)]
|
||||
|
||||
uplevel 1 "$motor home $home"
|
||||
uplevel 1 "$motor hardlowerlim $lowlim"
|
||||
uplevel 1 "$motor hardupperlim $uplim"
|
||||
uplevel 1 "$motor softlowerlim $lowlim"
|
||||
uplevel 1 "$motor softupperlim $uplim"
|
||||
}
|
||||
|
||||
# Use this to create an array of named parameters to initialise motors.
|
||||
proc params {args} {
|
||||
upvar 1 "" x;
|
||||
if [info exists x] {unset x}
|
||||
eval "array set x [list $args]"
|
||||
}
|
||||
|
||||
# Parse motor readings for virtual motor scripts.
|
||||
proc SplitReply { text } {
|
||||
set l [split $text =]
|
||||
return [lindex $l 1]
|
||||
}
|
||||
|
||||
# Sets motor position reading to pos by adjusting the softzero
|
||||
proc setpos {motor pos} {
|
||||
set currPos [SplitReply [$motor]]
|
||||
set oldZero [SplitReply [$motor softzero]]
|
||||
set newZero [expr $currPos - $pos + $oldZero]
|
||||
uplevel #0 "$motor softzero $newZero"
|
||||
}
|
||||
publish setpos user
|
||||
publish SplitReply user
|
||||
Reference in New Issue
Block a user