\subsection{AMOR Reflectometer Settings}
This is yet another module for calculating the settings for the AMOR
 spectrometer. This version is of 2005 and implements the new calculation 
 scheme as devised by the Jochen where the base line and height zero point 
 is the beam height at the chop, chop, chopper. 
 
 Again a lot of parameters have to be maintained. For each optical bench 
 component an active flag, a fixed offset for correcting the scale reading to
 the actual position and an offset regarding the zero point of the scale need
  to be kept. And of course the value as read. This is offloaded into a
  separate module, amorcomp. Beamline components to be controlled are:
 \begin{description}
 \item[DS] The slit at the monochromator bunker
 \item[M] The monochromator
 \item[Dx] various slits
 \item[A] the analyzer
 \item[D] the detector.
 \end{description} 
  
  A master module encloses all those beamline components and performs the 
  actual calculation. The calculation is controlled through three virtual 
  motors: m2t (monochromator 2 theta), s2t (sample 2 theta) and ath, the
  analyzer angle.  For the formula used for the exact calculation, see the 
  paper from the Jochen.
  
  
 The amorcomp module provides the following interface:
 \begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
$\langle$amorcompint {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ typedef struct {@\\
\mbox{}\verb@        int activeFlag;  /* component present */@\\
\mbox{}\verb@        double markOffset; /* offset mark to real */@\\
\mbox{}\verb@        double scaleOffset; /* offset of the scale */@\\
\mbox{}\verb@        double readPosition; /* the position as read */@\\
\mbox{}\verb@} amorComp, *pamorComp;@\\
\mbox{}\verb@/*----------------------------------------------------------------------*/@\\
\mbox{}\verb@double calcCompPosition(pamorComp comp);                @\\
\mbox{}\verb@int handleCompCommand(pamorComp comp, SConnection *pCon, @\\
\mbox{}\verb@        int argc, char *argv[]);@\\
\mbox{}\verb@int saveAmorComp(FILE *fd, char *name, char *compname, pamorComp comp);                 @\\
\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 amorset module implements the container for all the data and the actual
 calculation. Most of the interesting stuff is in the functions relating to
  the interpreter interface and the drivable interface.  Again the virtual 
  motors only set values in the amorset data structure and amorset then takes 
  control off the driving operation. 
  
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
$\langle$amorsetint {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@typedef struct {@\\
\mbox{}\verb@        pObjectDescriptor pDes;@\\
\mbox{}\verb@        pIDrivable pDriv;@\\
\mbox{}\verb@        pIDrivable listDrive;@\\
\mbox{}\verb@        amorComp chopper;@\\
\mbox{}\verb@        amorComp M;@\\
\mbox{}\verb@        amorComp DS;@\\
\mbox{}\verb@        amorComp D1;@\\
\mbox{}\verb@        amorComp D2;@\\
\mbox{}\verb@        amorComp D3;@\\
\mbox{}\verb@        amorComp S;@\\
\mbox{}\verb@        amorComp D4;@\\
\mbox{}\verb@        amorComp A;@\\
\mbox{}\verb@        amorComp D5;@\\
\mbox{}\verb@        amorComp D;@\\
\mbox{}\verb@        double targetm2t;@\\
\mbox{}\verb@        double targets2t;@\\
\mbox{}\verb@        double targetath;@\\
\mbox{}\verb@        double actualm2t;@\\
\mbox{}\verb@        double actuals2t;@\\
\mbox{}\verb@        double actualath;@\\
\mbox{}\verb@        int mustDrive;@\\
\mbox{}\verb@        int mustRecalculate;@\\
\mbox{}\verb@        int driveList;@\\
\mbox{}\verb@        double dspar;@\\
\mbox{}\verb@        double detectoroffset;@\\
\mbox{}\verb@        int verbose;@\\
\mbox{}\verb@}amorSet, *pamorSet;@\\
\mbox{}\verb@/*--------------------------------------------------------------------*/@\\
\mbox{}\verb@int AmorSetFactory(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@                                        int argc, char *argv[]);@\\
\mbox{}\verb@int AmorSetAction(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@                                        int argc, char *argv[]);@\\
\mbox{}\verb@/*============ helper functions for the virtual motors ===============*/                                        @\\
\mbox{}\verb@void amorSetMotor(pamorSet amor, int type, double value);@\\
\mbox{}\verb@double amorGetMotor(pamorSet amor, SConnection *pCon, int type);@\\
\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 virtual motors just implement the bare minimum:
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap3}
$\langle$amordriveint {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@typedef struct{@\\
\mbox{}\verb@        pObjectDescriptor pDes;@\\
\mbox{}\verb@        pIDrivable pDriv;@\\
\mbox{}\verb@        pamorSet mama;@\\
\mbox{}\verb@        int type;@\\
\mbox{}\verb@} amorDrive, *pamorDrive;@\\
\mbox{}\verb@/*-----------------------------------------------------------------*/@\\
\mbox{}\verb@pamorDrive makeAmorDrive(pamorSet papa, int type);@\\
\mbox{}\verb@void killAmorDrive(void *data);@\\
\mbox{}\verb@int AmorDriveAction(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@                                        int argc, char *argv[]);@\\
\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{scrap4}
\verb@"amorset.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*-------------------------------------------------------------------@\\
\mbox{}\verb@ AMORSET together with  amorcomp and amordrive implement the position@\\
\mbox{}\verb@ control facility for the reflectometer AMOR. This uses the algorithm@\\
\mbox{}\verb@ with the beam height as the baseline.@\\
\mbox{}\verb@ @\\
\mbox{}\verb@ copyright: see file COPYRIGHT@\\
\mbox{}\verb@ @\\
\mbox{}\verb@ Mark Koennecke, October 2005@\\
\mbox{}\verb@--------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef AMORSET@\\
\mbox{}\verb@#define AMORSET@\\
\mbox{}\verb@#include "amorcomp.h"@\\
\mbox{}\verb@@$\langle$amorsetint {\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{scrap5}
\verb@"amorcomp.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*---------------------------------------------------------------------@\\
\mbox{}\verb@ AMOR component handling module. For the new (2005) calculation of the@\\
\mbox{}\verb@ positions using the beam height as zero.@\\
\mbox{}\verb@ @\\
\mbox{}\verb@ copyright: see file COPYRIGHT@\\
\mbox{}\verb@ @\\
\mbox{}\verb@ Mark Koennecke, October  2005@\\
\mbox{}\verb@-----------------------------------------------------------------------*/@\\
\mbox{}\verb@ #ifndef AMORCOMP@\\
\mbox{}\verb@ #define AMORCOMP@\\
\mbox{}\verb@ #include <stdio.h>@\\
\mbox{}\verb@ #include <sics.h>@\\
\mbox{}\verb@ @$\langle$amorcompint {\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{scrap6}
\verb@"amordrive.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ /*--------------------------------------------------------------------@\\
\mbox{}\verb@  Part of the AMOR position calculation module.@\\
\mbox{}\verb@@\\
\mbox{}\verb@  copyright: see file COPYRIGHT@\\
\mbox{}\verb@@\\
\mbox{}\verb@  Mark Koennecke, October 2005@\\
\mbox{}\verb@----------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef AMORDRIVE@\\
\mbox{}\verb@#define AMORDRIVE@\\
\mbox{}\verb@@$\langle$amordriveint {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@\\
\mbox{}\verb@ @$\diamond$
\end{list}
\vspace{-2ex}
\end{minipage}\\[4ex]
\end{flushleft}
