GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> EFC / V4-5-5 > defc / rhel5-64
#include <EFC/EFS.h>
#include <EFC/EFC.h>
#include <EFC/EFA_def.h>
#include <EFC/EFS_ids.h>
#include <EFC/EFS_ctxCtb.h>
#include <EFC_time.ih>
#include <dprintf.h>
#include <EDS/EBF_gem.h>
#include <EMP/LSD_sdi.h>
#include <LSE/LSEW_ctxTim.h>
#include <EFC_DB/EFC_DB_schemaAnalysis.h>
#include <LSF/LSF.h>
#include <LSF/LSF_ids.h>
#include <LSF/LSF_cpu.h>
#include <LSF/LSF_origin.h>
#include <LSF/LSF_reason.h>
#include <LDT/BFP.h>
#include <PBS/PBS.h>
#include <PBS/FPA.h>
#include <PBS/SEM.h>
#include <PBS/FORK.h>
#include <PBI/FFS.ih>
#include <string.h>
Classes | |
struct | _EfsPrvHdr |
The previous last event header, used as the baseline for encoding the difference. More... | |
struct | _EFS_stats |
The statistics counters. More... | |
struct | _EFS_datagram |
Maps out the fixed part of an EFS datagram. More... | |
struct | _EFS |
The generic Event Filter Statistics utility handle. More... | |
Defines | |
#define | ROUND(_val) ((((int)(_val)) + 7) & ~(7)) |
#define | NPACKETS 4 |
#define | DATAGRAM_VERSION 0 |
#define | CONTRIBUTION_VERSION 0 |
#define | EFS_K_APID_BASE 0x3b7 |
Typedefs | |
typedef struct _EfsPrvHdr | EfsPrvHdr |
Typedef for struct _EfsPrvHdr. | |
typedef struct _EFS_stats | EFS_stats |
Typedef for struct _EFS_stats. | |
typedef struct _EFS_datagram | EFS_datagram |
Typedef for struct EFS_datagram. | |
typedef struct _EFS | EFS |
Typedef for struct _EFS. | |
Functions | |
static unsigned int | sbsKeyGet (void) |
Retrieves the secondary boot script key. | |
static int | get_datagram_size (int max_records) |
Computes, in bytes, the maximal size of a datagram of max_records. | |
static int | get_datagram_pool_size (int max_records) |
Calculates the size in bytes of the ring buffer pool size from which the datagrams will be allocated. | |
static void | accumulate (EFS_stats *stats, unsigned int stride, const void *beg, const void *end) |
Accumulates the event statistics for the results from beg to end. | |
static __inline unsigned int * | copy (unsigned int *dst, const unsigned int *src, int nbytes) |
Copies the specified number of bytes. | |
static __inline void | add (unsigned int *dst, const unsigned int *src, int cnt) |
static unsigned int * | format_hdr (unsigned int *dat, const EFA_hdr *hdr, const EfsPrvHdr *prv) |
static unsigned int * | format (unsigned int *dat, const unsigned int *buf, int n, unsigned int max) |
Encodes the input buffer using a significant bit count followed by the significant bits. | |
static unsigned int * | format_stats (unsigned int *dat, const EFS_stats *stats) |
Format the statisitics buffer. | |
static unsigned int * | format_diff_stats (unsigned int *dat, const EFS_stats *cur, const EFS_stats *prv) |
Format the statisitics buffer as the difference between the current and previous. | |
static LSF_record * | format_global_record (LSF_record *rec, const EFA_span *span, const EFS_stats *stats) |
Formats the global statistics record. | |
static LSF_record * | format_begin_record (LSF_record *rec, const EFA_span *span, const EFS_stats *stats) |
Formats a normal record with 2 headers. | |
static LSF_record * | format_record (LSF_record *rec, const EFA_span *span, const EFS_stats *stats) |
Formats a standard statistics record with one header. | |
static LSF_record * | format_diff_record (LSF_record *rec, const EfsPrvHdr *prv_hdr, const EFA_span *span, const EFS_stats *cur, const EFS_stats *prv) |
Formats a standard statistics record. | |
static __inline void | clear (EFS *efs) |
Clears the statistics block. | |
static __inline void | compose_ctx_template (EFS_ctxCtb *ctb, unsigned int sbs, unsigned int schema_key, LSF_CPU_K cpu, LSF_ORIGIN_K origin) |
Composes the static (one-time fill-in) fields of the context contribution. | |
unsigned char * | EFS_construct (EFS *efs, const EFC_DB_SchemaAnalysis *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_sdiWriteCbp *write) |
Constructs an Event Filter Statistics handle. | |
void | EFS_post (EFS *efs, int reason, const void *beg, const void *end, const EFA_span *span) |
Formats the datagram and eventually writes the datagram to the output device. | |
int | EFS_sizeof (int max_records) |
Computes the size, in bytes, of the EFS control structure. | |
int | EFS_start (EFS *efs, int reason, int run_id, int startTime, int mode) |
Captures the start run information. | |
Variables | |
static const unsigned char | OpenReasons [16] |
Maps a closing reason into its complimentary open reason. |
CVS $Id: EFS.c,v 1.6 2011/03/27 04:55:30 russell Exp $
static void accumulate | ( | EFS_stats * | stats, | |
unsigned int | stride, | |||
const void * | beg, | |||
const void * | end | |||
) | [static] |
Accumulates the event statistics for the results from beg to end.
stats | The target statistics block | |
stride | The number of 32-bit words in each results block | |
beg | The first results block | |
end | The last results block (actually one past it) |
References _EFS_stats::cnts.
Referenced by EFS_post().
static __inline void clear | ( | EFS * | efs | ) | [static] |
Clears the statistics block.
efs | statistics block to clear. |
References _EFS::gbl_span, and _EFS::stats.
Referenced by EFS_post().
static __inline void compose_ctx_template | ( | EFS_ctxCtb * | ctb, | |
unsigned int | sbs, | |||
unsigned int | schema_key, | |||
LSF_CPU_K | cpu, | |||
LSF_ORIGIN_K | origin | |||
) | [static] |
Composes the static (one-time fill-in) fields of the context contribution.
ctb | The context contribtution to fill-in | |
sbs | The secondary boot script file key | |
schema_key | The handler configuration key (likely FMX key) | |
cpu | The originating cpu | |
origin | The originating data source |
References _EFS_ctxCtb::bdy, _EFS_ctxKeys::cfg, _EFS_ctxBdy::did, EFS_ID_K_CTX, _EFS_ctxKeys::handler, _EFS_ctxCtb::hdr, _EFS_ctxBdy::key, and _EFS_ctxKeys::sbs.
Referenced by EFS_construct().
static __inline unsigned int * copy | ( | unsigned int * | dst, | |
const unsigned int * | src, | |||
int | nbytes | |||
) | [static] |
Copies the specified number of bytes.
dst | The destination address | |
src | The source address | |
nbytes | The number of bytes (must be x4) to copy |
Referenced by format_begin_record(), format_global_record(), and format_record().
unsigned char* EFS_construct | ( | EFS * | efs, | |
const EFC_DB_SchemaAnalysis * | 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_sdiWriteCbp * | write | |||
) |
Constructs an Event Filter Statistics handle.
efs | The control handle to be initialized | |
schema | The analysis schema | |
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. | |
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 | |
dgmid_offset | The offset of the datagram id. The value LSF_ID_K_EFS will be added to this value. | |
cpu | One of the enumeration LSE_CPU_K specifying the CPU that is writing the datagram | |
origin | One of the enumeration LSE_ORIGIN_K specifying the origin of the data | |
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 | |
write | Callback routine and parameter to commit the formatted datagram to the output device |
References compose_ctx_template(), _EFS::ctbHdrId, _EFS::ctxCtb, _EFS::cur_idx, _EFS::dgm_size, _EFS::dgmHdrId, EFS_ID_K_STATS, get_datagram_pool_size(), get_datagram_size(), _EFS::nrecs, _EFS::recLimit, sbsKeyGet(), _EFS::sdi, and _EFS::stride.
Referenced by EFC_stdConstruct().
Formats the datagram and eventually writes the datagram to the output device.
efs | The Event Filter Statistics handle | |
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. | |
beg | The first result vector to analyze | |
end | The last (actually one past the last) result vector to analyze | |
span | Structure defining the span of events, both in time and event sequence numbers, that are being analyzed. |
References accumulate(), _EFS_ctxCtb::bdy, _EFS_ctxBridge::bf, _EFS_ctxKeys::cfg, _EFA_span::cfg_id, _EFS_ctxBdy::cfg_id, _EFA_span::cfg_key, clear(), _EFS_ctxBridge_bf::close, _EFS_stats::cnts, _EFS::ctbHdrId, _EFS_datagram::ctx, _EFS::ctxCtb, _EFS::cur_idx, _EFS::dgm, _EFS::dgm_size, _EFS::dgmHdrId, _EFS_ctxBdy::did, _EfsPrvHdr::diff, EFA__hdrSeqGet(), _EfsPrvHdr::efaHdr, EFC__timestampGet(), _EFC_time::f, format_begin_record(), format_diff_record(), format_global_record(), format_record(), _EFS::gbl_span, _EFS_ctxCtb::hdr, _EFS_datagram::hdr, _EFA_span::hdrs, _EFS_ctxBdy::key, _EFS::last, _EFA_span::mode, _EFS::nrecs, OpenReasons, _EFS::pds, _EFS::prvHdr, _EFS::rec, _EFS::rec_span, _EFS::recLimit, _EFS::sdi, _EFA_hdr::seq, _EFS::stats, _EFS_datagram::stb, _EFS::stride, and _EFC_time::ull.
Referenced by EFC_stdConstruct().
int EFS_sizeof | ( | int | max_records | ) |
Computes the size, in bytes, of the EFS control structure.
max_records | The maximum number of records in a datagram |
References get_datagram_pool_size().
Referenced by EFC_stdConstruct(), and EFC_stdSizeof().
int EFS_start | ( | EFS * | efs, | |
int | reason, | |||
int | run_id, | |||
int | startTime, | |||
int | mode | |||
) |
Captures the start run information.
efs | The Event Filter Statistics handle | |
reason | The LSF_REASON_OPEN to indicate why the stream is being started | |
run_id | Suggested use is to identify the block of events between when EDS_fwHandlerStart is called and EDS_fwHandlerFlush is called with a stop reason | |
startTime | The run start time rounded to the nearest second | |
mode | This must be the running mode. |
References _EFS_ctxCtb::bdy, _EFS_ctxBridge::bf, _EFS_ctxBridge_bf::close, _EFS::ctxCtb, _EFS::cur_idx, _EFS_ctxBdy::did, _EFS_ctxCtb::hdr, _EFS::nrecs, _EFS_ctxBridge_bf::open, and _EFS_ctxBridge::ub.
Referenced by EFC_stdConstruct().
static unsigned int format | ( | unsigned int * | dat, | |
const unsigned int * | buf, | |||
int | n, | |||
unsigned int | max | |||
) | [static] |
Encodes the input buffer using a significant bit count followed by the significant bits.
dat | The output data buffer | |
buf | The input data buffer | |
n | The number of values to encode | |
max | The maximum value |
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 . .
Referenced by format_diff_stats(), and format_stats().
static LSF_record * format_begin_record | ( | LSF_record * | rec, | |
const EFA_span * | span, | |||
const EFS_stats * | stats | |||
) | [static] |
Formats a normal record with 2 headers.
rec | The record to format | |
span | The beginning and ending event sample specification | |
stats | The statistics |
References copy(), format_stats(), and _EFA_span::hdrs.
Referenced by EFS_post().
static LSF_record * format_diff_record | ( | LSF_record * | rec, | |
const EfsPrvHdr * | prv_hdr, | |||
const EFA_span * | span, | |||
const EFS_stats * | cur, | |||
const EFS_stats * | prv | |||
) | [static] |
Formats a standard statistics record.
rec | The record to format. | |
prv_hdr | Information about the last event header. | |
span | The beginning and ending event sample specification. | |
cur | The current set of statistics. | |
prv | The previous set of statistics. This is used to form differences with the current set. It is these differences that are encoded |
References format_diff_stats(), and _EFA_span::hdrs.
Referenced by EFS_post().
static unsigned int * format_diff_stats | ( | unsigned int * | dat, | |
const EFS_stats * | cur, | |||
const EFS_stats * | prv | |||
) | [static] |
Format the statisitics buffer as the difference between the current and previous.
dat | The data area | |
cur | The current statistics | |
prv | The previous statistics |
References _EFS_stats::cnts, and format().
Referenced by format_diff_record().
static LSF_record * format_global_record | ( | LSF_record * | rec, | |
const EFA_span * | span, | |||
const EFS_stats * | stats | |||
) | [static] |
Formats the global statistics record.
rec | The record to format | |
span | The beginning and ending event sample specification | |
stats | The statistics |
References copy(), format_stats(), and _EFA_span::hdrs.
Referenced by EFS_post().
static LSF_record * format_record | ( | LSF_record * | rec, | |
const EFA_span * | span, | |||
const EFS_stats * | stats | |||
) | [static] |
Formats a standard statistics record with one header.
rec | The record to format | |
span | The beginning and ending event sample specification | |
stats | The statistics |
References copy(), format_stats(), and _EFA_span::hdrs.
Referenced by EFS_post().
static unsigned int * format_stats | ( | unsigned int * | dat, | |
const EFS_stats * | stats | |||
) | [static] |
Format the statisitics buffer.
dat | The data area | |
stats | The statistics block to format |
References _EFS_stats::cnts, and format().
Referenced by format_begin_record(), format_global_record(), and format_record().
static int get_datagram_pool_size | ( | int | max_records | ) | [static] |
Calculates the size in bytes of the ring buffer pool size from which the datagrams will be allocated.
max_records | The maximum number of records. |
A reasonable number of records would be less than 50. This will give a datagram size of around 17Kbytes.
References get_datagram_size().
Referenced by EFS_construct(), and EFS_sizeof().
static int get_datagram_size | ( | int | max_records | ) | [static] |
Computes, in bytes, the maximal size of a datagram of max_records.
max_records | The maximum number of records in a datagram |
Referenced by EFS_construct(), and get_datagram_pool_size().
static unsigned int sbsKeyGet | ( | void | ) | [static] |
Retrieves the secondary boot script key.
Referenced by EFS_construct().
unsigned char OpenReasons[16] [static] |
Initial value:
{ 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 }
Referenced by EFS_post().