\hypertarget{collect_8h}{
\section{collect.h File Reference}
\label{collect_8h}\index{collect.h@{collect.h}}
}
The collection routines coordinate between the LCDB task recieving the event packets and the LCI task that will handle the complete events. 

{\tt \#include \char`\"{}EDS/EBF\_\-pkt.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-dir.h\char`\"{}}\par
{\tt \#include \char`\"{}LCBD/LCBD\_\-evt.h\char`\"{}}\par
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{collect_8h_698b7e7580c6a59ac46c84329fd4ab45}{
typedef struct \hyperlink{struct__LCI__collection}{\_\-LCI\_\-collection} \hyperlink{collect_8h_698b7e7580c6a59ac46c84329fd4ab45}{LCI\_\-collection}}
\label{collect_8h_698b7e7580c6a59ac46c84329fd4ab45}

\begin{CompactList}\small\item\em Declaration of the opaque collection structure. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{collect_8h_f3524b47dcc4c8a519c313516156d34a}{LCI\_\-collClearCounts} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll)
\begin{CompactList}\small\item\em Clear collection counters. \item\end{CompactList}\item 
void \hyperlink{collect_8h_936120ec5e02377866adcd2b3436738c}{LCI\_\-collCounts} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll, unsigned int $\ast$nWait, unsigned int $\ast$nSignal, unsigned int $\ast$nTimeout)
\begin{CompactList}\small\item\em Get collection counters. \item\end{CompactList}\item 
\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$ \hyperlink{collect_8h_fa43420509815b590494a8ebbcea681a}{LCI\_\-collCreate} (unsigned cap)
\begin{CompactList}\small\item\em Allocate and initialise an LCI\_\-collection structure. \item\end{CompactList}\item 
void \hyperlink{collect_8h_f14a96d6db14458bff1ef67b233f4c69}{LCI\_\-collDelete} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll)
\begin{CompactList}\small\item\em Free a structure previously allocated using LCI\_\-collCreate. \item\end{CompactList}\item 
unsigned \hyperlink{collect_8h_ecc869d080dd8fe86132aa8100c48722}{LCI\_\-collect} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll, unsigned nev, unsigned period)
\begin{CompactList}\small\item\em Initiate the calibration triggers and wait for the events to be collected and constructed. \item\end{CompactList}\item 
unsigned \hyperlink{collect_8h_536a5b775b11cf336cea6542aeb58503}{LCI\_\-collected} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll)
\begin{CompactList}\small\item\em Get the number of events collected. \item\end{CompactList}\item 
unsigned \hyperlink{collect_8h_1e6a9408e269a2af6ee6227258a8bfc5}{LCI\_\-collEventCB} (void $\ast$prm, unsigned int dsc, LCBD\_\-evt $\ast$pkt)
\begin{CompactList}\small\item\em LCI event handler. \item\end{CompactList}\item 
EBF\_\-dir $\ast$ \hyperlink{collect_8h_6093eee7e479d616459507f64c43b2fc}{LCI\_\-collGet} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll)
\begin{CompactList}\small\item\em Return the directory of the next event (or NULL) and advance the read counter. \item\end{CompactList}\item 
void \hyperlink{collect_8h_b93ae0a5a6a5a1df247b1d80d09fc7de}{LCI\_\-collRestart} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll)
\begin{CompactList}\small\item\em Reset the read counter to 0. \item\end{CompactList}\item 
void \hyperlink{collect_8h_024b571e3daaf11d14c668cfcbad30d4}{LCI\_\-collSetCom} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll, void $\ast$lcbd, void $\ast$cr)
\begin{CompactList}\small\item\em Set the communications pointers of the collection structure. \item\end{CompactList}\item 
void \hyperlink{collect_8h_0234773c918ef0cbaeb3efca9f4187ff}{LCI\_\-collTime} (\hyperlink{struct__LCI__collection}{LCI\_\-collection} $\ast$cll, int clear, long long $\ast$ctime)
\begin{CompactList}\small\item\em Return accumulated collection time. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
The collection routines coordinate between the LCDB task recieving the event packets and the LCI task that will handle the complete events. 

\begin{Desc}
\item[Author:]James Swain \& Owen Saxton\end{Desc}
\begin{Desc}
\item[Id]\end{Desc}


\subsection{Function Documentation}
\hypertarget{collect_8h_f3524b47dcc4c8a519c313516156d34a}{
\index{collect.h@{collect.h}!LCI_collClearCounts@{LCI\_\-collClearCounts}}
\index{LCI_collClearCounts@{LCI\_\-collClearCounts}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collClearCounts ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8h_f3524b47dcc4c8a519c313516156d34a}


Clear collection counters. 

This routine calls through to the cue counter clear routine.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to an allocated and initialised collection structure that has been used to collect events \end{description}
\end{Desc}
\hypertarget{collect_8h_936120ec5e02377866adcd2b3436738c}{
\index{collect.h@{collect.h}!LCI_collCounts@{LCI\_\-collCounts}}
\index{LCI_collCounts@{LCI\_\-collCounts}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collCounts ({\bf LCI\_\-collection} $\ast$ {\em cll}, unsigned int $\ast$ {\em nWait}, unsigned int $\ast$ {\em nSignal}, unsigned int $\ast$ {\em nTimeout})}}
\label{collect_8h_936120ec5e02377866adcd2b3436738c}


Get collection counters. 

This routine calls through to the cue counters get routine, returning the counts accumulated since the last clear.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to a collection structure.\item[{\em nWait}]Address of an integer to receive the number of wait calls, or NULL if not needed.\item[{\em nSignal}]Address of an integer to receive the number of signal calls, or NULL if not needed.\item[{\em nTimeout}]Address of an integer to receive the number of timeouts, or NULL if not needed. \end{description}
\end{Desc}
\hypertarget{collect_8h_fa43420509815b590494a8ebbcea681a}{
\index{collect.h@{collect.h}!LCI_collCreate@{LCI\_\-collCreate}}
\index{LCI_collCreate@{LCI\_\-collCreate}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf LCI\_\-collection}$\ast$ LCI\_\-collCreate (unsigned {\em cap})}}
\label{collect_8h_fa43420509815b590494a8ebbcea681a}


Allocate and initialise an LCI\_\-collection structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cap}]Capacity, the maximum number of events that can be collected\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to an allocated, initialised LCI\_\-collection \end{Desc}
\hypertarget{collect_8h_f14a96d6db14458bff1ef67b233f4c69}{
\index{collect.h@{collect.h}!LCI_collDelete@{LCI\_\-collDelete}}
\index{LCI_collDelete@{LCI\_\-collDelete}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collDelete ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8h_f14a96d6db14458bff1ef67b233f4c69}


Free a structure previously allocated using LCI\_\-collCreate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to an allocated and initialised LCI\_\-collection structure \end{description}
\end{Desc}
\hypertarget{collect_8h_ecc869d080dd8fe86132aa8100c48722}{
\index{collect.h@{collect.h}!LCI_collect@{LCI\_\-collect}}
\index{LCI_collect@{LCI\_\-collect}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-collect ({\bf LCI\_\-collection} $\ast$ {\em cll}, unsigned {\em nev}, unsigned {\em period})}}
\label{collect_8h_ecc869d080dd8fe86132aa8100c48722}


Initiate the calibration triggers and wait for the events to be collected and constructed. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to an intialised event collection structure\item[{\em nev}]Number of events to be collected\item[{\em period}]The period (in 50 ns ticks) between triggers\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]If all the expected events were successfully collected \item[{\em LCI\_\-LOSTEVT}]If some of the events were not collected \end{description}
\end{Desc}
\hypertarget{collect_8h_536a5b775b11cf336cea6542aeb58503}{
\index{collect.h@{collect.h}!LCI_collected@{LCI\_\-collected}}
\index{LCI_collected@{LCI\_\-collected}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-collected ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8h_536a5b775b11cf336cea6542aeb58503}


Get the number of events collected. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to an allocated and initialised collection structure that has been used to collect events\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Number of events collected \end{Desc}
\hypertarget{collect_8h_1e6a9408e269a2af6ee6227258a8bfc5}{
\index{collect.h@{collect.h}!LCI_collEventCB@{LCI\_\-collEventCB}}
\index{LCI_collEventCB@{LCI\_\-collEventCB}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-collEventCB (void $\ast$ {\em prm}, unsigned int {\em edw}, LCBD\_\-evt $\ast$ {\em pkt})}}
\label{collect_8h_1e6a9408e269a2af6ee6227258a8bfc5}


LCI event handler. 

Copy the packet into the storage area, update the state information vector and compose the directory - on the last packet of the event construct the event

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em prm}]Pointer to the LCI\_\-collection structure, passed through the LCBD event handler\item[{\em edw}]Description of the event (a thirty-two bit number that indicates, among other things, errors in the event transmission)\item[{\em pkt}]Pointer to the event packet\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]Indicates that the packet should be freed by the LCB driver \end{description}
\end{Desc}
\hypertarget{collect_8h_6093eee7e479d616459507f64c43b2fc}{
\index{collect.h@{collect.h}!LCI_collGet@{LCI\_\-collGet}}
\index{LCI_collGet@{LCI\_\-collGet}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}EBF\_\-dir$\ast$ LCI\_\-collGet ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8h_6093eee7e479d616459507f64c43b2fc}


Return the directory of the next event (or NULL) and advance the read counter. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to an allocated and initialised collection\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the directory of the next event, or none if the collection has been exhausted. \end{Desc}
\hypertarget{collect_8h_b93ae0a5a6a5a1df247b1d80d09fc7de}{
\index{collect.h@{collect.h}!LCI_collRestart@{LCI\_\-collRestart}}
\index{LCI_collRestart@{LCI\_\-collRestart}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collRestart ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8h_b93ae0a5a6a5a1df247b1d80d09fc7de}


Reset the read counter to 0. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to a collection structure \end{description}
\end{Desc}
\hypertarget{collect_8h_024b571e3daaf11d14c668cfcbad30d4}{
\index{collect.h@{collect.h}!LCI_collSetCom@{LCI\_\-collSetCom}}
\index{LCI_collSetCom@{LCI\_\-collSetCom}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collSetCom ({\bf LCI\_\-collection} $\ast$ {\em cll}, void $\ast$ {\em lcbd}, void $\ast$ {\em cr})}}
\label{collect_8h_024b571e3daaf11d14c668cfcbad30d4}


Set the communications pointers of the collection structure. 

The lcbd and cr pointers are void to avoid dragging in LCBD and LEM dependancies

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to a collection structure.\item[{\em lcbd}]Pointer to the LCB control block,\item[{\em cr}]Pointer to a multi-item command-response list. \end{description}
\end{Desc}
\hypertarget{collect_8h_0234773c918ef0cbaeb3efca9f4187ff}{
\index{collect.h@{collect.h}!LCI_collTime@{LCI\_\-collTime}}
\index{LCI_collTime@{LCI\_\-collTime}!collect.h@{collect.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collTime ({\bf LCI\_\-collection} $\ast$ {\em cll}, int {\em clear}, long long $\ast$ {\em ctime})}}
\label{collect_8h_0234773c918ef0cbaeb3efca9f4187ff}


Return accumulated collection time. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cll}]Pointer to a collection structure.\item[{\em clear}]If TRUE, clear the time after copying it.\item[{\em ctime}]Address of a variable to receive the accumulated time taken to do collections, or NULL if no time wanted. \end{description}
\end{Desc}
