Next: Subject-Oriented Programming
Previous: The Data Analysis System for the SUBARU Telescope
Table of Contents --- Search ---
PS reprint
David L. Terrett
Rutherford Appleton Laboratory, Chilton, Didcot, Oxfordshire OX11 0QX,
United Kingdom
As astronomical data reduction packages have become larger and more complex it has become increasingly difficult for users to make use of more than one package. The barriers to using a second package include a new command language, a different look-and-feel to the applications and an unfamiliar documentation layout. This leads to ever-increasing duplication of functionality between packages as the users of any particular package demand that the full range of applications they require are available in their chosen environment in spite of the same applications already being available in other systems. Furthermore, by restricting their choice in this way they may not be using the best available algorithms for the job in hand. If the applications from other environments could be run from within the user's current environment the choice of applications would be wider and there would, perhaps, be less wasteful duplication.
The architectures of IRAF and the Starlink software environment are very similar in that they both have tasks which run as independent processes which are sent commands by the command language, and individual commands each have a set of named parameters. In view of these similarities we have attempted to construct an ``adaptor'' that enables the IRAF command language (cl) to load and control Starlink applications.
The adaptor communicates with the IRAF cl using the clio protocol, and communicates with Starlink applications using the Starlink inter-process messaging system; to the cl it behaves like a normal IRAF task and to the Starlink application it appears to be a command language (Figure 1). It is written in tcl, which has been extended to include commands for sending and receiving messages with both messaging systems.
Figure 1: IRAF/Starlink adaptor architecture.
The IRAF cl (as implemented on UNIX) communicates with a task by reading from and writing to the task's standard output and standard input. Each message has a 2 byte header, a 2 byte byte count and then the message itself as a stream of 2 byte characters. This protocol is implemented in os$zfiopr.c. Anything the task writes to its standard error stream will be written to the terminal window running the cl and can be used for debugging output.
A task is loaded the first time one of the commands it supports is used and the cl sends it a series of set commands to set the task's environment. For example,
set editor=vi set clobber=no set host=/iraf/iraf/unix/ set iraf=/iraf/iraf/These are followed by a chdir command to set the task's current directory, e.g.,
chdir rlssp0!/home/user/dlt/When the setup phase is complete the cl sends:
_go_At this point the adapter process loads the Starlink application and is ready to receive commands for the application task to execute.
A typical command looks like:
cadd in=comwest label="Kappa - Cadd" mode='ql' $nargs=0i.e., a command name followed by a list of names and values of parameters. All the parameters that are either hidden and have values, or have had their values specified on the command line that was typed by the user will appear on this list. ``mode'' and ``$args'' are special parameters that exist for all tasks.
The adapter now sends all the parameter values to the Starlink application, followed by the instruction to start executing the command. The adaptor now switches to waiting for messages from the task. In the case of Starlink applications, the sorts of messages that can be expected are:
xmit(4,13)Message text\nThe first number specifies that the message should be written to standard output and the second is the number of characters in the message.
=outwhere out is the name of the parameter. The cl will prompt the user if necessary and reply with a message containing the parameter value.
byeif the command was successful or:
error(1,"Error text")if it failed.
Once a ``bye'' or ``error'' command has been set to the cl, the adaptor reverts to waiting for the next command from the cl. This can be any of the messages discussed so far or ``bye'' which is a signal to the adaptor to unload the application task and exit.
A task can interact with the parameter system in a number of ways in addition to simply retrieving the values of parameters.
A parameter's value can be set by sending, for example:
in=comwestThis can be used to change the default value (displayed in brackets) when the cl prompts for a parameter value (but only if the parameter's mode is ``query''; if it is ``hidden'' the cl will simply return the value set when asked for the value, and not prompt the user) and to set parameters to values calculated by an application and make them available to cl procedures.
The various parameter attributes can be obtained by, for example:
=in.p_typeto get the parameter's type. The adaptor needs this information in order to translate the representation of certain data types (e.g., boolean) before sending the value to the Starlink application.1 A complete list of parameter attributes can be found in the cl help under `parameters'.
It is also possible to change some parameter attributes (but not p_name, p_type or p_xtype), but the changes may not have the desired effect while a task is active. Also, the storage for the prompt string ( p_prompt) is allocated when the task's parameter file is read and cannot be increased.
The adaptor must also handle the SIGTERM signal that the cl sends to a task when the user attempts to interrupt a task by typing Control C. The cl expects the task to respond with an ``error'' command and return to a state where it is ready for another command to the cl. If this is impossible, it is acceptable for the adaptor to exit after sending the ``error'' command; when the next command is typed, the cl will report that the task has died unexpectedly and re-load it.
I would like to thank Doug Tody, NOAO, for encouraging me to embark on this project, describing the clio protocol for me and answering my many questions about the internal workings of IRAF.
1The value of p_type is not necessarily the same as the type field in the parameter file; for example. ``file'' is changed to ``string'' by the cl.