\subsubsection{Site Abstraction Layer}
With ANSTO using SICS as well it became necessary to separate the
general parts  of SICS from the installation specific components. Each
installation will have a separate set of drivers and, to some
extent,  instrument specific commands. Such code has to be in a
separate library. Access to this library is through an interface which
consists of a structure containing pointers to functions which allow
for the creation of site specific drivers and commands. Moreover, the
site specific library has to implement a function,  getSite, which
returns the appropriate data structure for the site for which SICS is
being compiled. This data structure looks like this:

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
$\langle$sitedata {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@        typedef struct {@\\
\mbox{}\verb@                void (*AddSiteCommands)(SicsInterp *pSics);@\\
\mbox{}\verb@                void (*RemoveSiteCommands)(SicsInterp *pSics);@\\
\mbox{}\verb@                pMotor (*CreateMotor)(SConnection *pCon,@\\
\mbox{}\verb@                                            int argc, char *argv[]);@\\
\mbox{}\verb@                pCounterDriver (*CreateCounterDriver)(@\\
\mbox{}\verb@                                                SConnection *pCon,@\\
\mbox{}\verb@                                                int argc, @\\
\mbox{}\verb@                                                char *argv[]);@\\
\mbox{}\verb@                HistDriver *(*CreateHistogramMemoryDriver)(@\\
\mbox{}\verb@                                char *name, pStringDict pOption);@\\
\mbox{}\verb@                pVelSelDriv (*CreateVelocitySelector)(char *name, @\\
\mbox{}\verb@                                char *array, Tcl_Interp *pTcl);@\\
\mbox{}\verb@                pCodri      (*CreateControllerDriver)(SConnection *pCon,@\\
\mbox{}\verb@                                                        int argc,@\\
\mbox{}\verb@                                                        char *argv[]);@\\
\mbox{}\verb@                pEVControl            (*InstallEnvironmentController)(@\\
\mbox{}\verb@                                        SicsInterp *pSics,@\\
\mbox{}\verb@                                        SConnection *pCon,@\\
\mbox{}\verb@                                        int argc,@\\
\mbox{}\verb@                                        char *argv[]);@\\
\mbox{}\verb@                int                     (*ConfigureScan)(pScanData self,@\\
\mbox{}\verb@                                                char *option);@\\
\mbox{}\verb@                void (*KillSite)(void *pData);@\\
\mbox{}\verb@}Site, *pSite;@\\
\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{description}
\item[AddSiteCommands] adds site specific object creation and
instrument specific commands to the SICS interpreter, pSics.
\item[RemoveSiteCommands] will be called to remove surplus object
creation commands after the SICS interpreter has processed the
initialization files. Please note, that SICS does not support the
removal of objects at runtime in general. This is due to the fact that
any possible object may be used by or linked to others and and it
would be a bookeeping nightmare to keep track of all those relations.
\item[CreateMotor] creates a motor using the arguments in argc and
argv. It returns a pointer to the new motor structure on success or
NULL in case of a failure. This function has to return a complete
motor in order to allow for special configurations of the motor to
take place in its initialization.
\item[CreateCounterDriver] returns a driver for a new counter box
driver if the parameters are valid or NULL if not. Driver arguments
are in the argc, argv pair.  
\item[CreateHistogramMemoryDriver] creates a driver for a histogram
memory. The driver type is specified through name. 
Driver options are in pOptions. 
\item[CreateVelocitySelector] create a driver for a velocity selector.
The parameter name is the name of the driver, array is the name of a
Tcl array holding configuration parameters for the driver and pTcl is
the Tcl interpreter in which array lives. 
\item[CreateControllerDriver] creates a driver for the general
controller module within SICS. argc and argv hold the parameters,
starting with the name of the driver to create.  
\item[InstallEnvironmentController] installs a a sample
environment device such as a temperature controller or magnet
controller etc. into the interpreter pSics. pCon is a connection
object to  which errors can be
reported, argc and argv are the controller parameters starting with
the driver name. This method does not get away with creating a driver
but must install the command into SICS because  some environment
devices overload the standard Wrapper function with special ones. The
newly created object is still returned for further processing. In the
case of failure NULL is returned. Errors will have been printed to
pCon. 
\item[ConfigureScan] allows for modules which configure the scan
object. option is the option to xxscan configure to process, the scan
object to configure is passed in in self. This returns 1 on success
and 0 on failures or options which are not recognized. 
\item[KillSite] is a function to remove the site data structure when
SICS is done with it. pData must point to the site data structure.
KillSite's  purpose is to free all memory associated with
the site data structure. This is mostly a cleanup thing, to keep the
fortify logs clear off inconsequential and confusing data.
\end{description} 


\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
\verb@"site.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*-----------------------------------------------------------------------@\\
\mbox{}\verb@        S i t e  A b s t r a c t  i o n  L a y e r@\\
\mbox{}\verb@@\\
\mbox{}\verb@With ANSTO using SICS as well it became necessary to separate the@\\
\mbox{}\verb@general parts  of SICS from the installation specific components. Each@\\
\mbox{}\verb@installation will have a separate set of drivers and, to some@\\
\mbox{}\verb@extent,  instrument specific commands. Such code has to be in a@\\
\mbox{}\verb@separate library. Access to this library is through an interface which@\\
\mbox{}\verb@consists of a structure containing pointers to functions which allow@\\
\mbox{}\verb@for the creation of site specific drivers and commands. Moreover, the@\\
\mbox{}\verb@site specific library has to implement a function,  getSite, which@\\
\mbox{}\verb@returns the appropriate data structure for the site for which SICS is@\\
\mbox{}\verb@being compiled. @\\
\mbox{}\verb@------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef SICSSITE@\\
\mbox{}\verb@#define SICSSITE@\\
\mbox{}\verb@#include <sics.h>@\\
\mbox{}\verb@#include <motor.h>@\\
\mbox{}\verb@#include <countdriv.h>@\\
\mbox{}\verb@#include <HistDriv.i>@\\
\mbox{}\verb@#include <stringdict.h>@\\
\mbox{}\verb@#include <velo.h>@\\
\mbox{}\verb@#include <tcl.h>@\\
\mbox{}\verb@#include <codri.h>@\\
\mbox{}\verb@#include <evcontroller.h>@\\
\mbox{}\verb@#include <scan.h>@\\
\mbox{}\verb@@$\langle$sitedata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*-------------------------------------------------------------------*/@\\
\mbox{}\verb@pSite getSite(void);@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-2ex}
\end{minipage}\\[4ex]
\end{flushleft}
