\subsection{The Difrac Subsystem}
Difrac is a F77 package for controlling a four circle diffractometer
developed by P. Gabe and White for PC's. This package became only
available very late. This package has been included into SICS for four
circle diffraction. All the code for the difrac package resides in the
difrac subdirectory to sics. For more information about the difrac
system see the documentation coming with difrac. In order to
integrate difrac into SICS the following steps had to be taken:
\begin{itemize}
\item Define an interface from SICS to DIFRAC. 
\item Modify the DIFRAC hardware control to run the hardware through
SICS.
\item Adapt I/O
\item Modify DIFRAC to be a subsystem instead of a program of its own. 
\item Adapt measurement procedures to the special needs of TRICS.
\end{itemize}

\subsubsection{The Interface SICS to DIFRAC}
This is implemented in difrac.c. It it is just a interface wrapper
function which takes the command given and forwards it to the DIFRAC
interpreter. A tricky bit about this ist, that this module has to keep
track of which cconnection issued the command. This is done through a
connection stack. 

\subsubsection{DIFRAC HW control}
DIFRAC controls the hardware through a couple of function originally
defined in the file ralf.f. This file has been replaced by a file
trics.f which in turn calls C-functions implemented in difrac.c which
do the actual job. 

\subsubsection{DIFRAC I/O}
In contrast to many F77 prograsm DIFRAC has a very intelligent I/O
system. All input is channelled through the function GETLIN in
gwrite.f. This function has been modified to call a C-function which
gets a line of input from SICS. This adpater is again in difrac.c. All
output is printed first into a internal string buffer, COUT, and then
printed using the function GWRITE. This function has been modified to
call a C-function which writes the output to a SICS connection. The
integration of DIFRAC into SICS was only possible because of the
existence of this I/O system. 

\subsubsection{Changes in DIFRAC}
The DIFRAC main program was taken apart into a initialisation routine
(difini.f) and a callable interpreter  function (difint.f). Further
changes were required because TRICS does not do continous scans in the
way a X-ray four circle diffractometer does. DIFRAC's concept of a
scan drives a motor slowly and collects data. This has been modified
to do step scans for TRICS. Some commands which do not make sense
within SICS have been  disabled. Some little changes to measurement
routines were necessary.

  
