7.10.2 Description
This example opens a TCP connection, kills the XY group, then initializes and homes
the group. It sets the parameters for the position analog tracking functionality
(positioner, analog input, offset, scale, velocity and acceleration) and enables the analog
tracking mode. The mode gets activated for 20 seconds. During this time, the stage
position follows the voltage of the analog input GPIO2.ADC1. Then, the analog
tracking mode gets disabled and the program ends by closing the socket.
Please see the sections:
4 Principle of a Tcl script redirection to a telnet session.
6 Proposed function for error handling.
7.10.3 TCL Code
# Set channel’s name to be used for telnet.
# In this example we assume it is passed to the script as the
# first argument, if not specified output to stdio.
# Open the channel for read mode and get its id,
# this is the id that will be passed to puts function.
if {$tcl_argv(0) != 0} {
set telnetOut [ open "/dev/$tcl_argv(0)" r+]
} else {
set telnetOut stdout
}
# Initialization
set TimeOut 60
set Group "XY"
set Positioner "XY.X"
set AnalogInput "GPIO2.ADC1"
set Offset 0
set Scale 1
set Velocity 20
set Acceleration 80
set TrackingType "Position"
set code 0
# Open TCP socket
set code [catch "OpenConnection $TimeOut socketID"]
if {$code != 0} {
puts stdout "OpenConnection failed => $code"
} else {
# Kill group
set code [catch "GroupKill $socketID $Group"]
if {$code != 0} {
DisplayErrorAndClose $socketID $code "GroupKill" $telnetOut
return
}
EDH0307En1041 — 10/17
49