Proposed Function For Error Handling - Newport XPS-Q8 Manual

Universal high-performance motion controller/driver
Table of Contents

Advertisement

XPS-Q8
6.0

Proposed Function for Error Handling

EDH0307En1041 — 10/17
For convenient error debugging and safe program execution, the response (errors) of
each XPS command should be read and tested. To do this, a procedure to "display error
and close" can be used. This procedure is defined at the beginning of Tcl scripts. Users
simply have to call this procedure after each API. This allows for a significant reduction
of code when many APIs are used.
###########################################
#
Display error and close procedure
###########################################
proc
DisplayErrorAndClose {socketID code APIName telnetOut} {
# Set global variable
global
tcl_argv
# If error occurred other than Timeout error
if
{$code != -2} {
# Error => Get error description
set
code2 [catch "ErrorStringGet $socketID $code strError"]
# If error occurred with the API ErrorStringGet
if
{$code2 != 0} {
# Display API name, error code and
# ErrorStringGet error code
# in the telnet window when using APIs
# TCLScriptExecute or
# TCLScriptExecuteAndWait
puts
$telnetOut "$APIName ERROR => $code /
ErrorStringGet ERROR => $code2"
# Force transfer to channel's output buffer
flush
$telnetOut
# in the web terminal when using API
# TCLScriptExecuteAndWait
set
tcl_argv(0) "$APIName ERROR => $code"
else
}
{
# Display API name, number and description
# of the error
# in the telnet window when using APIs
#TCLScriptExecute or
# TCLScriptExecuteAndWait
puts
$telnetOut "$APIName ERROR => $code :
$strError
# Force transfer to channel's output
# buffer
flush
$telnetOut
# in the web terminal when using API
# TCLScriptExecuteAndWait
set
tcl_argv(0) "$APIName ERROR => $code : $strError"
}
else
}
{
# Display Timeout error
20
Tcl Manual
#

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents