GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> QSE / V2-3-0 > qse / sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

QSE_aemRepack.c File Reference

Repacks an QSE_aem structurec back to EBF. More...

#include "QSE/QSE_aem.h"
#include "QSE/QSE_map.h"

Defines

#define HIT(_hit,_chn)   ((_hit) << (T0_V_HIT + T0_S_HIT - 1 - (_chn)))
 Forms the hit mask to place into the T0 word for the specified channel.
#define ACCEPT(_accept, _chn)   ((_accept) << (T1_V_ACCEPT + T1_S_ACCEPT - 1 - (_chn)))
 Forms the accept mask to place into the T1 word for the specified channel.
#define S0(_t0)   ((_t0) >> 16)
 Extracts the bits from _t0 that comprise S0.
#define S1(_t0, _t1)   ((_t0) | ((_t1) >> 19))
#define S2(_t1)   ((_t1) >> 3)
#define SIZE(_ncables, _nphas)   ((6 * (_ncables) + (_nphas) ) * sizeof (short int))
 Calculates the size, in bytes, of the output record needed to hold an EBF record of ncables and _nphas.
#define NCABLES_MAX   12
 The maximum number of cables possible.
#define NPHAS_MAX   (NCABLES_MAX * 18)
 The maximum number of phas possible.
#define SIZE_MAX   SIZE(NCABLES_MAX, NPHAS_MAX)
 The maximum size, in bytes, of output EBF record.

Typedefs

typedef enum _T0_S T0_S
 Typedef for enum _T0_S.
typedef enum _T0_V T0_V
 Typedef for enum _T0_V.
typedef enum _T0_M T0_M
 Typedef for enum _T0_M.
typedef enum _T1_S T1_S
 Typedef for enum _T1_S.
typedef enum _T1_V T1_V
 Typedef for enum _T1_V.
typedef enum _T1_M T1_M
 Typedef for enum _T1_M.
typedef enum _PHA_S PHA_S
 Typedef for enum _PHA_S.
typedef enum _PHA_V PHA_V
 Typedef for enum _PHA_V.
typedef enum _PHA_M PHA_M
 Typedef for enum _PHA_M.

Enumerations

enum  _T0_S {
  T0_S_START = 1,
  T0_S_HIT = 18,
  T0_S_MBZ = 12
}
 Map out the sizes, in bits of the first header word.
enum  _T0_V {
  T0_V_START = 31,
  T0_V_HIT = 13,
  T0_V_MBZ = 0
}
 Map out the right justified bit shifts of the first header word.
enum  _T0_M {
  T0_M_START = ((1 << T0_S_START) - 1) << T0_V_START,
  T0_M_HIT = ((1 << T0_S_HIT ) - 1) << T0_V_HIT,
  T0_M_MBZ = ((1 << T0_S_MBZ ) - 1) << T0_V_MBZ
}
 Map out the in place bit masks of the first header word.
enum  _T1_S {
  T1_S_ACCEPT = 18,
  T1_S_VALID = 1,
  T1_S_PE = 1,
  T1_S_END = 1,
  T1_S_CABLE = 4,
  T1_S_MBZ = 7
}
 Map out the sizes, in bits of the 2rd word of the cable header.
enum  _T1_V {
  T1_V_ACCEPT = 14,
  T1_V_VALID = 13,
  T1_V_PE = 12,
  T1_V_END = 11,
  T1_V_CABLE = 7,
  T1_V_MBZ = 0
}
 Map out the right justified bit offsets 3rd word of the cable header.
enum  _T1_M {
  T1_M_ACCEPT = ((1 << T1_S_ACCEPT) - 1) << T1_V_ACCEPT,
  T1_M_VALID = ((1 << T1_S_VALID ) - 1) << T1_V_VALID,
  T1_M_PE = ((1 << T1_S_PE ) - 1) << T1_V_PE,
  T1_M_END = ((1 << T1_S_END ) - 1) << T1_V_END,
  T1_M_CABLE = ((1 << T1_S_CABLE ) - 1) << T1_V_CABLE,
  T1_M_MBZ = ((1 << T1_S_MBZ ) - 1) << T1_V_MBZ
}
 Map out in in-place bit masks of the 2nd word of the cable header.
enum  _PHA_S {
  PHA_S_MBZ = 1,
  PHA_S_MORE = 1,
  PHA_S_RNG = 1,
  PHA_S_ADC = 12,
  PHA_S_PE = 1
}
 Size, in bits, of the fields in the PHA vector.
enum  _PHA_V {
  PHA_V_MBZ = 15,
  PHA_V_MORE = 14,
  PHA_V_RNG = 13,
  PHA_V_ADC = 1,
  PHA_V_PE = 0
}
 Right justified bit offset of the fields in the PHA vector.
enum  _PHA_M {
  PHA_M_MBZ = ((1 << PHA_S_MBZ ) - 1) << PHA_V_MBZ,
  PHA_M_MORE = ((1 << PHA_S_MORE) - 1) << PHA_V_MORE,
  PHA_M_RNG = ((1 << PHA_S_RNG ) - 1) << PHA_V_RNG,
  PHA_M_ADC = ((1 << PHA_S_ADC ) - 1) << PHA_V_ADC,
  PHA_M_PE = ((1 << PHA_S_PE ) - 1) << PHA_V_PE
}
 In-place masks of the bit offset of the fields in the PHA vector.

Functions

static __inline int count_phas (const QSE_aem_chn *chns, int nchns)
 Counts the number of PHAs in the channel array.
static __inline int count_cables (unsigned short int present)
 Counts the number of cables present.
int QSE_aemRepack (const unsigned int *dat, unsigned int len, const QSE_aem *aem)
 Repacks the ACD in record make into EBF format.


Detailed Description

Repacks an QSE_aem structurec back to EBF.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: QSE_aemRepack.c,v 1.4 2006/11/10 22:35:55 russell Exp $

All references to the AEM hardware data format are from LAT-TD-00639, The ACD Electronics Module, Programming ICD, V2.11, September 8, 2004.


Define Documentation

#define ACCEPT ( _accept,
_chn   )     ((_accept) << (T1_V_ACCEPT + T1_S_ACCEPT - 1 - (_chn)))

Forms the accept mask to place into the T1 word for the specified channel.

Returns:
The accept mask to place into the T1 word for the specified channel.
Parameters:
_accept The value (0 or 1) of the PHA accept flag for _chn
_chn The FREE board electronics channel (0-17) for this accept flag

#define HIT ( _hit,
_chn   )     ((_hit) << (T0_V_HIT + T0_S_HIT - 1 - (_chn)))

Forms the hit mask to place into the T0 word for the specified channel.

Returns:
The hit mask to place into the T0 word for the specified channel.
Parameters:
_hit The value (0 or 1) of the hit flag for _chn
_chn The FREE board electronics channel (0-17) for this hit flag

#define S0 ( _t0   )     ((_t0) >> 16)

Extracts the bits from _t0 that comprise S0.

Returns:
The bits from _t0 to that comprise S0
Parameters:
_t0 The first 32-bits of the pseudo-header words

#define SIZE ( _ncables,
_nphas   )     ((6 * (_ncables) + (_nphas) ) * sizeof (short int))

Calculates the size, in bytes, of the output record needed to hold an EBF record of ncables and _nphas.

Returns:
The size, in bytes, of the output record needed to hold an EBF record of ncables and _nphas.
Parameters:
_ncables The number of cable headers needed
_nphas The number of pha values


Function Documentation

static __inline int count_cables ( unsigned short int  present  )  [static]

Counts the number of cables present.

Returns:
the number of cables that are present
Parameters:
present Bit array of the present cables

static __inline int count_phas ( const QSE_aem_chn chns,
int  nchns 
) [static]

Counts the number of PHAs in the channel array.

Returns:
the number of PHAs in the channel array
Parameters:
chns The array of ACD channels with hits/PHA values
nchns The number of such channels

int QSE_aemRepack ( const unsigned int *  dat,
unsigned int  len,
const QSE_aem aem 
)

Repacks the ACD in record make into EBF format.

Returns:
The number of bytes used. If this is negative, then this value should be interpretted as a failure
Parameters:
dat The 32-bit array to pack the data into
len The length, in bytes, of dat
aem The source AEM data record


Generated on Thu Sep 2 14:54:57 2010 by  doxygen 1.5.3