GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LSEC / V7-1-0 > lsec / linux-gcc
#include "LSEC/LSEC.h"
#include "LSEC/LSEC_ctx.h"
#include "EDS/EBF_dir.h"
#include "EDS/EBF_ctb.h"
#include <stdio.h>
Typedefs | |
typedef struct _LSEC_compaction | LSEC_compaction |
Declaration of the opaque compaction structure. | |
typedef struct _LSEC_calEvent | LSEC_calEvent |
Declaration of the opaque CAL event structure. | |
typedef struct _LSEC_compression | LSEC_compression |
Declaration of the opaque compression structure. | |
typedef struct _LSEC_consignment | LSEC_consignment |
Declaration of the opaque consignment structure. | |
typedef struct _LSEC_event | LSEC_event |
Declaration of the opaque event structure. | |
typedef unsigned | LSEC_eventProcRtn (void *parm, EBF_dir *dir) |
Event processing routine. | |
Functions | |
LSEC_consignment * | LSEC_consCreate (unsigned cpuid, unsigned srcid, unsigned cap, LSEC_compaction *cpc, LSEC_event *evt, long long *times) |
Create a new consignment. | |
LSEC_ctx * | LSEC_consCtxGet (LSEC_consignment *cns) |
Get the address of the context structure. | |
void | LSEC_consDelete (LSEC_consignment *cns) |
Free the previously allocated consignment structure. | |
unsigned | LSEC_consEventCal (void *parm, EBF_dir *dir) |
Process a compressed CAL event. | |
unsigned | LSEC_consEventImm (void *parm, EBF_dir *dir) |
Process an event immediately. | |
void | LSEC_consPrepare (LSEC_consignment *cns, unsigned runid, unsigned mode, LSEC_compLevel comp) |
Prepare for a new calibration run. | |
unsigned | LSEC_consProcess (LSEC_consignment *cns) |
Process a consignment. | |
void | LSEC_consReason (LSEC_consignment *cns, int reason) |
Set the current datagram close reason. | |
void | LSEC_accumCalMeans (LSEC_compaction *cpc, unsigned int *evt, EBF_dir *dir) |
Accumulate the means of the CAL log end values. | |
unsigned | LSEC_checkCalCompaction (LSEC_compaction *cpc) |
Check the CAL substructure for errors. | |
void | LSEC_clearCalCompaction (LSEC_compaction *cpc) |
Clear away any CAL context from a previous cycle. | |
unsigned int * | LSEC_copyUser (LSEC_compaction *cpc, unsigned int *buf) |
Copy datagram header information into the buffer. | |
void | LSEC_deleteCompaction (LSEC_compaction *cpc) |
Free memory previously allocated with a call to LSEC_newCompaction. | |
unsigned int | LSEC_eventSizeCal (const LSEC_calEvent *event) |
Get the size of a saved CAL event. | |
EBF_ctb * | LSEC_gemContribCal (const LSEC_calEvent *event) |
Get the GEM contribution address from a saved CAL event. | |
void | LSEC_histoCalMeans (LSEC_compaction *cpc) |
Calculate and histogram the mean values for the CAL log ends. | |
void | LSEC_histogramCal (LSEC_compaction *cpc, LSEC_calEvent *event) |
Perform histogramming of the CAL data. | |
LSEC_compaction * | LSEC_newCompaction (unsigned cap, long long *times) |
Allocate memory for an LSEC_compaction structure and all the substructures. | |
unsigned | LSEC_processCal (LSEC_compaction *cpc) |
Process the CAL compression structures. | |
void | LSEC_reportCalCompaction (LSEC_compaction *exp, FILE *fp) |
Write CAL compression table contents to an ASCII file. | |
void | LSEC_setContext (LSEC_compaction *cpc, const LSEC_ctx *ctx) |
Set the context information pointer. | |
void | LSEC_setMode (LSEC_compaction *cpc, unsigned mode) |
Set the calibration mode. | |
unsigned int | LSEC_sizeofUser (LSEC_compaction *cpc) |
Calculate the number of 32-bit words required to hold the tables against which the contributions will be encoded. | |
unsigned | LSEC_checkCompression (LSEC_compression *cpr) |
Check if there were errors during the histogram or encode operations. | |
void | LSEC_clearCompression (LSEC_compression *cpr) |
Clear the compression structrure of any data from a previous cycle. | |
void | LSEC_deleteCompression (LSEC_compression *cpr) |
Free the memory associated with the compression structure. | |
unsigned int | LSEC_getBin (LSEC_compression *cpr, unsigned int bin) |
Return the contents of one bin of the histogram. | |
unsigned int | LSEC_getCount (LSEC_compression *cpr) |
Return the number of non-zero bins in the histogram. | |
LSEC_compression * | LSEC_newCompression (unsigned int nbits, const char *name) |
Allocate and initialise a new compression structure for APE encoding. | |
LSEC_compression * | LSEC_newCompressionH (unsigned int nbits, const char *name) |
Allocate and initialise a new compression structure for Huffman encoding. | |
unsigned int * | LSEC_pack (LSEC_compression *cpr, unsigned *buffer) |
Pack the tables of a compression structure into a buffer. | |
unsigned int | LSEC_packedSize32 (LSEC_compression *cpr) |
Calculate the size of a packed compression structure. | |
unsigned | LSEC_process (LSEC_compression *cpr) |
Build the lookup, frequency and probability tables required by the APE. | |
void | LSEC_reportCompression (LSEC_compression *cmp, FILE *fp) |
Describe the contents of a compression structure. | |
void | LSEC_zeroBin (LSEC_compression *cpr, unsigned int bin) |
Set the selected bin of the histogram to zero. | |
unsigned int * | LSEC_encodeCal (LSEC_compaction *cpc, const LSEC_calEvent *event, unsigned int *buf) |
Encode the CAL portion of the event. | |
unsigned int * | LSEC_encodeTkr (LSEC_compaction *cpc, const EBF_dir *dir, unsigned int *buf) |
Encode the TKR portion of the event. | |
void | LSEC_eventClear (LSEC_event *evt) |
Clear the stored event data. | |
LSEC_event * | LSEC_eventCreate (int cap, long long *times) |
Create a new event structure. | |
void | LSEC_eventDelete (LSEC_event *evt) |
Delete the previously allocated event structure. | |
unsigned int * | LSEC_eventGet (LSEC_event *evt) |
Get the address of the next stored event. | |
void | LSEC_eventPrepare (LSEC_event *evt) |
Prepare for a new run. | |
unsigned | LSEC_eventProcess (LSEC_event *evt, unsigned int edw, EBF_pkt *pkt) |
Process an event packet. | |
void | LSEC_eventProcSet (LSEC_event *evt, LSEC_eventProcRtn *rtn, void *parm) |
Set the event processing routine to use. | |
unsigned int * | LSEC_eventPut (LSEC_event *evt) |
Get the address of the next event to store. | |
void | LSEC_eventRewind (LSEC_event *evt) |
Rewind the event store reading to the beginning. |
$Id: LSEC_p.h,v 1.4 2010/08/12 21:04:44 saxton Exp $
void LSEC_accumCalMeans | ( | LSEC_compaction * | cpc, | |
unsigned int * | evt, | |||
EBF_dir * | dir | |||
) |
Accumulate the means of the CAL log end values.
This routine accumulates the CAL ADC values, keeping a separate sum for each log end.
cpc | Compaction structure | |
evt | Pointer to the event storage area | |
dir | Pointer to the event to analyse |
unsigned LSEC_checkCalCompaction | ( | LSEC_compaction * | cpc | ) |
Check the CAL substructure for errors.
cpc | Pointer to a compaction object |
unsigned LSEC_checkCompression | ( | LSEC_compression * | cpr | ) |
Check if there were errors during the histogram or encode operations.
cpr | Pointer to a compression structure |
LSEC_SYMOOR | If any of the symbols histogrammed or encoded by this compression structure were out of range | |
LSEC_AWEFAIL | If there were any error during the encoding | |
LSEC_SUCCESS | If there were no errors |
void LSEC_clearCalCompaction | ( | LSEC_compaction * | cpc | ) |
Clear away any CAL context from a previous cycle.
cpc | Pointer to a compaction object |
void LSEC_clearCompression | ( | LSEC_compression * | cpr | ) |
Clear the compression structrure of any data from a previous cycle.
cpr | Pointer to an allocated, initialised, compression structure |
LSEC_consignment* LSEC_consCreate | ( | unsigned | cpuid, | |
unsigned | srcid, | |||
unsigned | cap, | |||
LSEC_compaction * | cpc, | |||
LSEC_event * | evt, | |||
long long * | times | |||
) |
Create a new consignment.
This routine allocates memory for a consigment structure and its associated data structures, and initialises it.
srcid | ID of the data source | |
cpuid | ID of the CPU the calibration is being run on | |
cap | The capacity (in events) of the consignment | |
cpc | Pointer to the compaction state information | |
evt | Pointer to the event store | |
times | Pointer to the processing times array. |
LSEC_ctx* LSEC_consCtxGet | ( | LSEC_consignment * | cns | ) |
Get the address of the context structure.
cns | Pointer to the consignment structure |
void LSEC_consDelete | ( | LSEC_consignment * | cns | ) |
Free the previously allocated consignment structure.
cns | Pointer to allocated, intialised consignment structure |
unsigned LSEC_consEventCal | ( | void * | parm, | |
EBF_dir * | dir | |||
) |
Process a compressed CAL event.
This routine starts the process by accumulating data for the CAL means calculation.
parm | Pointer to the consignment structure | |
dir | Pointer to the event directory |
LSEC_SUCCESS | Success (always) |
unsigned LSEC_consEventImm | ( | void * | parm, | |
EBF_dir * | dir | |||
) |
Process an event immediately.
This routine is used to pass an event immediately to the datagram framework. It is used in all cases except compressed CAL events.
parm | Pointer to the consignment structure | |
dir | Pointer to the event directory |
LSEC_SUCCESS | Success | |
LSEC_OVERSIZE | Event too large for a datagram |
void LSEC_consPrepare | ( | LSEC_consignment * | cns, | |
unsigned | runid, | |||
unsigned | mode, | |||
LSEC_compLevel | comp | |||
) |
Prepare for a new calibration run.
This routine sets the runid and start time for the first datagram of a new calibration, as well as several other mode-dependent parameters.
cns | Pointer to allocated, intialised consignment structure | |
runid | 32-bit number identifying the calibration run | |
mode | The calibration mode (ACD, CAL or TKR) | |
comp | The compression level (normal, only, none) |
unsigned LSEC_consProcess | ( | LSEC_consignment * | cns | ) |
Process a consignment.
cns | Pointer to a consignment structure |
LSEC_SUCCESS | If all goes well |
void LSEC_consReason | ( | LSEC_consignment * | cns, | |
int | reason | |||
) |
Set the current datagram close reason.
cns | Pointer to the consignment structure | |
reason | The reason code to be set |
unsigned int* LSEC_copyUser | ( | LSEC_compaction * | cpc, | |
unsigned int * | buf | |||
) |
Copy datagram header information into the buffer.
buf | Pointer to the buffer where the context should be placed | |
cpc | Pointer to the structure containing the tables (a compaction) |
void LSEC_deleteCompaction | ( | LSEC_compaction * | cpc | ) |
Free memory previously allocated with a call to LSEC_newCompaction.
cpc | Pointer to a compaction structure previously created by a call to LSEC_newCompaction |
void LSEC_deleteCompression | ( | LSEC_compression * | cpr | ) |
Free the memory associated with the compression structure.
cpr | Pointer to an allocated compression structure |
unsigned int* LSEC_encodeCal | ( | LSEC_compaction * | cpc, | |
const LSEC_calEvent * | event, | |||
unsigned int * | buf | |||
) |
Encode the CAL portion of the event.
cpc | Compaction structure | |
event | Pointer to the saved event | |
buf | Pointer to the buffer receiving the encoded data |
unsigned int* LSEC_encodeTkr | ( | LSEC_compaction * | cpc, | |
const EBF_dir * | dir, | |||
unsigned int * | buf | |||
) |
Encode the TKR portion of the event.
cpc | Compaction structure | |
dir | Pointer to the event directory | |
buf | Pointer to the buffer receiving the encoded data |
void LSEC_eventClear | ( | LSEC_event * | evt | ) |
Clear the stored event data.
evt | Pointer to an event structure. |
LSEC_event* LSEC_eventCreate | ( | int | cap, | |
long long * | times | |||
) |
Create a new event structure.
cap | The maximum number of events that can be stored. | |
times | Address of the processing times array. |
void LSEC_eventDelete | ( | LSEC_event * | evt | ) |
Delete the previously allocated event structure.
evt | Pointer to allocated, intialised event structure |
unsigned int* LSEC_eventGet | ( | LSEC_event * | evt | ) |
Get the address of the next stored event.
This routine return a pointer to the next event and advances the read pointer.
evt | Pointer to an event structure |
void LSEC_eventPrepare | ( | LSEC_event * | evt | ) |
Prepare for a new run.
evt | Pointer to allocated, intialised event structure |
unsigned LSEC_eventProcess | ( | LSEC_event * | evt, | |
unsigned int | edw, | |||
EBF_pkt * | pkt | |||
) |
Process an event packet.
This routine is called whenever a new event packet arrives.
evt | Pointer to an event structure | |
edw | Description of the event (a thirty-two bit number that indicates, among other things, errors in the event transmission) | |
pkt | Pointer to the event packet |
void LSEC_eventProcSet | ( | LSEC_event * | evt, | |
LSEC_eventProcRtn * | rtn, | |||
void * | parm | |||
) |
Set the event processing routine to use.
evt | Pointer to an event structure. | |
rtn | Pointer to the processing routine. | |
parm | Parameter to pass to the processing routine. |
unsigned int* LSEC_eventPut | ( | LSEC_event * | evt | ) |
Get the address of the next event to store.
This routine return a pointer to the next event that can be stored and advances the write pointer.
evt | Pointer to an event structure |
void LSEC_eventRewind | ( | LSEC_event * | evt | ) |
Rewind the event store reading to the beginning.
evt | Pointer to an event structure. |
unsigned int LSEC_eventSizeCal | ( | const LSEC_calEvent * | event | ) |
Get the size of a saved CAL event.
event | Pointer to a CAL event data structure. |
EBF_ctb* LSEC_gemContribCal | ( | const LSEC_calEvent * | event | ) |
Get the GEM contribution address from a saved CAL event.
event | Pointer to a CAL event data structure. |
unsigned int LSEC_getBin | ( | LSEC_compression * | cpr, | |
unsigned int | bin | |||
) |
Return the contents of one bin of the histogram.
cpr | Pointer to an allocated, initialised, populated, compression structure | |
bin | ID of one of the bins of the histogram |
unsigned int LSEC_getCount | ( | LSEC_compression * | cpr | ) |
Return the number of non-zero bins in the histogram.
cpr | Pointer to a compression structure |
void LSEC_histoCalMeans | ( | LSEC_compaction * | cpc | ) |
Calculate and histogram the mean values for the CAL log ends.
The mean ADC values for each CAL log end are calculated and histogrammed, one histogram per range, ready for being encoded.
cpc | Pointer to an LSEC_compaction structure |
void LSEC_histogramCal | ( | LSEC_compaction * | cpc, | |
LSEC_calEvent * | event | |||
) |
Perform histogramming of the CAL data.
Several quantities associated with the CAL are histogrammed in preparation for being encoded. These include: the tower map; the mean-subtracted ADC values, offset to be positive, and grouped by range; the diagnostic tower map; and the diagnostic data.
cpc | Compaction structure | |
event | Pointer to the stored event |
LSEC_compaction* LSEC_newCompaction | ( | unsigned | cap, | |
long long * | times | |||
) |
Allocate memory for an LSEC_compaction structure and all the substructures.
cap | Capacity of the calibration task, the maximum number of events that can be collected each cycle | |
times | Pointer to the array of processing times. |
LSEC_compression* LSEC_newCompression | ( | unsigned int | nbits, | |
const char * | name | |||
) |
Allocate and initialise a new compression structure for APE encoding.
nbits | Number of symbols in the complete range of possible symbols (including excluded internal sub-ranges), hence the number of bins in the histogram and frequency tables | |
name | String used in the reporting of error to identify a compression structure |
LSEC_compression* LSEC_newCompressionH | ( | unsigned int | nbits, | |
const char * | name | |||
) |
Allocate and initialise a new compression structure for Huffman encoding.
nbits | Number of symbols in the complete range of possible symbols (including excluded internal sub-ranges), hence the number of bins in the histogram and frequency tables | |
name | String used in the reporting of error to identify a compression structure |
unsigned int* LSEC_pack | ( | LSEC_compression * | cpr, | |
unsigned * | buffer | |||
) |
Pack the tables of a compression structure into a buffer.
This routine selects sufficient data from the tables of the compression structure to be able to recreate the tables required to decompress the data, and pack it into the consignment
buffer | Pointer to the start of the buffer to place the packed structure | |
cpr | Pointer to an initialised, populated and processed compression structure |
unsigned int LSEC_packedSize32 | ( | LSEC_compression * | cpr | ) |
Calculate the size of a packed compression structure.
This routine calculates the number of 32-bit words required to hold the packed compression structure
cpr | Pointer to a compression structure |
unsigned LSEC_process | ( | LSEC_compression * | cpr | ) |
Build the lookup, frequency and probability tables required by the APE.
cpr | Pointer to an allocated, initialised, populated, compression structure |
LSEC_SUCCESS | If the processing goes well |
unsigned LSEC_processCal | ( | LSEC_compaction * | cpc | ) |
Process the CAL compression structures.
cpc | Pointer to an LSEC_compaction structure |
void LSEC_reportCalCompaction | ( | LSEC_compaction * | cpc, | |
FILE * | fp | |||
) |
Write CAL compression table contents to an ASCII file.
cpc | Pointer to a compaction object | |
fp | Pointer to the destination file |
void LSEC_reportCompression | ( | LSEC_compression * | cpr, | |
FILE * | fp | |||
) |
Describe the contents of a compression structure.
This routine formats the compression structure as ASCII text and writes it to the specified file
cpr | Pointer to the compression structure | |
fp | Pointer to the file used as the destination |
void LSEC_setContext | ( | LSEC_compaction * | cpc, | |
const LSEC_ctx * | ctx | |||
) |
Set the context information pointer.
cpc | Pointer to a compaction structure | |
ctx | Pointer to the context block |
void LSEC_setMode | ( | LSEC_compaction * | cpc, | |
unsigned | mode | |||
) |
Set the calibration mode.
cpc | Pointer to a compaction structure | |
mode | The calibration mode |
unsigned int LSEC_sizeofUser | ( | LSEC_compaction * | cpc | ) |
Calculate the number of 32-bit words required to hold the tables against which the contributions will be encoded.
cpc | Pointer to the compaction structure |
void LSEC_zeroBin | ( | LSEC_compression * | cpr, | |
unsigned int | bin | |||
) |
Set the selected bin of the histogram to zero.
This indicates that this symbol will be selectively removed from the uncompressed data stream before encoding
cpr | Pointer to an allocated, initialised, populated, compression structure | |
bin | ID of one of the bins of the histogram |