GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> ASC / V0-0-6 > test_ascOes / linux-gcc
#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_file * | EBF_open (const char *fileName, int segment_size) |
Opens a EBF file for reading. | |
struct _EBF_file * | EBF_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. |
* $ 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 _ADVANCE | ( | _ptr, | |||
_nbytes | ) | (void *)((unsigned char *)(_ptr) + (_nbytes)) |
Advances _ptr by _nbytes. The return value is always recast to the type of _ptr.
_ptr | The pointer to advance | |
_nbytes | The number of nbytes to advance _ptr by. |
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.
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().
Loops through the input files one at a time, calling the accumulation routine.
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.
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.
ebd | Pointer to the in memory data structure. |
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.
ebf | The event builder format file handle |
References _EBF_file::free.
EBF_file * EBF_open | ( | const char * | fileName, | |
int | segment_size | |||
) | [read] |
Opens a EBF file for reading.
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. |
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.
ebf | A previously opened event builder file handle |
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.
ctl | The parameter control block. | |
argc | The number of command line parameters. | |
argv | The array of pointers to the command line parameters. |
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.
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.
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.
argc | The number of arguments | |
argv | The vector of arguments. |
* $ 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.
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.
timing | The timing information to print |
References _AscTiming::eacc, _AscTiming::edir, _AscTiming::etotal, _AscTiming::eunpack, and _AscTiming::nevts.
Referenced by print().