select() driven event loop, using careful flow control to
guard against deadlocks and the loss of important messages.
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.