# SICS programs, Scripts and Prerequisites

## Hardware

The following hardware is usually present for any SICs instrument:

- An instrument computer
- A Lantronix terminal server with 8-16 serial ports for connecting:
- Motor controllers
- Counter boxes
- Temperature controllers.
- Optionally 1-n histogram memory computers are present.

The terminal server software is provided by Lantronix, see the appropriate manuals for the device for a description. The histogram memories are 68000 VME or MEN-A12 onboard computers running the VXworks realtime operating system and some home grown histogramming software documented elsewhere.

## Server programs

For proper operation of an instrument the following software components are required:

SerPortServer
  This is a TCP/IP server which implements a special protocoll for communicating with serial ports. The actual communication with the serial ports is done through the Lantronix terminal server. Both the serial port protocoll and the SerPortServer are only documented in the source code. The SerPortServer program is on its way out.
TecsServer
  This is a TCP/IP server which watches over temperature controllers. The only known source of documentation about this software is Markus Zolliker.
FileSync
  This is a little UDP server which waits for UDP messages from the instrument control program. Then the server starts a script which synchronizes the local data directory with the central data storage on the labarotory server. FileSync is configured through an initialization file usually called fs.ini. See the comments in the initialization file for more information.
SICServer
  This is the actual instrument control server. The configuration of this program is documented in this manual.

Additionally a client program is needed which connects to the instrument control server and provides a user interface to it.

# General SICS Setup

SICS is a client server system. This implies that there is a server program which implements all the functionlity and client programs which implement the user interface. The client program is the only thing the user is intended to see. This also means that the location of the client programs is quite independent from the computer where the server runs. In the following the layout of a server installation is described as established at SINQ.

For each instrument there is a data aquisition computer. On this computer there exists a user name and consequently a home directory for the instrument. In the following text this instrument root directory will be called sicsroot. This root directory has the following subdirectories:

bin
  The directory where some executables live.
inst_sics
  All instrument configuration files and the SICServer live in this directory. Replace inst by the name of the instrument as appropriate.
data
  The data directory is the central place where all data files collected at the instrument are stored. This directory contains subdirectories for each year. These directories hold the data collected at the instrument in this year plus a file named DataNumber which keeps the current serial number of the data files. This file should never be edited. At the start of each year the instruement manager must create a new directory with an empty DataNumber file. Additionally the path variables both for the data file directory and the DataNumber file have to be set to the new directory in the instrument initialization file.
log
  The log directory contains the server log files and the automatically generated client log files. Any now and then, and especially when disk space problems loom, the client*.log files should be deleted by the instrument manager.
lib
  Contains some files needed for running SICS clients locally.
doc
  This directory holds a copy of the SICS user documentation for the instrument. These are html files which can be viewed with WWW-browsers such as lynx or netscape.
motor
  This directory holds a script for reading and restoring the motor parameter from the EL734 motor controllers. And the motor parameters stored in parameter files. It is the instrument scientists responsability to save the motor parameters after changes to the configuration of the instrument.
tmp
  A directory for temporary and PID files.
help
  A directory for help files for the help system.

Besides these directories there should be nothing on the instrument account. All evaluated data, personal command files etc. should be held on the normal user account of the instrument user.

## System Control

All commands listed in this section have to issued with the privilege of the instrument user account.

In order to watch over all these servers, the monit software is used. This is a program which watches server processes and restarts them as necessary. Monit can also be used to watch over hardware and the file system. Monit writes a log file and can trigger e-mail alerts on certain problematic conditions.

Monit itself is controlled through a configuration file, .monitrc, which lives in the instrument accounts home directory. Monit also uses another Tcl program runwithpid which is responsible for starting and stopping server programs. In order to configure all this, there is another program: makemonit which creates the monit configuration file and copies and edits the runwithpid program. The syntax of makemonit is:

makemonit instrument terminalserver data-mount-point hm1 hm2 ..
  instrument is the instrument name in lowercase, terminalserver is the name of the terminal server used for serial port access, data-mount-point is the name of file system onto which the instruments data is written. This is followed by a list of all the histogram memory computers used by the instrument.
monitinit
  monitinit is an alias which calls makemonit with all required parameters for a given instrument in standard configuration.

Monit itself can be controlled with the following commands:

monit
  Starts the monit daemon and all configured processes. This is only necessary after a reboot of the system.
monit status
  This shows a status message listing the status of all configured servers and the checked hardware. The monit status is also available on the WWW from http://lns00.psi.ch/monit/instrument. Replace instrument with the appropriate instrument name.
monit stop target
  Stops the server process target. The following targest exist:
  all
    All processes
  sicsserver
    The SICS server
  SerPortServer
    The serial port server.
  sync
    The file synchronisation server.
  tecs
    The TecsServer for controlling environment devices.
  simserver
    A simulation server(not on all instruments).
monit start target
  Starts a server process, targest are the same as described above.
monit restart target
  Stops and starts the process target. Targets are as listed above.
monit quit
  Stops monit alltogether. Please note, that servers stay running with this command. In order to sop everything the sequence: monit stop all; monit quit is required.
startsics
  This script starts all the necessary server programs for driving the instrument through monit.
killsics
  This script shuts down all instrument control servers properly through monit.
instsync
  replace inst by the name of the instrument in lower case. This script is invoked by the FileSync server and is responsible for synchronizing the local data store with the one on the labaratory server. This is usally done by calling the unix program rsync with appropriate parameters.