\hypertarget{consign_8c}{
\section{consign.c File Reference}
\label{consign_8c}\index{consign.c@{consign.c}}
}
Routines that act upon the consignment structure. 

{\tt \#include \char`\"{}LSEC\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/LSEC.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/LSEC\_\-ctx.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/LSEC\_\-msgs.h\char`\"{}}\par
{\tt \#include \char`\"{}LSE/LSEW\_\-dgmFw.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-cid.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-dir.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-edw.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-gemLocate.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-siv.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-tem.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-tkr.h\char`\"{}}\par
{\tt \#include \char`\"{}ITC/ITC\_\-pubdefs.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/BSWP.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/FPA.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/MBA.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/SEM.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/WCT.h\char`\"{}}\par
{\tt \#include \char`\"{}MSG/MSG\_\-pubdefs.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par
\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__LSEC__consignment}{\_\-LSEC\_\-consignment}
\begin{CompactList}\small\item\em Structure holding processed event data. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{consign_8c_58adfacbf0942fb7944deab3aac19634}{
typedef enum \hyperlink{consign_8c_ff250b7a644986787ff3ff34d4212964}{\_\-LSEC\_\-cnsState} \hyperlink{consign_8c_58adfacbf0942fb7944deab3aac19634}{LSEC\_\-cnsState}}
\label{consign_8c_58adfacbf0942fb7944deab3aac19634}

\begin{CompactList}\small\item\em Consignment state. \item\end{CompactList}\item 
\hypertarget{consign_8c_b401304dc706323ddaf3da423f592241}{
typedef unsigned \hyperlink{consign_8c_b401304dc706323ddaf3da423f592241}{LSEC\_\-consignRtn} (\hyperlink{struct__LSEC__consignment}{LSEC\_\-consignment} $\ast$cns)}
\label{consign_8c_b401304dc706323ddaf3da423f592241}

\begin{CompactList}\small\item\em Definition of routine to perform the consignment. \item\end{CompactList}\end{CompactItemize}
\subsection*{Enumerations}
\begin{CompactItemize}
\item 
enum \hyperlink{consign_8c_ff250b7a644986787ff3ff34d4212964}{\_\-LSEC\_\-cnsState} \{ \par
\hyperlink{consign_8c_ff250b7a644986787ff3ff34d4212964461815aa8dff78fb4e1cd6b829b1f34f}{LSEC\_\-CNS\_\-EMPTY} =  0, 
\par
\hyperlink{consign_8c_ff250b7a644986787ff3ff34d4212964e12f12144be2302572fb9d30e5ecd601}{LSEC\_\-CNS\_\-FULL} =  1
 \}
\begin{CompactList}\small\item\em Consignment state. \item\end{CompactList}\item 
enum \{ \par
\textbf{DATAGRAM\_\-SIZE} =  1024 $\ast$ 128, 
\par
\textbf{MAX\_\-EVENT\_\-SIZE} =  26500, 
\par
\textbf{MAX\_\-CAL\_\-EVENT\_\-SIZE} =  6530 + 10, 
\par
\textbf{MAX\_\-TKR\_\-EVENT\_\-SIZE} =  6594 + 10, 
\par
\textbf{SSR\_\-APID\_\-BASE} =  0x3c5, 
\par
\textbf{EVT\_\-CELL\_\-SIZE} =  4, 
\par
\textbf{EVT\_\-CELL\_\-MASK} =  EVT\_\-CELL\_\-SIZE - 1
 \}
\begin{CompactList}\small\item\em Various constants. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{struct__LSEC__consignment}{LSEC\_\-consignment} $\ast$ \hyperlink{consign_8c_64dcd1ca18fb5c8b9b63ae4f0970ebd6}{LSEC\_\-consCreate} (unsigned cpuid, unsigned srcid, unsigned cap, \hyperlink{struct__LSEC__compaction}{LSEC\_\-compaction} $\ast$cpc, \hyperlink{struct__LSEC__event}{LSEC\_\-event} $\ast$evt, long long $\ast$times)
\begin{CompactList}\small\item\em Create a new consignment. \item\end{CompactList}\item 
\hyperlink{structLSEC__ctx}{LSEC\_\-ctx} $\ast$ \hyperlink{consign_8c_2f8874a77d6625b5661e281bd03cd02e}{LSEC\_\-consCtxGet} (\hyperlink{struct__LSEC__consignment}{LSEC\_\-consignment} $\ast$cns)
\begin{CompactList}\small\item\em Get the address of the context structure. \item\end{CompactList}\item 
void \hyperlink{consign_8c_973c685154a7ca5c9756c65929b5afd8}{LSEC\_\-consDelete} (\hyperlink{struct__LSEC__consignment}{LSEC\_\-consignment} $\ast$cns)
\begin{CompactList}\small\item\em Free the previously allocated consignment structure. \item\end{CompactList}\item 
unsigned \hyperlink{consign_8c_045f12034518fd859690705a4a37c184}{LSEC\_\-consEventCal} (void $\ast$parm, EBF\_\-dir $\ast$dir)
\begin{CompactList}\small\item\em Process a compressed CAL event. \item\end{CompactList}\item 
unsigned \hyperlink{consign_8c_ba688e1f4a32a62b201fd9c64005d12e}{LSEC\_\-consEventImm} (void $\ast$parm, EBF\_\-dir $\ast$dir)
\begin{CompactList}\small\item\em Process an event immediately. \item\end{CompactList}\item 
void \hyperlink{consign_8c_48f0a5510421de603f53e804fc04137a}{LSEC\_\-consPrepare} (\hyperlink{struct__LSEC__consignment}{LSEC\_\-consignment} $\ast$cns, unsigned runid, unsigned mode, \hyperlink{LSEC_8h_7d36ae53d4120093fc435cf36a0a698a}{LSEC\_\-compLevel} comp)
\begin{CompactList}\small\item\em Prepare for a new calibration run. \item\end{CompactList}\item 
unsigned \hyperlink{consign_8c_94c95f28cba8c0c6bc6b99d9514a76e4}{LSEC\_\-consProcess} (\hyperlink{struct__LSEC__consignment}{LSEC\_\-consignment} $\ast$cns)
\begin{CompactList}\small\item\em Process a consignment. \item\end{CompactList}\item 
void \hyperlink{consign_8c_38e89e267fb141c6e4de1b52f792ed60}{LSEC\_\-consReason} (\hyperlink{struct__LSEC__consignment}{LSEC\_\-consignment} $\ast$cns, int reason)
\begin{CompactList}\small\item\em Set the current datagram close reason. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Routines that act upon the consignment structure. 

\begin{Desc}
\item[Author:]James Swain \& Owen Saxton\end{Desc}
{\bf \$Id:} \hyperlink{consign_8c}{consign.c},v 1.4 2010/08/12 21:11:56 saxton Exp \$ 

\subsection{Enumeration Type Documentation}
\hypertarget{consign_8c_ff250b7a644986787ff3ff34d4212964}{
\index{consign.c@{consign.c}!_LSEC_cnsState@{\_\-LSEC\_\-cnsState}}
\index{_LSEC_cnsState@{\_\-LSEC\_\-cnsState}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}enum {\bf \_\-LSEC\_\-cnsState}}}
\label{consign_8c_ff250b7a644986787ff3ff34d4212964}


Consignment state. 

\begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{LSEC_CNS_EMPTY@{LSEC\_\-CNS\_\-EMPTY}!consign.c@{consign.c}}\index{consign.c@{consign.c}!LSEC_CNS_EMPTY@{LSEC\_\-CNS\_\-EMPTY}}\item[{\em 
\hypertarget{consign_8c_ff250b7a644986787ff3ff34d4212964461815aa8dff78fb4e1cd6b829b1f34f}{
LSEC\_\-CNS\_\-EMPTY}
\label{consign_8c_ff250b7a644986787ff3ff34d4212964461815aa8dff78fb4e1cd6b829b1f34f}
}]Ready to encode another event. \index{LSEC_CNS_FULL@{LSEC\_\-CNS\_\-FULL}!consign.c@{consign.c}}\index{consign.c@{consign.c}!LSEC_CNS_FULL@{LSEC\_\-CNS\_\-FULL}}\item[{\em 
\hypertarget{consign_8c_ff250b7a644986787ff3ff34d4212964e12f12144be2302572fb9d30e5ecd601}{
LSEC\_\-CNS\_\-FULL}
\label{consign_8c_ff250b7a644986787ff3ff34d4212964e12f12144be2302572fb9d30e5ecd601}
}]An event has been encoded and is waiting to be consigned. \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{consign_8c_64dcd1ca18fb5c8b9b63ae4f0970ebd6}{
\index{consign.c@{consign.c}!LSEC_consCreate@{LSEC\_\-consCreate}}
\index{LSEC_consCreate@{LSEC\_\-consCreate}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf LSEC\_\-consignment}$\ast$ LSEC\_\-consCreate (unsigned {\em cpuid}, unsigned {\em srcid}, unsigned {\em cap}, {\bf LSEC\_\-compaction} $\ast$ {\em cpc}, {\bf LSEC\_\-event} $\ast$ {\em evt}, long long $\ast$ {\em times})}}
\label{consign_8c_64dcd1ca18fb5c8b9b63ae4f0970ebd6}


Create a new consignment. 

This routine allocates memory for a consigment structure and its associated data structures, and initialises it.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em srcid}]ID of the data source\item[{\em cpuid}]ID of the CPU the calibration is being run on\item[{\em cap}]The capacity (in events) of the consignment\item[{\em cpc}]Pointer to the compaction state information\item[{\em evt}]Pointer to the event store\item[{\em times}]Pointer to the processing times array.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to an allocated, initialised consignment (NULL if there is an error allocating memory) \end{Desc}
\hypertarget{consign_8c_2f8874a77d6625b5661e281bd03cd02e}{
\index{consign.c@{consign.c}!LSEC_consCtxGet@{LSEC\_\-consCtxGet}}
\index{LSEC_consCtxGet@{LSEC\_\-consCtxGet}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf LSEC\_\-ctx}$\ast$ LSEC\_\-consCtxGet ({\bf LSEC\_\-consignment} $\ast$ {\em cns})}}
\label{consign_8c_2f8874a77d6625b5661e281bd03cd02e}


Get the address of the context structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cns}]Pointer to the consignment structure\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The address of the context structure \end{Desc}
\hypertarget{consign_8c_973c685154a7ca5c9756c65929b5afd8}{
\index{consign.c@{consign.c}!LSEC_consDelete@{LSEC\_\-consDelete}}
\index{LSEC_consDelete@{LSEC\_\-consDelete}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-consDelete ({\bf LSEC\_\-consignment} $\ast$ {\em cns})}}
\label{consign_8c_973c685154a7ca5c9756c65929b5afd8}


Free the previously allocated consignment structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cns}]Pointer to allocated, intialised consignment structure \end{description}
\end{Desc}
\hypertarget{consign_8c_045f12034518fd859690705a4a37c184}{
\index{consign.c@{consign.c}!LSEC_consEventCal@{LSEC\_\-consEventCal}}
\index{LSEC_consEventCal@{LSEC\_\-consEventCal}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-consEventCal (void $\ast$ {\em parm}, EBF\_\-dir $\ast$ {\em dir})}}
\label{consign_8c_045f12034518fd859690705a4a37c184}


Process a compressed CAL event. 

This routine starts the process by accumulating data for the CAL means calculation.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em parm}]Pointer to the consignment structure\item[{\em dir}]Pointer to the event directory\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LSEC\_\-SUCCESS}]Success (always) \end{description}
\end{Desc}
\hypertarget{consign_8c_ba688e1f4a32a62b201fd9c64005d12e}{
\index{consign.c@{consign.c}!LSEC_consEventImm@{LSEC\_\-consEventImm}}
\index{LSEC_consEventImm@{LSEC\_\-consEventImm}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-consEventImm (void $\ast$ {\em parm}, EBF\_\-dir $\ast$ {\em dir})}}
\label{consign_8c_ba688e1f4a32a62b201fd9c64005d12e}


Process an event immediately. 

This routine is used to pass an event immediately to the datagram framework. It is used in all cases except compressed CAL events.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em parm}]Pointer to the consignment structure\item[{\em dir}]Pointer to the event directory\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LSEC\_\-SUCCESS}]Success \item[{\em LSEC\_\-OVERSIZE}]Event too large for a datagram \end{description}
\end{Desc}
\hypertarget{consign_8c_48f0a5510421de603f53e804fc04137a}{
\index{consign.c@{consign.c}!LSEC_consPrepare@{LSEC\_\-consPrepare}}
\index{LSEC_consPrepare@{LSEC\_\-consPrepare}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-consPrepare ({\bf LSEC\_\-consignment} $\ast$ {\em cns}, unsigned {\em runid}, unsigned {\em mode}, {\bf LSEC\_\-compLevel} {\em comp})}}
\label{consign_8c_48f0a5510421de603f53e804fc04137a}


Prepare for a new calibration run. 

This routine sets the runid and start time for the first datagram of a new calibration, as well as several other mode-dependent parameters.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cns}]Pointer to allocated, intialised consignment structure\item[{\em runid}]32-bit number identifying the calibration run\item[{\em mode}]The calibration mode (ACD, CAL or TKR)\item[{\em comp}]The compression level (normal, only, none) \end{description}
\end{Desc}
\hypertarget{consign_8c_94c95f28cba8c0c6bc6b99d9514a76e4}{
\index{consign.c@{consign.c}!LSEC_consProcess@{LSEC\_\-consProcess}}
\index{LSEC_consProcess@{LSEC\_\-consProcess}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-consProcess ({\bf LSEC\_\-consignment} $\ast$ {\em cns})}}
\label{consign_8c_94c95f28cba8c0c6bc6b99d9514a76e4}


Process a consignment. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cns}]Pointer to a consignment structure\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LSEC\_\-SUCCESS}]If all goes well \end{description}
\end{Desc}
\hypertarget{consign_8c_38e89e267fb141c6e4de1b52f792ed60}{
\index{consign.c@{consign.c}!LSEC_consReason@{LSEC\_\-consReason}}
\index{LSEC_consReason@{LSEC\_\-consReason}!consign.c@{consign.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-consReason ({\bf LSEC\_\-consignment} $\ast$ {\em cns}, int {\em reason})}}
\label{consign_8c_38e89e267fb141c6e4de1b52f792ed60}


Set the current datagram close reason. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cns}]Pointer to the consignment structure\item[{\em reason}]The reason code to be set \end{description}
\end{Desc}
