GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> EMP / V1-4-1 > asc / rhel5-32
#include <EMP/LSD_sdi.h>
#include <EMP/ASC.h>
#include <EMP/ASC_ids.h>
#include <EMP/ASC_ascCtb.h>
#include <EMP/ASC_ascBdy.h>
#include <EMP/EMP_hdrdefs.h>
#include <EMP/EMP_tlmdefs.h>
#include <EMP/EMP_write.h>
#include <EMP_hdr.h>
#include <EMP/ASC_statsdefs.h>
#include <EMP/EMP_msgs.h>
#include <EMP_DB/ASC_DB_schema.h>
#include <EDS_DB/EDS_DB_schema.h>
#include <EDS/EDS_fw.h>
#include <EDS/EBF_evt.h>
#include <EDS/EBF_cid.h>
#include <EDS/EBF_gem.h>
#include <EDS/EBF_dir.h>
#include <EDS/EBF_gemLocate.h>
#include <EDS/EDR_acdUnpack.h>
#include <LSF/LSF.h>
#include <LSF/LSF_ids.h>
#include <LSF/LSF_reason.h>
#include <ZLIB/zlib.h>
#include <MSG/MSG_pubdefs.h>
#include <PBS/TMR.h>
#include <PBS/MBA.h>
#include <PBS/FPA.h>
#include <PBS/WUT.h>
#include <PBS/WUT_tmr.h>
#include <PBS/FORK.h>
#include <PBS/PTS.h>
#include <PBS/WCT.h>
#include <PBS/BSWP.h>
#include <string.h>
Classes | |
struct | _OutputMessage |
This is a buffer with a header large enough to hold the control information to both store this on the FPA free que and post it to an output FORK que. The body of the message is the buffer for the output datagram. More... | |
struct | _Prescaler |
Prescaler control structure. More... | |
struct | _LastEvent |
Information about the last event in the previous packet. This used to seed the begin information of the next packet. More... | |
struct | _FlushMessage |
Flush fork message structure. More... | |
struct | _Flush |
Flush control structure. More... | |
struct | _ASC |
The control structure for an ASC process. More... | |
Defines | |
#define | TRACE_PUT(xx, yy) |
#define | ASC_VER_K_DATAGRAM 0 |
The version of the ASC datagram that is being produced. | |
#define | NUM_COUNTER_BUFFS 3 |
Number of messages to accumulate histograms in. | |
#define | RND_TO(_v, _r) (((_v) + (_r) - 1) & ~((_r) - 1)) |
Rounds the specified value up to the _r. _r must be a binary power of 2. | |
Typedefs | |
typedef struct _OutputMessage | OutputMessage |
Typedef for struct _OutputMessage. | |
typedef struct _Prescaler | Prescaler |
Typedef for struct _Prescaler. | |
typedef struct _LastEvent | LastEvent |
Typedef for struct _LastEvent. | |
typedef struct _FlushMessage | FlushMessage |
Typedef for struct _FlushMessage. | |
typedef int(* | FlushDeliverRtn )(void *ctx, FORK_cb_rtn rtn, FORK_msg_hdr *msg) |
Signature of routine to deliver a flush message. | |
typedef struct _Flush | Flush |
Typedef for struct _Flush. | |
typedef struct _ASC | ASC |
Typedef for struct _ASC. | |
Functions | |
static int | get_node_id () |
Return the node id. | |
static const char * | get_task_name () |
Return the name of the task. | |
static int | get_task_priority () |
Return priority to assign the task. | |
static unsigned int | AscEdsSizeof (const void *db, void *prm) |
This is the EDS service to return the size of the context structure. | |
static const EDS_fwHandlerServicesX1 * | AscEdsConstruct (ASC *asc, unsigned int id, const ASC_DB_Schema *db, unsigned int key, ASC_handlerConstructCfg *cfg, EDS_fw *edsFw) |
This is the EDS constructor for ASC. It's name is supplied to the caller via the ASC_constructServicesGet routine. | |
static int | AscEdsDestruct (ASC *asc) |
The EDS destructor service. | |
static unsigned int | AscEdsObjectsGet (ASC *asc) |
The EDS Objects Get service. This returns a bit mask of the objects managed EDS that ASC requires. | |
static unsigned int | AscEdsNeedsGet (ASC *asc) |
The EDS Needs Get service. | |
static int | AscEdsFlush (ASC *asc, int reason) |
The EDS flush service. | |
static unsigned int | AscEdsProcess (ASC *asc, unsigned int pktBytes, EBF_pkt *pkt, EBF_siv siv, EDS_fwIxb *ixb, int id) |
The EDS Event Processing Service. | |
static int | CompressIt (z_stream *zstream, void *dst, int dstLen, void *src, int srcLen) |
Utility function to call the ZLIB deflate routine. | |
static unsigned int | output (ASC *asc, OutputMessage *msg) |
The datagram output routine. This is a FORK service callback routine. | |
static unsigned int | forkExit (ASC *asc, OutputMessage *msg) |
Forces the FORK task to exit. | |
static void | initMsg (void *unused, OutputMessage *msg, int msg_size, int pcb_offset) |
This is the FPA initialization callback routine used to initialize each packet in the FPA pool. | |
const EDS_DB_HandlerConstructServices * | ASC_constructServicesGet (ASC_handlerConstructCfg *cfg) |
Routine called by LPA (via EMP_DB) to get constructionr info for ASC. | |
static void __inline | swap32bN (unsigned int *buf, int n32) |
Inplace 32 swap to a big-endian buffer, noop on big-endian machines. | |
static __inline FPA_fcb * | createFpaPool (int cnt) |
Creates the FPA pool used to hold the input message packets. | |
static __inline unsigned int | createOutputTask (ASC *asc) |
static __inline ASC_ascBdy_Raw0 * | get_packet (ASC *asc) |
Returns a pointer to the packet to be filled in. | |
static __inline void | set_aem (EBF_dir *dir, EBF_pkt *pkt, unsigned int pktBytes) |
Locates the AEM data without doing a full directory. The pointer to the AEM contribution is stashed away in the EBF directory structure. This is a little sleazy, but that's where EDR_acdUnpack expects to find it. | |
static void * | zlibMalloc (void *arg, unsigned int nitems, unsigned int size) |
Callback function used by ZLIB to allocate memory. | |
static void | zlibFree (void *arg, void *address) |
Callback function used by ZLIB to free memory. | |
static unsigned int | zlibInitStream (z_stream *stream, int level) |
Does the one time initialization of the compression stream. | |
int | flush_forward (void *lcb, FlushMessage *msg) |
Executes in the context of the event handling task. | |
WUT_cb_status | flush_tmr (ASC *asc, WUT_tmr *tmr) |
This is the timer ISR flush routine. | |
static __inline void | dgmComplete (LSF_datagram *dgm, ASC *asc, unsigned int payloadSize, unsigned int bridge) |
Completes the datagram header information. | |
Variables | |
static const unsigned char | OpenReasons [16] |
Maps a closing reason into its complimentary open reason. |
CVS $Id: ASC_eds.c,v 1.13 2011/04/01 18:26:36 russell Exp $
#define NUM_COUNTER_BUFFS 3 |
Number of messages to accumulate histograms in.
Processing in fork takes about 300mSec for compress,clear, and output Since buffers will be switched after maybe 10sec, double buffer would probably work but 3 are specified for safety
Referenced by AscEdsConstruct().
#define RND_TO | ( | _v, | |||
_r | ) | (((_v) + (_r) - 1) & ~((_r) - 1)) |
Rounds the specified value up to the _r. _r must be a binary power of 2.
_v | The value to round | |
_r | The boundary to round up to. This must be a binary power of 2, e.g. 2, 4, 8, 16 etc. |
Referenced by createFpaPool(), LSD_sdiConstruct(), and output().
int(* FlushDeliverRtn)(void *ctx, FORK_cb_rtn rtn, FORK_msg_hdr *msg) |
Signature of routine to deliver a flush message.
ctx | Context parameter, likely controls the destination | |
rtn | The routine to call once the message is delivered | |
msg | The message to deliver |
const EDS_DB_HandlerConstructServices ASC_constructServicesGet | ( | ASC_handlerConstructCfg * | cfg | ) |
Routine called by LPA (via EMP_DB) to get constructionr info for ASC.
cfg | The handler construction configuration |
References AscEdsConstruct(), and AscEdsSizeof().
static const EDS_fwHandlerServicesX1 * AscEdsConstruct | ( | ASC * | asc, | |
unsigned int | id, | |||
const ASC_DB_Schema * | db, | |||
unsigned int | key, | |||
ASC_handlerConstructCfg * | cfg, | |||
EDS_fw * | edsFw | |||
) | [static] |
This is the EDS constructor for ASC. It's name is supplied to the caller via the ASC_constructServicesGet routine.
asc | The ASC context handle to fill in | |
id | The ID of this handler | |
db | The configuration database. | |
key | The configuration database file key | |
cfg | Optional user parameter. This is just part of the EDS services interface and is not used in the case of ASC. In some applications, the size of the context structure might depend on this parameter. Whereas the schema is meant to be fairly static object read from a file, prm is meant to be used more dynamically, perhaps being derived from command line parameters | |
edsFw | The handle of the controlling EDS framework |
References _FlushMessage::asc, ASC_ID_K_ASC, ASC_ID_K_DATAGRAM, ASC_VER_K_DATAGRAM, AscEdsDestruct(), AscEdsFlush(), AscEdsNeedsGet(), AscEdsObjectsGet(), AscEdsProcess(), _LastEvent::beg_invalid, _Flush::cnt, createFpaPool(), createOutputTask(), _ASC::ctbId, _Flush::ctx, _ASC::db, _ASC::dgmId, EMP_ASCSIU_TLM_APID, _LastEvent::evt, _ASC::flush, flush_tmr(), _ASC::frequency, get_node_id(), _ASC::last, _Prescaler::left, LSD_sdiConstruct(), LSD_sdiSizeof(), _ASC::msg, _Flush::msg, _ASC::msg_pool, _Flush::nsecx, NUM_COUNTER_BUFFS, _ASC::open_reason, _ASC::prescaler, _LSD_sdiWriteCbp::prm, _Prescaler::refresh, _EMP_hdrEvt::relative, _Flush::rtn, _LSD_sdiWriteCbp::rtn, _ASC::sdi, _Flush::tmr, _ASC_handlerConstructCfg::write, zlibInitStream(), and _ASC::zstream.
Referenced by ASC_constructServicesGet().
static int AscEdsDestruct | ( | ASC * | asc | ) | [static] |
The EDS destructor service.
asc | The ASC context handle |
References _ASC::flush, _ASC::fork_que, _ASC::fork_task, forkExit(), LSD_sdiDestruct(), _ASC::msg, _ASC::msg_pool, _ASC::sdi, and _Flush::tmr.
Referenced by AscEdsConstruct().
static int AscEdsFlush | ( | ASC * | asc, | |
int | reason | |||
) | [static] |
The EDS flush service.
asc | The ASC context handle | |
reason | An enumeration of why the flush is being called. |
References _EMP_hdrEvtSpan::beg, _LastEvent::beg_invalid, _OutputMessage::bridge, _EMP_hdrEvtSpan::end, _LastEvent::evt, _OutputMessage::fork, _ASC::fork_que, _ASC::frequency, _ASC_stats::frequency, _OutputMessage::hdr, _ASC_ascBdy_Raw0::hdr, _ASC::last, _ASC::msg, _ASC::nmissed, _ASC_stats::nmissed, _EMP_hdr::nsampled, _ASC::open_reason, OpenReasons, output(), _OutputMessage::pkt, _EMP_hdrEvt::relative, _EMP_hdr::span, and _ASC_ascBdy_Raw0::stats.
Referenced by AscEdsConstruct(), AscEdsProcess(), and flush_forward().
static unsigned int AscEdsNeedsGet | ( | ASC * | asc | ) | [static] |
The EDS Needs Get service.
asc | The ASC context handle |
Referenced by AscEdsConstruct().
static unsigned int AscEdsObjectsGet | ( | ASC * | asc | ) | [static] |
The EDS Objects Get service. This returns a bit mask of the objects managed EDS that ASC requires.
asc | The ASC context handle |
Referenced by AscEdsConstruct().
static unsigned int AscEdsProcess | ( | ASC * | asc, | |
unsigned int | pktBytes, | |||
EBF_pkt * | ebfPkt, | |||
EBF_siv | siv, | |||
EDS_fwIxb * | ixb, | |||
int | id | |||
) | [static] |
The EDS Event Processing Service.
EDS_FW_FN_M_NO_MORE,when | no more packets of this event are needed to complete the processing. | |
EDS_FW_FN_M_DIR,when | ASC is requesting EDS to compose a directory on its behalf. | |
0,when | ASC has been handed one of the middle packets in a sequence. This is an error either in AscEdsNeedsGet (it should only specifiy the first and last packet be delivered to this routine) or an internal error in the EDS framework. |
asc | The ASC context handle | |
pktBytes | The number of bytes in ebfPkt | |
ebfPkt | The EBF packet as delivered by the hardware | |
siv | The state information vector. This value is provided as a community service to all event handlers. It summarizes the current state of the packet, including an transport or protocol errors it has encounter and the packet's sequencing information (FIRST, ONLY, MIDDLE, LAST). | |
ixb | The information exchange block. This is a shared knowledge base managed by EDS and used by the event processors. It contains higher level information about the event. Once filled by one processor, all others are free to use it. This tactic saves the CPU from producing this information for each consumer. | |
id | The EDS identifier. This value is unused in the case for ASC, but some applications need this value as a way of identifying themselves. |
References ASC_accumulateU(), AscEdsFlush(), _EMP_hdrEvtSpan::beg, _LastEvent::beg_invalid, _Flush::cnt, _ASC_ascBdy_Raw0::counters, _ASC_stats::eacc, _ASC_stats::edir, EMP_hdrEvtSet(), _ASC_stats::etotal, _ASC_stats::eunpack, _LastEvent::evt, _ASC::flush, get_packet(), _ASC_ascBdy_Raw0::hdr, _ASC::last, _Prescaler::left, _ASC::msg, _EMP_hdr::nsampled, _Flush::nsecx, _ASC_stats::nused, _OutputMessage::pkt, _ASC::prescaler, _Prescaler::refresh, set_aem(), _EMP_hdr::span, _ASC_ascBdy_Raw0::stats, and _Flush::tmr.
Referenced by AscEdsConstruct().
static unsigned int AscEdsSizeof | ( | const void * | db, | |
void * | prm | |||
) | [static] |
This is the EDS service to return the size of the context structure.
db | The configuration database. This parameter is just part of the EDS services interface and is not used in the case of ASC. In some applications, the size of the context structure might depend on configuration parameters in the database. | |
prm | Optional user parameter. This is just part of the EDS services interface and is not used in the case of ASC. In some applications, the size of the context structure might depend on this parameter. Whereas the schema is meant to be fairly static object read from a file, prm is meant to be used more dynamically, perhaps being derived from command line parameters |
Referenced by ASC_constructServicesGet().
static int CompressIt | ( | z_stream * | stream, | |
void * | dst, | |||
int | dstLen, | |||
void * | src, | |||
int | srcLen | |||
) | [static] |
Utility function to call the ZLIB deflate routine.
stream | The ZLIB stream used to control the deflation | |
dst | The destination buffer | |
dstLen | The length, in bytes, of the destination buffer | |
src | The source buffer to compress | |
srcLen | The length, in bytes, of the source buffer. |
Referenced by output().
static __inline FPA_fcb * createFpaPool | ( | int | cnt | ) | [static] |
Creates the FPA pool used to hold the input message packets.
cnt | The number of packets to place in the pool |
References initMsg(), and RND_TO.
Referenced by AscEdsConstruct().
static __inline unsigned int createOutputTask | ( | ASC * | asc | ) | [static] |
asc | The ASC control structure, this is just passed transparently as the user parameter to the created FORK task |
References _ASC::fork_que, _ASC::fork_task, get_task_name(), and get_task_priority().
Referenced by AscEdsConstruct().
static __inline void dgmComplete | ( | LSF_datagram * | dgm, | |
ASC * | asc, | |||
unsigned int | payloadSize, | |||
unsigned int | bridge | |||
) | [static] |
Completes the datagram header information.
dgm | The target datagram | |
asc | The ASC context handle | |
payloadSize | The size, in bytes, of the contribution's data | |
bridge | The contribuion bridge word |
References _ASC::ctbId, and _ASC::dgmId.
Referenced by output().
int flush_forward | ( | void * | lcb, | |
FlushMessage * | msg | |||
) |
Executes in the context of the event handling task.
lcb | The LCB device context handle, not used here | |
msg | The message |
References _FlushMessage::asc, AscEdsFlush(), _ASC::flush, _Flush::nsecx, and _Flush::tmr.
Referenced by flush_tmr().
WUT_cb_status flush_tmr | ( | ASC * | asc, | |
WUT_tmr * | tmr | |||
) |
This is the timer ISR flush routine.
asc | The ASC context handle | |
tmr | The timer |
References _Flush::ctx, _ASC::flush, flush_forward(), _FlushMessage::hdr, _Flush::msg, and _Flush::rtn.
Referenced by AscEdsConstruct().
static unsigned int forkExit | ( | ASC * | asc, | |
OutputMessage * | msg | |||
) | [static] |
Forces the FORK task to exit.
!FORK_C_CONTINUE |
asc | The ASC context handle, ignored | |
msg | The FORK messsage, ignored |
Referenced by AscEdsDestruct().
static inline int get_node_id | ( | ) | [inline, static] |
Return the node id.
Referenced by AscEdsConstruct().
static __inline ASC_ascBdy_Raw0 * get_packet | ( | ASC * | asc | ) | [static] |
Returns a pointer to the packet to be filled in.
asc | The ASC context handle |
References _EMP_hdrEvtSpan::beg, _LastEvent::beg_invalid, _LastEvent::evt, _ASC_ascBdy_Raw0::hdr, _ASC::last, _ASC::msg, _ASC::msg_pool, _ASC::nmissed, _OutputMessage::pkt, _EMP_hdrEvt::relative, and _EMP_hdr::span.
Referenced by AscEdsProcess().
static inline get_task_name | ( | ) | [inline, static] |
Return the name of the task.
The task name This routine eliminates the dependency of this file on CPU_DB.
Referenced by createOutputTask().
static inline get_task_priority | ( | ) | [inline, static] |
Return priority to assign the task.
The priority to be assigned to the Event Monitor Task This routine eliminates the dependency of this file on CPU_DB.
Referenced by createOutputTask().
static void initMsg | ( | void * | unused, | |
OutputMessage * | msg, | |||
int | msg_size, | |||
int | pcb_offset | |||
) | [static] |
This is the FPA initialization callback routine used to initialize each packet in the FPA pool.
unused | This is usually the user context parameter. In this case it is unused. | |
msg | The message packet to initialize. | |
msg_size | The size, in bytes, of msg. In this case it is unused. | |
pcb_offset | The offset, in bytes, of the packet control block. This parameter is provided by FPA so that the user may avoid stomping on the control block of this packet. |
References ASC_clear(), _ASC_ascBdy_Raw0::counters, EMP_hdrClear(), _ASC_ascBdy_Raw0::hdr, _OutputMessage::pkt, and _ASC_ascBdy_Raw0::stats.
Referenced by createFpaPool().
static unsigned int output | ( | ASC * | asc, | |
OutputMessage * | msg | |||
) | [static] |
The datagram output routine. This is a FORK service callback routine.
FORK_C_CONTINUE,to | continue processing packets |
asc | The ASC context handle | |
msg | The FORK messsage |
References ASC_clear(), _OutputMessage::bridge, _ASC_ascBdy_Gzip0::buf, CompressIt(), _ASC_ascBdy_Raw0::counters, _ASC::db, dgmComplete(), _ASC_stats::eacc, _ASC_stats::ecompress, _ASC_stats::edir, EMP_hdrClear(), _ASC_stats::etotal, _ASC_stats::eunpack, _ASC_stats::frequency, _ASC_ascBdy_Raw0::hdr, _ASC_ascBdy_Gzip0::hdr, _ASC_ascBdy_Gzip0::len, LSD_sdiGetW(), LSD_sdiPdsDgmGet(), LSD_sdiSend(), LSD_sdiShrink(), _ASC::msg_pool, _ASC_stats::nmissed, _ASC_stats::nused, _OutputMessage::pkt, RND_TO, _ASC::sdi, _ASC_ascBdy_Raw0::stats, _ASC_ascBdy_Gzip0::stats, swap32bN(), and _ASC::zstream.
Referenced by AscEdsFlush().
static __inline void set_aem | ( | EBF_dir * | dir, | |
EBF_pkt * | pkt, | |||
unsigned int | pktBytes | |||
) | [static] |
Locates the AEM data without doing a full directory. The pointer to the AEM contribution is stashed away in the EBF directory structure. This is a little sleazy, but that's where EDR_acdUnpack expects to find it.
dir | The directory structure | |
pkt | The event packet | |
pktBytes | The number of bytes in the packet |
References ASC_aem_locate().
Referenced by AscEdsProcess().
static void __inline swap32bN | ( | unsigned int * | buf, | |
int | n32 | |||
) | [static] |
Inplace 32 swap to a big-endian buffer, noop on big-endian machines.
buf | The 32-bit buffer to swap | |
n32 | The number of 32-bit words to swap |
Referenced by output().
static void * zlibFree | ( | void * | arg, | |
void * | address | |||
) | [static] |
Callback function used by ZLIB to free memory.
arg | Arbitrary user parameter, unused in this routine | |
address | The adddress of the memory to free |
Referenced by zlibInitStream().
static unsigned int zlibInitStream | ( | z_stream * | stream, | |
int | level | |||
) | [static] |
Does the one time initialization of the compression stream.
0,on | success | |
EMP_GENERROR,on | error |
stream | The compression stream to initialize | |
level | The compression level to use |
References zlibFree(), and zlibMalloc().
Referenced by AscEdsConstruct().
static void * zlibMalloc | ( | void * | arg, | |
unsigned int | nitems, | |||
unsigned int | size | |||
) | [static] |
Callback function used by ZLIB to allocate memory.
arg | Arbitrary user parameter, unused in this routine | |
nitems | The number of items to allocate | |
size | The size, in bytes, of an item |
Referenced by zlibInitStream().
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_OPEN_K_AUTO_TIME, LSF_REASON_OPEN_K_AUTO_COUNT, LSF_REASON_OPEN_K_AUTO_FULL }
Referenced by AscEdsFlush().