\subsection{The hardware driver for the Dornier velocity selector at SINQ}
SANS uses a velocity selector provided by Dornier, Germany. This velocity
selector comes with a IBM--compatible PC for control. On this PC there is a
control program for the velocity selector. This program can be operated from
the PC's monitor and keyboard or remotely, from a host computer, 
through a RS--232 connection. The protocoll on this RS--232 connection is a
simple ASCII command protocoll detailed in the documentation delivered by
Dornier. At SINQ this velocity selcector control PC is connected via the
RS--232 connection to a Macintosh computer. This Mac is connected to the
network by TCP/IP. The Mac runs a terminal server program. This program
forwards commands sent by TCP/IP to the apropriate RS--232 port. Due to this
complicated setup, the hardware driver for the Dornier velocity selector has
three layers:
\begin{itemize}
\item A command forwarding layer, which sends command to the selector via
TCP/IP, the MAC and RS--232 and collects answers. This is fairly general
code, used for many SICS hardware drivers.
\item A primitive operations layer which implements simple command on the
selector. This layer is based on code provided by Dr. Emmelmann, HMI. 
\item At the end, there is the actual SICS hardware driver which builds the
interface to the SICS system.
\end{itemize}

The implementation of the Dornier velocity selector driver is further
complicated by the fact that it is very slow in responding to commands
and moreover due to the fact that it has different modes:
\begin{itemize}
\item Starting is just after starting the velocity selector
\item regel is the normal mode.
\item halting is the mode when the velocity selector has been asked to
stop. 
\end{itemize}
Unfortunately the actions necessary to run a Dornier velocity
selector to a desired speed depend on those modes. For instance if the
Dornier velocity
selector is stopped it first needs to be started and then, when a
certain speed has been reached, the command to set the desired
rotation speed can be sent. The necessary mode dependent switching is
done in the DornierStat function.  

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
$\langle$dh {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@   int GetDornierStatus(void **pData, pDornierStatus pDornier);@\\
\mbox{}\verb@   int DornierSend(void **pData, char *pCommand, char *pReply, int iLen);@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap ?.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
\verb@"velodorn.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*---------------------------------------------------------------------------@\\
\mbox{}\verb@                        V E L O D O R N@\\
\mbox{}\verb@@\\
\mbox{}\verb@  a set of utility functions needed in order to communicate with a @\\
\mbox{}\verb@  Dornier velocity selector through the SINQ system. @\\
\mbox{}\verb@@\\
\mbox{}\verb@  Mark Koennecke, Juli 1997@\\
\mbox{}\verb@@\\
\mbox{}\verb@  copyright: see implementation file.@\\
\mbox{}\verb@------------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef VELODORN@\\
\mbox{}\verb@#define VELODORN@\\
\mbox{}\verb@/*-------------------- a data structure for status analysis ---------------*/@\\
\mbox{}\verb@ typedef struct {@\\
\mbox{}\verb@                 char echo[30]; /* echo of command */@\\
\mbox{}\verb@                 char rm[10]; /* operation status: REG == adjusting, STB == idle, @\\
\mbox{}\verb@                         BRE == braking */@\\
\mbox{}\verb@                 int nom_rpm; /* envisaged rotation */@\\
\mbox{}\verb@                 int cur_rpm; /* actual rotation speed */        @\\
\mbox{}\verb@                 int pwr;     /* loss current, only valid after check */@\\
\mbox{}\verb@                 float curr;  /* electircal current */@\\
\mbox{}\verb@                 int  rot_temp; /* temperature of rotor */@\\
\mbox{}\verb@                 int cont_temp; /* temperature of housing */@\\
\mbox{}\verb@                 int inl_temp;  /* in temperature of cooling water */@\\
\mbox{}\verb@                 int outl_temp; /* temperature of cooling water after @\\
\mbox{}\verb@                                   velocity selector */@\\
\mbox{}\verb@                 float cool_wat; /* cooling water flow (l/minute) */@\\
\mbox{}\verb@                 float vacuum;  /* vacuum (mbar) */@\\
\mbox{}\verb@                 float accel;   /* rotation acceleration (g) */@\\
\mbox{}\verb@                 int komm;      /* communication status PC-Host,@\\
\mbox{}\verb@                                   0 = enabled,  1 = disabled @\\
\mbox{}\verb@                                */@\\
\mbox{}\verb@                 int iHz;@\\
\mbox{}\verb@                 } DornierStatus, *pDornierStatus;                                   @\\
\mbox{}\verb@@\\
\mbox{}\verb@/*--------- error codes */@\\
\mbox{}\verb@#define NOCOMMAND -300@\\
\mbox{}\verb@#define ECHOMISSING -302@\\
\mbox{}\verb@#define BADANALYSIS -303@\\
\mbox{}\verb@#define STARTTIMEOUT -304@\\
\mbox{}\verb@#define INVALIDSTATUS -305@\\
\mbox{}\verb@/*------ functions */@\\
\mbox{}\verb@@$\langle$dh {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-2ex}
\end{minipage}\\[4ex]
\end{flushleft}
