\hypertarget{configure_8c}{
\section{configure.c File Reference}
\label{configure_8c}\index{configure.c@{configure.c}}
}
Routines that manipulate the configuration structure and the associated data file. 

{\tt \#include \char`\"{}configure\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}lci\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}LCI/LCI\_\-msgs.h\char`\"{}}\par
{\tt \#include \char`\"{}LCFG/LCFG.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/LSEC\_\-ctx.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/LSEC.h\char`\"{}}\par
{\tt \#include \char`\"{}FBS/FBS\_\-pubrtos.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/msg\_\-macros.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/defs.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/encode.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/decode.h\char`\"{}}\par
{\tt \#include \char`\"{}MSG/MSG\_\-pubdefs.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/BSWP.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/MBA.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/TASK.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/TOV.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/WCT.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$fcntl.h$>$}\par
{\tt \#include $<$unistd.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned \hyperlink{configure_8c_54fad3468e6a777e839cfbe0edca9414}{LCI\_\-confBufferModel} (unsigned select, LEM\_\-micr $\ast$cr, unsigned $\ast$mods)
\begin{CompactList}\small\item\em Set the TEM buffer model. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_09295044a1920db462932bf8f4aaa6b9}{LCI\_\-confCache} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf, unsigned latc\_\-fid)
\begin{CompactList}\small\item\em Read in the LATC files. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_ade003120ed8873b1cdb9ec3f2ca2522}{LCI\_\-confClose} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf)
\begin{CompactList}\small\item\em Close the file that acts as the source of the configuration. \item\end{CompactList}\item 
void \hyperlink{configure_8c_3eb0c3efe23d7ca902a458f1738b3306}{LCI\_\-confCopy} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnfIn, \hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnfOut)
\begin{CompactList}\small\item\em Copy a configuration. \item\end{CompactList}\item 
\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$ \hyperlink{configure_8c_0d04e48c83b4dbd26fbd1617d8f342d7}{LCI\_\-confCreate} (LSEC\_\-control $\ast$lsec)
\begin{CompactList}\small\item\em Create a new configuration structure. \item\end{CompactList}\item 
void \hyperlink{configure_8c_e50e55be3835a812d2698ba9522b06e1}{LCI\_\-confDelete} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf)
\begin{CompactList}\small\item\em Free memory previously allocated with a call to LCI\_\-confCreate. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_ac7c025c89f60eea10f40ed6541249d3}{LCI\_\-configure} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf, LEM\_\-micr $\ast$cr, unsigned runId)
\begin{CompactList}\small\item\em Load the configuration onto the LAT. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_b37b924dc9ffbeb48e043c4d73afb06b}{LCI\_\-confMode} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf)
\begin{CompactList}\small\item\em Return the configuration type. \item\end{CompactList}\item 
void \hyperlink{configure_8c_8e570d01050204f5249588069d758549}{LCI\_\-confNodeId} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf, unsigned siu\_\-id)
\begin{CompactList}\small\item\em Set the destination address to be used in the TAM configuration. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_d3f24364d91beb5822d69e25e964207e}{LCI\_\-confOpen} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf, const char $\ast$fn)
\begin{CompactList}\small\item\em Open the file and associate it with this configuration structure. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_4de0c4168613a7472cd2ca0f750f06d1}{LCI\_\-confOpenFid} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf, unsigned fid)
\begin{CompactList}\small\item\em Open the file and associate it with this configuration structure. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_b2955b7caa8526580e8667877ea53a55}{LCI\_\-confPeriod} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf)
\begin{CompactList}\small\item\em Return the period between triggers. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_23d7696843650c424ce1c1ca28173956}{LCI\_\-confRead} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf)
\begin{CompactList}\small\item\em Get the values for the next step of the configuration. \item\end{CompactList}\item 
void \hyperlink{configure_8c_43aa4f3ab836636a344adc18f6e19478}{LCI\_\-confReport} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf, FILE $\ast$fp)
\begin{CompactList}\small\item\em Produce a formatted report of the contents of a binary configuration. \item\end{CompactList}\item 
void \hyperlink{configure_8c_d55095be6a7e2d48feddb150c8367f13}{LCI\_\-confTimes} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf, int clear, long long $\ast$lci\_\-time, long long $\ast$lat\_\-time)
\begin{CompactList}\small\item\em Return accumulated configuration times. \item\end{CompactList}\item 
unsigned \hyperlink{configure_8c_8deb98af23281fae5e70b404f08ed27f}{LCI\_\-confTriggers} (\hyperlink{struct__LCI__configuration}{LCI\_\-configuration} $\ast$cnf)
\begin{CompactList}\small\item\em Return the number of triggers required. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Routines that manipulate the configuration structure and the associated data file. 

\begin{Desc}
\item[Author:]James Swain \& Owen Saxton\end{Desc}
{\bf \$Id:} \hyperlink{configure_8c}{configure.c},v 1.28 2010/05/25 18:34:47 saxton Exp \$ 

\subsection{Function Documentation}
\hypertarget{configure_8c_54fad3468e6a777e839cfbe0edca9414}{
\index{configure.c@{configure.c}!LCI_confBufferModel@{LCI\_\-confBufferModel}}
\index{LCI_confBufferModel@{LCI\_\-confBufferModel}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confBufferModel (unsigned {\em select}, LEM\_\-micr $\ast$ {\em cr}, unsigned $\ast$ {\em mods})}}
\label{configure_8c_54fad3468e6a777e839cfbe0edca9414}


Set the TEM buffer model. 

This routine sets the value of the buffer model select bit in the TEM CONFIGURATION register, necessary because the calibration requires non-standard single buffering. It optionally also returns the operational state of the various data acquisition modules (TEMs, GEM and AEM), needed for event data checking.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em select}]Zero to select the multi buffer model, non-zero to select the single buffer model\item[{\em cr}]Pointer to the multi-item command/response list.\item[{\em mods}]Pointer to an integer to receive the bit mask of operational acquisition modules, or NULL if this information is not required.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]Success \item[{\em LCI\_\-TEMCR}]The command and response masks don't have the same TEMs present \item[{\em LEM\_\-$\ast$}]If there was an error reading or loading one of the registers \end{description}
\end{Desc}
\hypertarget{configure_8c_09295044a1920db462932bf8f4aaa6b9}{
\index{configure.c@{configure.c}!LCI_confCache@{LCI\_\-confCache}}
\index{LCI_confCache@{LCI\_\-confCache}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confCache ({\bf LCI\_\-configuration} $\ast$ {\em cnf}, unsigned {\em latc\_\-fid})}}
\label{configure_8c_09295044a1920db462932bf8f4aaa6b9}


Read in the LATC files. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an initialised configuration structure\item[{\em latc\_\-fid}]ID of the LATC configuration to cache\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]if all goes well \item[{\em LCFG\_\-BADFOPEN}]if the fid, or any of the names the LAT configuration master file contains, does not match a valid file. \item[{\em LCFG\_\-BADTYPE}]if the LATC file contains a bad type identifier \item[{\em LCFG\_\-BADREAD}]if an error occurs whilst the file is being read \end{description}
\end{Desc}
\hypertarget{configure_8c_ade003120ed8873b1cdb9ec3f2ca2522}{
\index{configure.c@{configure.c}!LCI_confClose@{LCI\_\-confClose}}
\index{LCI_confClose@{LCI\_\-confClose}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confClose ({\bf LCI\_\-configuration} $\ast$ {\em cnf})}}
\label{configure_8c_ade003120ed8873b1cdb9ec3f2ca2522}


Close the file that acts as the source of the configuration. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an opened configuration\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]If the file closes successfully \item[{\em LCI\_\-FCLOSE}]If there is an error closing the file \end{description}
\end{Desc}
\hypertarget{configure_8c_3eb0c3efe23d7ca902a458f1738b3306}{
\index{configure.c@{configure.c}!LCI_confCopy@{LCI\_\-confCopy}}
\index{LCI_confCopy@{LCI\_\-confCopy}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-confCopy ({\bf LCI\_\-configuration} $\ast$ {\em cnfIn}, {\bf LCI\_\-configuration} $\ast$ {\em cnfOut})}}
\label{configure_8c_3eb0c3efe23d7ca902a458f1738b3306}


Copy a configuration. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnfIn}]The configuration structure to be copied from\item[{\em cnfOut}]The configuration structure to be copied to \end{description}
\end{Desc}
\hypertarget{configure_8c_0d04e48c83b4dbd26fbd1617d8f342d7}{
\index{configure.c@{configure.c}!LCI_confCreate@{LCI\_\-confCreate}}
\index{LCI_confCreate@{LCI\_\-confCreate}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf LCI\_\-configuration}$\ast$ LCI\_\-confCreate (LSEC\_\-control $\ast$ {\em lsec})}}
\label{configure_8c_0d04e48c83b4dbd26fbd1617d8f342d7}


Create a new configuration structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em lsec}]The LSEC handle.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to an allocated, initialised configuration structure \end{Desc}
\hypertarget{configure_8c_e50e55be3835a812d2698ba9522b06e1}{
\index{configure.c@{configure.c}!LCI_confDelete@{LCI\_\-confDelete}}
\index{LCI_confDelete@{LCI\_\-confDelete}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-confDelete ({\bf LCI\_\-configuration} $\ast$ {\em cnf})}}
\label{configure_8c_e50e55be3835a812d2698ba9522b06e1}


Free memory previously allocated with a call to LCI\_\-confCreate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]A configuration structure created by a call to LCI\_\-confCreate \end{description}
\end{Desc}
\hypertarget{configure_8c_ac7c025c89f60eea10f40ed6541249d3}{
\index{configure.c@{configure.c}!LCI_configure@{LCI\_\-configure}}
\index{LCI_configure@{LCI\_\-configure}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-configure ({\bf LCI\_\-configuration} $\ast$ {\em cnf}, LEM\_\-micr $\ast$ {\em cr}, unsigned {\em runId})}}
\label{configure_8c_ac7c025c89f60eea10f40ed6541249d3}


Load the configuration onto the LAT. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to a populated configuration structure\item[{\em cr}]Pointer to the common configuration multi-item command response list\item[{\em runId}]The current run ID.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]LCI\_\-SUCCESS if all goes well, or one of the LEM errors if there is a problem loading the configuration onto the LAT \end{Desc}
\hypertarget{configure_8c_b37b924dc9ffbeb48e043c4d73afb06b}{
\index{configure.c@{configure.c}!LCI_confMode@{LCI\_\-confMode}}
\index{LCI_confMode@{LCI\_\-confMode}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confMode ({\bf LCI\_\-configuration} $\ast$ {\em cnf})}}
\label{configure_8c_b37b924dc9ffbeb48e043c4d73afb06b}


Return the configuration type. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to the configuration structure\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]One of LSEC\_\-MODE\_\-XXX \end{Desc}
\hypertarget{configure_8c_8e570d01050204f5249588069d758549}{
\index{configure.c@{configure.c}!LCI_confNodeId@{LCI\_\-confNodeId}}
\index{LCI_confNodeId@{LCI\_\-confNodeId}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-confNodeId ({\bf LCI\_\-configuration} $\ast$ {\em cnf}, unsigned {\em siu\_\-id})}}
\label{configure_8c_8e570d01050204f5249588069d758549}


Set the destination address to be used in the TAM configuration. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to the configuration structure\item[{\em siu\_\-id}]LATp address of the node that the events will be collected on \end{description}
\end{Desc}
\hypertarget{configure_8c_d3f24364d91beb5822d69e25e964207e}{
\index{configure.c@{configure.c}!LCI_confOpen@{LCI\_\-confOpen}}
\index{LCI_confOpen@{LCI\_\-confOpen}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confOpen ({\bf LCI\_\-configuration} $\ast$ {\em cnf}, const char $\ast$ {\em fn})}}
\label{configure_8c_d3f24364d91beb5822d69e25e964207e}


Open the file and associate it with this configuration structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an initialised configuration structure\item[{\em fn}]Name of file to open\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]if the file opens successfully \item[{\em LCI\_\-FOPEN}]if the file failed to open successfully \item[{\em LCI\_\-FREAD}]if there is an error recovering the version information (including file too short). \item[{\em LCI\_\-VERSION}]if the file version information is bad (unknown type, major version mismatch, minor version decrease). \end{description}
\end{Desc}
\hypertarget{configure_8c_4de0c4168613a7472cd2ca0f750f06d1}{
\index{configure.c@{configure.c}!LCI_confOpenFid@{LCI\_\-confOpenFid}}
\index{LCI_confOpenFid@{LCI\_\-confOpenFid}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confOpenFid ({\bf LCI\_\-configuration} $\ast$ {\em cnf}, unsigned {\em fid})}}
\label{configure_8c_4de0c4168613a7472cd2ca0f750f06d1}


Open the file and associate it with this configuration structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an initialised configuration structure\item[{\em fid}]The ID of the file to open\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]if the file opens successfully \item[{\em LCI\_\-FOPEN}]if the file failed to open successfully \item[{\em LCI\_\-FREAD}]if there is an error recovering the version information (including file too short). \item[{\em LCI\_\-VERSION}]if the file version information is bad (unknown type, major version mismatch, minor version decrease). \end{description}
\end{Desc}
\hypertarget{configure_8c_b2955b7caa8526580e8667877ea53a55}{
\index{configure.c@{configure.c}!LCI_confPeriod@{LCI\_\-confPeriod}}
\index{LCI_confPeriod@{LCI\_\-confPeriod}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confPeriod ({\bf LCI\_\-configuration} $\ast$ {\em cnf})}}
\label{configure_8c_b2955b7caa8526580e8667877ea53a55}


Return the period between triggers. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an initialised, populated configuration structure\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The period between triggers (in 50ns clock ticks) \end{Desc}
\hypertarget{configure_8c_23d7696843650c424ce1c1ca28173956}{
\index{configure.c@{configure.c}!LCI_confRead@{LCI\_\-confRead}}
\index{LCI_confRead@{LCI\_\-confRead}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confRead ({\bf LCI\_\-configuration} $\ast$ {\em cnf})}}
\label{configure_8c_23d7696843650c424ce1c1ca28173956}


Get the values for the next step of the configuration. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an opened configuration\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]if a configuration was read successfully \item[{\em LCI\_\-ENDOFILE}]if there are no more configurations in the file (returned, but not reported). \item[{\em LCI\_\-FREAD}]if there is an error during the read or the configuration is incomplete \end{description}
\end{Desc}
\hypertarget{configure_8c_43aa4f3ab836636a344adc18f6e19478}{
\index{configure.c@{configure.c}!LCI_confReport@{LCI\_\-confReport}}
\index{LCI_confReport@{LCI\_\-confReport}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-confReport ({\bf LCI\_\-configuration} $\ast$ {\em cnf}, FILE $\ast$ {\em fp})}}
\label{configure_8c_43aa4f3ab836636a344adc18f6e19478}


Produce a formatted report of the contents of a binary configuration. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to the configuration structure to output\item[{\em fp}]Pointer to file to print report \end{description}
\end{Desc}
\hypertarget{configure_8c_d55095be6a7e2d48feddb150c8367f13}{
\index{configure.c@{configure.c}!LCI_confTimes@{LCI\_\-confTimes}}
\index{LCI_confTimes@{LCI\_\-confTimes}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-confTimes ({\bf LCI\_\-configuration} $\ast$ {\em cnf}, int {\em clear}, long long $\ast$ {\em lci\_\-time}, long long $\ast$ {\em lat\_\-time})}}
\label{configure_8c_d55095be6a7e2d48feddb150c8367f13}


Return accumulated configuration times. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an initialised, populated configuration structure.\item[{\em clear}]If TRUE, clear the times after copying them.\item[{\em lci\_\-time}]Address of a variable to receive the accumulated time taken to do LCI configurations or NULL if the time is not wanted.\item[{\em lat\_\-time}]Address of a variable to receive the accumulated time taken to do any LAT configurations or NULL if the time is not wanted. \end{description}
\end{Desc}
\hypertarget{configure_8c_8deb98af23281fae5e70b404f08ed27f}{
\index{configure.c@{configure.c}!LCI_confTriggers@{LCI\_\-confTriggers}}
\index{LCI_confTriggers@{LCI\_\-confTriggers}!configure.c@{configure.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-confTriggers ({\bf LCI\_\-configuration} $\ast$ {\em cnf})}}
\label{configure_8c_8deb98af23281fae5e70b404f08ed27f}


Return the number of triggers required. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnf}]Pointer to an initialised, populated configuration structure\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Number of triggers to request for this configuration \end{Desc}
