XPS-Q8
Tcl Manual
DisplayErrorAndClose
$socketID $code "GroupMoveRelative"
$telnetOut
return
}
# Disable Backlash (if you want to do trajectory, jogging or
# tracking)
# CAUTION : to enable backlash, you must call “GroupKill” or
# “KillAll” to
come back in “not initialized” status
set
code [
catch
"
PositionerBacklashDisable
$socketID $Positioner"]
if
{$code !=
0
} {
DisplayErrorAndClose
$socketID $code
"PositionerBacklashDisable" $telnetOut
return
}
# Close TCP socket
puts
$telnetOut "End of program"
flush
$telnetOut
set
code [
catch
"
TCP_CloseSocket
$socketID"]
}
7.12
Timer Event and Global Variables
7.12.1
Configuration
Group type Number
Group name
Positioner name
Single axis
1
SINGLE_AXIS
SINGLE_AXIS.MY_STAGE
7.12.2
Description
The script
StartScript.tcl
opens a TCP connection, configures a timer and uses this timer
as an event. The action, in relation to this timer event, executes a second Tcl script
named
MyScript.tcl
. The
StartScript.tcl
script sets a global variable and closes the
socket.
The timer is a permanent event. The frequency of the timer is set by the divisor, in this
example 20000, which means that the second Tcl script gets executed every 20000
th
servo loop or every 2 seconds (divisor/servo loop rate = 20000/10000 = 2 seconds).
The script
MyScript.tcl
reads the global variable, increments it as long as the variable is
below 10. When the global variable is equal to 10, the second script deletes the timer
event and finally, 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.12.3
TCL Code
StartScript.tcl
# 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
}
EDH0307En1041 — 10/17
53