\hypertarget{EFS_8c}{
\section{EFS.c File Reference}
\label{EFS_8c}\index{EFS.c@{EFS.c}}
}
Event Filter Statistics, Generic. 

{\tt \#include \char`\"{}EFC/EFS.h\char`\"{}}\par
{\tt \#include \char`\"{}EFC/EFC.h\char`\"{}}\par
{\tt \#include \char`\"{}EFC/EFA\_\-def.h\char`\"{}}\par
{\tt \#include \char`\"{}EFC/EFS\_\-ids.h\char`\"{}}\par
{\tt \#include \char`\"{}EFC/EFS\_\-ctx\-Ctb.h\char`\"{}}\par
{\tt \#include \char`\"{}EFC\_\-time.ih\char`\"{}}\par
{\tt \#include \char`\"{}dprintf.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/FFS.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-gem.h\char`\"{}}\par
{\tt \#include \char`\"{}EMP/LSD\_\-sdi.h\char`\"{}}\par
{\tt \#include \char`\"{}LSE/LSEW\_\-ctx\-Tim.h\char`\"{}}\par
{\tt \#include \char`\"{}EFC\_\-DB/EFC\_\-DB\_\-schema\-Analysis.h\char`\"{}}\par
{\tt \#include \char`\"{}LSF/LSF.h\char`\"{}}\par
{\tt \#include \char`\"{}LSF/LSF\_\-ids.h\char`\"{}}\par
{\tt \#include \char`\"{}LSF/LSF\_\-cpu.h\char`\"{}}\par
{\tt \#include \char`\"{}LSF/LSF\_\-origin.h\char`\"{}}\par
{\tt \#include \char`\"{}LSF/LSF\_\-reason.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/BFP.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/PBS.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/FPA.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/SEM.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/FORK.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par


Include dependency graph for EFS.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=238pt]{EFS_8c__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__EfsPrvHdr}{\_\-Efs\-Prv\-Hdr}
\begin{CompactList}\small\item\em The previous last event header, used as the baseline for encoding the difference. \item\end{CompactList}\item 
struct \hyperlink{struct__EFS__stats}{\_\-EFS\_\-stats}
\begin{CompactList}\small\item\em The statistics counters. \item\end{CompactList}\item 
struct \hyperlink{struct__EFS__datagram}{\_\-EFS\_\-datagram}
\begin{CompactList}\small\item\em Maps out the fixed part of an EFS datagram. \item\end{CompactList}\item 
struct \hyperlink{struct__EFS}{\_\-EFS}
\begin{CompactList}\small\item\em The generic Event Filter Statistics utility handle. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{EFS_8c_a0}{
\#define {\bf ROUND}(\_\-val)~((((int)(\_\-val)) + 7) \& $\sim$(7))}
\label{EFS_8c_a0}

\item 
\hypertarget{EFS_8c_a1}{
\#define {\bf NPACKETS}~4}
\label{EFS_8c_a1}

\item 
\hypertarget{EFS_8c_a2}{
\#define {\bf DATAGRAM\_\-VERSION}~0}
\label{EFS_8c_a2}

\item 
\hypertarget{EFS_8c_a3}{
\#define {\bf CONTRIBUTION\_\-VERSION}~0}
\label{EFS_8c_a3}

\item 
\hypertarget{EFS_8c_a4}{
\#define {\bf EFS\_\-K\_\-APID\_\-BASE}~0x3b7}
\label{EFS_8c_a4}

\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{EFS_8c_a6}{
typedef \hyperlink{struct__EfsPrvHdr}{\_\-Efs\-Prv\-Hdr} \hyperlink{EFS_8c_a6}{Efs\-Prv\-Hdr}}
\label{EFS_8c_a6}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__EfsPrvHdr}{\_\-Efs\-Prv\-Hdr}. \item\end{CompactList}\item 
\hypertarget{EFS_8c_a7}{
typedef \hyperlink{struct__EFS__stats}{\_\-EFS\_\-stats} \hyperlink{EFS_8c_a7}{EFS\_\-stats}}
\label{EFS_8c_a7}

\begin{CompactList}\small\item\em Typedef for struct {\bf \hyperlink{struct__EFS__stats}{\_\-EFS\_\-stats}}. \item\end{CompactList}\item 
\hypertarget{EFS_8c_a8}{
typedef \hyperlink{struct__EFS__datagram}{\_\-EFS\_\-datagram} \hyperlink{EFS_8c_a8}{EFS\_\-datagram}}
\label{EFS_8c_a8}

\begin{CompactList}\small\item\em Typedef for struct EFS\_\-datagram. \item\end{CompactList}\item 
\hypertarget{EFS_8c_a9}{
typedef \hyperlink{struct__EFS}{\_\-EFS} \hyperlink{EFS_8c_a9}{EFS}}
\label{EFS_8c_a9}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__EFS}{\_\-EFS}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static int \hyperlink{EFS_8c_a10}{get\_\-datagram\_\-size} (int max\_\-records)
\begin{CompactList}\small\item\em Computes, in bytes, the maximal size of a datagram of {\em max\_\-records\/}. \item\end{CompactList}\item 
static int \hyperlink{EFS_8c_a11}{get\_\-datagram\_\-pool\_\-size} (int max\_\-records)
\begin{CompactList}\small\item\em Calculates the size in bytes of the ring buffer pool size from which the datagrams will be allocated. \item\end{CompactList}\item 
static void \hyperlink{EFS_8c_a12}{accumulate} (\hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$stats, unsigned int stride, const void $\ast$beg, const void $\ast$end)
\begin{CompactList}\small\item\em Accumulates the event statistics for the results from {\em beg\/} to {\em end\/}. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int $\ast$ \hyperlink{EFS_8c_a13}{copy} (unsigned int $\ast$dst, const unsigned int $\ast$src, int nbytes)
\begin{CompactList}\small\item\em Copies the specified number of bytes. \item\end{CompactList}\item 
\hypertarget{EFS_8c_a14}{
static \_\-\_\-inline void {\bf add} (unsigned int $\ast$dst, const unsigned int $\ast$src, int cnt)}
\label{EFS_8c_a14}

\item 
\hypertarget{EFS_8c_a15}{
static unsigned int $\ast$ {\bf format\_\-hdr} (unsigned int $\ast$dat, const \hyperlink{struct__EFA__hdr}{EFA\_\-hdr} $\ast$hdr, const \hyperlink{struct__EfsPrvHdr}{Efs\-Prv\-Hdr} $\ast$prv)}
\label{EFS_8c_a15}

\item 
static unsigned int $\ast$ \hyperlink{EFS_8c_a16}{format} (unsigned int $\ast$dat, const unsigned int $\ast$buf, int n, unsigned int max)
\begin{CompactList}\small\item\em Encodes the input buffer using a significant bit count followed by the significant bits. \item\end{CompactList}\item 
static unsigned int $\ast$ \hyperlink{EFS_8c_a17}{format\_\-stats} (unsigned int $\ast$dat, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$stats)
\begin{CompactList}\small\item\em Format the statisitics buffer. \item\end{CompactList}\item 
static unsigned int $\ast$ \hyperlink{EFS_8c_a18}{format\_\-diff\_\-stats} (unsigned int $\ast$dat, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$cur, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$prv)
\begin{CompactList}\small\item\em Format the statisitics buffer as the difference between the current and previous. \item\end{CompactList}\item 
static LSF\_\-record $\ast$ \hyperlink{EFS_8c_a19}{format\_\-global\_\-record} (LSF\_\-record $\ast$rec, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$span, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$stats)
\begin{CompactList}\small\item\em Formats the global statistics record. \item\end{CompactList}\item 
static LSF\_\-record $\ast$ \hyperlink{EFS_8c_a20}{format\_\-begin\_\-record} (LSF\_\-record $\ast$rec, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$span, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$stats)
\begin{CompactList}\small\item\em Formats a normal record with 2 headers. \item\end{CompactList}\item 
static LSF\_\-record $\ast$ \hyperlink{EFS_8c_a21}{format\_\-record} (LSF\_\-record $\ast$rec, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$span, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$stats)
\begin{CompactList}\small\item\em Formats a standard statistics record with one header. \item\end{CompactList}\item 
static LSF\_\-record $\ast$ \hyperlink{EFS_8c_a22}{format\_\-diff\_\-record} (LSF\_\-record $\ast$rec, const \hyperlink{struct__EfsPrvHdr}{Efs\-Prv\-Hdr} $\ast$prv\_\-hdr, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$span, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$cur, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$prv)
\begin{CompactList}\small\item\em Formats a standard statistics record. \item\end{CompactList}\item 
static \_\-\_\-inline void \hyperlink{EFS_8c_a23}{clear} (\hyperlink{struct__EFS}{EFS} $\ast$efs)
\begin{CompactList}\small\item\em Clears the statistics block. \item\end{CompactList}\item 
static \_\-\_\-inline void \hyperlink{EFS_8c_a24}{compose\_\-ctx\_\-template} (\hyperlink{struct__EFS__ctxCtb}{EFS\_\-ctx\-Ctb} $\ast$ctb, unsigned int schema\_\-key, LSF\_\-CPU\_\-K cpu, LSF\_\-ORIGIN\_\-K origin)
\begin{CompactList}\small\item\em Composes the static (one-time fill-in) fields of the context contribution. \item\end{CompactList}\item 
unsigned char $\ast$ \hyperlink{EFS_8c_a25}{EFS\_\-construct} (\hyperlink{struct__EFS}{EFS} $\ast$efs, const EFC\_\-DB\_\-Schema\-Analysis $\ast$schema, int result\_\-size, unsigned int apid\_\-offset, unsigned int dgmid\_\-offset, LSF\_\-CPU\_\-K cpu, LSF\_\-ORIGIN\_\-K origin, unsigned int schema\_\-key, LSD\_\-sdi\-Write\-Cbp $\ast$write)
\begin{CompactList}\small\item\em Constructs an Event Filter Statistics handle. \item\end{CompactList}\item 
void \hyperlink{EFS_8c_a26}{EFS\_\-post} (\hyperlink{struct__EFS}{EFS} $\ast$efs, int reason, const void $\ast$beg, const void $\ast$end, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$span)
\begin{CompactList}\small\item\em Formats the datagram and eventually writes the datagram to the output device. \item\end{CompactList}\item 
int \hyperlink{EFS_8c_a27}{EFS\_\-sizeof} (int max\_\-records)
\begin{CompactList}\small\item\em Computes the size, in bytes, of the EFS control structure. \item\end{CompactList}\item 
int \hyperlink{EFS_8c_a28}{EFS\_\-start} (\hyperlink{struct__EFS}{EFS} $\ast$efs, int reason, int run\_\-id, int start\-Time, int mode)
\begin{CompactList}\small\item\em Captures the start run information. \item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
static const unsigned char \hyperlink{EFS_8c_a5}{Open\-Reasons} \mbox{[}16\mbox{]}
\begin{CompactList}\small\item\em Maps a closing reason into its complimentary open reason. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Event Filter Statistics, Generic. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}   CVS $Id: EFS.c,v 1.4 2007/11/03 00:41:41 jgt Exp $
\end{verbatim}
\normalsize


\subsection{Function Documentation}
\hypertarget{EFS_8c_a12}{
\index{EFS.c@{EFS.c}!accumulate@{accumulate}}
\index{accumulate@{accumulate}!EFS.c@{EFS.c}}
\subsubsection[accumulate]{\setlength{\rightskip}{0pt plus 5cm}static void accumulate (\hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em stats}, unsigned int {\em stride}, const void $\ast$ {\em beg}, const void $\ast$ {\em end})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a12}


Accumulates the event statistics for the results from {\em beg\/} to {\em end\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em stats}]The target statistics block \item[{\em stride}]The number of 32-bit words in each results block \item[{\em beg}]The first results block \item[{\em end}]The last results block (actually one past it)\end{description}
\end{Desc}
\hypertarget{EFS_8c_a23}{
\index{EFS.c@{EFS.c}!clear@{clear}}
\index{clear@{clear}!EFS.c@{EFS.c}}
\subsubsection[clear]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline void clear (\hyperlink{struct__EFS}{EFS} $\ast$ {\em efs})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a23}


Clears the statistics block. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efs}]statistics block to clear.\end{description}
\end{Desc}
\hypertarget{EFS_8c_a24}{
\index{EFS.c@{EFS.c}!compose_ctx_template@{compose\_\-ctx\_\-template}}
\index{compose_ctx_template@{compose\_\-ctx\_\-template}!EFS.c@{EFS.c}}
\subsubsection[compose\_\-ctx\_\-template]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline void compose\_\-ctx\_\-template (\hyperlink{struct__EFS__ctxCtb}{EFS\_\-ctx\-Ctb} $\ast$ {\em ctb}, unsigned int {\em schema\_\-key}, LSF\_\-CPU\_\-K {\em cpu}, LSF\_\-ORIGIN\_\-K {\em origin})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a24}


Composes the static (one-time fill-in) fields of the context contribution. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ctb}]The context contribtution to fill-in \item[{\em schema\_\-key}]The handler configuration key (likely FMX key) \item[{\em cpu}]The originating cpu \item[{\em origin}]The originating data source\end{description}
\end{Desc}
\hypertarget{EFS_8c_a13}{
\index{EFS.c@{EFS.c}!copy@{copy}}
\index{copy@{copy}!EFS.c@{EFS.c}}
\subsubsection[copy]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int $\ast$ copy (unsigned int $\ast$ {\em dst}, const unsigned int $\ast$ {\em src}, int {\em nbytes})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a13}


Copies the specified number of bytes. 

\begin{Desc}
\item[Returns:]Pointer to the next destination address to fill\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dst}]The destination address \item[{\em src}]The source address \item[{\em nbytes}]The number of bytes (must be x4) to copy\end{description}
\end{Desc}
\hypertarget{EFS_8c_a25}{
\index{EFS.c@{EFS.c}!EFS_construct@{EFS\_\-construct}}
\index{EFS_construct@{EFS\_\-construct}!EFS.c@{EFS.c}}
\subsubsection[EFS\_\-construct]{\setlength{\rightskip}{0pt plus 5cm}unsigned char$\ast$ EFS\_\-construct (\hyperlink{struct__EFS}{EFS} $\ast$ {\em efs}, const EFC\_\-DB\_\-Schema\-Analysis $\ast$ {\em schema}, int {\em result\_\-size}, unsigned int {\em apid\_\-offset}, unsigned int {\em dgmid\_\-offset}, LSF\_\-CPU\_\-K {\em cpu}, LSF\_\-ORIGIN\_\-K {\em origin}, unsigned int {\em schema\_\-key}, LSD\_\-sdi\-Write\-Cbp $\ast$ {\em write})}}
\label{EFS_8c_a25}


Constructs an Event Filter Statistics handle. 

\begin{Desc}
\item[Returns:]The next available memory location\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efs}]The control handle to be initialized \item[{\em schema}]The analysis schema \item[{\em result\_\-size}]The size, in 32-bit words, of a result vector This application only uses the first 32-bits assuming them to be a 32-bit Event Filter status mask. \item[{\em apid\_\-offset}]The offset to the base value of the APID. This must be a value between 0 - 4. In general it is represented by on of the values LSF\_\-CPU\_\-K\_\-EPU\_\-0,1,2 or LSF\_\-CPU\_\-SIU\_\-0,1 \item[{\em dgmid\_\-offset}]The offset of the datagram id. The value LSF\_\-ID\_\-K\_\-EFS will be added to this value. \item[{\em cpu}]One of the enumeration LSE\_\-CPU\_\-K specifying the CPU that is writing the datagram \item[{\em origin}]One of the enumeration LSE\_\-ORIGIN\_\-K specifying the origin of the data \item[{\em schema\_\-key}]The, usually FMX, key of the configuration file currently being used to produce the result vectors. This allows the consumer of the EFS datagrams to understand the conditions that the data was taken \item[{\em write}]Callback routine and parameter to commit the formatted datagram to the output device\end{description}
\end{Desc}
\hypertarget{EFS_8c_a26}{
\index{EFS.c@{EFS.c}!EFS_post@{EFS\_\-post}}
\index{EFS_post@{EFS\_\-post}!EFS.c@{EFS.c}}
\subsubsection[EFS\_\-post]{\setlength{\rightskip}{0pt plus 5cm}void EFS\_\-post (\hyperlink{struct__EFS}{EFS} $\ast$ {\em efs}, int {\em reason}, const void $\ast$ {\em beg}, const void $\ast$ {\em end}, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$ {\em span})}}
\label{EFS_8c_a26}


Formats the datagram and eventually writes the datagram to the output device. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efs}]The Event Filter Statistics handle \item[{\em reason}]The reason EFS\_\-post is being called. These are enumerated in EFA\_\-FLUSH\_\-REASON but, briefly are the set of the LSF\_\-REASONs augmented to a record update reason and a record process reason. \item[{\em beg}]The first result vector to analyze \item[{\em end}]The last (actually one past the last) result vector to analyze \item[{\em span}]Structure defining the span of events, both in time and event sequence numbers, that are being analyzed.\end{description}
\end{Desc}
\hypertarget{EFS_8c_a27}{
\index{EFS.c@{EFS.c}!EFS_sizeof@{EFS\_\-sizeof}}
\index{EFS_sizeof@{EFS\_\-sizeof}!EFS.c@{EFS.c}}
\subsubsection[EFS\_\-sizeof]{\setlength{\rightskip}{0pt plus 5cm}int EFS\_\-sizeof (int {\em max\_\-records})}}
\label{EFS_8c_a27}


Computes the size, in bytes, of the EFS control structure. 

\begin{Desc}
\item[Returns:]The size, in bytes,\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em max\_\-records}]The maximum number of records in a datagram\end{description}
\end{Desc}
\hypertarget{EFS_8c_a28}{
\index{EFS.c@{EFS.c}!EFS_start@{EFS\_\-start}}
\index{EFS_start@{EFS\_\-start}!EFS.c@{EFS.c}}
\subsubsection[EFS\_\-start]{\setlength{\rightskip}{0pt plus 5cm}int EFS\_\-start (\hyperlink{struct__EFS}{EFS} $\ast$ {\em efs}, int {\em reason}, int {\em run\_\-id}, int {\em start\-Time}, int {\em mode})}}
\label{EFS_8c_a28}


Captures the start run information. 

\begin{Desc}
\item[Returns:]0 is successful, non-zero otherwise\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efs}]The Event Filter Statistics handle \item[{\em reason}]The LSF\_\-REASON\_\-OPEN to indicate why the stream is being started \item[{\em run\_\-id}]Suggested use is to identify the block of events between when EDS\_\-fw\-Handler\-Start is called and EDS\_\-fw\-Handler\-Flush is called with a stop reason \item[{\em start\-Time}]The run start time rounded to the nearest second \item[{\em mode}]This must be the running mode.\end{description}
\end{Desc}
\hypertarget{EFS_8c_a16}{
\index{EFS.c@{EFS.c}!format@{format}}
\index{format@{format}!EFS.c@{EFS.c}}
\subsubsection[format]{\setlength{\rightskip}{0pt plus 5cm}static unsigned int format (unsigned int $\ast$ {\em dat}, const unsigned int $\ast$ {\em buf}, int {\em n}, unsigned int {\em max})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a16}


Encodes the input buffer using a significant bit count followed by the significant bits. 

\begin{Desc}
\item[Returns:]The next 32-bit word to fill in\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dat}]The output data buffer \item[{\em buf}]The input data buffer \item[{\em n}]The number of values to encode \item[{\em max}]The maximum value\end{description}
\end{Desc}
The format is



\footnotesize\begin{verbatim}       number of bits in the count of number of significant digits (5)
       number of significant digits | significant bits (first + nsig)
       number of significant digits | significant bits
       number of significant digits | significant bits
       .
       .
\end{verbatim}
\normalsize
\hypertarget{EFS_8c_a20}{
\index{EFS.c@{EFS.c}!format_begin_record@{format\_\-begin\_\-record}}
\index{format_begin_record@{format\_\-begin\_\-record}!EFS.c@{EFS.c}}
\subsubsection[format\_\-begin\_\-record]{\setlength{\rightskip}{0pt plus 5cm}static LSF\_\-record $\ast$ format\_\-begin\_\-record (LSF\_\-record $\ast$ {\em rec}, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$ {\em span}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em stats})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a20}


Formats a normal record with 2 headers. 

\begin{Desc}
\item[Returns:]Pointer to the next record to fill\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rec}]The record to format \item[{\em span}]The beginning and ending event sample specification \item[{\em stats}]The statistics\end{description}
\end{Desc}
\hypertarget{EFS_8c_a22}{
\index{EFS.c@{EFS.c}!format_diff_record@{format\_\-diff\_\-record}}
\index{format_diff_record@{format\_\-diff\_\-record}!EFS.c@{EFS.c}}
\subsubsection[format\_\-diff\_\-record]{\setlength{\rightskip}{0pt plus 5cm}static LSF\_\-record $\ast$ format\_\-diff\_\-record (LSF\_\-record $\ast$ {\em rec}, const \hyperlink{struct__EfsPrvHdr}{Efs\-Prv\-Hdr} $\ast$ {\em prv\_\-hdr}, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$ {\em span}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em cur}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em prv})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a22}


Formats a standard statistics record. 

\begin{Desc}
\item[Returns:]Pointer to the next record to fill\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rec}]The record to format. \item[{\em prv\_\-hdr}]Information about the last event header. \item[{\em span}]The beginning and ending event sample specification. \item[{\em cur}]The current set of statistics. \item[{\em prv}]The previous set of statistics. This is used to form differences with the current set. It is these differences that are encoded\end{description}
\end{Desc}
\hypertarget{EFS_8c_a18}{
\index{EFS.c@{EFS.c}!format_diff_stats@{format\_\-diff\_\-stats}}
\index{format_diff_stats@{format\_\-diff\_\-stats}!EFS.c@{EFS.c}}
\subsubsection[format\_\-diff\_\-stats]{\setlength{\rightskip}{0pt plus 5cm}static unsigned int $\ast$ format\_\-diff\_\-stats (unsigned int $\ast$ {\em dat}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em cur}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em prv})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a18}


Format the statisitics buffer as the difference between the current and previous. 

\begin{Desc}
\item[Returns:]A pointer to the next data location to fill\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dat}]The data area \item[{\em cur}]The current statistics \item[{\em prv}]The previous statistics\end{description}
\end{Desc}
Each of the two statistics blocks is formatted the same; a bit mask indicating which counters are non-zero followed by an array of 32-bit counters, one for each set bit.\hypertarget{EFS_8c_a19}{
\index{EFS.c@{EFS.c}!format_global_record@{format\_\-global\_\-record}}
\index{format_global_record@{format\_\-global\_\-record}!EFS.c@{EFS.c}}
\subsubsection[format\_\-global\_\-record]{\setlength{\rightskip}{0pt plus 5cm}static LSF\_\-record $\ast$ format\_\-global\_\-record (LSF\_\-record $\ast$ {\em rec}, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$ {\em span}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em stats})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a19}


Formats the global statistics record. 

\begin{Desc}
\item[Returns:]Pointer to the next record to fill\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rec}]The record to format \item[{\em span}]The beginning and ending event sample specification \item[{\em stats}]The statistics\end{description}
\end{Desc}
\hypertarget{EFS_8c_a21}{
\index{EFS.c@{EFS.c}!format_record@{format\_\-record}}
\index{format_record@{format\_\-record}!EFS.c@{EFS.c}}
\subsubsection[format\_\-record]{\setlength{\rightskip}{0pt plus 5cm}static LSF\_\-record $\ast$ format\_\-record (LSF\_\-record $\ast$ {\em rec}, const \hyperlink{struct__EFA__span}{EFA\_\-span} $\ast$ {\em span}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em stats})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a21}


Formats a standard statistics record with one header. 

\begin{Desc}
\item[Returns:]Pointer to the next record to fill\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rec}]The record to format \item[{\em span}]The beginning and ending event sample specification \item[{\em stats}]The statistics\end{description}
\end{Desc}
\hypertarget{EFS_8c_a17}{
\index{EFS.c@{EFS.c}!format_stats@{format\_\-stats}}
\index{format_stats@{format\_\-stats}!EFS.c@{EFS.c}}
\subsubsection[format\_\-stats]{\setlength{\rightskip}{0pt plus 5cm}static unsigned int $\ast$ format\_\-stats (unsigned int $\ast$ {\em dat}, const \hyperlink{struct__EFS__stats}{EFS\_\-stats} $\ast$ {\em stats})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a17}


Format the statisitics buffer. 

\begin{Desc}
\item[Returns:]A pointer to the next data location to fill\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dat}]The data area \item[{\em stats}]The statistics block to format\end{description}
\end{Desc}
Each of the two statistics blocks is formatted the same; a bit mask indicating which counters are non-zero followed by an array of 32-bit counters, one for each set bit.\hypertarget{EFS_8c_a11}{
\index{EFS.c@{EFS.c}!get_datagram_pool_size@{get\_\-datagram\_\-pool\_\-size}}
\index{get_datagram_pool_size@{get\_\-datagram\_\-pool\_\-size}!EFS.c@{EFS.c}}
\subsubsection[get\_\-datagram\_\-pool\_\-size]{\setlength{\rightskip}{0pt plus 5cm}static int get\_\-datagram\_\-pool\_\-size (int {\em max\_\-records})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a11}


Calculates the size in bytes of the ring buffer pool size from which the datagrams will be allocated. 

\begin{Desc}
\item[Returns:]The size in bytes of the ring buffer pool\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em max\_\-records}]The maximum number of records.\end{description}
\end{Desc}
The datagram pool size is determined by allocating NPACKETS of the maximal datagram size. The maximal datagram size assumes no compression, which is usually in the range of 2-4.

A reasonable number of records would be less than 50. This will give a datagram size of around 17Kbytes.\hypertarget{EFS_8c_a10}{
\index{EFS.c@{EFS.c}!get_datagram_size@{get\_\-datagram\_\-size}}
\index{get_datagram_size@{get\_\-datagram\_\-size}!EFS.c@{EFS.c}}
\subsubsection[get\_\-datagram\_\-size]{\setlength{\rightskip}{0pt plus 5cm}static int get\_\-datagram\_\-size (int {\em max\_\-records})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a10}


Computes, in bytes, the maximal size of a datagram of {\em max\_\-records\/}. 

\begin{Desc}
\item[Returns:]The size of a maximal datagram\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em max\_\-records}]The maximum number of records in a datagram\end{description}
\end{Desc}
This calculation is based on computing the maximal size of a datagram, ignoring compression. The calculation is dominated by the size of {\em max\_\-records\/} number of records. The other datagram overhead is minimal. Each record can take up to 2 full headers (40 bytes each, total of 80) + 64 4 byte counters (256 bytes) for a total of 336 bytes. For example a datagram of 50 records would take approximately 17Kbytes.

\subsection{Variable Documentation}
\hypertarget{EFS_8c_a5}{
\index{EFS.c@{EFS.c}!OpenReasons@{OpenReasons}}
\index{OpenReasons@{OpenReasons}!EFS.c@{EFS.c}}
\subsubsection[OpenReasons]{\setlength{\rightskip}{0pt plus 5cm}unsigned char \hyperlink{EFS_8c_a5}{Open\-Reasons}\mbox{[}16\mbox{]}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{EFS_8c_a5}


{\bf Initial value:}

\footnotesize\begin{verbatim}
{
  LSF_REASON_OPEN_K_START,      
  LSF_REASON_OPEN_K_START_OP,   
  LSF_REASON_OPEN_K_AUTO_TIME,  
  LSF_REASON_OPEN_K_AUTO_COUNT, 


                                
  LSF_REASON_OPEN_K_START,      
  LSF_REASON_OPEN_K_START_OP,   
  LSF_REASON_OPEN_K_START_AUTO, 
  LSF_REASON_OPEN_K_START,      

                                
  LSF_REASON_OPEN_K_RESUME,     
  LSF_REASON_OPEN_K_RESUME_OP,  
  LSF_REASON_OPEN_K_RESUME_AUTO,

                                
  LSF_REASON_OPEN_K_AUTO,       
  LSF_REASON_OPEN_K_AUTO_MODE,  
  LSF_REASON_CLOSE_K_AUTO_TIME, 
  LSF_REASON_CLOSE_K_AUTO_COUNT,
  LSF_REASON_CLOSE_K_AUTO_FULL  
}
\end{verbatim}\normalsize 
Maps a closing reason into its complimentary open reason. 

\begin{Desc}
\item[]When a datagram is closed, it is highly likely that a new one will be opened. This new datagram needs a reason for being opened. In many cases this reopening is automatic, so the opening reason must be internally generated. This array fills that need, mapping an closing reason into its complimentary open reason.\end{Desc}
\begin{Desc}
\item[]Even though this maps all close reasons, some the close reasons are not automatically and likely will not be used. For completeness, a reasonable value is filled in. These entries are marked in the comments with an XX\end{Desc}
