//*** dat_fnx.h  prototypes for data acq. and post-processing
//*** Jan 2009 : jts 
//************************************************************************
//definitions for SBD data packing:
// The SBD ISU packet from Spray is 1960 bytes max.
// The packet has:
// 		12 bytes for header+chksum,
//      2*23 for 2 GPS messages 
//      36 for engineering, 
//		4*4 for data headers+';' = 110 bytes,
// leaving 1850 bytes for four sensors, taking 22 bytes/20 samples
// allowing 21 blocks of 20 samples = 420 samples per sensor

// If 6 sensors, then 410 *4 / 6 = MAX_AVG_PTS =273 points per sensor

#define MAX_AVG_PTS 410 //***=max output pts after averaging
#define MAX_AVG_BUF 500 //19Nov04 : set > 3 + 22*/20 *MAX_AVG_PTS

#define YMAX 126 // = largest allowed 1st-differenced value
#define NSUB  20 // = #pts for ea 1st-diff block

// ** prototypes
short alloc_dat_ram ( struct dat_param *DP );  // allocate buffer space
void  take_data     ( void );  // take & store data

void  store_pro_dat   ( struct dat_param *DP );
void  store_eng_dat   ( struct dat_param *DP );
void  store_dat2flash ( struct dat_param *DP );

float dBar        ( ushort p, struct flight_param *fp ); 
short altimeter   ( short dt );
short c2eng       ( short cnt, short type );
short battery     ( void );
short vacuum      ( void );
void  vac_cycle   ( void );
void  a2d_cycle   ( void );
void  opt_cycle   ( void );

// prototypes for satellite data packing
short data_pack   ( void );  // pack profile sensor data
short eng_pack    ( void ) ;  

//sep04 recast tmp arrays from ushort to long
short pack_str    ( char *b,  char *x, char id, short n, short i, short k); //nov08 added for straight xfr
short pack_dat    ( char *b,  long *x, short n, short i, short k);
short pack_dat2   ( char *b,  long *x, short n, short i, short k, short id2 ); //sep16
void  pack_sub    ( long *y,  char *b, short n, short *k);
short avg_dat     ( short i, short *d, short nr,short na, short n, 
              long *x, short j);

void  eng_nav_store ( void );


void  daq_test      ( void );
