\hypertarget{QSEC_8c}{
\section{QSEC.c File Reference}
\label{QSEC_8c}\index{QSEC.c@{QSEC.c}}
}
Manages the updating of the calibration event context.  


{\tt \#include \char`\"{}QSEC\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}decode.h\char`\"{}}\par
{\tt \#include \char`\"{}expand.h\char`\"{}}\par
{\tt \#include \char`\"{}QSEC/QSEC.h\char`\"{}}\par
{\tt \#include \char`\"{}QSEC/QSEC\_\-ctx.h\char`\"{}}\par
{\tt \#include \char`\"{}QSE/QSE\_\-ctx.h\char`\"{}}\par
{\tt \#include \char`\"{}QSE/QSE\_\-ctxUpdate.h\char`\"{}}\par
{\tt \#include \char`\"{}LSE/LSE\_\-stdCtb.h\char`\"{}}\par
{\tt \#include \char`\"{}LSF/LSF\_\-scan.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/enums.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-gem.h\char`\"{}}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$string.h$>$}\par
\subsection*{Enumerations}
\begin{CompactItemize}
\item 
enum \{ \textbf{QSEC\_\-MAX\_\-N\_\-EVENTS} =  100
 \}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hypertarget{QSEC_8c_e329a6b949ec184b55eecfd399929715}{
static LSF\_\-scanRecordHandler \textbf{root\_\-update} (QSEC $\ast$qsec, const LSF\_\-contribution $\ast$ctb)}
\label{QSEC_8c_e329a6b949ec184b55eecfd399929715}

\item 
QSEC $\ast$ \hyperlink{QSEC_8c_7494e6595a9d8ef1ff871762a89054e6}{QSEC\_\-alloc} (void)
\begin{CompactList}\small\item\em Allocate and construct the QSEC handle. \item\end{CompactList}\item 
unsigned int \hyperlink{QSEC_8c_1b5b2034da1ea7b0589f96e8581fc3bb}{QSEC\_\-sizeof} (void $\ast$prm)
\begin{CompactList}\small\item\em Get the size of the area needed to hold the event meta-information. \item\end{CompactList}\item 
QSEC $\ast$ \hyperlink{QSEC_8c_2d221bdf586673a04d790d586b34de90}{QSEC\_\-construct} (QSEC $\ast$qsec, void $\ast$prm)
\begin{CompactList}\small\item\em Construct (initializes) the handle for updating the standard event meta-information. \item\end{CompactList}\item 
void \hyperlink{QSEC_8c_79f261ad4fa1381ecab06b39bffed993}{QSEC\_\-destruct} (QSEC $\ast$qsec)
\begin{CompactList}\small\item\em Destroy the QSEC handle. \item\end{CompactList}\item 
void \hyperlink{QSEC_8c_3e76a8cee9c4cd7e485f0c55bcddda45}{QSEC\_\-updateAtDatagram} (void $\ast$qsec, const LSF\_\-datagram $\ast$dgm)
\begin{CompactList}\small\item\em Update the run oriented information in the event context using the information from the event datagram. \item\end{CompactList}\item 
void \hyperlink{QSEC_8c_1e42fb629f04b1918520fb0d1969f490}{QSEC\_\-updateAtContribution} (void $\ast$qsec, const LSF\_\-contribution $\ast$ctb)
\begin{CompactList}\small\item\em Update the context based on the contribution. \item\end{CompactList}\item 
int \hyperlink{QSEC_8c_5cf6a83ceb47d157f035a1f9ab782131}{QSEC\_\-updateAtRecord} (void $\ast$qsec, const LSF\_\-record $\ast$rec)
\begin{CompactList}\small\item\em Update the context based on the record. \item\end{CompactList}\item 
int \hyperlink{QSEC_8c_1994e644c046cf387142fe0fc5d6b7b8}{QSEC\_\-expand} (QSEC $\ast$qsec, const LSF\_\-record $\ast$rec, QSE\_\-ebfEvt $\ast$ebf, int ebf\_\-size, int $\ast$ret\_\-size)
\begin{CompactList}\small\item\em Expand the event into EBF format. \item\end{CompactList}\item 
const \hyperlink{struct__QSEC__ctx}{QSEC\_\-ctx} $\ast$ \hyperlink{QSEC_8c_afd2fa29b87bad610eac96df70cf7a7c}{QSEC\_\-appCtxGet} (const QSEC $\ast$qsec)
\begin{CompactList}\small\item\em Return a pointer to the public QSEC application specific context block. \item\end{CompactList}\item 
const QSE\_\-ctx $\ast$ \hyperlink{QSEC_8c_a7951b43feda02f165fe05f62a905b2a}{QSEC\_\-stdCtxGet} (const QSEC $\ast$qsec)
\begin{CompactList}\small\item\em Return a pointer to the standard QSE context block. \item\end{CompactList}\item 
const EBF\_\-gem $\ast$ \hyperlink{QSEC_8c_e2186c57f15fd90b381f66e0a53c4554}{QSEC\_\-gemGet} (const QSEC $\ast$qsec)
\begin{CompactList}\small\item\em Return a pointer to the expanded GEM data. \item\end{CompactList}\item 
void \hyperlink{QSEC_8c_5c40e3514417032a7c115342a747444d}{QSEC\_\-reportExpand} (const QSEC $\ast$qsec, FILE $\ast$fp, unsigned int optns)
\begin{CompactList}\small\item\em Report the contents of an expansion. \item\end{CompactList}\item 
void \hyperlink{QSEC_8c_878998f21b950ec96a49278982a10e2f}{QSEC\_\-reportExp} (const QSEC $\ast$qsec, FILE $\ast$fp)
\begin{CompactList}\small\item\em Report the contents of an expansion context. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Manages the updating of the calibration event context. 

\begin{Desc}
\item[Author:]James Swain \& Owen Saxton\end{Desc}
\begin{Desc}
\item[Id]\hyperlink{QSEC_8c}{QSEC.c},v 1.14 2010/08/10 18:31:47 saxton Exp \end{Desc}


\subsection{Function Documentation}
\hypertarget{QSEC_8c_7494e6595a9d8ef1ff871762a89054e6}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-alloc@{QSEC\_\-alloc}}
\index{QSEC\_\-alloc@{QSEC\_\-alloc}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-alloc}]{\setlength{\rightskip}{0pt plus 5cm}QSEC$\ast$ QSEC\_\-alloc (void)}}
\label{QSEC_8c_7494e6595a9d8ef1ff871762a89054e6}


Allocate and construct the QSEC handle. 

\begin{Desc}
\item[Returns:]A pointer to the allocated and constructed QSEC handle \end{Desc}


References QSEC\_\-construct().\hypertarget{QSEC_8c_afd2fa29b87bad610eac96df70cf7a7c}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-appCtxGet@{QSEC\_\-appCtxGet}}
\index{QSEC\_\-appCtxGet@{QSEC\_\-appCtxGet}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-appCtxGet}]{\setlength{\rightskip}{0pt plus 5cm}const {\bf QSEC\_\-ctx}$\ast$ QSEC\_\-appCtxGet (const QSEC $\ast$ {\em qsec})}}
\label{QSEC_8c_afd2fa29b87bad610eac96df70cf7a7c}


Return a pointer to the public QSEC application specific context block. 

This routine is just an accessor to keep the structure of QSEC private.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A pointer to the QSEC application specific context block \end{Desc}
\hypertarget{QSEC_8c_2d221bdf586673a04d790d586b34de90}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-construct@{QSEC\_\-construct}}
\index{QSEC\_\-construct@{QSEC\_\-construct}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-construct}]{\setlength{\rightskip}{0pt plus 5cm}QSEC$\ast$ QSEC\_\-construct (QSEC $\ast$ {\em qsec}, \/  void $\ast$ {\em prm})}}
\label{QSEC_8c_2d221bdf586673a04d790d586b34de90}


Construct (initializes) the handle for updating the standard event meta-information. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The handle to initialize, if specified as NULL, one will be allocated\item[{\em prm}]A run-time set parameter used to stylize the configuration\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The QSEC context structure \end{Desc}


References QSEC\_\-constructCtx(), QSEC\_\-constructExpansion(), and QSEC\_\-sizeof().

Referenced by QSEC\_\-alloc().\hypertarget{QSEC_8c_79f261ad4fa1381ecab06b39bffed993}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-destruct@{QSEC\_\-destruct}}
\index{QSEC\_\-destruct@{QSEC\_\-destruct}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-destruct}]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-destruct (QSEC $\ast$ {\em qsec})}}
\label{QSEC_8c_79f261ad4fa1381ecab06b39bffed993}


Destroy the QSEC handle. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]Pointer to the QSEC handle to delete. \end{description}
\end{Desc}
\hypertarget{QSEC_8c_1994e644c046cf387142fe0fc5d6b7b8}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-expand@{QSEC\_\-expand}}
\index{QSEC\_\-expand@{QSEC\_\-expand}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-expand}]{\setlength{\rightskip}{0pt plus 5cm}int QSEC\_\-expand (QSEC $\ast$ {\em qsec}, \/  const LSF\_\-record $\ast$ {\em rec}, \/  QSE\_\-ebfEvt $\ast$ {\em ebf}, \/  int {\em ebf\_\-size}, \/  int $\ast$ {\em ret\_\-size})}}
\label{QSEC_8c_1994e644c046cf387142fe0fc5d6b7b8}


Expand the event into EBF format. 

This just launders the call

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle\item[{\em rec}]The LSF record containing the event\item[{\em ebf}]The ebf buffer to expand the event into, this pointer must be 32-bit aligned\item[{\em ebf\_\-size}]The size, in bytes, of the buffer\item[{\em ret\_\-size}]Returned as the size of the expanded event\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]Successful expand \item[{\em $<$0}]Failure, see the enumeration QSEC\_\-STATUS\_\-K for the reasons \end{description}
\end{Desc}


References QSEC\_\-decode(), QSEC\_\-ID\_\-CALIB\_\-RAW\_\-EVT, QSEC\_\-STATUS\_\-K\_\-DECODE, and QSEC\_\-STATUS\_\-K\_\-TOO\_\-SMALL.\hypertarget{QSEC_8c_e2186c57f15fd90b381f66e0a53c4554}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-gemGet@{QSEC\_\-gemGet}}
\index{QSEC\_\-gemGet@{QSEC\_\-gemGet}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-gemGet}]{\setlength{\rightskip}{0pt plus 5cm}const EBF\_\-gem$\ast$ QSEC\_\-gemGet (const QSEC $\ast$ {\em qsec})}}
\label{QSEC_8c_e2186c57f15fd90b381f66e0a53c4554}


Return a pointer to the expanded GEM data. 

This routine is just an accessor to keep the structure of QSEC private.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A pointer to the expanded GEM record \end{Desc}
\hypertarget{QSEC_8c_878998f21b950ec96a49278982a10e2f}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-reportExp@{QSEC\_\-reportExp}}
\index{QSEC\_\-reportExp@{QSEC\_\-reportExp}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-reportExp}]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-reportExp (const QSEC $\ast$ {\em qsec}, \/  FILE $\ast$ {\em fp})}}
\label{QSEC_8c_878998f21b950ec96a49278982a10e2f}


Report the contents of an expansion context. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle\item[{\em fp}]Pointer to the destination file \end{description}
\end{Desc}


References QSEC\_\-reportExpCtx().\hypertarget{QSEC_8c_5c40e3514417032a7c115342a747444d}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-reportExpand@{QSEC\_\-reportExpand}}
\index{QSEC\_\-reportExpand@{QSEC\_\-reportExpand}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-reportExpand}]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-reportExpand (const QSEC $\ast$ {\em qsec}, \/  FILE $\ast$ {\em fp}, \/  unsigned int {\em optns})}}
\label{QSEC_8c_5c40e3514417032a7c115342a747444d}


Report the contents of an expansion. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle\item[{\em fp}]Pointer to the destination file\item[{\em optns}]Options controlling the report (not used) \end{description}
\end{Desc}


References QSEC\_\-reportExpansion().\hypertarget{QSEC_8c_1b5b2034da1ea7b0589f96e8581fc3bb}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-sizeof@{QSEC\_\-sizeof}}
\index{QSEC\_\-sizeof@{QSEC\_\-sizeof}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-sizeof}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int QSEC\_\-sizeof (void $\ast$ {\em prm})}}
\label{QSEC_8c_1b5b2034da1ea7b0589f96e8581fc3bb}


Get the size of the area needed to hold the event meta-information. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em prm}]A run-time set parameter used to stylize the configuration\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The size, in bytes, of the area needed to hold the event meta-information \end{Desc}


References QSEC\_\-sizeofExpansion().

Referenced by QSEC\_\-construct().\hypertarget{QSEC_8c_a7951b43feda02f165fe05f62a905b2a}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-stdCtxGet@{QSEC\_\-stdCtxGet}}
\index{QSEC\_\-stdCtxGet@{QSEC\_\-stdCtxGet}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-stdCtxGet}]{\setlength{\rightskip}{0pt plus 5cm}const QSE\_\-ctx$\ast$ QSEC\_\-stdCtxGet (const QSEC $\ast$ {\em qsec})}}
\label{QSEC_8c_a7951b43feda02f165fe05f62a905b2a}


Return a pointer to the standard QSE context block. 

This routine is just an accessor to keep the structure of QSEC private.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A pointer to the QSE context block \end{Desc}
\hypertarget{QSEC_8c_1e42fb629f04b1918520fb0d1969f490}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-updateAtContribution@{QSEC\_\-updateAtContribution}}
\index{QSEC\_\-updateAtContribution@{QSEC\_\-updateAtContribution}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-updateAtContribution}]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-updateAtContribution (void $\ast$ {\em qsec}, \/  const LSF\_\-contribution $\ast$ {\em ctb})}}
\label{QSEC_8c_1e42fb629f04b1918520fb0d1969f490}


Update the context based on the contribution. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle to update\item[{\em ctb}]The contribution \end{description}
\end{Desc}


References QSEC\_\-ID\_\-CALIB\_\-ACD\_\-CTX, QSEC\_\-ID\_\-CALIB\_\-CAL\_\-CTX, QSEC\_\-ID\_\-CALIB\_\-TKR\_\-CTX, QSEC\_\-recoverCtx(), QSEC\_\-recoverUser(), and QSEC\_\-setMode().\hypertarget{QSEC_8c_3e76a8cee9c4cd7e485f0c55bcddda45}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-updateAtDatagram@{QSEC\_\-updateAtDatagram}}
\index{QSEC\_\-updateAtDatagram@{QSEC\_\-updateAtDatagram}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-updateAtDatagram}]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-updateAtDatagram (void $\ast$ {\em qsec}, \/  const LSF\_\-datagram $\ast$ {\em dgm})}}
\label{QSEC_8c_3e76a8cee9c4cd7e485f0c55bcddda45}


Update the run oriented information in the event context using the information from the event datagram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle\item[{\em dgm}]The event datagram\end{description}
\end{Desc}
\begin{Desc}
\item[Note:]The root contribution is opaque to the caller, so QSEC must handle the contributions within the root. There are two strategies one could use\begin{enumerate}
\item Call LSF\_\-scanContribtions and let it parse through them and invoke a user call back routine\item Do the scan by hand.\end{enumerate}
\end{Desc}
Initially I have opted for strategy \#1, but the second strategy makes detailed error checking easier. For example, if the sequence of the contributions is fixed, it is likely easier to do this when doing the scan by hand. \hypertarget{QSEC_8c_5cf6a83ceb47d157f035a1f9ab782131}{
\index{QSEC.c@{QSEC.c}!QSEC\_\-updateAtRecord@{QSEC\_\-updateAtRecord}}
\index{QSEC\_\-updateAtRecord@{QSEC\_\-updateAtRecord}!QSEC.c@{QSEC.c}}
\subsubsection[{QSEC\_\-updateAtRecord}]{\setlength{\rightskip}{0pt plus 5cm}int QSEC\_\-updateAtRecord (void $\ast$ {\em qsec}, \/  const LSF\_\-record $\ast$ {\em rec})}}
\label{QSEC_8c_5cf6a83ceb47d157f035a1f9ab782131}


Update the context based on the record. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qsec}]The calibration event handle to update\item[{\em rec}]The event record\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em $>$0}]If successful update to an event record \item[{\em $<$0}]If unsuccessful update to an event record \item[{\em 0}]If this was not an event record \end{description}
\end{Desc}


References QSEC\_\-update().