\subsection{AMOR Two Theta}
AMOR is SINQ's new reflectometer. It has the peculiar feature that the
two theta movement of the detector is expressed in translations along
the reflectometer base axis and the detector height. Additionally the
detector is tilted. The height of two diaphragms has to be adjusted as
well. And, in polarizing mode, the analyzer has to be operated as
well. Quite a complicated movement. I fear this module may only be
useful for AMOR, but may be, other reflectometers may profit as well. 
This object implements this complex movement as a virtual motor. 

The following formulas are used for the necessary calculations:
\begin{eqnarray}
delta height & = & h_{s} - \sin \alpha \\
delta x      & = & |x_{c} - x_{s}| - R \cos \alpha \\
omega        & = & -2 MOM + 2 SOM \\
\end{eqnarray} 
with 
\begin{eqnarray}
h_{s} & = & \tan(2MOM)|x_{c} - x_{s}| \\
R & = & \sqrt{hs^{2} - |x_{c} - x_{s}|^{2}} \\
\alpha & = & ATT - 2SOM \\
\beta & = & 180 - 90 - 2MOM \\
MOM & = & polarizer \omega \\
SOM & = & sample \omega   \\
x_{c} & = & counter position \\
x_{s} & = & sample position\\
\end{eqnarray}
The same equations hold true for the calculations of the diaphragm
heights, just replace the distances. The equations for the analyzer
are not yet known. 

Due to this complicated movement this module needs to know about a lot
of motors and a lot of parameters. The distances of the various
components need to be modified at run time in order to allow for
configuration changes. These are not motorized but must be entered
manually. 

\subsubsection{Data Structures}
Consequently data structures are complex. The first data structure
used is an entry in an array of motors to start:
@d putput @{
   typedef struct {
                    pMotor pMot;
                    char pName[80];
                    float fTarget;
                  }MotEntry, *pMotEntry;
@}
\begin{description}
\item[pMot] is a pointer to the motors data structure.
\item[pName] is the name of the motor to start.
\item[fTarget] is the target value for the motor.
\end{description}

The next data structure is the class data structure for amor2t:
@d amoredata @{
  typedef struct __AMOR2T {
                            pObjectDescriptor pDes;
                            pIDrivable        pDriv;
                            pMotor            aEngine[MAXMOT];
                            MotEntry          toStart[MAXMOT];
                            int               iStart;
                            ObPar             *aParameter;
                          }Amor2T;
@} 
\begin{description}
\item[pDes] The standard SICS object descriptor.
\item[pDriv] The drivable interface. The functions defined for the
drivable interface implement most of the work of this class.
\item[aEngine] An array of pointers to the motor data structures this
class has to deal with. The proper initialization of this is taken
care of during the initialization of the object. 
\item[toStart] An array of motors to start when all calculations have
been performed.
\item[iStart] The number of valid entries in toStart.
\item[aParameter] An array of parameters for this object.
\end{description}

\subsubsection{The Interface}
The interface to this module is quite primitive. Most of the
functionality is hidden in the drivable interface. So there are only
functions for interacting with the interpreter.

@d amorinterface @{
   typedef struct __AMOR2T *pAmor2T;

   int Amor2TFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
                     int argc, char *argv[]);
   int Amor2TAction(SConnection *pCon, SicsInterp *pSics, void *pData,
                     int argc, char *argv[]);
   void Amor2TKill(void *pData);                 
@}

@o amor2t.i @{
/*--------------------------------------------------------------------------
                       A m o r 2 T . i
  Internal data structure definitions for Amor2T. For details see amor2t.tex.
  DO NOT TOUCH! This file is automatically created from amor2t.w.

  Mark Koennecke, September 1999
----------------------------------------------------------------------------*/

/* distance detector sample */
#define PARDS  0
/* constant height of sample: height = PARDH + MOTSOZ + MOTSTZ */
#define PARDH  1
/* distance diaphragm 4 - sample */
#define PARDD4 2
/* distance to diaphragm 5 */
#define PARDD5 3
/* interrupt to issue when a motor fails on this */
#define PARINT 4
/* base height of counter station */
#define PARDDH 5
/* height of D4 */
#define PARD4H 6
/* height of D5 */
#define PARD5H 7
/* base height of analyzer */
#define PARANA 8
/* distance of analyzer from sample */
#define PARADIS 9
/* flag analyzer calculation on/off */
#define ANAFLAG 10
/* constant for second detector */
#define PARDDD 11
/* constant part of AOM */
#define PARAOM 12

@<putput@>

@<amoredata@>

@}

@o amor2t.h @{
/*-------------------------------------------------------------------------
                     A m o r 2 T
 A class for controlling the two theta movement of a reflectometer. 
 Especially the AMOR reflectometer at SINQ. For details see the file 
 amor2t.tex. DO NOT TOUCH! This file is automatically created from amor2t.w
 with nuweb.

 Mark Koennecke, September 1999
---------------------------------------------------------------------------*/
#ifndef AMOR2T
#define AMOR2T
@<amorinterface@>
#endif 
@}

