[user/user-app-bnet.tex]
%\lsection{user:Bnet}{Application: network event building}
\label{user-app-bnet-chapter}
\lsection[DABC eventbuilder network (BNET)]{user-app-bnet-dabc}{\dabc\ eventbuilder network (BNET)}
The full functionality of \dabc\ is shown in the case that the DAQ uses
an event building network (BNET), transferring the partial data from $n$ readout nodes
to $m$ event building nodes, such that each event builder can work on the full
detector data. This scenario is discussed in detail in chapter \paref{prog_exabnet}
of the \dabc\ programmer's manual. Appropriate configuration files can be found at \\
{\tt \$DABCSYS/applications/bnet-test} directory.
An example setup file {\tt SetupBnet.xml} may look like this:

\begin{small}
\begin{verbatim}
 <?xml version="1.0"?>
<dabc version="1">
  <Context host="localhost" name="Controller:41">
    <Run>
      <runfunc value="RunTestBnet"/>
    </Run>
    <Application class="bnet::Cluster">
       <NetDevice value="dabc::SocketDevice"/>
    </Application>
  </Context>
  <Context host="lxi009" name="Worker1:42"/>
  <Context host="lxi010" name="Worker2:42"/>
  <Context host="lxi011" name="Worker3:42"/>
  <Context host="lxi012" name="Worker4:42"/>
  <Defaults>
    <Context name="*">
      <Run>
        <logfile value="test${DABCNODEID}.log"/>
        <loglevel value="1"/>
        <lib value="libDabcBnet.so"/>
      </Run>
    </Context>
    <Context name="*Worker*">
       <Run>
          <lib value="${DABCSYS}/applications/bnet-test/libBnetTest.so"/>
       </Run>
       <Application class="bnet::TestWorker">
         <IsGenerator value="true"/>
         <IsSender value="true"/>
         <IsReceiver value="true"/>
         <NumReadouts value="4"/>
      </Application>       
    </Context>
  </Defaults>
</dabc>
\end{verbatim}
\end{small}

The setup of such BNET contains several \keyw{<Context>} nodes. Generally, the
BNET has two types of nodes: 
\bbul
\item One "Controller" node that has a master
controller functionality, implemented in the \keyw{<Application>} of
class "bnet::Cluster". The controller node must be specified at the \dabc\ GUI setup
to receive the direct cluster control commands, e.~g.~ state machine transitions commands. In the \dabc\ BNET framework, the controller also keeps a general
parameter \keyw{<NetDevice>} for the data connection device of the entire DAQ cluster;
this can be "dabc::SocketDevice" for tcp/ip, or "verbs::Device" for an {\em InfiniBand}
cluster.

\item Several "Worker" nodes of an experiment specific \keyw{<Application>}. They
may be configured for different jobs in the BNET; this example provides
an \class{Application} class "bnet::TestWorker" with some boolean parameters
to define the functionality.
\ebul 
Note the usage of wildcards "*" in the \keyw{<Context>} names to define
properties that should be valid for all nodes matching the pattern, e.~g.~
the libraries to load, or the common application setup for all worker nodes.
Here there are 4 workers which all produce random event data (enabled in \keyw{<IsGenerator>}),
and all send their data to all others (enabled in \keyw{<IsSender>}). In parallel,
they all receive data from the other workers to build the complete event
(enabled in \keyw{<IsReceiver>}).

Such BNET setup is best started by means of the \dabc\ GUI.
The name of the controller \keyw{<Context>} node and
the setup file name must be specified in the control panel of the GUI
(see section \paref{user:controlDabc}). Then all nodes can be started just by the
"Launch" button \icon{connprm}. The configuration and run control of the nodes is done by the state machine buttons of the control panel.


\lsection[DABC eventbuilder network (BNET) with MBS]{user-app-bnetmbs}{\dabc\ eventbuilder network (BNET) with \mbs\ }
\index{TODO!Mbs BNET example with real mbs nodes instead generators}
\index{TODO!Adjust old mbs bnet configurator scripts for new xml format?}
A more realistic example of a BNET uses data which is read from $n$ external \mbs\ 
nodes, each connected to one \dabc\ readout node, and transferred to
$m$ \dabc\ eventbuilder nodes.
Example file \\
{\tt \$DABCSYS/applications/bnet-mbs/SetupBnetMbs.xml}
shows the configuration for an \mbs\  event building with 2 \dabc\ readout nodes, connected with 2 \mbs\ nodes each (simulated by \dabc\ generator modules here),
and 2 \dabc\ event builder nodes. A detailled description
of this setup is given in section \paref{prog_exabnet_mbs} of the \dabc\
programmer manual.
The usage of such configuration is similar to the BNET example as
described above in section \paref{user-app-bnet-dabc}:
The list of \keyw{<Context>} nodes (or the
corresponding \keyw{<Variables>}, resp.) 
must be edited for the actual node names. Additionally the names of the
\mbs\ nodes for readout should be specified. Then the BNET
setup may be launched and controlled by the \dabc\ GUI.
