/**---------------------------------------------------------------------------
 ** 
 ** nav.h -- Definitions for processing navigation data
 ** 
 ** Author          : Pierre Jaccard
 ** Created On      : 1999/07/15 15:11:39
 ** Last Modified By: Pierre Jaccard
 ** Last Modified On: 1999/09/04 16:59:14
 ** Update Count    : 7
 ** Directory       : /home/pego/pcd1/codas3c/gfi/src/libs/nav/
 ** Version         : 0.0
 ** Status          : Unknown
 ** ---------------------------------------------------------------------- ** 
 ** DESCRIPTION: 
 ** 
 **    This file provides definitions and macros required for processing
 **    navigation files.
 ** 
 ** ---------------------------------------------------------------------- ** 
 ** REVISIONS: 
 ** ---------------------------------------------------------------------- ** 
 ** CHANGES: 
 **
 ** 1999/09/03 Pierre Jaccard
 **            Addding support for RMC message
 ** 1999/09/04 Pierre Jaccard
 **            Addding support for GLL message
 **------------------------------------------------------------------------**/

#ifndef gfilib_nav_nav_already_included
#define gfilib_nav_nav_already_included

/* 
   The following are navigation line codes
*/
#define IGNORED_LINE_CODE                125 
#define EMPTY_LINE_CODE                  126 
#define BAD_LINE_CODE                    127
#define TRANSECT_LINE_CODE                 0
#define ZDA_LINE_CODE                      1
#define GGA_LINE_CODE                      2
#define HDT_LINE_CODE                      3
#define PRDID_LINE_CODE                    4
#define VTG_LINE_CODE                      5
#define RMC_LINE_CODE                      6
#define GLL_LINE_CODE                      7

#define MAX_NAV_LINE_CODES                 8

#define NAV_LINE_MAX_LENGTH 500  /* Max length of a navigation line, including
																		last '\0' character */

typedef struct
{
	ULONG  pc_time;
	USHORT ensemble_number;
} TRANSECT_LINE_TYPE;

typedef struct
{
	double yd;
} ZDA_LINE_TYPE;

typedef struct
{
	double yd;
	DOUBLE_LL_TYPE pos;
	USHORT qual;
	USHORT nsat;
	double hdop;
	double height;
} GGA_LINE_TYPE;

typedef struct
{
	DOUBLE_LL_TYPE pos;
} GLL_LINE_TYPE;

typedef struct
{
  double yd;
  DOUBLE_LL_TYPE pos;
	double course;
	double speed;
} RMC_LINE_TYPE;
  
typedef struct
{
	double heading;
} HDT_LINE_TYPE;

typedef struct
{
	double pitch;
	double roll;
	double heading;
} PRDID_LINE_TYPE;

typedef struct
{
	double course;
	double speed;
} VTG_LINE_TYPE;

/*
  The next type groups all navigation lines type
*/
typedef struct
{
	
	GGA_LINE_TYPE gga;
	ZDA_LINE_TYPE zda;
	HDT_LINE_TYPE hdt;
	VTG_LINE_TYPE vtg;
	RMC_LINE_TYPE rmc;
	GLL_LINE_TYPE gll;
	TRANSECT_LINE_TYPE transect;
	PRDID_LINE_TYPE prdid;
} NAV_LINES_TYPE;

/*
  The next structure contains all variables that can be present in navigation
  files. 
*/
typedef struct
{
	USHORT number;         /* Ensemble number                      */
	double inc;            /* Time increment decimal days, or zero */
	double yd;             /* Decimal day                          */
	DOUBLE_LL_TYPE pos;    /* Position                             */
	double heading;        /* Heading                              */
	double pitch;          /* Pitch                                */
	double roll;           /* Roll                                 */
	USHORT qual;           /* GPS quality                          */
	USHORT nsat;           /* Number of satellites                 */
	double hdop;           /* Horizontal dilution of precision     */
	double height;         /* Height above geoid                   */
	double course;         /* ship's course over ground            */
	double speed;          /* ship's speed over ground             */
} NAV_TYPE;

/*
  This macro returns true if the given navigation code correspond to a
  message including time
*/
#define is_nav_time(x)    (((x) == GGA_LINE_CODE) || ((x) == ZDA_LINE_CODE) \
                            || ((x) == RMC_LINE_CODE))

/*
  This macro returns true if the given navigation code corresponds to a line
  with heading information
*/
#define is_nav_heading(x) ((x) == HDT_LINE_CODE)
  

#endif /* gfilib_nav_nav_already_included */










