\subsection{The SICS Server Object}
This objects responsability is the proper initialisation and shutdown
 of the SICS server and the provision of some utility functions. 
The Server's data structure holds pointers to the most important parts of
the system:

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
$\langle$servdat {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@   typedef struct __SicsServer {@\\
\mbox{}\verb@                    SicsInterp *pSics;@\\
\mbox{}\verb@                    pTaskMan   pTasker;@\\
\mbox{}\verb@                    pExeList   pExecutor;@\\
\mbox{}\verb@                    pEnvMon    pMonitor;@\\
\mbox{}\verb@                    mkChannel  *pServerPort;@\\
\mbox{}\verb@                    pNetRead   pReader;@\\
\mbox{}\verb@                    int        simMode;@\\
\mbox{}\verb@                    SConnection *dummyCon;@\\
\mbox{}\verb@                   } SicsServer;@\\
\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}
The fields are:
\begin{description}
\item[pSics] is a pointer to the SICS interpreter.
\item[pTasker] is a pointer to the task scheduler.
\item[pExecutor] is a pointer to the device executor. This module monitors 
 variables during counting and driving operations.
\item[pMonitor] is a pointer to an environment device controller monitor.
This module monitors sample environment controllers.
\item[pServerPort] points to a data structure describing the port at which
the SICS server is listening for connections.
\item[pReader] points to a data structure which defines the network
communication object.  
\item[simMode] a flag which is true when the SICS server is a simulation
 server.
\item[dummyCon] A dummy connection to use when no other connection is
available for some reason. 
\end{description}


In terms of a function interface the server module supplies.  

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
$\langle$servint {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*----------------------------------------------------------------------*/@\\
\mbox{}\verb@    int     InitServer(char *file, pServer *pServ);@\\
\mbox{}\verb@    void    RunServer(pServer self);@\\
\mbox{}\verb@    void    StopServer(pServer self);@\\
\mbox{}\verb@/*----------------------------------------------------------------------*/@\\
\mbox{}\verb@    SicsInterp  *GetInterpreter(void);@\\
\mbox{}\verb@    pExeList    GetExecutor(void);@\\
\mbox{}\verb@    pTaskMan    GetTasker(void);@\\
\mbox{}\verb@    void ServerWriteGlobal(char *pMessage, int iCode);@\\
\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}
For most functions the name already says what it does. {\bf
InitServer} initializes the SICS servers data structures. {\bf
RunServer} implements the main loop and essentially calls the task
modules ScheduleTask function for running all the SICS tasks which
will handle the rest of the job. {\bf Stopserver} is responisble for
closing the SICS server down in a sensible manner and in a  well
defined sequence of events. 
{\bf ServerWriteGlobal}
is special. This function sends the message pMessage to all clients
currently connected to the SICS server with the output code iCode. iCode has
the same meaning as in the connection object.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap3}
\verb@"nserver.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*--------------------------------------------------------------------------@\\
\mbox{}\verb@                        N S E R V E R@\\
\mbox{}\verb@@\\
\mbox{}\verb@  The SICS server main data structure and functions.@\\
\mbox{}\verb@@\\
\mbox{}\verb@  Restructured: September 1997@\\
\mbox{}\verb@@\\
\mbox{}\verb@  Mark Koennecke.@\\
\mbox{}\verb@  @\\
\mbox{}\verb@  copyright: see copyright.h@\\
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef SICSNSERVER@\\
\mbox{}\verb@#define SICSNSERVER@\\
\mbox{}\verb@#include "conman.h"@\\
\mbox{}\verb@#include "SCinter.h"@\\
\mbox{}\verb@#include "emon.h"@\\
\mbox{}\verb@#include "devexec.h"@\\
\mbox{}\verb@#include "task.h"@\\
\mbox{}\verb@#include "network.h"@\\
\mbox{}\verb@@\\
\mbox{}\verb@ typedef struct __SicsServer *pServer;@\\
\mbox{}\verb@@\\
\mbox{}\verb@#include "nread.h"@\\
\mbox{}\verb@@$\langle$servdat {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$servint {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@     int UserWait(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@                  int argc, char *argv[]);@\\
\mbox{}\verb@@\\
\mbox{}\verb@     int SicsWait(long lTime);@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-2ex}
\end{minipage}\\[4ex]
\end{flushleft}
