CTIO TCS ROUTER (Rev. 1.0)
The following explains the idea behind the TCS Router software. On one hand you have the TCS router and on the other hand applications (Mosaic, Arcon, Hydra, etc.) wanting to send commands to the TCS. All of them are connected to the GWC router. When applications want to send a request to the TCS (i.e current focus, time, coordinates, etc.) they publish the request in a variable subscribed by the TCS router. The TCS router see the variable change and send its contents to the TCS. The result returned by the TCS to the TCS router is then published in another variable subscribed by the originators. To avoid race conditions every originator has to use a different variable.
The idea of this architecture to pass requests to TCS is a consequence of the lack of support for GWC libraries under the VxWorks environment in which the TCS program was written. Under those circumstances the TCS router was born as an auxiliary program to route TCS requests arriving through the GWC router. Soon it became obvious that the TCS router program could hold another macro style functionalities like controlling the Hydra comparison lamp system.
The TCS router software leaves in /ut22/newgui/tcsrouter. The structure of the directory tree is as follows:
The TCS router software consists of an extended TCL/TK interpreter plus a set of TCL/TK scripts that build the functionality required by the application. The extended TCL/TK interpreter leaves at sub directory "src". Support is provided for compiling the interpreter under Linux, SunOs and Solaris. The TCL/TK scripts leave at sub directory lib/tcsrgui.
A bare bones implementation of the TCS router under a TCL/TK environment would be as following:
TCS Router Part
---------------------------------------------
proc tcs_command_callback {var command type value} {
# Here goes the code to send the command to TCS
}
connect ctio_4m tcsrouter
ctio_4m newwvar tcs.main.etalon etalon string
set etalon(value) off
ctio_4m put tcs.main
ctio_4m comevent "tcs.main.command" tcs_command_callback
---------------------------------------------
The Hydra Part
---------------------------------------------
proc etalon_callback {var action type value} {
# Here goes the code to handle the status of the etalon variable
}
connect ctio_4m hydra
ctio_4m atevent "tcs.main.etalon" etalon_callback
ctio_4m newcvar tcs.main.command tcsCommand set string
set tcsCommand(action) set
---------------------------------------------
Both scripts will run eventually in different machines. The code for the TCS router opens a connection to the router, create a variable to publish the result of an operation (etalon) and binds a callback function to command stream. The code for Hydra on the other hand, opens a connection to the router, bind a callback function to the etalon variable and creates a new variable associated to the command stream.
The TCS router starts along with the TCP interface on ctiot2. Starting a TCP session runs a script called "start_tcsrouter" that actually launches the program. This start up shell script will search the home directory for file .tcsrrc to set the environment before running. If not found it will look for the default version of that file at /usr/local/tcsrouter/bin. Following is the file that actually leaves at /ut20/tcp4m.
---------------------------------------------------------------
#
#
# .tcsrrc
#
# Environment variables for the TCS Router program
#
#********* Check these out and set them as you wish ************
# Environment variable for the TCS_ROUTER home directory
setenv TCS_ROUTER_HOME /ut22/newgui/tcsrouter
# Home directory of the TCL/TK library
setenv TCL_LIBRARY $TCS_ROUTER_HOME/share/lib/tcl7.6
setenv TK_LIBRARY $TCS_ROUTER_HOME/share/lib/tk4.2
# The MPG_ROUTER variable designates the name of the host in which
# the router run. When not defined the the mpg router is supposed
# to be running in indus.tuc.noao.edu.
setenv MPG_ROUTER ctioa1
# The variable MPG_ROUTER_PORT designates the port in which the mpg
# router is listening for incoming connections. The default value
# for this variable is 1 plus the the wiyn router port (2345).
setenv MPG_ROUTER_PORT 2347
# Hostname for the RPC server (TCS).
setenv TCP_NAME ctiox0
# This tell the program where to find the binaries and configurations file.
setenv TCS_ROUTER_BIN $TCS_ROUTER_HOME/bin
# Make sure that guidebin is in the search path
set path = ( $TCS_ROUTER_BIN $path )
# Make sure we have the right man path
if ($?MANPATH) then
setenv MANPATH {$MANPATH}:$TCS_ROUTER_HOME/man
else
setenv MANPATH {/usr/man}:$TCS_ROUTER_HOME/man
endif
# Uncomment this line if running in SunOs environment
setenv LD_LIBRARY_PATH /usr/lib:/usr/local/X11R5/lib:/usr/openwin/lib
---------------------------------------------------------------
The graphic user interface of the TCS router program allows the user to check for resent requests to the TCS and their result as well as for the current status of the communication link to the TCS and to the GWC router.
The GUI also provides a means for sending commands to the TCS in a similar fashion as the TCP command mode does.
When the application starts it opens one connection to the TCS and one connection to the GWC router. Then subscribe to some GWC variables of interest and publish others of its own. Incoming request are logged into the logging panel along with a time stamp and a correlative number. Messages to the TCS are prefixed with the words "to TCS'. When an exception occurs the error message is put in the log with the word "ERROR" preceding the message.
The menu bar has three menus: Options, Windows and Help.
Use the options menu to activate/deactivate the alarm bell and to quit the application. When selected the alarm bell flag activate an audible tone to signal that the communication link to either the TCS or the GWC router is broken.
Use the windows menu to pop up a console window to send commands to the TCS. Right now the console supports only two commands: "complamp" and "local".
complamp [lamp] - turn the comparison lamps system on or off. Valid options for this command are "off", "tha", "etalon", "qua", "hene" and "pen".
local [command] - send string command to serial port C of the TCS, where all SMC devices are connected.
The logging area shows all the incoming requests to the TCS and the exceptions that have occurred during the session. All messages are prefixed with a time stamp and a correlative number. Use the scroll bar to move across the log messages.
The status bar presents the current status of the communication link to the GWC router and to the TCS. When either link is broken the correspondent label will go red and will start blinking signaling that the communication has been lost. After that the program will start a reconnection sequence trying to connect every ten seconds to either the GWC router or to the TCS.
To send command requests to the TCS router the program subscribes to some command variables and publish an associated variable to respond to each of those command variable.
The TCS router subscribes to the following GWC variables:
tcs.main.command - non specific owner command variable to send TCS requests
tcs.main.Hcommand - hydra command variable to send TCS requests
tcs.main.Icommand - icsInfo command variable to send TCS requests
tcs.main.clamp - command variable to move the comparison lamp system
To publish the results of the requests on the first three command variables, the TCS router creates the following write variables:
tcs.main.response - results to TCS request through tcs.main.command
tcs.main.Hresponse - results to TCS requests through tcs.main.Hcommand
tcs.main.Iresponse - results to TCS requests through tcs.main.Icommand
The tcs.main.clamp variable is used in a more GWC way and no variable is required to publish the request results. Instead a set of write variables are created to publish the status of the various parts of the comparison lamps system. The variables created are:
tcs.caliblamps.flat - flat mirror status
tcs.caliblamps.sphe - spherical mirror status
tcs.caliblamps.plamps - diffuse lamps mirror status
tcs.caliblamps.lamps - lamp selector mirror status
tcs.caliblamps.etalon - Etalon lamp status
tcs.caliblamps.tha - Tha lamp status
tcs.caliblamps.qua - Quartz lamp status
tcs.caliblamps.hene - He-Ne-Ar lamp status
tcs.caliblamps.pen - Pen rays lamp status
"ERROR: tcs router can't connect to GWC ROUTER..." - Check that the GWC router is actually running on its host machine. If its running check that the machine in which the TCS router is running is an enabled machine. Check the /usr/local/gwc/config/routersetup.tcl file for your machine name. If not present add the name using the rest of the file as a template. Check also that the environment variables MPG_ROUTER and MPG_ROUTER_PORT are set to the proper values in the tcsrrc file.
"WARNING: tcs router not connected to GWC ROUTER..." - This warning message appears to warn the user he chose not to connect to the GWC router. Consequences are that no header information will be available when image acquisition with the Arcon system.
"WARNING: system busy" - This warning message tell the user that a request for moving the comparison lamp system has arrived while executing a previous request. The warning shows at the logging panel.
"ERROR: timeout while waiting SMC response" - This message tell the user that no response was received while waiting for the SMC box to finish some operation. The timeout has been preset to 120 seconds.
"ERROR: "local... failed (...)" - This error message appears when the response to an SMC command is an error message of the form "err(...) (box.motor) ......". The message in parenthesis is the actual response from the SMC box.
"ERROR: timeout while waiting TCS response" - This message tell the user that no response was received while waiting for the TCS to finish some operation. The timeout has been preset to 120 seconds.
"WARNING: tcs router not connected to TCS..." - This warning message appears to warn the user he chose not to connect to the TCS. Consequences are that no header information will be available when image acquisition with the Arcon system.
Last Updated: April 25, 2000
rcantaruttiATnoao.edu