GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> QSSP / dev > qssp / sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

QASC.c File Reference

Expand and access routines to the ACD Software Counters. More...

#include <QSSP/QASC.h>
#include <QSSP/QASC_sample.h>
#include <QASC_pvtdefs.h>
#include <QSP/QFCP_cache.h>
#include <QSD/QSD_acdMap.h>
#include <QSD/QFC_member.h>
#include <QSD/QFR_file.h>
#include <EMP/ASC_ascCtb.h>
#include <EMP/ASC_ids.h>
#include <LSF/LSF_reason.h>
#include <EFC_DB/EH_ids.h>
#include <ZLIB/zlib.h>
#include <PBI/Endianness.h>
#include <PBI/Check.h>
#include <PBI/Ofs.h>
#include <string.h>
#include <stdio.h>

Defines

#define NULL   ((void *)0)
#define RND_8(_v)   ((_v + 7) & ~0x7)
 Rounds-up an integer to the nearest multiply of 8. This is used to set allocations to quadwords.

Functions

static QASC_STATUS expand_raw0 (QASC_sampleV0 *qasc, const ASC_ascBdy_Raw0 *asc, unsigned int size)
 Expand the ASC data in the raw format to QASC format.
static QASC_STATUS expand_gzip0 (QASC_sampleV0 *qasc, const ASC_ascBdy_Gzip0 *asc, unsigned int size)
 Expand the ASC data in the raw format to QASC format.
static int do_inflate (const void *src, unsigned int srcSize, void *dst, unsigned int dstSize)
 Decompress the source buffer to the destination buffer.
static void add_samples (QASC_sampleV0 *dst, const QASC_sampleV0 *src)
 Adds the source sample, src, to the destination sample, dst.
static __inline QFCP_cache * qasc_file_cache_get (void)
 Returns a pointer to the file cache.
QASCQASC_alloc (void *must_be_null)
 Allocates and constructs a QASC handle.
QASCQASC_construct (QASC *qasc, void *must_be_null)
 The constructor for a QASC control structure.
void QASC_destruct (QASC *qasc)
 The destructor for a QASC control structure.
const QASC_ctxQASC_ctxGet (const QASC *qasc)
 Locates the statistics context (meta-data).
int QASC_sizeof (void *must_be_null)
 Return the size, in bytes, of the buffer needed to handle a QASC datagram.
QASC_status QASC_expand (QASC *qasc, const LSF_contribution *ctb)
 Routine to check integrity and swap/uncompress input data into a 2nd buffer.
const LSF_contribution * QASC_updateAtDatagram (QASC *qasc, const LSF_datagram *dgm)
 Updates the context at datagram time.
int QASC_updateAtContribution (QASC *qasc, const LSF_contribution *ctb)
 Updates the context at datagram time.
int QASC_updateAtRecord (QASC *qasc, const LSF_record *rec)
 Updates the context at record time.
int QASC_idxGemGet (int group, int channel)
 Maps an ACD GEM group and channel into a universal index.
int QASC_idxAemGet (int board, int channel)
 Maps an ACD AEM board number and channel into a universal index.
static __inline void swap32bN (unsigned int *d32, const unsigned int *s32, int n32)
 Swaps the specified number of 32-bit integers, presumed to be in a big endian representation to the local endianness.. This is a NOOP on big endian machines.
static __inline int inflater (const void *src, unsigned int srcSize, void *dst, unsigned int dstSize)
 Decompress the source buffer to the destination buffe.
static __inline void pointV0_transfer (QSSP_pointV0 *dst, const EMP_hdrEvt *src)
 Transfer an EMP_hdrEvt structure to a QSSP_point structure.
static __inline void span_transfer (QSSP_spanV1 *dst, const EMP_hdr *src)
 Transfers the contents of an EMP_hdr structure to a QSSP_spanV1 structure.
static void __inline monitor_transfer (QASC_monitorV0 *dst, const ASC_stats *src, unsigned int nsampled)
 Transfers the contents of an ASC_stats structure plus the number of events sampled to a QASC_monitorV0 structure.


Detailed Description

Expand and access routines to the ACD Software Counters.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: QASC.c,v 1.4 2011/03/29 00:14:57 russell Exp $

Define Documentation

#define RND_8 ( _v   )     ((_v + 7) & ~0x7)

Rounds-up an integer to the nearest multiply of 8. This is used to set allocations to quadwords.

Returns:
The rounded integer

Referenced by qasc_file_cache_get(), and qstd_file_cache_get().


Function Documentation

static void add_samples ( QASC_sampleV0 dst,
const QASC_sampleV0 src 
) [static]

Adds the source sample, src, to the destination sample, dst.

Parameters:
dst The destination sample
src The source sample

References _QASC_monitorV0::etotal, _QASC_monitorV0::frequency, _QASC_sampleV0::monitor, QSSP_spanV1Update(), _QASC_sampleV0::span, and _QASC_sampleV0::statistics.

Referenced by QASC_expand().

static int do_inflate ( const void *  src,
unsigned int  srcSize,
void *  dst,
unsigned int  dstSize 
) [static]

Decompress the source buffer to the destination buffer.

Return values:
0 Success
-1 Failure
Parameters:
src The source buffer of compressed data
srcSize The size, in bytes, of the source buffer of compressed data
dst The destination buffer for decompressed data
dstSize The available space, in bytes, of the destination buffer

Referenced by expand_gzip0().

static QASC_STATUS expand_gzip0 ( QASC_sampleV0 qasc,
const ASC_ascBdy_Gzip0 *  asc,
unsigned int  size 
) [static]

Expand the ASC data in the raw format to QASC format.

Return values:
QASC_STATUS_SUCCESS,if successful (0)
QASC_STATUS_CTB_BAD_LEN32,if the contributor length is inconsistent with the data.
QASC_STATUS_CTB_INFLATE_FAIL,indicates inflate failed
Parameters:
qasc The data access handle to be filled
asc The source data
size The size, in bytes, of the source data.

References do_inflate(), _QASC_sampleV0::monitor, monitor_transfer(), _QSSP_spanV1::nused, QASC_STATUS_CTB_BAD_LEN32, QASC_STATUS_CTB_INFLATE_FAIL, QASC_STATUS_SUCCESS, _QASC_sampleV0::span, span_transfer(), and _QASC_sampleV0::statistics.

Referenced by QASC_expand().

static QASC_STATUS expand_raw0 ( QASC_sampleV0 qasc,
const ASC_ascBdy_Raw0 *  asc,
unsigned int  size 
) [static]

Expand the ASC data in the raw format to QASC format.

Return values:
QASC_STATUS_SUCCESS,if successful (0)
QASC_STATUS_CTB_BAD_LEN32,if the contributor length is inconsistent with the data.
Parameters:
qasc The data access handle to be filled
asc The source data
size The size, in bytes, of the source data.

References _QASC_sampleV0::monitor, monitor_transfer(), _QASC_monitorV0::nsampled, QASC_STATUS_CTB_BAD_LEN32, QASC_STATUS_SUCCESS, _QASC_sampleV0::span, span_transfer(), and _QASC_sampleV0::statistics.

Referenced by QASC_expand().

static __inline int inflater ( const void *  src,
unsigned int  srcSize,
void *  dst,
unsigned int  dstSize 
) [static]

Decompress the source buffer to the destination buffe.

Return values:
0 Success
-1 Failure
Parameters:
src The source buffer of compressed data
srcSize The size, in bytes, of the source buffer of compressed data
dst The destination buffer for decompressed data
dstSize The available space, in bytes, of the destination buffer

static __inline void monitor_transfer ( QASC_monitorV0 dst,
const ASC_stats *  src,
unsigned int  nsampled 
) [static]

Transfers the contents of an ASC_stats structure plus the number of events sampled to a QASC_monitorV0 structure.

Parameters:
dst The destination QASC_monitor structure
src The source ASC_stats structure
nsampled The number of events sampled
The QASC_monitor structure is not a mirror of an ASC_stats, having the number of events sampled as an additional member. Because of this a formalized transfer method is needed.

References _QASC_monitorV0::nsampled.

Referenced by expand_gzip0(), and expand_raw0().

static __inline void pointV0_transfer ( QSSP_pointV0 dst,
const EMP_hdrEvt *  src 
) [static]

Transfer an EMP_hdrEvt structure to a QSSP_point structure.

Parameters:
dst The destination QSSP_point structure
src The source EMP_hdrEvt structure

References _QSSP_pointV0::gemClock, QSSP_pointV0Complete(), _QSSP_pointV0::relative, _QSSP_pointV0::sequence, and _QSSP_pointV0::timetones.

Referenced by span_transfer().

QASC* QASC_alloc ( void *  must_be_null  ) 

Allocates and constructs a QASC handle.

Returns:
Pointer to the allocated handle
Parameters:
must_be_null Reserved for future use.

References QASC_construct().

QASC* QASC_construct ( QASC qasc,
void *  must_be_null 
)

The constructor for a QASC control structure.

Returns:
Pointer to the QASC control structure
Parameters:
qasc The control structure to be constructed. If NULL, a control structure will be allocated
must_be_null Reserved for future use.

References _QASC_ctx::com, _QASC::ctx, _QASC::cumulative, _QASC_ctx::cumulative, _QASC::free, _QASC_ctx::qasc, qasc_file_cache_get(), QASC_sizeof(), and QSSP_ctxConstruct().

Referenced by QASC_alloc().

const QASC_ctx* QASC_ctxGet ( const QASC qasc  ) 

Locates the statistics context (meta-data).

Parameters:
qasc The statistics context

References _QASC::ctx.

void QASC_destruct ( QASC qasc  ) 

The destructor for a QASC control structure.

Returns:
Pointer to the QSS control structure
Parameters:
qasc The control structure to be destructed.

References _QASC::free.

QASC_status QASC_expand ( QASC qasc,
const LSF_contribution *  ctb 
)

Routine to check integrity and swap/uncompress input data into a 2nd buffer.

Return values:
QASC_STATUS_SUCCESS,if successful (0)
QASC_STATUS_CTB_BAD_LEN32,if the contributor length is inconsistent with the data.
QASC_STATUS_CTB_UNKNOWN_VER,if the encoding/data format version is unknown.
QASC_STATUS_CTB_INFLATE_FAIL,for compressed formats, indicates the failure to inflate the data
Parameters:
qasc The data access handle to be filled
ctb Input buffer
The check routine does integrity checks on the given LSF contributor packet and then decompress/swaps data into the output buffer. THe size of the output buffer is determined by QASC_sizeof(). The output buffer can then be used as input with the QASC_xxxxLocate routines.

This routine assumes the contributor has been byte-swapped.

References add_samples(), _QASC::ctx, _QASC::cumulative, _QASC_ctx::current, expand_gzip0(), expand_raw0(), QASC_STATUS_CTB_UNKNOWN_VER, _QASC::sample, and _QASC_sample::v0.

Referenced by QASC_updateAtContribution().

static __inline QFCP_cache * qasc_file_cache_get ( void   )  [static]

Returns a pointer to the file cache.

Returns:
The file cache
This routine return the handle, creating it if necessary. This not really the right architecture. This needs to be part of a QSS global environment. This can't be accomplished at this time because it would require a backwardly incompatiable change to QSSP_construct.

References RND_8.

Referenced by QASC_construct().

int QASC_idxAemGet ( int  board,
int  channel 
)

Maps an ACD AEM board number and channel into a universal index.

Return values:
>=0,The universal index for the specifed ACD AEM board and channel
< 0, Invalid board or channel number
Parameters:
board This is a value between 0 and 11 corresponding to the the 12 AEM FREE board/cable numbers
  • 0 1LA, 1 1RB
  • 2 2LA, 3 2LB
  • 4 2RA, 5 2RB
  • 6 3LA, 7 3RB
  • 8 4LA, 9 4LB
  • 9 4RA, 10 4RB
channel The channel, 0-18, within each FREE board/cable.

int QASC_idxGemGet ( int  group,
int  channel 
)

Maps an ACD GEM group and channel into a universal index.

Return values:
>=0,The universal index for the specifed ACD group and channel
< 0, Invalid list or channel number
Parameters:
group This is a value between 0 and 3 corresponding to the 4 words in the GEM record -0 XZ plane -1 YZ plane -2 XY plane -3 RU plane
channel The channel, 0-31, within each list. The bits are numbered from least significant bit to most significant bit

int QASC_sizeof ( void *  must_be_null  ) 

Return the size, in bytes, of the buffer needed to handle a QASC datagram.

Return values:
The size, in bytes, of the buffer needed to handle a QASC datagram

Referenced by QASC_construct().

int QASC_updateAtContribution ( QASC qasc,
const LSF_contribution *  ctb 
)

Updates the context at datagram time.

Return values:
If have a statistics sample contribution, the number of records in the contribution.
>0,if have a record contributor
=0,if have the contribution context
-1,if unrecognized
Parameters:
qasc The statistics context to update.
ctb The statistics contribution

References _QSSP_ctxKeys::cfg, _QSSP_ctxIds::cfg, _QASC_ctx::com, _QASC::ctx, _QSSP_ctx::dgm, _QASC::dgm_version, _QSSP_ctxIds::handler, _QSSP_ctx::id, _QSSP_ctx::key, _QSSP_ctxKeys::master, QASC_expand(), and _QSSP_ctxKeys::sbs.

const LSF_contribution* QASC_updateAtDatagram ( QASC qasc,
const LSF_datagram *  dgm 
)

Updates the context at datagram time.

Returns:
The contribution to resume processsing at
Parameters:
qasc The statistics context to update.
dgm The statistics datagram

References _QASC_ctx::com, _QASC::ctx, _QASC::cumulative, _QSSP_ctx::dgm, _QASC::dgm_version, _QSSP_ctx::files, QSSP_ctxUpdateAtDatagram(), and _QASC_ctx::version.

int QASC_updateAtRecord ( QASC qasc,
const LSF_record *  rec 
)

Updates the context at record time.

Return values:
Non-negative values indicate are one of the QASC_type's
Negative values indicate an unsuccessful update
Parameters:
qasc The statistics context to update.
rec The statistics record

References _QASC::ctx, _QASC_ctx::current, _QASC_sampleV0::type, and _QASC_sample::v0.

static __inline void span_transfer ( QSSP_spanV1 dst,
const EMP_hdr *  src 
) [static]

Transfers the contents of an EMP_hdr structure to a QSSP_spanV1 structure.

Parameters:
dst The destination QSSP_spanV1 structure
src The source EMP_hdr structure
Because the EMP structure contains 64-bit long long, and because the alignment of these is compiler dependent, they cannot be simply copied to one another. Hence the need for a formalized transfer routine.

Note:
This is not part of the public interface.

References _QSSP_spanV1::nused, _QSSP_spanV1::points, pointV0_transfer(), and QSSP_spanV1Complete().

Referenced by expand_gzip0(), and expand_raw0().

void swap32bN ( unsigned int *  d32,
const unsigned int *  s32,
int  n32 
) [static]

Swaps the specified number of 32-bit integers, presumed to be in a big endian representation to the local endianness.. This is a NOOP on big endian machines.

Parameters:
d32 The destinatin array of 32-bit swapped words
s32 The source array of 32-bit words to swap
n32 The number of words to word swap


Generated on Mon Mar 28 17:20:23 2011 by  doxygen 1.5.8