/*
   FILE:  userbuff.h

   This include file takes the place of nav.h
   2000/01/19 changed "spare" to "quality" in GPS_FIX_TYPE.

*/

#ifdef data_id_included
#undef U                  /* in order to correctly compile this .h file */
#undef V                  /* will be redefined at the end of this file  */
#define REINCLUDE         /* set flag to note that U & V must be redefined */
#endif

#define userbuff_included

#define N_REF_AVGS      10
#define N_REF_AVGS_1320  2 /* max number of ref layer averages within an ensemble. */

/* These defines are used for indexing, so they must not be changed */
/* position sources */
#define PS_NONE    0
#define PS_GPS     1
#define PS_TRANSIT 2

#define NO_FIX		0
#define GGA_FIX		1
#define MSG8_FIX 	2
#define PBN_FIX 	3

#define SECONDS_PER_DAY 86400L

typedef struct
{
   LONG pc_seconds, gps_seconds;
   DOUBLE lat, lon;
   FLOAT height;
   CHAR dop, nsat, msg_type, quality;
} GPS_FIX_TYPE;  /* 32 bytes */

/* The compressed raw data message from the Magnavox 4200:
*/
typedef struct
{
   CHAR c[76];
} RAW_2_TYPE;

typedef struct
{
   SHORT            version,
                    n_samples,
                    s_added,    /* for auto clock correction */
                    spare;
   GPS_FIX_TYPE     fix[2];
   RAW_2_TYPE       raw[2];
} USER_BUFFER_2240_TYPE;

typedef struct
{
   SHORT            version,
                    n_samples,
                    s_added,    /* for auto clock correction */
                    spare;
   GPS_FIX_TYPE     fix[2];
} USER_BUFFER_720_TYPE;

typedef struct
{
   SHORT dh_mean,   dh_std,  dh_min,  dh_max,
	 p_mean,    p_std,   p_min,   p_max,
	 r_mean,    r_std,   r_min,   r_max,
	 mrms_mean, mrms_std,mrms_min,mrms_max,
	 brms_mean, brms_std,brms_min,brms_max;
   SHORT n_att, n_used,
    	 n_reacq, n_mrms,
	 n_brms, n_outlier,
	 spare1, spare2;
} ASHTECH_ATT_STAT_TYPE; /* 56 bytes */

typedef struct
{
   SHORT                 version,
	        	 n_samples,
		         s_added,
           	         spare;
   GPS_FIX_TYPE       	 fix[4];
   ASHTECH_ATT_STAT_TYPE att;
} USER_BUFFER_1920_TYPE;

typedef struct
{
   SHORT ref_u,
         ref_v,
         ref_count,
         sat_id;
   LONG  pc_time,
         fix_time,
         lon,
         lat,
         antenna;
   SHORT dr_dist,
         dr_dir,
         sigma_lon,
         sigma_lat;
   BYTE  used,
         q1,
         q2,
         q3,
         elevation,
         iterations,
         dop_count,
         spare;
} TRANSIT_FIX_TYPE;  /* 44 bytes */

typedef struct
{
   LONG time, lon, lat;
} L_FIX_TYPE;

typedef struct
{
   SHORT received;
   BYTE  nsat,
         quality,
         track_status[3],
         state,
         mode,
         hdop;
   SHORT dopN,
         dopE,
         dopV,
         OscBias,
         V,
         U,
         altitude;
} GPS_STATUS_TYPE;  /* 24 bytes */

typedef struct
{
   SHORT            version,
                    max_avgs,
                    first_bin,
                    n_bins,
                    avg_uv[2*N_REF_AVGS_1320],
                    set,
                    drift,
                    position_source,
                    dr_time;
   L_FIX_TYPE       avg_fix[N_REF_AVGS_1320+1];
   TRANSIT_FIX_TYPE fix;
   LONG             time;
   GPS_STATUS_TYPE  gps_status;
} USER_BUFFER_1320_TYPE;

typedef struct
{
   SHORT            version,
                    max_avgs,
                    first_bin,
                    n_bins,
                    avg_uv[2*N_REF_AVGS],
                    set,
                    drift,
                    position_source,
                    dr_time;
   TRANSIT_FIX_TYPE fix;
   LONG             time;
   GPS_STATUS_TYPE  gps_status;
} USER_BUFFER_1281_TYPE;

typedef struct
{
   TRANSIT_FIX_TYPE fix;
   LONG             time;
   SHORT            max_avgs,
                    first_bin,
                    n_bins,
                    avg_uv[2*N_REF_AVGS],
                    set,
                    drift,
                    position_source,
                    dr_time;
} USER_BUFFER_1021_TYPE;

#define MAX_UB_BYTES 2048    /* must be MAX of all possible ub sizes */

#ifdef REINCLUDE
#include "data_id.h"  /* in order to redefine U and V */
#endif
