\subsection{Monochromator}

The monochromator pseudomotor is implemented using a large collection
of MX records.  These records can be categorized into several groups:
\begin{itemize}
   \item The \MxInternalLink{monochromator}{monochromator}
	record with \textit{N} dependencies.
   \item \textit{N} \MxInternalLink{dependency_list}{dependency list} records.
   \item \textit{N} \MxInternalLink{dependency_enable}{dependency enable} records.
   \item \textit{N} \MxInternalLink{dependency_parameter}{
					dependency parameter} records.
   \item \textit{N} \MxInternalLink{dependency_record_list}{
					dependency record list} records.
   \item \textit{N} \MxInternalLink{dependency_type}{dependency type} records.
\end{itemize}
where the value of \textit{N} above is set by the value of the
\textit{num\_dependencies} field in the monochromator record.

\subsubsection{\MxInternalLabel{monochromator}{Monochromator Record}}

The \MxLink{motor.html}{MX Motor Driver Support}
page describes the common motor record description fields.
For the \textit{monochromator} driver, the following driver specific fields
are present:

\begin{tabular}{|c|c|c|c|p{50mm}|}
\hline
\MxTextFieldName & \MxTextFieldType & \MxTextNumDimensions
	& \MxTextSizes & \MxTextDescription \\
\hline
\multicolumn{5}{|c|}{\linkmotorfields} \\
\hline
\textit{num\_dependencies} & long & 0 & 0 &
	The number of dependencies for this monochromator pseudomotor.\\
\hline
\textit{list\_array} & record & 1 & \textit{num\_dependencies} &
	The list of depencency list records.\\
\hline
\end{tabular}

\textbf{Example:}
\begin{verbatim}
theta device motor monochromator "" "" 0 0 -10 270 0 -1 -1 1 0 deg 4 theta_list momega_list id_ev_list normal_list
\end{verbatim}

The monochromator record is a pseudomotor record which contains a list of
the dependencies used by the pseudomotor.  In general, one of the dependencies
will be a \textit{primary} dependency which describes the primary axis used by
the monochromator pseudomotor \textit{(usually theta)}.
The rest of the dependencies will be \textit{secondary} dependencies that 
describe motors that are to be moved to positions that depend on the
position of the primary dependency motor.  There should only be one
primary dependency.

In the example above, the dependencies specified are:
\begin{itemize}
  \item \textit{theta\_list} - This is the primary dependency
	and describes the dependence of the monochromator pseudomotor
	on the real theta axis of the monochromator.
  \item \textit{momega\_list} - A secondary dependency that controls the
	angle between the first and second monochromator crystal.
  \item \textit{id\_ev\_list} - A secondary dependency that controls the
	energy of the peak of the undulator spectrum for this beamline.
  \item \textit{normal\_list} - A secondary dependency that controls the
	perpendicular spacing between the first and second monochromator
	crystals.
\end{itemize}
This example does not include all of the available dependency types which
are described in more detail below.  In addition, the primary dependency
does not have to be the first record listed, but it is customary to do so.

\subsubsection{\MxInternalLabel{dependency_list}{Dependency List Records}}

An example dependency list record looks like
\begin{verbatim}
momega_list  variable inline record "" "" 1  4  momega_enabled momega_type momega_params momega_records
\end{verbatim}
Dependency list records must be four element 1-dimensional arrays of type
MXFT\_RECORD.  The individual elements of this array must be in the following
order:
\begin{itemize}
  \item \textit{Dependency enable record}
	- used to enable or disable the dependency.
	 (\textit{momega\_enabled} in the example above.)
  \item \textit{Dependency type record} - describes what type of dependency this is.
	 (\textit{momega\_type} in the example above.)
  \item \textit{Dependency parameters record} - describes the parameters used
	by this dependency.
	 (\textit{momega\_params} in the example above.)
  \item \textit{Dependency record list} - describes the records used
	by this dependency.
	 (\textit{momega\_records} in the example above.)
\end{itemize}
The individual elements of the array are described in more detail below.

\subsubsection{\MxInternalLabel{dependency_enable}{Dependency Enable Records}}

An example dependency enable record looks like
\begin{verbatim}
momega_enabled variable net_variable net_int "" "" localhost momega_enabled.value 1  1  0
\end{verbatim}
The dependency enable record must be a variable record of type MXFT\_INT.
It has two legal values:
\begin{itemize}
  \item \textit{1} - The dependency is enabled and the dependent motor(s)
	will be moved to positions that correspond to the position
	of the primary dependency.
  \item \textit{0} - The dependency is disabled and the dependent motor(s) will
	not be moved.
\end{itemize}

\subsubsection{\MxInternalLabel{dependency_parameter}{Dependency Parameter Records}}

An example dependency parameters record looks like
\begin{verbatim}
momega_params variable net_variable net_double "" "" localhost momega_params.value 1 4 0 0 0 0
\end{verbatim}
The dependency parameters record will be a 1-dimensional variable record
of some kind.  The particular variable type used will depend on the
dependency type as described below.  In the example above, the parameters
record is a 1-dimensional array of integers that are all initialized to 0.

\subsubsection{\MxInternalLabel{dependency_record_list}{Dependency Record List Records}}

An example dependency record list looks like
\begin{verbatim}
momega_records variable inline record "" "" 1 1 momega
\end{verbatim}
The dependency record list record will be a 1-dimensional variable record
of type MXFT\_RECORD.  The number and identity of the listed records will
depend on the dependency type as described below.  In the example above,
the record list array contains only the record \textit{momega}.

\subsubsection{\MxInternalLabel{dependency_type}{Dependency Type Records}}

An example dependency type record looks like
\begin{verbatim}
momega_type variable inline int "" "" 1 1 2
\end{verbatim}
The dependency type record will be 1-dimensional variable record of type
MXFT\_INT with only one element, namely, the dependency type.  In the example
above, the dependency type is 2.


At present, nine different dependency types are available.
Dependency types 0 and 1 are \textit{primary} dependency types, while
types 2 through 8 are \textit{secondary} dependency types.
\subsubsection{Type 0 - Theta dependency}

The theta dependency is used to control the position of the primary theta axis.
This dependency is normally the \textit{primary} dependency for the monochromator
pseudomotor.  If this dependency does not exist or is disabled, the real theta
axis will not be moved at all.
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array with only
	one element, specifically, the name of the
	\textit{real} theta motor record.
  \item \textbf{Parameters record} - This record must be present, but its
	contents are not used by this dependency.  Typically, a dummy variable
	will be used here as in the example below.
\end{itemize}
An example set of records for the theta dependency looks like
\begin{verbatim}
theta_list    variable inline record "" "" 1  4  theta_enabled theta_type dummy_params theta_records
theta_type    variable inline int    "" "" 1  1  0
theta_enabled variable inline int    "" "" 1  1  1
theta_records variable inline record "" "" 1  1  theta_real
dummy_params  variable inline double "" "" 1  1  0
\end{verbatim}

Normally, there is no reason for the users to disable this dependency, so it
is standard to hard code it to 1 as in the example above.

\subsubsection{Type 1 - Energy dependency}

The energy dependency is a \textit{primary} dependency that computes the
monochromator theta angle from a monochromator energy provided by a
foreign beamline control system.  Use of this dependency is
\textbf{not recommended}, unless the underlying beamline control 
software/hardware does not provide a direct way of querying and
controlling the theta angle.  Use of this dependency is
\textbf{incompatible} with the type 0 theta dependency specified above.
Do not specify both of them in the same MX database.

If you are looking for a way to control a \textit{dependent} motor as a
polynomial function of energy, you should be using the type 8
\textit{energy polynomial} dependency described below.
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array of type
	MXFT\_RECORD containing two elements:
	\begin{itemize}
	  \item \textit{energy record} - This motor record queries and controls the
		monochromator energy.
	  \item \textit{monochromator d spacing record} - This is a
		variable record that contains the d spacing of the 
		monochromator crystal in angstroms.
	\end{itemize}
  \item \textbf{Parameters record} - This record must be present, but its
	contents are not used by this dependency.  Typically, a dummy variable
	will be used here as in the example below.
\end{itemize}

An example set of records for the energy dependency looks like
\begin{verbatim}
energy_list    variable inline record        "" "" 1  4  energy_enabled energy_type dummy_params energy_records
energy_type    variable inline int           "" "" 1  1  1
energy_enabled variable net_variable net_int "" "" 1  1  1
energy_records variable inline record        "" "" 1  2  energy d_spacing
dummy_params   variable inline double        "" "" 1  1  0
\end{verbatim}
A corresponding d spacing variable would look like
\begin{verbatim}
d_spacing variable net_variable net_double "" "" localhost d_spacing.value 1  1  3.1355
\end{verbatim}

The monochromator theta angle is computed using the standard Bragg equation

theta = asin( 12398.5 / ( 2.0 * d\_spacing * energy ) )

Normally, there is no reason for the users to disable this dependency, so it
is standard to hard code it to 1 as in the example above.

\subsubsection{Type 2 - Polynomial dependency}

This dependency type is a \textit{secondary} dependency that allows a dependent
motor to be moved to positions that are a polynomial function of the
theta position of the monochromator.  The computed position will be of
the form

dependent\_position = c0 + c1 * theta + c2 * (theta**2) + c3 * (theta**3) + ...

Beamline staff may configure this polynomial to have as few or as many terms
in it as they want by changing the number of elements in the parameters
array below.  For example, a parameters array record with only two array
elements will describe a dependent position that has a linear dependence
on theta, while a parameters array record with four array elements describes
a cubic dependence on theta.  It is generally not useful to use a polynomial
of higher order than cubic, although there is no limit in the record as
to how high the order may be.
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array with only
	one element, specifically, the name of the dependent motor record.
  \item \textbf{Parameters record} - This is a 1-dimensional array of type
	MXFT\_DOUBLE which contains the coefficients of the polynomial.
	The coefficients are specified in order starting with the constant
	term and continuing up to the coefficient of the highest order term.
\end{itemize}
An example set of records for the polynomial dependency looks like
\begin{verbatim}
momega_list    variable inline record           "" "" 1  4  momega_enabled momega_type momega_params momega_records
momega_type    variable inline int              "" "" 1  1  2
momega_enabled variable net_variable net_int    "" "" localhost momega_enabled.value 1  1  0
momega_records variable inline record           "" "" 1  1  momega
momega_params  variable net_variable net_double "" "" localhost momega_params.value  1  4  0 0 0 0
\end{verbatim}
In the example above, \textit{momega\_params} is a cubic polynomial.  If the
value of \textit{momega\_params} at some particular time was set to 
something like ( 0.32, 0.41, -0.02, 0.015 ), the computed polynomial
would have the form

momega = 0.32 + 0.41 * theta - 0.02 * (theta**2) + 0.015 * (theta**3)

Typically, the values of these coefficients will be determined by 
measuring the location of the peak X-ray intensity as a function of
the dependent motor position for several values of theta
Then a curve will be fitted to the measurements.

\subsubsection{Type 3 - Insertion device energy dependency}

This dependency type is a \textit{secondary} dependency that changes the
energy of the undulator peak such that the maximum of the undulator spectrum
is at the same energy as the monochromator.

\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array of type
	MXFT\_RECORD containing two elements:
	\begin{itemize}
	  \item \textit{insertion device motor record} - This is a motor
		record that controls the position of the undulator peak
		in units of eV.
	  \item \textit{monochromator d spacing record} - This is a
		variable record that contains the d spacing of the 
		monochromator crystal in angstroms.
	\end{itemize}
  \item \textbf{Parameters record} - This is a 1-dimensional array
	of type MXFT\_DOUBLE which contains two elements:
	\begin{itemize}
	  \item \textit{gap harmonic} - This is the requested undulator
		harmonic number and should be a positive odd integer
		such as 1, 3, 5, etc.  This is usually set to 1.
	  \item \textit{gap offset} - This is an offset to be added to the
		computed gap energy.
	\end{itemize}
\end{itemize}

For a given monochromator \textit{theta} position in degrees,
the undulator energy is computed as follows:

mono\_energy = 12398.5 / ( 2.0 * d\_spacing * sin( theta ) )

undulator\_energy = ( mono\_energy + gap\_offset ) / gap\_harmonic

Please note that if the undulator controls provided by your storage ring
\textit{also} have a way of setting the gap harmonic in addition to the
method provided by MX, then you should only set one of them to the 
harmonic number and set the other to 1.  For example, at the APS, if
you set both EPICS's variable for the gap harmonic to 3 \textit{and}
MX's variable for the gap harmonic to 3, you would actually end up
with the ninth harmonic.

An example set of records for the insertion device energy dependency looks like
\begin{verbatim}
id_ev_list    variable inline record           "" "" 1  4  id_ev_enabled id_ev_type id_ev_params id_ev_records
id_ev_type    variable inline int              "" "" 1  1  3
id_ev_enabled variable net_variable net_int    "" "" localhost id_ev_enabled.value 1  1  0
id_ev_records variable inline record           "" "" 1  2  id_ev d_spacing
id_ev_params  variable net_variable net_double "" "" localhost id_ev_params.value 1  2  1 100
\end{verbatim}
\subsubsection{Type 4 - Constant exit Bragg normal dependency}

This dependency type is a \textit{secondary} dependency that changes the
perpendicular spacing between the first and second monochromator crystals
so that the
X-ray beam exiting the monochromator stays at a constant height.
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array of type
	MXFT\_RECORD containing two elements:
	\begin{itemize}
	  \item \textit{normal record} - This motor record controls the
		perpendicular spacing between the two monochromators crystals.
	  \item \textit{beam offset record} - This is a variable record of type
		MXFT\_DOUBLE that contains the desired fixed offset distance
		of the beam expressed in the same units as 
		the \textit{normal} motor.
	\end{itemize}
  \item \textbf{Parameters record} - This record must be present, but its
	contents are not used by this dependency.  Typically, a dummy variable
	will be used here as in the example below.
\end{itemize}

An example set of records for the Bragg normal dependency looks like
\begin{verbatim}
normal_list    variable inline record        "" "" 1  4  normal_enabled normal_type dummy_params normal_records
normal_type    variable inline int           "" "" 1  1  4
normal_enabled variable net_variable net_int "" "" localhost normal_enabled.value 1  1  0
normal_records variable inline record        "" "" 1  2  normal beam_offset
dummy_params   variable inline double        "" "" 1  1  0
\end{verbatim}
A corresponding beam offset variable would look like
\begin{verbatim}
beam_offset variable net_variable net_double "" "" localhost beam_offset.value 1  1  -35000
\end{verbatim}
The Bragg normal position is computed from the beam offset and the
monochromator theta angle via the equation

bragg\_normal = beam\_offset / ( 2.0 * cos( theta ) )

If a positive move of the normal motor at theta = 0
is in the opposite direction from
the desired beam offset, then the value of the beam offset must be set to
a negative number.  For example, this is true of the MX installations
at APS sectors 10 and 17 where beam\_offset = -35000 um.

\subsubsection{Type 5 - Constant exit Bragg parallel dependency dependency}

This dependency type is a \textit{secondary} dependency that translates
the second crystal parallel to its surface.  This dependency should
normally be used in combination with the Bragg normal dependency listed
above.  It is used to ensure that the X-ray beam does not fall off the
end of the second crystal.
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array of type
	MXFT\_RECORD containing two elements:
	\begin{itemize}
	  \item \textit{parallel record} - This motor record controls the
		translated position of the second crystal.
	  \item \textit{beam offset record} - This is a variable record of type
		MXFT\_DOUBLE that contains the desired fixed offset distance
		of the beam expressed in the same units as 
		the \textit{normal} motor.
	\end{itemize}
  \item \textbf{Parameters record} - This record must be present, but its
	contents are not used by this dependency.  Typically, a dummy variable
	will be used here as in the example below.
\end{itemize}

An example set of records for the Bragg parallel dependency looks like
\begin{verbatim}
parallel_list    variable inline record        "" "" 1  4  parallel_enabled parallel_type dummy_params parallel_records
parallel_type    variable inline int           "" "" 1  1  5
parallel_enabled variable net_variable net_int "" "" localhost parallel_enabled.value 1  1  0
parallel_records variable inline record        "" "" 1  2  parallel beam_offset
dummy_params     variable inline double        "" "" 1  1  0
\end{verbatim}
A corresponding beam offset variable would look like
\begin{verbatim}
beam_offset variable net_variable net_double "" "" localhost beam_offset.value 1  1  -35000
\end{verbatim}
If used in combination with a Bragg normal dependency, the two dependencies
should use the same MX variable to control the beam offset.

The Bragg parallel position is computed from the beam offset and the
monochromator theta angle via the equation

bragg\_parallel = beam\_offset / ( 2.0 * sin( theta ) )

\subsubsection{Type 6 - Experiment table height dependency}

If a given monochromator does not support fixed exit beam operation, an
alternate way to ensure that the X-ray beam hits the desired target is
to put the experiment on a table that can be vertically translated to
track the beam.
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array of type
	MXFT\_RECORD containing three elements:
	\begin{itemize}
	  \item \textit{table height record} - This motor record controls the
		vertical height of the experiment table.
	  \item \textit{table offset record} - This is a variable record of
		type MXFT\_DOUBLE that provides a way of adding a 
		constant offset to the computed table height.
	  \item \textit{crystal separation record} - This is a variable record of
		type MXFT\_DOUBLE that contains the perpendicular
		crystal separation distance expressed in the same units as 
		the \textit{table height} motor.
	\end{itemize}
  \item \textbf{Parameters record} - This record must be present, but its
	contents are not used by this dependency.  Typically, a dummy variable
	will be used here as in the example below.
\end{itemize}

An example set of records for the experiment table height dependency looks like
\begin{verbatim}
theight_list    variable inline record        "" "" 1  4  theight_enabled theight_type dummy_params theight_records
theight_type    variable inline int           "" "" 1  1  6
theight_enabled variable net_variable net_int "" "" localhost theight_enabled.value 1  1  0
theight_records variable inline record        "" "" 1  3  theight toffset crystal_sep
dummy_params    variable inline double        "" "" 1  1  0
\end{verbatim}
A corresponding pair of variables would look like
\begin{verbatim}
toffset     variable net_variable net_double "" "" localhost toffset.value 1  1  0
crystal_sep variable net_variable net_double "" "" localhost crystal_sep.value 1  1  5000
\end{verbatim}

The experiment table height position is computed via the equation

table\_height = table\_offset + 2.0 * crystal\_separation * cos( theta )

\subsubsection{Type 7 - Diffractometer theta dependency}

The diffractometer theta dependency is used to control the Bragg angle of
a diffractometer or goniostat in the experimental hutch so that it is set
to the correct angle to diffract the X-ray beam coming from the monochromator.
This dependency assumes that, in general, the crystal on the diffractometer
will have a different d spacing than that of the monochromator crystal.

If the diffractometer angle is called \textit{htheta} and the diffractometer
d spacing is called \textit{hd\_spacing}, the diffractometer angle is computed
by the equation

sin(htheta) = d\_spacing * sin(theta) / hd\_spacing

The raw value of \textit{htheta} is adjusted using a linear equation
of the form

htheta\_adjusted = diffractometer\_scale * htheta + diffractometer\_offset
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array of type
	MXFT\_RECORD containing three elements:
	\begin{itemize}
	  \item \textit{diffractometer theta motor record} - This the a motor
		record that controls the diffractometer theta angle.
	  \item \textit{monochromator d spacing record} - This is a
		variable record that contains the d spacing of the 
		monochromator crystal in angstroms.
	  \item \textit{diffractometer d spacing record} - This is a
		variable record that contains the d spacing of the 
		diffractometer crystal in angstroms.
	\end{itemize}
  \item \textbf{Parameters record} - This is a 1-dimensional array
	of type MXFT\_DOUBLE which contains two elements which are
	used to compute the adjusted diffractometer angle:
	\begin{itemize}
	  \item \textit{diffractometer scale}
	  \item \textit{diffractometer offset}
	\end{itemize}
\end{itemize}
An example set of records for the diffractometer theta dependency looks like
\begin{verbatim}
htheta_list     variable inline record           "" "" 1 4 htheta_enabled htheta_type htheta_params htheta_records
htheta_type     variable inline int              "" "" 1 1 7
htheta_enabled  variable net_variable net_int    "" "" localhost htheta_enabled.value 1  1  0
htheta_records  variable inline record           "" "" 1 3 htheta d_spacing hd_spacing
htheta_params   variable net_variable net_double "" "" localhost htheta_params.value 1  2  0 0
\end{verbatim}

\subsubsection{Type 8 - Energy polynomial dependency}

The energy polynomial dependency is similar to the type 2 polynomial dependency
described above, except the dependent motor position is a polynomial function
of the monochromator X-ray energy.  Thus, the dependent position will
have the form

dependent\_position = c0 + c1 * energy + c2 * (energy**2) + c3 * (energy**3) + ...

This dependency assumes that the energy is expressed in eV.
\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array containing
	two elements:
	\begin{itemize}
	  \item \textit{dependent motor record} - This motor record controls the
		dependent motor whose position is determined by the
		energy polynomial.
	  \item \textit{monochromator d spacing record} - This is a
		variable record that contains the d spacing of the 
		monochromator crystal in angstroms.  This record
		is used to convert the theta angle in degrees to 
		energy in eV.
	\end{itemize}
  \item \textbf{Parameters record} - This is a 1-dimensional array of type
	MXFT\_DOUBLE which contains the coefficients of the polynomial.
	The coefficients are specified in order starting with the constant
	term and continuing up to the coefficient of the highest order term.
\end{itemize}

An example set of records for the energy polynomial dependency looks like
\begin{verbatim}
focus_list     variable inline record           "" "" 1 4 focus_enabled focus_type focus_params focus_records
focus_type     variable inline int              "" "" 1 1 8
focus_enabled  variable net_variable net_int    "" "" localhost focus_enabled.value 1  1  0
focus_records  variable inline record           "" "" 1 2 focus d_spacing
focus_params   variable net_variable net_double "" "" localhost focus_params.value 1  4  0 0 0 0
\end{verbatim}

\subsubsection{Type 9 - Option selector dependency}

The option selector dependency is used together with a ``position\_select''
calculation record to switch an external value between multiple settings
depending on the current value of the monochromator theta position.
The ``position\_select'' variable has an integer value from 1 to N.
For example, this could be used to automatically switch between mirror stripes
at certain X-ray energies.

\begin{itemize}
  \item \textbf{Record list record} - This is a 1-dimensional array of type
	MXFT\_RECORD containing two elements:
	\begin{itemize}
	  \item \textit{option selector record} - This should be a calculation
	  	variable record of type ``position\_select'' that controls
		the external value and contains a list of allowed values for
		the external value.
	  \item \textit{option range record} - This is the name of the 
	  	parameters record below.
	\end{itemize}
  \item \textbf{Parameters record} - This is a 2-dimensional Nx2 array
	of type MXFT\_DOUBLE which contains pairs of elements
	that describe the limits for each allowed theta range.
	The two values for each theta range are
	\begin{itemize}
	  \item \textit{theta range lower limit}
	  \item \textit{theta range upper limit}
	\end{itemize}
	The number N is the number of theta ranges.
\end{itemize}

An example set of records for the option selector dependency looks like
\begin{verbatim}
stripe_list    variable inline record "" "" 1  4  stripe_enabled stripe_type dummy_params stripe_records
stripe_type    variable inline int "" "" 1  1  9
stripe_enabled variable inline int "" "" 1  1  1
stripe_records variable inline record "" "" 1  2  stripe_select stripe_params
stripe_params  variable inline double "" "" 2  4  2  0 5  4.5 8.5  8 11  10.5 15
stripe_select  variable calc position_select "" "" stripe 4 300 600 900 1200 1 1 -1
stripe         device motor soft_motor "" "" 0 0 -1000000000 1000000000 0 -1 -1 0.01 0 um 100000 0 50000
\end{verbatim}

The example above is for an X-ray mirror whose transverse position is
determined by a motor record called \textit{stripe}.  There are 4 allowed
positions for \textit{stripe}, namely, 300, 600, 900, and 1200.
The allowed \textit{theta} ranges corresponding to the allowed positions
are 0 to 5 degrees, 4.5 to 8.5 degrees, 8 to 11 degrees, and 10.5 to 15 degrees.
The \textit{stripe} position to be selected is determined by comparing the
current position of \textit{theta} to the parameter ranges in the variable
\textit{stripe\_params}.  According to \textit{stripe\_params},
the \textit{stripe} motor is allowed to be at 300 if \textit{theta} is 
between 0 and 5, or it is allowed to be at 600 if \textit{theta}
is between 4.5 and 8.5, and so forth.  If \textit{theta} moves outside
the allowed range of positions for the current selection, the option
selector will switch to the next selection.

Notice that the allowed ranges for \textit{theta} overlap.  This is to
provide a deadband for switches between option selector ranges.  As an example,
suppose \textit{theta} is currently at 7 degrees.  This means that
\textit{theta} is within the second option selector range of 4.5 to 8.5 degrees
and that the \textit{stripe} motor should currently be at 600.  However,
if \textit{theta} is moved to 9 degrees, this is outside the current option
selector range, so \textit{stripe} will be moved to the next allowed position
of 900.  However, the lower end of the new range, namely, 8 degrees, is below
the upper end of the original range, namely, 8.5 degrees.  This means that
\textit{theta} must be moved below 8 degrees before the \textit{stripe}
position will be moved back to the previous value of 600.

Note that if \textit{theta} is below 0 degrees, the \textit{stripe} motor
will be sent to 300, while if \textit{theta} is above 15 degrees, the
\textit{stripe} motor will be moved to 1200.

\subsubsection{Bugs}
The MX database for the monochromator pseudomotor system has turned out
to be much more complex to set up than I had originally wanted.  It is
my intention to revise this pseudomotor to be easier to configure, but I
have no time estimate as to when that will happen.

Some of the dependencies are user configurable via the parameters record
while others are configured via additional records added to the record list.

