XPS-Q8
Tcl Manual
7.5
External gathering
7.5.1
Configuration
Group type Number
Group name
Positioner name
Single axis
1
SINGLE_AXIS
SINGLE_AXIS.MY_STAGE
7.5.2
Description
This example opens a TCP connection, kills the single axis group, then initializes and
homes the group. The program then configures the parameters for the external gathering
(data to be collected: ExternalLatchPosition and GPIO2.ADC1 value). It defines an
action (ExternalGatheringRun) to an event (Immediate). Each time the trigger in
receives a signal, the data is gathered (with a divisor equal to 1, gathering takes place
every signal on the trigger input). Every second, the current number of gathered data
points is displayed. At the end, the external gathering is stopped and saved in a text file
(
ExternalGathering.dat
in Admin/Public directory of the controller). Finally, the
program ends by closing the socket.
Please see
Section 6
,
Proposed function for error handling.
7.5.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 "SINGLE_AXIS"
set
Positioner "SINGLE_AXIS.MY_STAGE"
set
Type1 "SINGLE_AXIS.MY_STAGE.ExternalLatchPosition"
set
Type2 "GPIO2.ADC1"
set
Event "Immediate"
set
Action "ExternalGatheringRun"
set
NbPoints
20
set
Div 1
set
Current
0
set
code
0
# Open TCP socket
set
code [
catch
"
OpenConnection
$TimeOut socketID"]
if
{$code !=
0
} {
puts
$telnetOut "OpenConnection failed => $code"
# Force transfer to channel’s output buffer
flush
$telnetOut
}
else
{
# Kill group
set
code [
catch
"
GroupKill
$socketID $Group"]
if
{$code !=
0
} {
EDH0307En1041 — 10/17
34