\hypertarget{collect_8c}{
\section{collect.c File Reference}
\label{collect_8c}\index{collect.c@{collect.c}}
}
Routines to collect the event data. 

{\tt \#include \char`\"{}LCI/LCI\_\-msgs.h\char`\"{}}\par
{\tt \#include \char`\"{}collect\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}enums\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/enums.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/list.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/defs.h\char`\"{}}\par
{\tt \#include \char`\"{}MSG/MSG\_\-pubdefs.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/MBA.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/WCT.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-siv.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-cid.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-edw.h\char`\"{}}\par
{\tt \#include \char`\"{}macros\_\-p.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{collect_8c_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_8c_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_8c_fa43420509815b590494a8ebbcea681a}{LCI\_\-collCreate} (unsigned cap)
\begin{CompactList}\small\item\em Allocate and initialise an LCI\_\-collection structure. \item\end{CompactList}\item 
void \hyperlink{collect_8c_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_8c_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_8c_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 int \hyperlink{collect_8c_bdf6ff2532a4da420e2284b3910507f2}{LCI\_\-collEventCB} (void $\ast$prm, unsigned int edw, LCBD\_\-evt $\ast$pkt)
\begin{CompactList}\small\item\em LCI event handler. \item\end{CompactList}\item 
EBF\_\-dir $\ast$ \hyperlink{collect_8c_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_8c_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_8c_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_8c_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}
Routines to collect the event data. 

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


\subsection{Function Documentation}
\hypertarget{collect_8c_f3524b47dcc4c8a519c313516156d34a}{
\index{collect.c@{collect.c}!LCI_collClearCounts@{LCI\_\-collClearCounts}}
\index{LCI_collClearCounts@{LCI\_\-collClearCounts}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collClearCounts ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8c_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_8c_936120ec5e02377866adcd2b3436738c}{
\index{collect.c@{collect.c}!LCI_collCounts@{LCI\_\-collCounts}}
\index{LCI_collCounts@{LCI\_\-collCounts}!collect.c@{collect.c}}
\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_8c_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_8c_fa43420509815b590494a8ebbcea681a}{
\index{collect.c@{collect.c}!LCI_collCreate@{LCI\_\-collCreate}}
\index{LCI_collCreate@{LCI\_\-collCreate}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf LCI\_\-collection}$\ast$ LCI\_\-collCreate (unsigned {\em cap})}}
\label{collect_8c_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_8c_f14a96d6db14458bff1ef67b233f4c69}{
\index{collect.c@{collect.c}!LCI_collDelete@{LCI\_\-collDelete}}
\index{LCI_collDelete@{LCI\_\-collDelete}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collDelete ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8c_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_8c_ecc869d080dd8fe86132aa8100c48722}{
\index{collect.c@{collect.c}!LCI_collect@{LCI\_\-collect}}
\index{LCI_collect@{LCI\_\-collect}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-collect ({\bf LCI\_\-collection} $\ast$ {\em cll}, unsigned {\em nev}, unsigned {\em period})}}
\label{collect_8c_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_8c_536a5b775b11cf336cea6542aeb58503}{
\index{collect.c@{collect.c}!LCI_collected@{LCI\_\-collected}}
\index{LCI_collected@{LCI\_\-collected}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-collected ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8c_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_8c_bdf6ff2532a4da420e2284b3910507f2}{
\index{collect.c@{collect.c}!LCI_collEventCB@{LCI\_\-collEventCB}}
\index{LCI_collEventCB@{LCI\_\-collEventCB}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int LCI\_\-collEventCB (void $\ast$ {\em prm}, unsigned int {\em edw}, LCBD\_\-evt $\ast$ {\em pkt})}}
\label{collect_8c_bdf6ff2532a4da420e2284b3910507f2}


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_8c_6093eee7e479d616459507f64c43b2fc}{
\index{collect.c@{collect.c}!LCI_collGet@{LCI\_\-collGet}}
\index{LCI_collGet@{LCI\_\-collGet}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}EBF\_\-dir$\ast$ LCI\_\-collGet ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8c_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_8c_b93ae0a5a6a5a1df247b1d80d09fc7de}{
\index{collect.c@{collect.c}!LCI_collRestart@{LCI\_\-collRestart}}
\index{LCI_collRestart@{LCI\_\-collRestart}!collect.c@{collect.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-collRestart ({\bf LCI\_\-collection} $\ast$ {\em cll})}}
\label{collect_8c_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_8c_024b571e3daaf11d14c668cfcbad30d4}{
\index{collect.c@{collect.c}!LCI_collSetCom@{LCI\_\-collSetCom}}
\index{LCI_collSetCom@{LCI\_\-collSetCom}!collect.c@{collect.c}}
\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_8c_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_8c_0234773c918ef0cbaeb3efca9f4187ff}{
\index{collect.c@{collect.c}!LCI_collTime@{LCI\_\-collTime}}
\index{LCI_collTime@{LCI\_\-collTime}!collect.c@{collect.c}}
\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_8c_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}
