GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> XFC / dev > gxfc / rhel4-32


Interface   Data Structures   File List   Data Fields   Globals  

xfc.c File Reference

Utility/driver program for filter test code. More...

#include <xfc.h>
#include <xfc_sdi.h>
#include <xfc_rto_def.h>
#include <xfc_print_def.h>
#include <xfc_ebf_output.h>
#include <EFC_DB/EFC_DB_schema.h>
#include <EFC/EFC_display.h>
#include <EFC/EFS.h>
#include <EFC/EFA.h>
#include <EDS/io/EBF_stream.h>
#include <EDS/io/LCBP.h>
#include <EDS/io/EBF_evts.h>
#include <EDS/EDS_fw.h>
#include <EDS/LCBV.h>
#include <EDS/TMR.h>
#include <EFC/EFC.h>
#include <EDS/EBF_siv.h>
#include <EDS/EBF_dir.h>
#include <EDS/EDSD_print.h>
#include <EFC/EFC_time.h>
#include <EFC/EFR_key.h>
#include <LSE/CCSDS_ostream.h>
#include <LSE/LSE_time.h>
#include <LSF/LSF_ids.h>
#include <LSEP/LSEPW.h>
#include <ITC/ITC_pubdefs.h>
#include <IMM/FPM_pubdefs.h>
#include <IMM/RBM_pubdefs.h>
#include <MSG/MSG_pubdefs.h>
#include <CMX/CMX_lookupPub.h>
#include <CDM/CDM_pubdefs.h>
#include <PBS/PBS.h>
#include <PBS/MBA.h>
#include <PBS/TASK.h>
#include <PBI/FFS.ih>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

Classes

struct  _XfcStatsCtx
 The statistics context. More...
struct  _XfcResultsCtx
 The filter results context. More...
struct  _XfcPosterCtx
 The posting context. More...
struct  _XfcEfcCtx
 Kludge structure to hold some of the context that gets hidden in the EFC interface. This should be replaced by query calls into EFC, but that requires a new EFC release, just not worth it at this time. More...
struct  _XfcHandlerCtx
 Description of a handler. More...
struct  _XfcDisplayerCtx
 The displayer context. More...
struct  _XfcCtx
 Structure to bind all the filtering parameters together into something suitable for passing to the LCB event call back handler. More...
struct  _XfcConstructCtx
 Special structure to fee context to the services constructor. More...

Defines

#define CCSDS_ostream_d(variable)   CCSDS_ostream variable
#define RND8(_n)   (((_n) + 7) & ~0x7)
 Rounds _n to a value of 8.

Typedefs

typedef struct _XfcStatsCtx XfcStatsCtx
 Typedef for struct _XfcStatsCtx.
typedef struct _XfcResultsCtx XfcResultsCtx
 Typedef for struct _XfcResultsCtx.
typedef struct _XfcPosterCtx XfcPosterCtx
 Typedef for struct _XfcPosterCtx.
typedef struct _XfcEfcCtx XfcEfcCtx
 Typedef for stuct _XfcEfcCtx.
typedef struct _XfcHandlerCtx XfcHandlerCtx
 Typedef for struct _XfcHandlerCtx.
typedef struct _XfcDisplayerCtx XfcDisplayerCtx
 Typedef for struct _XfcDisplayCtx.
typedef struct _XfcCtx XfcCtx
 Typedef for struct _XfcCtx.
typedef struct _XfcConstructCtx XfcConstructCtx
 Typedef for struct XfcConstructCtx.

Functions

static void xfc_run_start (XfcCtx *ctx)
 Notifies the handlers and posters of the start run.
static void xfc_run_stop (XfcCtx *ctx)
 Stops the run.
static int createPoster (XfcPosterCtx *poster, const char *name, unsigned int options)
 Creates an output file if name is not NULL.
static void printPoster (XfcPosterCtx *poster, EDS_fwIxb *ixb)
 Prints a 1 line summary of the events that are output.
static void printElapsed (const char *caption, TMR_tick beg, TMR_tick end, int n)
 Utility routine to print elapsed times.
int xfc_initialize (void)
 One time initialization routine.
static unsigned int xfc_time_initialize (XfcCtx *ctx, const XfcRto *rto)
 Initializes the time base (fakes out WCT and THS).
static unsigned int xfc_edsFw_build (XfcCtx *ctx, const XfcRto *rto)
 Allocates and constructs the EDS framework.
static unsigned int xfc_istream_build (XfcCtx *ctx, const XfcRto *rto)
 Initializes the input data stream.
static unsigned int xfc_display_build (XfcCtx *ctx, const XfcRto *rto)
 Initializes the event display information.
static unsigned int xfc_output_build (XfcCtx *ctx, const XfcRto *rto)
static unsigned int xfc_handlers_build (XfcCtx *ctx, const XfcRto *rto)
void * xfc_filterCtx_get (const XfcCtx *ctx)
 Returns a pointer to the underlying user filter control structure.
void * xfc_resultsCtx_get (const XfcCtx *ctx)
 Returns a pointer to the results control structure.
void * xfc_statsCtx_get (const XfcCtx *ctx)
 Returns a pointer to the statistics control structure.
int xfc_sizeof (XfcConstructCtx *ctxx, const EFC_definition *def, const EFC_DB_Schema *schema, int stats_size)
 Computes the size needed to hold configuration defined by the specified context, definition block and schema.
const EDS_fwHandlerServicesX1 * xfc_construct (XfcConstructCtx *ctxx, EFC *efc, unsigned int handler_id, const EFC_DB_Schema *schema, unsigned int schema_key, EDS_fw *edsFw, unsigned int objects, unsigned int needs, XfcResultsPrintRtn resultsPrint, XfcStatsClearRtn statsClear, XfcStatsAccumulateRtn statsAcc, XfcStatsPrintRtn statsPrint, void *statsPrintCtx)
 Constructs the configuration for the specified set of parameters.
int xfc_any_display (const XfcCtx *ctx)
 Returns non-zero if there are any subsystems to display that need a directory.
void xfc_display (XfcCtx *ctx, unsigned int pktBytes, EBF_pkt *pkt, EBF_siv siv, EDS_fwIxb *ixb)
 Displays the requested subsystems.
int xfc_process (int id, const XfcRto *rto, const EDS_DB_HandlerConstructServices *services)
 Common routine to do the processing.
void xfc_results_post (XfcCtx *ctx, int reason, const void *beg, const void *end, const EFA_span *span)
 Dummy result vector post routine.
int xfc_results_start (XfcCtx *ctx, int reason, int run_id, int startTime, int mode)
 Handles the start run for the result analysis.
void xfc_begtick_set (XfcCtx *ctx, TMR_tick tick)
 Seeds the beginning tick of this sample.
void xfc_endtick_set (XfcCtx *ctx, TMR_tick tick)
 Seeds the ending tick of this sample.
void xfc_results_print (XfcCtx *ctx, const void *beg, const void *end)
 Prints the standard part of the results, then calls the filter specific piece.
unsigned int xfc_objects_get (const XfcCtx *ctx)
 Used to supply any additional EDS_fw objects needed by this filter context.
unsigned int xfc_needs_get (const XfcCtx *ctx)
 Used to supply any additional EDS_fw needs for this filter context.
static int dummyStart (void *prm, unsigned int run_id, unsigned int startTime, unsigned int mode, int reason)
 Dummy routine to intercept the posted events when one does not have a real posting routine.
static void dummyWrite (XfcPosterCtx *poster, EDS_fwIxb *ixb)
 Dummy routine to intercept the output events when one does not have a real output routine.
static int dummyNotify (void *prm, unsigned int mode, unsigned int active, const unsigned char cfgs[32], const EDS_rsdTbl *rsdTbl)
 Dummy routine to handle mode change notifications to the posting stream.
static void dummyFlush (void *prm, int reason)
 Dummy routine to close an posting stream.


Detailed Description

Utility/driver program for filter test code.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: xfc.c,v 1.2 2011/03/28 20:51:00 russell Exp $

Define Documentation

#define RND8 ( _n   )     (((_n) + 7) & ~0x7)

Rounds _n to a value of 8.

Returns:
The rounded value
Parameters:
_n The value to round

Referenced by xfc_sizeof().


Function Documentation

static int createPoster ( XfcPosterCtx poster,
const char *  name,
unsigned int  options 
) [static]

Creates an output file if name is not NULL.

Returns:
Status
Parameters:
poster The poster to fill in
name The name of the output file to create
options Bit list of output options.

References _XfcPosterCtx::count, _XfcPosterCtx::ctx, dummyFlush(), dummyNotify(), dummyStart(), dummyWrite(), _XfcPosterCtx::options, _XfcPosterCtx::services, xfc_ebf_output_construct(), and xfc_ebf_output_sizeof().

void dummyFlush ( void *  prm,
int  reason 
) [static]

Dummy routine to close an posting stream.

Parameters:
prm The user context parameter
reason The reason flush is being called

Referenced by createPoster().

int dummyNotify ( void *  prm,
unsigned int  mode,
unsigned int  active,
const unsigned char  cfgs[32],
const EDS_rsdTbl *  rsdTbl 
) [static]

Dummy routine to handle mode change notifications to the posting stream.

Parameters:
prm The user context parameter
mode The current mode
active The list of active handlers
cfgs The array of handler configurations
rsdTbl The result summary data table

Referenced by createPoster().

int dummyStart ( void *  prm,
unsigned int  run_id,
unsigned int  startTime,
unsigned int  mode,
int  reason 
) [static]

Dummy routine to intercept the posted events when one does not have a real posting routine.

Parameters:
prm The user context parameter
run_id The run identifier
startTime The start time (in seconds since the SA epoch)
mode The starting mode
reason The reason for starting

Referenced by createPoster().

void dummyWrite ( XfcPosterCtx post,
EDS_fwIxb *  ixb 
) [static]

Dummy routine to intercept the output events when one does not have a real output routine.

Parameters:
post The posting context handle
ixb The information exchange block, contains a reference to the event to write plus other event related information

References _XfcPosterCtx::options, and printPoster().

Referenced by createPoster().

static void printElapsed ( const char *  caption,
TMR_tick  beg,
TMR_tick  end,
int  n 
) [static]

Utility routine to print elapsed times.

Parameters:
caption The caption to print
beg The beginning time
end The ending time
n The normalizing count

Referenced by xfc_results_print().

static void printPoster ( XfcPosterCtx poster,
EDS_fwIxb *  ixb 
) [static]

Prints a 1 line summary of the events that are output.

Parameters:
poster The posting context handle
ixb The information exchange block

References _XfcPosterCtx::count.

Referenced by dummyWrite().

int xfc_any_display ( const XfcCtx ctx  ) 

Returns non-zero if there are any subsystems to display that need a directory.

Parameters:
ctx The filter context parameter

References _XfcCtx::displayer, and _XfcDisplayerCtx::printCtl.

void xfc_begtick_set ( XfcCtx ctx,
TMR_tick  tick 
)

Seeds the beginning tick of this sample.

Parameters:
ctx The xfc context
tick The beginning tick value

References _XfcCtx::tickBeg.

Referenced by xfc_results_post().

const EDS_fwHandlerServicesX1* xfc_construct ( XfcConstructCtx ctxx,
EFC *  efc,
unsigned int  handler_id,
const EFC_DB_Schema *  schema,
unsigned int  schema_key,
EDS_fw *  edsFw,
unsigned int  objects,
unsigned int  needs,
XfcResultsPrintRtn  resultsPrint,
XfcStatsClearRtn  statsClear,
XfcStatsAccumulateRtn  statsAcc,
XfcStatsPrintRtn  statsPrint,
void *  statsPrintCtx 
)

Constructs the configuration for the specified set of parameters.

Parameters:
ctxx Holds the run-time modifying context
efc The controlling Event Filter's handle
handler_id The handler's identifier
schema The defining schema. This must be what was passed to xfc_sizeof ().
schema_key The (likely FMX) key of the schema
edsFw The controlling EDS framework's handle
objects The EDS framework objects needed by this filter
needs The EDS framework service needs of this filter
resultsPrint The filter specific result print routine
statsClear The filter specific statistics buffer clear routine
statsAcc The filter specific statistics accumulation routine
statsPrint The fitler specific statistics print routine
statsPrintCtx The filter specific statistics print routine context parameter

!!!results;

References _XfcStatsCtx::acc, _XfcStatsCtx::bufs, _XfcSdi::cbp, _XfcStatsCtx::clear, _XfcConstructCtx::ctx, _XfcHandlerCtx::def, _XfcCtx::displayer, _XfcHandlerCtx::efa_post_cnt, _XfcHandlerCtx::efa_size, _XfcHandlerCtx::efc_size, _XfcCtx::efcCtx, _XfcResultsCtx::efs, _XfcHandlerCtx::efs_size, _XfcSdi::file, _XfcEfcCtx::filterCtx, _XfcCtx::handler, _XfcCtx::nevts, _XfcCtx::poster, _XfcResultsCtx::print, _XfcStatsCtx::print, _XfcDisplayerCtx::print_size, _XfcDisplayerCtx::printCtl, _XfcStatsCtx::printCtx, _XfcHandlerCtx::results, _XfcEfcCtx::resultsCtx, _XfcPosterCtx::sdi, _XfcResultsCtx::size, _XfcStatsCtx::size, _XfcDisplayerCtx::ss_to_print, _XfcHandlerCtx::stats, _XfcEfcCtx::statsCtx, xfc_needs_get(), xfc_objects_get(), xfc_results_post(), and xfc_results_start().

void xfc_display ( XfcCtx ctx,
unsigned int  pktBytes,
EBF_pkt *  pkt,
EBF_siv  siv,
EDS_fwIxb *  ixb 
)

Displays the requested subsystems.

Parameters:
ctx The filter context
pktBytes The number of bytes in the packet
pkt The event data packet
siv The packet state information vector
ixb The EDS information exchange block

References _XfcCtx::displayer, _XfcDisplayerCtx::printCtl, _XfcDisplayerCtx::ss_to_display, _XfcDisplayerCtx::ss_to_print, and _XfcDisplayerCtx::to_print.

static unsigned int xfc_display_build ( XfcCtx ctx,
const XfcRto rto 
) [static]

Initializes the event display information.

Parameters:
ctx The Xfc context handle
rto The run time options

References _XfcCtx::displayer, _XfcCtx::nevts, _XfcDisplayerCtx::ss_to_display, _XfcRto::ss_to_display, _XfcDisplayerCtx::ss_to_print, _XfcRto::ss_to_print, and _XfcDisplayerCtx::to_print.

Referenced by xfc_process().

static unsigned int xfc_edsFw_build ( XfcCtx ctx,
const XfcRto rto 
) [static]

Allocates and constructs the EDS framework.

Returns:
Status
Parameters:
ctx The Xfc context handle
rto The run time options

References _XfcCtx::edsFw.

Referenced by xfc_process().

void xfc_endtick_set ( XfcCtx ctx,
TMR_tick  tick 
)

Seeds the ending tick of this sample.

Parameters:
ctx The xfc context
tick The ending tick value

References _XfcCtx::tickEnd.

Referenced by xfc_results_post().

void* xfc_filterCtx_get ( const XfcCtx ctx  ) 

Returns a pointer to the underlying user filter control structure.

Returns:
A pointer to the underlying user filter control structure
Parameters:
ctx The filter control context

References _XfcCtx::efcCtx, and _XfcEfcCtx::filterCtx.

int xfc_initialize ( void   ) 

One time initialization routine.

Returns:
Status

static unsigned int status xfc_istream_build ( XfcCtx ctx,
const XfcRto rto 
) [static]

Initializes the input data stream.

Returns:
Status
Parameters:
ctx The Xfc context handle
rto The run time options

References _XfcCtx::ebf, _XfcCtx::ievt, _XfcRto::name, _XfcCtx::nevts, _XfcRto::to_process, _XfcRto::to_skip, and _XfcRto::type.

Referenced by xfc_process().

unsigned int xfc_needs_get ( const XfcCtx ctx  ) 

Used to supply any additional EDS_fw needs for this filter context.

Returns:
Bit mask of the addition objects
Parameters:
ctx The filter context handle

References _XfcPosterCtx::ctx, _XfcCtx::displayer, _XfcCtx::poster, and _XfcDisplayerCtx::printCtl.

Referenced by xfc_construct().

unsigned int xfc_objects_get ( const XfcCtx ctx  ) 

Used to supply any additional EDS_fw objects needed by this filter context.

Returns:
Bit mask of the addition objects
Parameters:
ctx The filter context handle

References _XfcPosterCtx::ctx, _XfcCtx::displayer, _XfcCtx::poster, and _XfcDisplayerCtx::printCtl.

Referenced by xfc_construct().

int xfc_process ( int  id,
const XfcRto rto,
const EDS_DB_HandlerConstructServices *  services 
)

Common routine to do the processing.

Parameters:
id The EFC_DB_id of this filter
rto The runtime options structure
services An alternative set of construction services, may be NULL, in which case the services resolved by the database schema and instance buried in the rto will be used.
Returns:
Status

References _XfcHandlerCtx::construction_services, _XfcCtx::ebf, _XfcCtx::edsFw, _XfcHandlerCtx::efc, _XfcCtx::handler, _XfcHandlerCtx::handler_id, _XfcRto::mode, _XfcCtx::mode, _XfcCtx::poster, _XfcPosterCtx::sdi, xfc_display_build(), xfc_edsFw_build(), xfc_istream_build(), xfc_run_start(), xfc_run_stop(), and xfc_time_initialize().

void xfc_results_post ( XfcCtx ctx,
int  reason,
const void *  beg,
const void *  end,
const EFA_span *  span 
)

Dummy result vector post routine.

Parameters:
ctx The xfc context
reason The posting reason
beg The first result vector
end The last result vector (actually one past the last one)
span The span of the sample

References _XfcStatsCtx::acc, _XfcStatsCtx::bufs, _XfcResultsCtx::efs, _XfcCtx::handler, _XfcResultsCtx::options, _XfcStatsCtx::print, _XfcStatsCtx::printCtx, _XfcHandlerCtx::results, _XfcHandlerCtx::stats, _XfcResultsCtx::verbose, _XfcResultsCtx::vetoes, xfc_begtick_set(), xfc_endtick_set(), and xfc_results_print().

Referenced by xfc_construct().

void xfc_results_print ( XfcCtx ctx,
const void *  beg,
const void *  end 
)

Prints the standard part of the results, then calls the filter specific piece.

Parameters:
ctx The xfc context
beg Pointer to the first filter specific result vector
end Pointer to the last filter specific result vector

References _XfcCtx::handler, _XfcResultsCtx::options, _XfcResultsCtx::print, printElapsed(), _XfcHandlerCtx::results, _XfcCtx::tickBeg, and _XfcCtx::tickEnd.

Referenced by xfc_results_post().

int xfc_results_start ( XfcCtx ctx,
int  reason,
int  run_id,
int  startTime,
int  mode 
)

Handles the start run for the result analysis.

Return values:
==0,if successfully started
!=0,if not successfully started
Parameters:
ctx The callback context parameter
reason The LSF_REASON_OPEN to indicate why the stream is being started
run_id Suggested use is to identify the block of events between when EDS_fwHandlerStart is called and EDS_fwHandlerFlush is called with a stop reason
startTime The run start time rounded to the nearest second
mode This must be the running mode.

References _XfcResultsCtx::efs, _XfcCtx::handler, and _XfcHandlerCtx::results.

Referenced by xfc_construct().

void* xfc_resultsCtx_get ( const XfcCtx ctx  ) 

Returns a pointer to the results control structure.

Returns:
A pointer to the results control structure
Parameters:
ctx The filter control context

References _XfcCtx::efcCtx, and _XfcEfcCtx::resultsCtx.

static void xfc_run_start ( XfcCtx ctx  )  [static]

Notifies the handlers and posters of the start run.

Parameters:
ctx The Xfc context handle

References _XfcCtx::ebf, _XfcCtx::edsFw, _XfcCtx::handler_mask, _XfcCtx::ievt, _XfcCtx::mode, _XfcCtx::nevts, _XfcPosterCtx::post_mask, _XfcCtx::poster, and _XfcCtx::tickBeg.

Referenced by xfc_process().

static void xfc_run_stop ( XfcCtx ctx  )  [static]

Stops the run.

Parameters:
ctx The Xfc context handle

References _XfcCtx::edsFw, _XfcCtx::handler_mask, _XfcPosterCtx::post_mask, and _XfcCtx::poster.

Referenced by xfc_process().

int xfc_sizeof ( XfcConstructCtx ctxx,
const EFC_definition *  def,
const EFC_DB_Schema *  schema,
int  stats_size 
)

Computes the size needed to hold configuration defined by the specified context, definition block and schema.

Returns:
The size, in bytes,
Parameters:
ctxx The filter control construction context
def The EFC definition block
schema The defining schema
stats_size The size, in bytes, of one statistics buffer

References _XfcConstructCtx::ctx, _XfcHandlerCtx::def, _XfcCtx::displayer, _XfcHandlerCtx::efa_post_cnt, _XfcHandlerCtx::efa_size, _XfcHandlerCtx::efc_size, _XfcHandlerCtx::efs_size, _XfcSdi::file, _XfcCtx::handler, _XfcCtx::poster, _XfcDisplayerCtx::print_size, RND8, _XfcHandlerCtx::schema, _XfcPosterCtx::sdi, _XfcStatsCtx::size, _XfcDisplayerCtx::ss_to_print, and _XfcHandlerCtx::stats.

void* xfc_statsCtx_get ( const XfcCtx ctx  ) 

Returns a pointer to the statistics control structure.

Returns:
A pointer to the statistics control structure
Parameters:
ctx The filter control context

References _XfcCtx::efcCtx, and _XfcEfcCtx::statsCtx.

static unsigned int xfc_time_initialize ( XfcCtx ctx,
const XfcRto rto 
) [static]

Initializes the time base (fakes out WCT and THS).

Returns:
Status
Parameters:
ctx The Xfc context handle
rto The run time options

Referenced by xfc_process().


Generated on Mon Aug 8 10:34:02 2011 by  doxygen 1.5.8