\subsection{Mar Desktop Beamline}
\textit{Platforms: All}

\ \newline
The MarDTB DeskTop Beamline is an advanced goniostat for computer-controlled
data collection from Rayonix (formerly MarUSA).  Their web site can be found at 
\MxLink{http://www.rayonix.com/}{http://www.rayonix.com/}.

The MarDTB system contains a variety of computer-controlled motors,
ion chamber readouts, and a shutter.  They are intended to be used
only by Rayonix-supplied software, so the interfaces for talking 
to them are almost completely undocumented.  However, by leveraging
what limited documentation exists and by reverse engineering some
information, I have been able to figure out how to talk to them
anyway.

Before continuing, I want to say one thing:

\begin{center}
\textbf{DO NOT ASK RAYONIX ANY QUESTIONS ABOUT THESE MX DRIVERS.}
\end{center}
%
%\ \newline
If you have questions, contact the author (William Lavender) for help.

Since these interfaces are undocumented, it is possible that changes
to the Rayonix software can break these MX drivers.  In fact, there
have been occasions in the past where Rayonix changes 
\textit{\textbf{have}}
broken these MX drivers.  Furthermore, I have not had a chance to test
the correctness of these drivers since 2007, so it is quite possible,
indeed likely, that the drivers do not work correctly with current
versions of Rayonix firmware.  
%
\textbf{In fact, it is possible that using
these drivers can break your MarDTB system.}
%
If it does, then I doubt that Rayonix will regard this as covered
by their warranty.  So, if you have any qualms or doubts, do not
use these drivers.

Having said all of that, here are the drivers that are available.
\newline\newline
\begin{tabular}{lp{12.0cm}}
  \textit{mardtb} & An interface driver for the MarDTB controller
	as a whole. \\
  \textit{mardtb\_motor} & A motor driver for controlling individual
	MarDTB motors. \\
  \textit{mardtb\_status} & Used for reading out various bits
	of status information from the MarDTB. \\
  \textit{mardtb\_shutter} & Controls the MarDTB shutter. \\
\end{tabular}

\ \newline\newline
\textbf{mardtb} driver

	The \textit{mardtb} driver communicates with the MarDTB control
	computer via a TCP socket using the \textit{tcp232} driver.
	Although the port number is the Telnet port number (23), it
	appears that the MarDTB operating system does not send any Telnet
	negotiation sequences, so using the \textit{tcp232} driver worked.
	If this no longer works, then using the \textit{telnet} MX driver
	may help.

	The driver specific fields are
	\newline
	%
	\newcommand{\MxFieldMardtbRsCDCZrecord}
	{This is the name of the \textit{tcp232} record used
	to communicate with the MarDTB.}
	%
	\newcommand{\MxFieldMardtbUsername}
	{This is the username used to login to the MarDTB.
	As far as I know, this must always be \textit{esd}.}
	%
	\newcommand{\MxFieldMardtbMardtbZflags}
	{The flag values are described below.}
	%
	\MxMardtbDriverFields

	\ \newline
	Flag values for the \textit{mardtb\_flags} field.
	\newline
	\begin{tabularx}{0.95\textwidth}{rcX}
	  0x1000 & - & Three parameter status dump.  Needed by very old
		MarDTB systems, as in, long before 2005.
		Probably you will not need this.\\
	\end{tabularx}
	%
	\newline
	Other flag values exist, but are not documented since they
	\textit{do not work!}  Don't try them.

\ \newline
\textbf{mardtb\_motor} driver

	The \textit{mardtb\_motor} driver moves one of the motors on
	the MarDTB system.  It may not be safe to move some of these
	motors, so be really careful with this one!
	
	The driver specific fields are
	\newline\newline
	%
	\newcommand{\MxFieldMardtbZmotorMardtbZrecord}
	{This is the name of the controller record for the MarDTB.}
	%
	\newcommand{\MxFieldMardtbZmotorMotorZnumber}
	{The MarDTB motor number for this motor.}
	%
	\newcommand{\MxFieldMardtbZmotorDefaultZspeed}
	{The default speed for this motor.  Reasonable values for this
	speed are not documented by Rayonix.}
	%
	\newcommand{\MxFieldMardtbZmotorDefaultZacceleration}
	{The default acceleration for this motor.  Reasonable values for this
	acceleration are not documented by Rayonix.}
	%
	\MxMardtbZmotorDriverFields

\ \newline
\textbf{mardtb\_status} driver

	This driver reads one of the internal status values from the MarDTB.

	The driver specific fields are:
	\newline\newline
	%
	\newcommand{\MxFieldMardtbZstatusMardtbZrecord}
	{This is the name of the controller record for the MarDTB.}
	%
	\newcommand{\MxFieldMardtbZstatusParameterZnumber}
	{The MarDTB parameter number for this status variable.}
	%
	\MxMardtbZstatusDriverFields

	The meaning of most of the status values is unknown.  However,
	it is known that 136 and 137 return the values from the two
	ion chambers of the MarDTB, while 138 returns the value from
	an internal MarDTB clock.

\ \newline
\textbf{mardtb\_shutter} driver

	This driver controls the MarDTB shutter.

	The driver specific fields are:
	\newline\newline
	%
	\newcommand{\MxFieldMardtbZshutterMardtbZrecord}
	{This is the name of the controller record for the MarDTB.}
	%
	\MxMardtbZshutterDriverFields
%
\newline

Here is an example database for the MarDTB:
\begin{verbatim}
mardtb_rs232 interface rs232 tcp232 "" "" 38400 8 N 1 H 0x0d0a 0x0d0a -1 0x0 192.0.2.3 23 0x0
mardtb  interface controller mardtb "" "" mardtb_rs232 esd 0x0
phi device motor mardtb_motor "" "" 0 0 -1000000 1000000 0 -1 -1 -0.00125 0 deg mardtb 6 10000 1000
p136  device analog_input mardtb_status "" "" 0 1 0 units 0x0 0 "" mardtb 136
p137  device analog_input mardtb_status "" "" 0 1 0 units 0x0 0 "" mardtb 137
clock device analog_input mardtb_status "" "" 0 1 0 units 0x0 0 "" mardtb 138
shutter device relay mardtb_shutter "" "" mardtb
\end{verbatim}

