GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> ASC / V0-0-6 > test_ascOes / linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

test_asc.c File Reference

Program to test ACD counting statistics. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "PBS/TMR.h"
#include "PBS/PTS.h"
#include "PBS/MBA.h"
#include "ASC/ASC.h"
#include "ASC/ASC_dbg.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include "PBI/Endianness.h"

Classes

struct  _AscTiming
 Keep track of the elapsed times. More...
struct  _GetCtx
 Structure to hold the context for retrieving a pointer to the next input file. More...
struct  _Ctl
 Collections all the control parameters together. These are essentially the interpretted command line options. More...
struct  _EBF_file
 Internal structure used to control the access to a EBF file. More...

Defines

#define _ADVANCE(_ptr, _nbytes)   (void *)((unsigned char *)(_ptr) + (_nbytes))
 Advances _ptr by _nbytes. The return value is always recast to the type of _ptr.

Typedefs

typedef struct _EBF_file EBF_file
 Typedef for struct _EBF_file.
typedef struct _AscTiming AscTiming
 Typedef for struct _AscTiming.
typedef struct _Ctl Ctl
 Typedef for struct _Ctl.
typedef const char *(* Get_filename )(void *ctx)
 Typedef of the callback routine to retrieve the next input file name.
typedef struct _GetCtx GetCtx
 Typedef for struct _GetCtx.

Functions

struct _EBF_fileEBF_open (const char *fileName, int segment_size)
 Opens a EBF file for reading.
struct _EBF_fileEBF_dmap (unsigned int *ebd)
 Prepares an in memory data structure to be read.
int EBF_read (EBF_file *ebf)
 Reads the EBF file associated with the event file handle ebf.
int EBF_close (EBF_file *ebf)
 Closes the file after it has been read.
int EBF_free (EBF_file *ebf)
 Frees the memory associated with the contents of the file.
unsigned int EBF_esize (const EBF_file *ebf)
 Returns the size of the event data (in bytes).
const unsigned int * EBF_edata (const EBF_file *ebf)
 Returns a pointer to the first event.
static int do_it (Ctl *ctl)
 Simple driver program to setup, accumulate and print the statistics.
static int accumulate (ASC_counters *counters, AscTiming *timing, Ctl *ctl)
 Loops through the input files one at a time, calling the accumulation routine.
static int finalize (ASC_counters *counters)
 Completes the statistics arrays by performing one time summary operations.
static void print (unsigned int options, const ASC_counters *counters, const AscTiming *timing)
 Prints the statistics and timing information.
static void printTiming (const AscTiming *timing)
 Prints the timing information.
static int acc_acd_stats (ASC_counters *counters, AscTiming *timing, struct _ASC_acd *acd, const unsigned int *edata, int esize, int ecnt, int eoffset)
 Accumulates the statistics for the specified array of events.
static int fill_ctl (Ctl *ctl, int argc, char *const argv[])
 Examines the command line parameters and fills the print control structure.
static const char * get_filename (GetCtx *ctx)
 User provide callback routine to retrieve the next input file.
int main (int argc, char *const argv[])
 Usual entry point for the test_asc.

Variables

const unsigned int EbfData []
 A small set of test data.


Detailed Description

Program to test ACD counting statistics.

Author:
JJRussell - russell@slac.stanford.edu
 *   $ test_asc -n <number_of_events> <input_files>
 *  

 *   CVS $Id: test_asc.c,v 1.1.1.1 2005/12/01 21:55:31 ebacho Exp $
 *   
 * 

Define Documentation

#define _ADVANCE ( _ptr,
_nbytes   )     (void *)((unsigned char *)(_ptr) + (_nbytes))

Advances _ptr by _nbytes. The return value is always recast to the type of _ptr.

Parameters:
_ptr The pointer to advance
_nbytes The number of nbytes to advance _ptr by.
Returns:
The advanced pointer, the pointer is recast to a void *.


Function Documentation

static int acc_acd_stats ( ASC_counters *  counters,
AscTiming timing,
struct _ASC_acd *  acd,
const unsigned int *  edata,
int  esize,
int  ecnt,
int  eoffset 
) [static]

Accumulates the statistics for the specified array of events.

Returns:
The number of events processed
Parameters:
counters Pointer to the counter block
timing Structure to keep track of the timing
acd Scratch memory to hold unpacked ACD data
edata The input data array
esize The total number of data bytes
ecnt The number of events to process
eoffset 32-bit offset to the length of the event

References _AscTiming::eacc, _AscTiming::edir, _AscTiming::etotal, _AscTiming::eunpack, and _AscTiming::nevts.

Referenced by accumulate().

static int accumulate ( ASC_counters *  counters,
AscTiming timing,
Ctl ctl 
) [static]

Loops through the input files one at a time, calling the accumulation routine.

Returns:
Status
Parameters:
counters The ACD statistics block to fill
timing Structure to keep track of the timing statistics
ctl The input parameter control block

References acc_acd_stats(), EBF_close(), EBF_edata(), EBF_esize(), EBF_open(), EBF_read(), EbfData, _Ctl::get, _Ctl::get_ctx, _GetCtx::names, and _Ctl::to_process.

Referenced by do_it().

static int do_it ( Ctl ctl  )  [static]

Simple driver program to setup, accumulate and print the statistics.

Parameters:
ctl The control statistics, containing such things as the list of files to accumulate over, the number of events to process etc

References accumulate(), finalize(), _Ctl::options, and print().

Referenced by main().

int EBF_close ( EBF_file ebf  ) 

Closes the file after it has been read.

This function only closes the file after its contents have been read into memory. To free the memory associated with the contents of the file, the user must call EBF_free().

References _EBF_file::fd.

Referenced by accumulate().

EBF_file * EBF_dmap ( unsigned int *  ebd  )  [read]

Prepares an in memory data structure to be read.

Parameters:
ebd Pointer to the in memory data structure.
Returns:
If successful, the file handle, else NULL

References _EBF_file::edata, _EBF_file::fd, _EBF_file::free, _EBF_file::name, and _EBF_file::size.

const unsigned int * EBF_edata ( const EBF_file ebf  ) 

Returns a pointer to the first event.

This function is called after EBF_read to locate the first event. Subsequent events are found by advancing this pointer by the size of the event. The size of the event is stored in the first 32-bit word of the event.

References _EBF_file::edata.

Referenced by accumulate().

int EBF_free ( EBF_file ebf  ) 

Frees the memory associated with the contents of the file.

Parameters:
ebf The event builder format file handle
After calling EBF_free, the contents and the event builder format file handle are no longer valid.

References _EBF_file::free.

EBF_file * EBF_open ( const char *  fileName,
int  segment_size 
) [read]

Opens a EBF file for reading.

Parameters:
fileName The name of the EBF file to open
segment_size The largest portion of the file that will be buffered on a read. (Currently unused, the whole file is read in all the time.
Returns:
If successful, the file handle else, NULL

References _EBF_file::edata, _EBF_file::fd, _EBF_file::free, _EBF_file::name, _EBF_file::seg_size, and _EBF_file::size.

Referenced by accumulate().

int EBF_read ( EBF_file ebf  ) 

Reads the EBF file associated with the event file handle ebf.

Parameters:
ebf A previously opened event builder file handle
Return values:
0,if successful
-1,if not

References _EBF_file::edata, _EBF_file::fd, _EBF_file::name, and _EBF_file::size.

Referenced by accumulate().

static int fill_ctl ( Ctl ctl,
int  argc,
char *const   argv[] 
) [static]

Examines the command line parameters and fills the print control structure.

Parameters:
ctl The parameter control block.
argc The number of command line parameters.
argv The array of pointers to the command line parameters.
Return values:
0,Everything is okay.
-1,Incorrect command usage. Usually this means that the input file name was absent.

References _GetCtx::cnt, _GetCtx::cur, _Ctl::get, _Ctl::get_ctx, get_filename(), _GetCtx::names, _Ctl::ofile, _Ctl::options, _Ctl::quiet, _Ctl::to_print, _Ctl::to_process, and _Ctl::to_skip.

Referenced by main().

static int finalize ( ASC_counters *  counters  )  [static]

Completes the statistics arrays by performing one time summary operations.

Parameters:
counters The ACD statistics

Referenced by do_it().

static const char * get_filename ( GetCtx ctx  )  [static]

User provide callback routine to retrieve the next input file.

Returns:
A pointer to the next file or NULL if no more
Parameters:
ctx The input file context handle

References _GetCtx::cnt, _GetCtx::cur, and _GetCtx::names.

Referenced by fill_ctl().

int main ( int  argc,
char *const   argv[] 
)

Usual entry point for the test_asc.

Parameters:
argc The number of arguments
argv The vector of arguments.
The squeeze t takes two parameters, the name of the file and the number of events to read and process. Example

 *   $ test_asc myEventFile.ebf 4
 *
 *     Accumulates the statistics for the the 4 events
 *
 *  

References do_it(), and fill_ctl().

static void print ( unsigned int  options,
const ASC_counters *  counters,
const AscTiming timing 
) [static]

Prints the statistics and timing information.

Parameters:
options If bit 0 is set, print statistics If bit 1 is set, print timing
counters The statistics counters
timing The timing numbers

References printTiming().

Referenced by do_it().

static void printTiming ( const AscTiming counters  )  [static]

Prints the timing information.

Parameters:
timing The timing information to print

References _AscTiming::eacc, _AscTiming::edir, _AscTiming::etotal, _AscTiming::eunpack, and _AscTiming::nevts.

Referenced by print().


Generated on Fri Sep 30 19:21:28 2011 by  doxygen 1.5.8