GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LSE / V2-1-0 > lsew / linux-gcc
#include <LSF/LSF.h>
#include <LSEW_ctx.h>
#include <LSE/LSE_ids.h>
#include <LSE/LSEW_dgm.h>
#include <LSE_time.ih>
#include <CCSDS/CCSDS_pkt.h>
#include <PBI/PTR.h>
#include <string.h>
Classes | |
struct | _LSEW_dgm |
Control structure for outputing events. More... | |
Defines | |
#define | RND_UP(_x, _r) |
Rounds _x up to the nearest multiple of _r. | |
#define | MAXIMUM_EVENTS_PER_CONTRIBUTION 255 |
Sets the maximum number of events that can be committed to one event contribution. | |
Typedefs | |
typedef struct _LSEW_dgm | LSEW_dgm |
Typedef for struct _LSEW_dgm. | |
Functions | |
static __inline unsigned int | evt_size (void) |
Returns the minimum size of a new event contribution. | |
static __inline unsigned int * | evt_open (unsigned int *beg) |
Opens a new event record contribution. | |
static __inline unsigned int * | evt_close (unsigned int *beg, const unsigned int *end, unsigned int id, unsigned short int bridge) |
Closes out (completes) the current event contribution by filling in the LSF event header. | |
static __inline void | datagram_close (unsigned int *beg, const unsigned int *end, unsigned int dgm_id) |
Closes out (completes) the current data packet by filling in the LSF packet header. | |
static __inline unsigned int * | ccsds_complete (unsigned int *beg, unsigned char *dat, unsigned int *lsf, unsigned int *evt, unsigned int *end, unsigned int nevts, unsigned int apid, unsigned int seq) |
Completes the CCSDS header. | |
unsigned int | LSEW_dgmSizeof (void) |
The size, in bytes, of the control structure. | |
unsigned int | LSEW_dgmInit (LSEW_dgm *dgm, unsigned short int apid, unsigned int dgm_id, LSF_CPU_K cpu, LSF_ORIGIN_K origin) |
Initializes the control structure. | |
int | LSEW_dgmBufSet (LSEW_dgm *dgm, unsigned int *buf, int buf_size) |
Sets the specified buffer as the new output buffer. | |
void | LSEW_dgmRunStart (LSEW_dgm *dgm, unsigned int runId, unsigned int startTime, LSF_MODE_K mode) |
Sets the context for a new run. | |
void | LSEW_dgmModeChange (LSEW_dgm *dgm, LSF_MODE_K mode) |
Changes the current data-taking mode. | |
unsigned int * | LSEW_dgmOpen (LSEW_dgm *dgm, unsigned int reason, unsigned int evt_seq, const EBF_gem *gem) |
Opens a new event datagram. | |
unsigned int * | LSEW_dgmEvtOpen (LSEW_dgm *dgm, unsigned int *cur) |
Opens a new event datagram. | |
void | LSEW_dgmRootClose (LSEW_dgm *dgm, const unsigned int *end) |
unsigned int * | LSEW_dgmEvtCommit (LSEW_dgm *dgm, unsigned int *cur) |
Commits this event. This does two things, updates the current write pointer and increments the number of events in this contribution. | |
unsigned int * | LSEW_dgmEvtClose (LSEW_dgm *dgm) |
Completes the final processing of an event just before it is presented to the output stream. | |
unsigned int * | LSEW_dgmUpdate (LSEW_dgm *dgm, unsigned int evt_seq, const EBF_gem *gem) |
Updates the current datagram, adding a time record if necessary. | |
unsigned int * | LSEW_dgmCommit (LSEW_dgm *dgm, unsigned int *cur) |
Commits the current write by updating the write potnter. | |
unsigned int * | LSEW_dgmClose (LSEW_dgm *dgm, unsigned int *cur, unsigned int reason) |
Closes out the datagram; it is now ready to be written out. | |
const LSEW_ctxPub * | LSEW_dgmCtxPub (const LSEW_dgm *dgm) |
Returns a pointer to the public context structure. | |
unsigned int * | LSEW_dgmBeg (const LSEW_dgm *dgm) |
Returns the value of the beginning of the specified event datagram. | |
unsigned int * | LSEW_dgmCur (const LSEW_dgm *dgm) |
Returns the value of the beginning of the specified event datagram. | |
unsigned int * | LSEW_dgmEnd (const LSEW_dgm *dgm) |
Returns the value of the end of the specified event datagram. | |
unsigned int | LSEW_dgmLeft32 (const LSEW_dgm *dgm) |
Returns the number of 32 words left in the buffer. |
CVS $Id: LSEW_dgm.c,v 1.16 2011/03/26 17:35:24 russell Exp $
#define MAXIMUM_EVENTS_PER_CONTRIBUTION 255 |
Sets the maximum number of events that can be committed to one event contribution.
This value is set by the width of the bridge word in the LSF contribution header (1 byte)
Referenced by LSEW_dgmUpdate().
#define RND_UP | ( | _x, | |||
_r | ) |
Value:
( (((PTR_as_uint)(_x)) + (_r) - 1) & \ ~(PTR_as_uint)((_r) - 1) )
_x | The value to round | |
_r | The multiple to round up to, must be a power of 2. |
Referenced by LSEW_dgmCommit(), and LSEW_dgmEvtCommit().
static __inline unsigned int ccsds_complete | ( | unsigned int * | beg, | |
unsigned char * | dat, | |||
unsigned int * | lsf, | |||
unsigned int * | evt, | |||
unsigned int * | end, | |||
unsigned int | nevts, | |||
unsigned int | apid, | |||
unsigned int | seq | |||
) | [static] |
Completes the CCSDS header.
beg | The beginning address of the packet | |
dat | The beginning address of the data portion of the CCSDS packet. | |
lsf | The beginning address of the LSF datagram | |
evt | The beginning address of the current event packet | |
end | The ending address of the packet | |
nevts | The nubmer of events in the event packet | |
apid | The base apid | |
seq | The CCSDS sequence count |
References _LSE_time::f, LSE__timestampGet(), and _LSE_time::ull.
Referenced by LSEW_dgmClose().
static __inline void datagram_close | ( | unsigned int * | beg, | |
const unsigned int * | end, | |||
unsigned int | dgm_id | |||
) | [static] |
Closes out (completes) the current data packet by filling in the LSF packet header.
beg | The beginning of the event contribution to closeout | |
end | The end of the event contribution to closeout | |
dgm_id | The LAT Science Format datagram identifier |
static __inline unsigned int evt_close | ( | unsigned int * | beg, | |
const unsigned int * | end, | |||
unsigned int | id, | |||
unsigned short int | bridge | |||
) | [static] |
Closes out (completes) the current event contribution by filling in the LSF event header.
beg | The beginning of the event contribution to closeout | |
end | The end of the event contribution to closeout | |
id | The LSF id of the event contribution | |
bridge | Arbitrary bridge word filled into the header. |
Referenced by LSEW_dgmEvtClose(), and LSEW_dgmUpdate().
static __inline unsigned int * evt_open | ( | unsigned int * | cur | ) | [static] |
Opens a new event record contribution.
cur | The beginning of the event contribution |
Referenced by LSEW_dgmEvtOpen(), and LSEW_dgmUpdate().
static __inline unsigned int * evt_size | ( | void | ) | [static] |
Returns the minimum size of a new event contribution.
Referenced by LSEW_dgmUpdate().
unsigned int* LSEW_dgmBeg | ( | const LSEW_dgm * | dgm | ) |
Returns the value of the beginning of the specified event datagram.
dgm | The event datagram to query |
References _LSEW_dgmBuf::beg, and _LSEW_dgm::buf.
int LSEW_dgmBufSet | ( | LSEW_dgm * | dgm, | |
unsigned int * | buf, | |||
int | buf_size | |||
) |
Sets the specified buffer as the new output buffer.
dgm | The output control block | |
buf | The new buffer | |
buf_size | The size, in bytes, of the new buffer |
References _LSEW_dgmBuf::beg, _LSEW_dgm::buf, _LSEW_dgmBuf::cur, _LSEW_dgm::dat, _LSEW_dgmBuf::end, _LSEW_dgm::hdr_size, _LSEW_dgm::lsf, and _LSEW_dgm::nevts.
Referenced by datagram_close(), and LSEW_dgmFwBufSet().
unsigned int* LSEW_dgmClose | ( | LSEW_dgm * | dgm, | |
unsigned int * | cur, | |||
unsigned int | reason | |||
) |
Closes out the datagram; it is now ready to be written out.
dgm | The event datagram to close | |
cur | The next write pointer, unless NULL, then it is ignored | |
reason | One of an enumeration describing why this event datagram is being closed. |
References _LSEW_dgm::apid, _LSEW_dgmBuf::beg, _LSEW_dgm::buf, ccsds_complete(), _LSEW_dgm::ccsds_seq, _LSEW_dgm::ctx, _LSEW_dgmBuf::cur, _LSEW_dgm::dat, datagram_close(), _LSEW_dgm::dgm_id, _LSEW_dgmBuf::end, _LSEW_dgm::evt, LSEW_ctxCloseAdd(), _LSEW_dgm::lsf, and _LSEW_dgm::nevts.
Referenced by datagram_close().
unsigned int* LSEW_dgmCommit | ( | LSEW_dgm * | dgm, | |
unsigned int * | cur | |||
) |
Commits the current write by updating the write potnter.
dgm | The output control block | |
cur | The current write pointer. |
References _LSEW_dgm::buf, _LSEW_dgmBuf::cur, and RND_UP.
Referenced by LSEW_dgmFwUsrAdd().
const LSEW_ctxPub* LSEW_dgmCtxPub | ( | const LSEW_dgm * | dgm | ) |
Returns a pointer to the public context structure.
dgm | The event datagram to query |
References _LSEW_dgm::ctx, and _LSEW_ctx::pub.
Referenced by LSEW_dgmFwCtxPub().
unsigned int* LSEW_dgmCur | ( | const LSEW_dgm * | dgm | ) |
Returns the value of the beginning of the specified event datagram.
dgm | The event datagram to query |
References _LSEW_dgm::buf, and _LSEW_dgmBuf::cur.
unsigned int* LSEW_dgmEnd | ( | const LSEW_dgm * | dgm | ) |
Returns the value of the end of the specified event datagram.
dgm | The event datagram to query |
References _LSEW_dgm::buf, and _LSEW_dgmBuf::end.
unsigned int* LSEW_dgmEvtClose | ( | LSEW_dgm * | dgm | ) |
Completes the final processing of an event just before it is presented to the output stream.
dgm | The datagram to close the event contribution |
References _LSEW_dgm::buf, _LSEW_dgmBuf::cur, _LSEW_dgm::evt, evt_close(), _LSEW_dgm::evt_id, and _LSEW_dgm::nevts.
Referenced by datagram_close(), and LSEW_dgmFwUsrAdd().
unsigned int* LSEW_dgmEvtCommit | ( | LSEW_dgm * | dgm, | |
unsigned int * | cur | |||
) |
Commits this event. This does two things, updates the current write pointer and increments the number of events in this contribution.
dgm | The output control block | |
cur | The current write pointer, if NULL, then the internal value of the write pointer is used. |
References _LSEW_dgm::buf, _LSEW_dgmBuf::cur, _LSEW_dgm::nevts, and RND_UP.
Referenced by LSEW_dgmFwEvtAdd().
unsigned int* LSEW_dgmEvtOpen | ( | LSEW_dgm * | dgm, | |
unsigned int * | cur | |||
) |
Opens a new event datagram.
dgm | The output control block | |
cur | The current write pointer, if NULL, then the internal value of the write pointer is used. |
References _LSEW_dgm::buf, _LSEW_dgmBuf::cur, _LSEW_dgm::evt, evt_open(), and _LSEW_dgm::nevts.
Referenced by datagram_open().
unsigned int LSEW_dgmInit | ( | LSEW_dgm * | dgm, | |
unsigned short int | apid, | |||
unsigned int | dgm_id, | |||
LSF_CPU_K | cpu, | |||
LSF_ORIGIN_K | origin | |||
) |
Initializes the control structure.
dgm | The output control structure to initialize | |
apid | The application id to use in the CCSDS packets | |
dgm_id | The LAT Science Format Data Id (LSF) to use | |
cpu | The CPU identifier | |
origin | The originating data source (ie LAT, GLEAM, etc) |
References _LSEW_dgm::apid, _LSEW_dgm::ccsds_seq, _LSEW_dgm::ctx, _LSEW_dgm::dgm_id, _LSEW_dgm::evt_id, _LSEW_dgm::hdr_size, LSE_ID_EVT_VERSION_K_2, LSE_ID_K_EVT, and LSEW_ctxInit().
Referenced by LSEW_dgmFwInit().
unsigned int LSEW_dgmLeft32 | ( | const LSEW_dgm * | dgm | ) |
Returns the number of 32 words left in the buffer.
dgm | The event datagram to query |
void LSEW_dgmModeChange | ( | LSEW_dgm * | dgm, | |
LSF_MODE_K | mode | |||
) |
Changes the current data-taking mode.
dgm | The destination event datagram context | |
mode | The new data-taking mode |
References _LSEW_dgm::ctx, and LSEW_ctxModeChange().
Referenced by LSEW_dgmFwModeChange().
unsigned int* LSEW_dgmOpen | ( | LSEW_dgm * | dgm, | |
unsigned int | reason, | |||
unsigned int | evt_seq, | |||
const EBF_gem * | gem | |||
) |
Opens a new event datagram.
dgm | The output control block | |
reason | One of an enumeration describing why this event datagram is being opened | |
evt_seq | The event sequence number | |
gem | The GEM contributor |
References _LSEW_dgm::buf, _LSEW_dgm::ctx, _LSEW_dgmBuf::end, LSEW_ctxOpenAdd(), and _LSEW_dgm::lsf.
Referenced by datagram_open().
void LSEW_dgmRootClose | ( | LSEW_dgm * | dgm, | |
const unsigned int * | end | |||
) |
dgm | The output control block | |
end | Pointer to the end of the root contribution |
References _LSEW_dgm::lsf.
Referenced by datagram_open().
void LSEW_dgmRunStart | ( | LSEW_dgm * | dgm, | |
unsigned int | runId, | |||
unsigned int | startTime, | |||
LSF_MODE_K | mode | |||
) |
Sets the context for a new run.
dgm | The event datagram control handle | |
runId | The run identifier | |
startTime | The run start time to the nearest second | |
mode | The running mode |
References _LSEW_dgm::ctx, and LSEW_ctxRunStart().
Referenced by LSEW_dgmFwRunStart().
unsigned int* LSEW_dgmUpdate | ( | LSEW_dgm * | dgm, | |
unsigned int | evt_seq, | |||
const EBF_gem * | gem | |||
) |
Updates the current datagram, adding a time record if necessary.
dgm | The output control block | |
evt_seq | The event sequence number | |
gem | The GEM contributor |
References _LSEW_dgm::buf, _LSEW_dgm::ctx, _LSEW_dgmBuf::cur, _LSEW_dgmBuf::end, _LSEW_dgm::evt, evt_close(), _LSEW_dgm::evt_id, evt_open(), evt_size(), LSEW_ctxUpdateAdd(), MAXIMUM_EVENTS_PER_CONTRIBUTION, and _LSEW_dgm::nevts.
Referenced by LSEW_dgmFwEvtAdd().