GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> GRBP / dev > grbp_siu / mv2304


Interface   Data Structures   File List   Data Fields   Globals  

grbp_siu.c File Reference

Program to test the SIU portion of the GRB algorithm. More...

#include <GRBP/io/GRB_stream.h>
#include <GRBP/io/ATT_stream.h>
#include <GRBP/io/ATT_dgm.h>
#include <GRBP/GRBP_client.h>
#include <GRBP_math.h>
#include <GRBP_msgdef.h>
#include <GRBP_pktdef.h>
#include <GRBP_DB/GRBP_DB_clientSchema.h>
#include <GRBP_DB/GRBP_DB_messageSchedule.h>
#include <GRBP_DB/GRBP_DB_window.h>
#include <GRBP_DB/GRBP_DB_print.h>
#include <GRBP_DB/GRBP_DB_locationSchedule.h>
#include <GRB/GRB_siu.h>
#include <ATT/ATT.h>
#include <CDM/CDM_pubdefs.h>
#include <CMX/CMX_lookupPub.h>
#include <stdio.h>
#include <stdlib.h>
#include <EDS/TMR.h>

Classes

struct  _Gbm
 Controls the contents and delivery of the GBM calculation message. More...
struct  _Ctl
 Captures the command line parameters. More...

Defines

#define RADIANS(_degrees)   ((_degrees) * (M_PI/180))
 Converts degrees to the equivalent number of radians.

Typedefs

typedef enum _OutStyle OutStyle
 Typedef for enum _OutStyle.
typedef struct _Gbm Gbm
 Typedef for struct _Gbm.
typedef struct _Ctl Ctl
 Typedef for struct _Ctl.

Enumerations

enum  _OutStyle {
  OUTSTYLE_K_NONE = 0,
  OUTSTYLE_K_ASCII = 1,
  OUTSTYLE_K_BINARY = 2
}
 The output styles. More...

Functions

int main (int argc, char *const argv[])
 Entry point to the client side (SIU) GRBP test program.
int doit (Ctl *ctl)
 Workhorse routine to feed the message and attitude files to the client-side GRBP code.
static int fill_gbm (Gbm *gbm, const char *string)
 Parses the gbm options string.
static void * mem_alloc (unsigned int nbytes)
 Wraps the 'real' allocator.
static void mem_free (void *ptr)
 Wraps the 'real' deallocator.
static const void * lookup (const char *symbol)
 Looksup the address of symbol using CMX_lookupSymbol and exits if not found.
static GRBP_DB_clientSchemaAll * getSchema (int verbose)
 Returns the GRBP DB schema.
static const GRB_latMsgServices * getMsgServices (OutStyle style, const char *name)
 Gets the message service vector based on the output style.
static void closeMsgServices (OutStyle style)
 Closes the message services based on the style.
static ATT_stream * read_att (const char *name, int flag)
 Opens and reads the specified ATT file.
static __inline ATT_Control * setup_att (int size)
 Sets up the ATT record history buffer.
static GRB_stream * read_grb (const char *name, int flag)
 Opens and reads the specified GRB message file.
static __inline unsigned long
long int 
get_base_time (const ATT_attitude *attitude)
 Gets the base time of the GRB.
static void __inline print_msg (const GRBP_msg *msg, int flag)
 Prints the specified GRB message.
static void __inline print_attitude (const ATT_attitude *attitude, int flag)
 Prints the attitude record.
static void __inline print_attitude_header (int flag)
 Prints the attitude header line.
static void close_fprintf (void)
 Closes the output file.
static void reportUsage (void)
 Reports on the usage of grbp_siu.
static int fillCtl (Ctl *ctl, int argc, char *const argv[])
 Examines the command line parameters and fills the control structure.
static int loadLib (const char *library_name, int verbose)
 Dynamically loads the specified configuration library.
static void suspect_null (const GRB_latAlertMsg *alert)
 Dummy GRB LAT suspect alert message handler.
static void confirm_null (int duration, double ra, double dec)
 Dummy a GRB LAT repoint request message handler.
static void update_null (const GRB_latAlertMsg *alert)
 Dummy GRB LAT update alert message handler.
static void closeout_null (const GRB_latAlertMsg *alert)
 Dummy GRB LAT closeout alert message handler.
static void open_fprintf (const char *name)
 Opens an output file to print the alert messages to.
static void suspect_fprintf (const GRB_latAlertMsg *alert)
 Print the contents of a GRB LAT suspect alert message.
static void confirm_fprintf (int duration, double ra, double dec)
 Print the parameters of the repoint request.
static void update_fprintf (const GRB_latAlertMsg *alert)
 Print the contents of a GRB LAT update alert message.
static void closeout_fprintf (const GRB_latAlertMsg *alert)
 Print the contents of a GRB LAT closeout alert message.
static void alert_fprintf (FILE *fp, const char *name, const GRB_latAlertMsg *alert)
 Print the contents of a GRB LAT a alert message.

Variables

static FILE * AlertFp
 The file pointer to write to.


Detailed Description

Program to test the SIU portion of the GRB algorithm.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: grbp_siu.c,v 1.8 2011/03/30 22:11:51 russell Exp $

Define Documentation

#define RADIANS ( _degrees   )     ((_degrees) * (M_PI/180))

Converts degrees to the equivalent number of radians.

Returns:
The equivalent number of radians
Parameters:
_degrees The value, in degrees, to convert to radians

Referenced by alert_fprintf(), confirm_fprintf(), and getSchema().


Enumeration Type Documentation

enum _OutStyle

The output styles.

Enumerator:
OUTSTYLE_K_NONE  No output file
OUTSTYLE_K_ASCII  ASCII output file
OUTSTYLE_K_BINARY  Binary output file


Function Documentation

static void alert_fprintf ( FILE *  fp,
const char *  type,
const GRB_latAlertMsg *  alert 
) [static]

Print the contents of a GRB LAT a alert message.

Parameters:
fp The target file pointer
type An ASCII string giving the type of message, ie. one of SUSPECT, CONFIRM, UPDATE. CLOSEOUT.
alert The alert message

References RADIANS.

Referenced by closeout_fprintf(), suspect_fprintf(), and update_fprintf().

static void closeMsgServices ( OutStyle  style  )  [static]

Closes the message services based on the style.

Parameters:
style The output style

References close_fprintf(), and OUTSTYLE_K_ASCII.

Referenced by doit().

static void closeout_fprintf ( const GRB_latAlertMsg *  alert  )  [static]

Print the contents of a GRB LAT closeout alert message.

Parameters:
alert The closeout alert message

References alert_fprintf().

Referenced by getMsgServices().

static void closeout_null ( const GRB_latAlertMsg *  alert  )  [static]

Dummy GRB LAT closeout alert message handler.

Parameters:
alert The closeout alert message

Referenced by getMsgServices().

static void confirm_fprintf ( int  duration,
double  ra,
double  dec 
) [static]

Print the parameters of the repoint request.

Parameters:
duration Duration, in seconds, of the alert
ra The right ascension, in arc minutes
dec The declination, in arc minutes

References RADIANS.

Referenced by getMsgServices().

static void confirm_null ( int  duration,
double  ra,
double  dec 
) [static]

Dummy a GRB LAT repoint request message handler.

Parameters:
duration Duration, in seconds, of the alert
ra The right ascension, in degrees
dec The declination, in degrees

Referenced by getMsgServices().

int doit ( Ctl ctl  ) 

static int fill_gbm ( Gbm gbm,
const char *  string 
) [static]

Parses the gbm options string.

Parameters:
gbm The Gbm structure to fill
string The Gbm options string

References _Gbm::msg, and _Gbm::time.

Referenced by fillCtl().

static int fillCtl ( Ctl ctl,
int  argc,
char *const   argv[] 
) [static]

Examines the command line parameters and fills the control structure.

Parameters:
ctl The parameter control block.
argc The number of command line parameters.
argv The array of pointers to the command line parameters.
Return values:
0,Everything is okay.
-1,Incorrect command usage. Usually this means that the input file name was absent.

References _Ctl::attname, fill_gbm(), _Ctl::gbm, _Ctl::gbm_flag, _Ctl::grbname, loadLib(), _Gbm::msg, _Ctl::oname, _Ctl::ostyle, OUTSTYLE_K_ASCII, OUTSTYLE_K_BINARY, OUTSTYLE_K_NONE, _Ctl::print_cfg, reportUsage(), _Gbm::time, and _Ctl::verbose.

Referenced by main().

static __inline unsigned long long int get_base_time ( const ATT_attitude attitude  )  [static]

Gets the base time of the GRB.

Returns:
The base time
Parameters:
attitude The first attitude record

References _ATT_timestamp::secs, and _ATT_attitude::timestamp.

Referenced by doit().

static const GRB_latMsgServices * getMsgServices ( OutStyle  style,
const char *  name 
) [static]

Gets the message service vector based on the output style.

Parameters:
style The output style
name The name of the output file

References closeout_fprintf(), closeout_null(), confirm_fprintf(), confirm_null(), open_fprintf(), OUTSTYLE_K_ASCII, OUTSTYLE_K_NONE, suspect_fprintf(), suspect_null(), update_fprintf(), and update_null().

Referenced by doit().

static GRBP_DB_clientSchemaAll * getSchema ( int  verbose  )  [static]

Returns the GRBP DB schema.

Returns:
The GRBP DB schema
Parameters:
verbose Flag indicating to print message about the origin either dynamically loaded CDM or default parameters

References RADIANS.

Referenced by doit().

static int loadLib ( const char *  library_name,
int  verbose 
) [static]

Dynamically loads the specified configuration library.

Return values:
0,success 
-1,failure 
Parameters:
library_name The name of the library to load
verbose The verbosity level

Referenced by fillCtl().

static const void * lookup ( const char *  symbol  )  [static]

Looksup the address of symbol using CMX_lookupSymbol and exits if not found.

Returns:
The address of the symbol.
Parameters:
symbol The symbol to lookup
This is just a cover for CMX_lookupSymbol, exiting if the symbol is not found.

Referenced by doit().

static void * mem_alloc ( unsigned int  nbytes  )  [static]

Wraps the 'real' allocator.

Returns:
Pointer to the allocated memory or NULL if not available
Parameters:
nbytes The number of bytes
On the embedded systems, the memory pool available to malloc is too small for the larger .ebf files. Typically in this environment one should use MBA_alloc/MBA_free, However, because the EDS package is supposed to be independent of other packages (including P B S) one can not link against in the traditional manner.
The solution is two fold
  • Do the usual thing and define wrapper functions that are different for the host and embedded systems.
  • Go one step further and define MBA_alloc/MBA_free as weak symbols.
This second point effectively transfers the burden of determining when the MBA_alloc/MBA_free symbols need to be satistied. Instead of at the static link or dynamic load stage, this is deferred till runtime.
Note:
There is likely an even trickier way to do this. Currently the code checks if MBA_alloc/MBA_free are non-NULL and if so uses them, else it reverts to malloc/free. Ideally the dynamic loader should do this, thus eliminating the need for any run-time code.

Referenced by doit().

static void mem_free ( void *  ptr  )  [static]

Wraps the 'real' deallocator.

See also:
mem_alloc
Parameters:
ptr Pointer to the memory to free
Note:
See mem_alloc for a discussion on why mem_alloc and mem_free exist and for the implementation details

Referenced by doit().

static void open_fprintf ( const char *  name  )  [static]

Opens an output file to print the alert messages to.

Parameters:
name The name of the output file

Referenced by getMsgServices().

static void __inline print_attitude ( const ATT_attitude attitude,
int  flag 
) [static]

Prints the attitude record.

Parameters:
attitude The attitude record to parse
flag Flag indicating whether to print or not

References _ATT_attitude::q, _ATT_timestamp::secs, _ATT_attitude::timestamp, and _ATT_timestamp::usecs.

Referenced by doit().

static void __inline print_attitude_header ( int  flag  )  [static]

Prints the attitude header line.

Parameters:
flag Flag indicating whether to print or not

Referenced by doit().

static __inline void print_msg ( const GRBP_msg msg,
int  flag 
) [static]

Prints the specified GRB message.

Parameters:
msg The message to print
flag The print flags

References _GRBP_msg::bdy, _GRBP_msgBdy::dx, _GRBP_msgBdy::dy, _GRBP_msgBdy::dz, _GRBP_msgBdy::energy, GRBP__msgKey(), and GRBP__msgTime().

Referenced by doit().

static ATT_stream * read_att ( const char *  name,
int  flag 
) [static]

Opens and reads the specified ATT file.

Parameters:
name The name of the file to open
flag Print flag

References ATT_STREAM_TYPE_K_FILE.

Referenced by doit().

static GRB_stream * read_grb ( const char *  name,
int  flag 
) [static]

Opens and reads the specified GRB message file.

Parameters:
name The name of the file to open
flag Print flag

References GRB_STREAM_TYPE_K_FILE.

Referenced by doit().

static __inline ATT_Control * setup_att ( int  size  )  [static]

Sets up the ATT record history buffer.

Returns:
A pointer to the history buffer
Parameters:
size The size of the history buffer

Referenced by doit().

static void suspect_fprintf ( const GRB_latAlertMsg *  alert  )  [static]

Print the contents of a GRB LAT suspect alert message.

Parameters:
alert The suspect alert message

References alert_fprintf().

Referenced by getMsgServices().

static void suspect_null ( const GRB_latAlertMsg *  alert  )  [static]

Dummy GRB LAT suspect alert message handler.

Parameters:
alert The suspect alert message

Referenced by getMsgServices().

static void update_fprintf ( const GRB_latAlertMsg *  alert  )  [static]

Print the contents of a GRB LAT update alert message.

Parameters:
alert The update alert message

References alert_fprintf().

Referenced by getMsgServices().

static void update_null ( const GRB_latAlertMsg *  alert  )  [static]

Dummy GRB LAT update alert message handler.

Parameters:
alert The update alert message

Referenced by getMsgServices().


Generated on Wed Sep 28 10:10:23 2011 by  doxygen 1.5.8