The CBI Control Program

The control program is a multi-threaded program that runs on the dedicated control Sun. It schedules the operations of the real-time control system, logs status messages to disk, archives data received from the real-time control system, manages source catalogs, ephemerides and time, and communicates commands and data to and from external cbiviewer programs.

The Communicator thread handles all inbound and outbound TCP/IP traffic.
The Scheduler thread executes interactive commands, scheduling scripts and initialization scripts.
The Astrometry thread handles source catalogs, ephemerides and time.
The Logger thread collects, archives and distributes log messages.
The Archiver thread collects, archives and distributes archive data.

The TCP/IP Communicator thread

The TCP/IP Gateway thread provides the TCP/IP interface between the outside world and the other control program threads. It handles the messy job of reading and writing network messages using non-blocking I/O, as well as the job of translating between the internal and external representations of network messages. It operates as a select() driven event loop, using careful flow control to guard against deadlocks and the loss of important messages.

The Scheduler Thread.

The Scheduler thread is responsible for the compilation and batch processing of a queue of user-written scheduling scripts. It is also charged with executing commands that are typed interactively into client Cbiviewer programs. The scheduling language uses very strict datatyping to ensure that if a scheduling script makes it through the compiler without incuring any errors, the script is guaranteed to run to completion without run-time errors.

Schedules are only executed when the real-time CPU is connected. Whenever the real-time software connects to the control program, the scheduler executes a schedule called $CBI_DIR/rtc.init, then starts to execute the schedule at the front of the schedule queue. If interactive commands are received from connected cbiviewer programs, they are executed immediately without requiring the current schedule to stop.

If the real-time software disconnects for any reason, the scheduler rewinds the currently running schedule and pushes it back to the front of the pending queue of schedules.

The Astrometry Thread.

The Astrometry thread is responsible for maintaining the source catalog, planetary ephemerides and the ephemeris of UT1-UTC. With these facilities it provides the real-time CPU with sufficient information to track the current source. This includes sending timely updates of the quadratic interpolation nodes used by the real-time CPU to compute UT1-UTC, the equation of the equinoxes, and the geocentric Right Ascension and Declination of the current source. To allow it to send information that is pertinent to the current source, all telescope positioning requests are forwarded from the scheduler through this task.

This task also supplies source and time information to scheduler script commands.

The Logger Thread.

The logger thread collects status messages from the real-time control system, and from the other control-program threads. It then prepends a time tag to each message and appends it to the current log file. Log file names are composed using the date and time at which the log file was created. The time part of the name is accurate to a second. This ensures that a new log file can be opened at any time, without having to worry about overwriting an existing one.

Log messages are also forwarded to any CbiViewer client programs that happen to be connected. This allows for remote monitoring of status messages.

The Archiver Thread

The primary responsibility of the Archiver thread is to write archive files of the register snapshots that the real-time Scanner task collects. On opening a new archive file, the Archiver thread writes the register map to the archive file. Thereafter it forms archive frames by coadding a user-configured number of register snapshots, and saves the archive frames to the current archive file. Archive files use the same binary format that is used for network transmission. This allows the same encoding and decoding functions to be used.

Before coadding each snapshot, the archiver also looks at the register selection-set of each of the connected cbiviewer programs. Each connected cbiviewer program can select a different set of registers that it wants to receive updated values for, and the archiver extracts the values of these registers from each snapshot, and arranges for them to be sent to the cbiviewer programs. If the network connection to a particular cbiviewer program is too slow to accomodate receiving these register values in real-time, the archiver will ignore that client until it has caught up. It will then resume sending registers from the following snapshot. Missed snapshots are not delivered.


Martin Shepherd (24-May-1998)