[user/user-app-mbs.tex]
\label{user-app-mbs-chapter}
\lsection[MBS event building with DABC]{user:mbsapp}{\mbs\ event building with \dabc}
In this case one \dabc\ node reads data from several
\mbs\ nodes via {\em Transport} socket connections, and combines them
into one \mbs\ output event.
To run \mbs\ front-ends with \dabc\ nodes as event builders some
modifications of the \mbs\ setup files must be done.
For the \dabc\ side setup files must be provided.
\subsection[MBS setup]{\mbs\ setup}
When we want to use \dabc\ nodes as event builders, we need a different
setup on the \mbs\ side. We assume that we have more than one
\mbs\ node. Such a multi-node system is controlled by an \mbs\ prompter running on one node.
\bbul
\item The setup has to be changed such that all nodes run as if they are stand alone
(this is done typically by setting \keyw{COL\_MODE} to 0 in the usf setup file).
That means that each node must run the \keyw{Readout} - \keyw{Collector} -
\keyw{Transport} - \keyw{Daq\_rate}
chain. The \dabc\ event builders connect to the transports.
\item The \mbs\ buffer size should be set to the stream size and the number of buffers per
stream must be set to one.
\ebul
\subsection[DABC setup]{\dabc\ setup}
On the \dabc\ user working directory we need configuration files.
Summary of parameters:
\bdes
\item[MbsFileName] File name for list mode data file (\keyw{LMD}). Overwritten by command.
\item[MbsFileSizeLimit] File closes when size is reached, and new file opens.
\item[BufferSize] Should match \mbs\ buffer size.
\item[MbsServerKind] \keyw{Transport} | \keyw{Stream}.
\item[MbsServerPort] Port number transport (6000).
\item[MbsServerName] \mbs\ node of transport.
\item[NumInputs] Number of \mbs\ channels for one combiner.
\item[DoFile] Provide output file.
\item[DoServer] Provide server.
\edes
These parameters are used to configure an optional event generator:
\bdes
\item[NumSubevents]
\item[FirstProcId]
\item[SubeventSize]
\item[Go4Random]
\edes
\index{TODO!dabcsetupfiles}
The following example configuration file {\tt \$DABCSYS/applications/mbs/Combiner.xml} shows how to
configure one combiner module reading from two \mbs\ transport servers.
A simple setup looks like this:
\begin{small}
\begin{verbatim}
\end{verbatim}
\end{small}
We have one node (\keyw{Context}) with a simple run function
\func{StartMbsCombiner()} that uses a single \keyw{Module} to do the
event combination from two input \keyw{Port}s.
The node names and other parameters of the external \mbs\ connections
are specified in the \keyw{MbsServerName} properties of these ports.
Of course the \mbs\ setup must match these definitions.
There are two output \keyw{Port}s in parallel here: A \keyw{FileOutput}
that writes into a {\tt *.lmd} file as specified in the property
\keyw{MbsFileName}; and a \keyw{ServerOutput} that offers a standard \mbs\ stream server
for a monitoring program.
A full description is in Programmer Manual section
\paref{exa_mbs_eventbuilding}.
Now we can use the combined controller panel to startup \mbs\ and \dabc.
\lsubsection[Combined DABC and MBS control panel]{user:controlDabcMbs}{Combined \dabc\ and \mbs\ control panel}
\figpng{user-gui-pan-dabcmbs1}{Combined DABC and MBS controller.}{htb}{0}{0.7}
This panel shown in Fig. \paref{fig:user-gui-pan-dabcmbs1} is simply a superposition of the single ones.
Here the \keyw{Context} name of the \dabc\ node and
the \dabc\ setup file name must be specified. Number of \dabc\ servers is one.
\subsubsection[Combined DABC and MBS controller buttons]{Combined \dabc\ and \mbs\ controller buttons}
\icon{savewin} Save panel settings, see \paref{user:guiSaveRestore}.\\
\icon{connprm} Execute script \verba{dabcstartup.sc} at \dabc\ master node.
Starts DIM servers.
Execute script \verba{prmstartup.sc} at \mbs\ master node.
Starts prompter, dispatchers and message loggers.
Waits for all components (Sum of DIM servers) are running.
A progress panel pops up during that time
(see \paref{user:guiProgress}).
If all components are up trigger the main \keyw{Update}.\\
\icon{dabcconfig} Configure. Execute user's \mbs\ startup procedure in prompter.
Waits for all \mbs\ \verba{Daq\_rate} tasks are running.
Executes state transition command \comm{Configure}
on \dabc\ master node and wait for the transition.
All plug-in components are created. Then execute \comm{Enable}.
If all components are up trigger the main \comm{Update}.\\
\icon{dabcstart} Start \mbs\ acquisition,
wait for all
acquisition states \keyw{Running}, then execute \dabc\ \comm{Start} command.
All components go into running state \keyw{Running}.\\
\icon{dabcstop} Pause acquisition. Execute \mbs\ \comm{stop acquisition},
wait for all
acquisition states \keyw{Stopped}.
Execute \dabc\ \comm{Stop} command.
All components go into standby state \keyw{Ready}.\\
\icon{mbsstop} Halt acquisition. Executes \dabc\ \comm{Halt} command.
This closes all plug-ins. States go into \keyw{Halted}.
Execute user's \mbs\ shutdown procedure in prompter.
Prompter, dispatcher and message loggers should still be running.
Next must be shut down or configure.
After two seconds trigger the main \keyw{Update}.\\
\icon{disconn} Shut down all. Execute \comm{EXIT} command on all \dabc\ nodes.
Execute script \verba{prmshutdown.sc} at \mbs\ master node.
After two seconds trigger the main \keyw{Update}.\\
\icon{info} \mbs\ \comm{Show acquisition}. Output in log panel.\\
\icon{controlmbs} Shell script for \mbs\ master node.\\
\icon{controldabc} Shell script for \dabc\ master node.
\lsection[MBS and DABC with Bnet]{user-app-mbs-multieb}{\mbs\ and \dabc\ with Bnet}
The following example configuration file {\tt \$DABCSYS/applications/bnet-mbs/SetupBnetMbs.xml} shows how to configure two \dabc\ nodes reading from two \mbs\ transport servers and two event builder nodes.
Another node is used as controller.
The example setup file shows two techniques: first the use of XML variables which are
set at the beginning, and can then be referenced, second the specification of default values
for parameters of contexts or modules.
\begin{small}
\begin{verbatim}
\end{verbatim}
\end{small}
With the same setup of the two \mbs\ nodes as before we can run this example.
In the \dabc\ control panel we only have to change the number of \dabc\ servers (5),
and the name of the setup file.