Initial revision
This commit is contained in:
351
choco.tex
Normal file
351
choco.tex
Normal file
@ -0,0 +1,351 @@
|
||||
\subsection{Chopper Controller}
|
||||
Yet another way to deal with a controller has beenn devised for
|
||||
SICS. This uses the concept of a general controller which can have
|
||||
parameters enquired and set. Furthermore it may have parameters which
|
||||
may be driven like a motor through a special adapter. This scheme is
|
||||
used for the chopper controller for FOCUS.
|
||||
\begin{itemize}
|
||||
\item A driver for a particular controller which allows to set and get
|
||||
parameters.
|
||||
\item The general controller object which holds things together.
|
||||
\item An adapter object which allows to drive special parameters in a general
|
||||
controller. Such adapter objects can be configured for each drivable parameter
|
||||
in a controller.
|
||||
\end{itemize}
|
||||
The test case for this way of doing things is a controller for running
|
||||
choppers. This is why it gets the name.
|
||||
|
||||
The chopper system in question is the FOCUS chopper system. There are two
|
||||
choppers, a fermi chopper and a disk chopper. This system can be run in two
|
||||
different modes: In synchronous mode both choppers run at a
|
||||
predefined ratio of speeds. For instance the fermi chopper is two
|
||||
times faster then the disk chopper. This means, that setting a new
|
||||
value for one chopper also changes the speed of the other chopper. In
|
||||
asynchronous mode both choppers operate independently. Also the ration
|
||||
to use for synchronous mode can be changed. Another parameter which
|
||||
frequently changes is the phase of the two choppers. In order to
|
||||
compensate for the fligh path between the two choppers there is a
|
||||
small angular displacement of the choppers against each other which
|
||||
varies with wavelength.
|
||||
|
||||
\subsubsection{The Controller Driver}
|
||||
The controller driver is represented by the following data structure:
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap1}
|
||||
$\langle$codri {\footnotesize ?}$\rangle\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ typedef struct __CODRI *pCodri;@\\
|
||||
\mbox{}\verb@ typedef struct __CODRI {@\\
|
||||
\mbox{}\verb@ int (*Init)(pCodri self);@\\
|
||||
\mbox{}\verb@ int (*Close)(pCodri self);@\\
|
||||
\mbox{}\verb@ int (*Delete)(pCodri self);@\\
|
||||
\mbox{}\verb@ int (*SetPar)(pCodri self, @\\
|
||||
\mbox{}\verb@ char *parname,@\\
|
||||
\mbox{}\verb@ float fValue);@\\
|
||||
\mbox{}\verb@ int (*SetPar2)(pCodri self, @\\
|
||||
\mbox{}\verb@ char *parname,@\\
|
||||
\mbox{}\verb@ char *value);@\\
|
||||
\mbox{}\verb@ int (*GetPar)(pCodri self,@\\
|
||||
\mbox{}\verb@ char *parname,@\\
|
||||
\mbox{}\verb@ char *pBuffer,@\\
|
||||
\mbox{}\verb@ int iBufLen);@\\
|
||||
\mbox{}\verb@ int (*CheckPar)(pCodri self, @\\
|
||||
\mbox{}\verb@ char *parname);@\\
|
||||
\mbox{}\verb@ int (*GetError)(pCodri self, int *iCode,@\\
|
||||
\mbox{}\verb@ char *pError, @\\
|
||||
\mbox{}\verb@ int iErrLen);@\\
|
||||
\mbox{}\verb@ int (*TryFixIt)(pCodri self, int iCode);@\\
|
||||
\mbox{}\verb@ int (*Halt)(pCodri self);@\\
|
||||
\mbox{}\verb@ char *pParList;@\\
|
||||
\mbox{}\verb@ void *pPrivate;@\\
|
||||
\mbox{}\verb@ }Codri;@\\
|
||||
\mbox{}\verb@ @\\
|
||||
\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}
|
||||
All functions take a pointer to the controller driver itself as a
|
||||
parameter. All functions except TryFixIt and CheckPar
|
||||
return 0 on failure and 1 for success.
|
||||
\begin{description}
|
||||
\item[Init] initializes the controller driver. The parameters argc,
|
||||
argv are main() style parameters for the initialization of the
|
||||
controller driver.
|
||||
\item[Close] closes the connection to the controller but does not delete a thing.
|
||||
\item[Delete] closes the connection to the controller and deletes private data structures. Called when deleting the controller.
|
||||
\item[SetPar] tries to set the parameter parname to the value
|
||||
fValue. The last is floating point which covers the frequent
|
||||
occurence of numeric values.
|
||||
\item[SetPar2] The same as SetPar but uses test string as input for
|
||||
parameter setting.
|
||||
\item[GetPar] retrieves the parameter parname formatted as test. The
|
||||
value is put into the buffer pBuffer. iBufLen is the maximum number of
|
||||
bytes permissable for pBuffer.
|
||||
\item[CheckPar] When parameters are driven a means is needed to find
|
||||
out about the progress of operations and errors during the
|
||||
operation. This is done by CheckPar for the parameter parname. The
|
||||
return value of this function must be one of the HWBusy, HWError,
|
||||
HWDone family documented in the motor driver object description.
|
||||
\item[GetError] retrieves the last error. An integer error code is
|
||||
placed into iCode and a textual description of the problem is written
|
||||
to pError. Maximum iErrLen bytes are copied to pError.
|
||||
\item[TryFixIt] tries to fix the error condition specified by iCode in
|
||||
software if this possible. TryFisIt returns HWRedo if the last command
|
||||
needs to resent, HWFault if the problem could not be fixed and HWOK if
|
||||
the error can be ignored or was fully resolved.
|
||||
\item[pParList] is text string containing a comma separated list of
|
||||
all parameters understood by this driver.
|
||||
\item[pPrivate] Is a pointer to a driver specific specific data
|
||||
structure. This data structure will not be messed with by upper level code.
|
||||
\end{description}
|
||||
|
||||
\subsubsection{The Controller Object}
|
||||
This is the general controller object visible from the SICS
|
||||
interpreter. This object allows to list all possible
|
||||
parameters. Internal functions are provided for setting
|
||||
parameters. But this is meant to be operated through a drive adapter
|
||||
object (see below) in SICS. Thus the interface to this object
|
||||
includes:
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap2}
|
||||
$\langle$chocoint {\footnotesize ?}$\rangle\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ typedef struct __CHOCO *pChoco;@\\
|
||||
\mbox{}\verb@/*------------------------------------------------------------------------*/@\\
|
||||
\mbox{}\verb@ int CHGetParameter(pChoco self, char *pParName, @\\
|
||||
\mbox{}\verb@ char *pParValue, int iBuflen); @\\
|
||||
\mbox{}\verb@ @\\
|
||||
\mbox{}\verb@ pCodri CHGetDriver(pChoco self);@\\
|
||||
\mbox{}\verb@ int CHList(pChoco self, SConnection *pCon, char *name);@\\
|
||||
\mbox{}\verb@/*------------------------------------------------------------------------*/@\\
|
||||
\mbox{}\verb@ int ChocoAction(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
|
||||
\mbox{}\verb@ int argc, char *argv[]);@\\
|
||||
\mbox{}\verb@ int ChocoFactory(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
|
||||
\mbox{}\verb@ int argc, char *argv[]);@\\
|
||||
\mbox{}\verb@ @\\
|
||||
\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[CHGetParameter] retrieves the value of the parameter ParName
|
||||
converted to text. Maximum iBufLen of result or error text are copied into the
|
||||
buffer pParvalue.
|
||||
\item[CHGetDriver] returns a pointer to the controller driver. This
|
||||
function will be used by the drive adapters for interfacing with the
|
||||
driver directly.
|
||||
\item[CHList] prints a listing of all parameters to the client
|
||||
described by pCon. name is the name of the controller.
|
||||
\item[ChocoAction] is the SICS interpreter interface function for the
|
||||
controller.
|
||||
\item[ChocoFactory] is the SICS interpreter interface function which
|
||||
installs a controller into SICS.
|
||||
\end{description}
|
||||
|
||||
Most of the actual work of the controller is left to the driver. Thus
|
||||
the internal data structure for a controller object is very simple:
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap3}
|
||||
$\langle$chocodata {\footnotesize ?}$\rangle\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ typedef struct __CHOCO {@\\
|
||||
\mbox{}\verb@ pObjectDescriptor pDes;@\\
|
||||
\mbox{}\verb@ pCodri pDriv;@\\
|
||||
\mbox{}\verb@ } Choco;@\\
|
||||
\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}
|
||||
It consists just of the standard SICS object descriptor and a pointer
|
||||
to the driver.
|
||||
|
||||
\subsubsection{The Drive Adapter}
|
||||
Most of the work of the drive adaptor is hidden in the functions
|
||||
implementing the drivable interface. Thus the interface to the
|
||||
DriveAdapter is fairly simple:
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap4}
|
||||
$\langle$adapter {\footnotesize ?}$\rangle\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ typedef struct __CHADAPTER *pCHAdapter;@\\
|
||||
\mbox{}\verb@/*-----------------------------------------------------------------------*/@\\
|
||||
\mbox{}\verb@ int CHAdapterFactory(SConnection *pCon, SicsInterp *pSics, @\\
|
||||
\mbox{}\verb@ void *pData,@\\
|
||||
\mbox{}\verb@ int argc, char *argv[]);@\\
|
||||
\mbox{}\verb@ @\\
|
||||
\mbox{}\verb@ int CHAdapterAction(SConnection *pCon, SicsInterp *pSics, @\\
|
||||
\mbox{}\verb@ void *pData,@\\
|
||||
\mbox{}\verb@ int argc, char *argv[]);@\\
|
||||
\mbox{}\verb@ @\\
|
||||
\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[CHAdapterFactory] is the SICS interpreter factory function for
|
||||
creating a drive adapter.
|
||||
\item[CHAdapterAction] is the SICS interpreter function for
|
||||
representing the object in SICS. Just a single action is supported:
|
||||
request the value of the parameter.
|
||||
\end{description}
|
||||
|
||||
The data structure for the drive adapter is slightly more interesting:
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap5}
|
||||
$\langle$adadata {\footnotesize ?}$\rangle\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ typedef struct __CHADAPTER {@\\
|
||||
\mbox{}\verb@ pObjectDescriptor pDes;@\\
|
||||
\mbox{}\verb@ pCodri pDriv;@\\
|
||||
\mbox{}\verb@ pIDrivable pInt;@\\
|
||||
\mbox{}\verb@ float fUpper;@\\
|
||||
\mbox{}\verb@ float fLower;@\\
|
||||
\mbox{}\verb@ float fTarget;@\\
|
||||
\mbox{}\verb@ char *pParName;@\\
|
||||
\mbox{}\verb@ }CHAdapter;@\\
|
||||
\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[pDes] is the standard object descriptor.
|
||||
\item[pDriv] is a pointer to the controller driver.
|
||||
\item[pInt] is a pointer to the drivable interface implemented by the
|
||||
adapter.
|
||||
\item[fUpper] upper limit for the parameter.
|
||||
\item[fLower] lower limit for the parameter.
|
||||
\item[pParName] is the name of the parameter which is driven through
|
||||
this adapter.
|
||||
\end{description}
|
||||
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap6}
|
||||
\verb@"codri.h"@ {\footnotesize ? }$\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@/*-------------------------------------------------------------------------@\\
|
||||
\mbox{}\verb@ C o n t r o l l e r D r i v e r@\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ This file contains the description of the data structure for a@\\
|
||||
\mbox{}\verb@ general controller driver.@\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ Mark Koennecke, January 1998@\\
|
||||
\mbox{}\verb@--------------------------------------------------------------------------*/@\\
|
||||
\mbox{}\verb@#ifndef CODRIV@\\
|
||||
\mbox{}\verb@#define CODRIV@\\
|
||||
\mbox{}\verb@#define CHFAIL -1@\\
|
||||
\mbox{}\verb@#define CHREDO -2@\\
|
||||
\mbox{}\verb@#define CHOK -3@\\
|
||||
\mbox{}\verb@@$\langle$codri {\footnotesize ?}$\rangle$\verb@@\\
|
||||
\mbox{}\verb@#endif@\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\end{list}
|
||||
\vspace{-2ex}
|
||||
\end{minipage}\\[4ex]
|
||||
\end{flushleft}
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap7}
|
||||
\verb@"choco.h"@ {\footnotesize ? }$\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@/*-----------------------------------------------------------------------@\\
|
||||
\mbox{}\verb@ C h o p p e r C o n t r o l l e r@\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ This is both the header file for a general controller and a SICS@\\
|
||||
\mbox{}\verb@ chopper controller.@\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ Mark Koennecke, January 1998@\\
|
||||
\mbox{}\verb@--------------------------------------------------------------------------*/@\\
|
||||
\mbox{}\verb@#ifndef CHOCOSICS@\\
|
||||
\mbox{}\verb@#define CHOCOSICS@\\
|
||||
\mbox{}\verb@#include "codri.h"@\\
|
||||
\mbox{}\verb@@$\langle$chocoint {\footnotesize ?}$\rangle$\verb@@\\
|
||||
\mbox{}\verb@#ifdef CHOCOINTERNAL@\\
|
||||
\mbox{}\verb@@$\langle$chocodata {\footnotesize ?}$\rangle$\verb@@\\
|
||||
\mbox{}\verb@#endif@\\
|
||||
\mbox{}\verb@#endif @\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\end{list}
|
||||
\vspace{-2ex}
|
||||
\end{minipage}\\[4ex]
|
||||
\end{flushleft}
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap8}
|
||||
\verb@"chadapter.h"@ {\footnotesize ? }$\equiv$
|
||||
\vspace{-1ex}
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@/*------------------------------------------------------------------------@\\
|
||||
\mbox{}\verb@ C H a d a p t e r@\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ This is the header file for a drive adapter for collaboration with a@\\
|
||||
\mbox{}\verb@ general device controller as implemented in choco.*@\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ Mark Koennecke, January 1998@\\
|
||||
\mbox{}\verb@--------------------------------------------------------------------------*/@\\
|
||||
\mbox{}\verb@#ifndef SICSCHADA@\\
|
||||
\mbox{}\verb@#define SICSCHADA@\\
|
||||
\mbox{}\verb@#include "codri.h"@\\
|
||||
\mbox{}\verb@@$\langle$adapter {\footnotesize ?}$\rangle$\verb@@\\
|
||||
\mbox{}\verb@#ifdef CHADAINTERNAL@\\
|
||||
\mbox{}\verb@@$\langle$adadata {\footnotesize ?}$\rangle$\verb@@\\
|
||||
\mbox{}\verb@#endif@\\
|
||||
\mbox{}\verb@#endif@\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\end{list}
|
||||
\vspace{-2ex}
|
||||
\end{minipage}\\[4ex]
|
||||
\end{flushleft}
|
||||
\subsubsection{To Do}
|
||||
This scheme seems to be quite promising for handling many SICS
|
||||
objects. The following enhancements could be considered. Allow to set
|
||||
certain primitive parameters without a drivable interface. And add an
|
||||
adapter for an environment variable in the controller.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user