⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defines.h

📁 GPS导航定位程序
💻 H
字号:
/****************************************************************************
* This include file contains definitions of various constants and macros used 
* throughout the GPS Builder-2 software.
****************************************************************************/

#if defined(__LARGE__)==0              /* Only use the LARGE memory model. */
#error Select the LARGE memory model option.
#endif

/*  Determine what version of the BORLAND C++ compiler is being used by
    examining the value of the predfined macro, __BORLANDC__. Exit if it is
    not recognised.

    Acceptable versions are:

    BORLAND C++ 3.1, __BORLANDC__ = 0x410
    BORLAND C++ 4.0-4.02, __BORLANDC__ = 0x452

    It's possible that you might have a different compiler revision. If this
    is the case, then try hard setting the identifier, CompilerVersion, below
    to either 31, for versions before 0x410, or to 40, for versions after
    0x452. This may give you a working executable but beware - only 3.1 and
    4.02 have been verfied. Good Luck! */

/* Check for recognised comipler version. */

#if((__BORLANDC__!=0x410) && (__BORLANDC__!=0x452))
#error Unidentified compiler version, you must set CompilerVersion manually
#endif

#if (__BORLANDC__==0x410)                  /* The Compiler is version 3.1. */
#define CompilerVersion 31
#endif

#if (__BORLANDC__==0x452)                  /* The Compiler is version 4.0. */
#define CompilerVersion 40
#endif

/* Manually adjust the identifier, INSTRMODE, for 16 or 32-bit instructions.

    16-bit mode: compile with the 80286 instruction set and save only the
                 16-bit register set when the GP2021 interrupts
    32-bit mode: compile with the 80386 instruction set and save the
                 complete 32-bit register set when the GP2021 interrupts */

#define INSTRMODE 32

/* Set compiler optimization options. */

#pragma option -Od        /* Disable all, then selectively re-enable some. */
#pragma option -Z-      /* -Z is too tricky in a multitasking environment. */
#pragma option -O                /* Remove redundant jumps, small benefit. */
#pragma option -Ot           /* Favor speed over code size, small benefit. */
#pragma option -r                /* Use register variables, great benefit. */
#pragma option -N-                  /* Disable stack checking, neceessary. */
#pragma option -k                 /* Use standard stack frame, neceessary. */

#pragma option -3                                 /* 80386 protected mode. */

#define CONFIG_CODE "A-1.3"           /* GPS Builder-2 configuration code. */

/* Descriptive string explaining the configuration. */

#define CONFIG_XPLAIN "Borland C++ 3.1/4.0 & MS-DOS"

/* Define __CPPARGS as "..." or null, according to whether we are compiling
   with C or C++, to accomodate varying styles of function prototypes. */

#ifdef __cplusplus
    #define __CPPARGS ...
#else
    #define __CPPARGS
#endif

#include <alloc.h>                   /* All the pre-defined include files. */
#include <bios.h>
#include <conio.h>
#include <ctype.h>
#include <dos.h>
#include <float.h>
#include <math.h>
#include <mem.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define IStkSiz 1000      /* Size of the GP2021 interrupt stacks in bytes. */

/* Maximum number of receiver channels which can be supported by the GP2021.
   The actual number of active channels being processed may be less and is
   set by the global variable ActiveChannels. */

#define MAXCHANNELS 12

/* Maximum number of observations which can be buffered awaiting
   processing.  Can decrease this for fast computers, to perhaps 10. */

#define NOBS   30

/* Maximum number of 1-ms correlator accumulations which can be buffered
   awaiting processing, plus 21.*/

#define NACCUM 50

/* Maximum allowable command file nesting levels. */

#define MaxCmdFileNesting 5

/* The value of PI specified for GPS receivers in ICD-GPS-200. */

#define PI 3.1415926535898

/* WGS-84 speed of light specified for GPS receivers in ICD-GPS-200. */

#define SPEED_OF_LIGHT 2.99792458e8

/* An "average" value for the radius of the earth, used to convert from small
   spherical angles to arc length in meters. */

#define REARTH 6371006.84

#define R2D 57.2957795131                            /* Radians to degrees */

/* Earth's WGS-84 gravitational constant (m^3/s^2) specified for GPS
   receivers in ICD-GPS-200.*/

#define GravConstant 3.986005E14

/* Earth's WGS-84 rotation rate (rads/s) specified for GPS receivers in
   ICD-GPS-200.*/

#define WGS84oe 7.2921151467E-5

#define NOISE_FLOOR_FLOAT 97142.0     /* expected accumulator noise floor. */

#define SD95PERCENT 1.645     /* SD for 95% 2-sided cumulative prob. dist. */

#define SINGULAR    0                      /* Indicates a singular matrix. */
#define NONSINGULAR 1                  /* Indicates a non-singular matrix. */

#define FALSE 0                                     /* Something is false. */
#define TRUE 1                                       /* Something is true. */
#define BAD 0                                         /* Something is bad. */
#define GOOD 1                                       /* Something is good. */
#define INVALID 0                                 /* Something is invalid. */
#define VALID 1                                     /* Something is valid. */
#define NO 0                                          /* The answer is no. */
#define YES 1                                        /* The answer is yes. */

#define IDLE 0                                       /* Nothing happening. */

#define CODE_LENGTH 2095104L       /* C/A code length in 1/2048 of a chip. */
#define HALF_CODE_LENGTH 1047522L                  /* 1/2 C/A code length. */ 
#define SEARCH_CODE_LENGTH 2400000L           /* Searched C/A code length. */

/* Zero Doppler setting for the code DCO, scaled by 32, to achieve 5
   software bits of extra precision. */

#define CODE_DCO_ZERO_DOPPLER 0x2DD49518L

#define CODE_DCO_SCALE 32.0                                        /* 2^5. */
#define CODE_DCO_RESOLUTION (4.0E7/7.0*ldexp(1.0,-26))              /* Hz. */

/* The number of Early-Minus-Late readings averaged in the code tracker. */

#define EMLREADINGS 40

/* Zero Doppler setting for the carrier DCO, scaled by 16, to achieve 4
   software bits of extra precision. */

#define CARR_DCO_ZERO_DOPPLER 0x1F7B1B89L

/* Zero Doppler setting for the carrier DCO, un-scaled. */

#define NOMINAL_CARRIER_DCO 33010104.547556

#define CARRIER_DCO_SCALE 16.0                                     /* 2^4. */
#define CARRIER_DCO_RESOLUTION (4.0E7/7.0*ldexp(1.0,-27))           /* Hz. */
#define CARRIER_PHASE_ADVANCE_IN_TIC 140539.542                 /* Cycles. */
#define CARRIER_DCO_PHASE_SCALE 1024.0          /* Fractional cycle count. */

#define L1 1575.42E6                                                /* Hz. */
#define L1_TO_CA 1540.0                                   /* L1/Code rate. */

#define HIGHEST_ELEVATIONS 1                      /* Tracking mode number. */
#define SELECT_SATELLITES  2
#define COLD_START         3
#define TRACK_MODE_MIN     1 
#define TRACK_MODE_MAX     3

#define FIX_NO 0                                              /* Fix mode. */
#define FIX_2D 1
#define FIX_3D 2

#define NO_DGPS 9999.0                             /* No DGPS corrections. */
#define BIG_DOP 999.9                                    /* GDOP is LARGE. */


#define TIC_PERIOD 0.0999999                                   /* seconds. */
#define SECONDS_IN_WEEK 604800.0
#define SECONDS_IN_DAY 86400.0
#define SECONDS_IN_HOUR 3600.0
#define SECONDS_IN_MINUTE 60.0
#define SECONDS_IN_HALF_HOUR 1800.0
#define FOUR_HOURS 14400.0                                     /* seconds. */
#define SECONDS_PER_MZCOUNT 0.6  /* seconds per RTCM-104 modified Z-count. */

#define MAXSATELLITES 32                         /* Normal GPS satellites. */

#define NUMBER_OF_VALID_PORTS 16                /* 16 different I/O ports. */
#define NUMBER_OF_VALID_INTERRUPTS 5            /* 5 different interrupts. */
#define MASK_INTERRUPT 0                    /* Mask GP2021 interrupts off. */
#define UNMASK_INTERRUPT 1                /* Unmask GP2021 interrupts off. */
#define ASSERT_MASTER_RESET 0                    /* GP2021 master disable. */
#define DEASSERT_MASTER_RESET 1                   /* GP2021 master enable. */
#define ENABLE_INTERRUPTS 0x0020              /* Enable GP2021 interrupts. */
#define ALL_CHANNELS 0x1FFF      /* Enable all GP2021 correlator channels. */
#define WATCHDOG_OFF 0x0200                    /* Switch the watchdog off. */

#define PREAMBLE        0x008B               /* GPS data message preamble. */
#define INVERSEPREAMBLE 0x0074                       /* Inverted preamble. */
#define FRAME_SIZE_PLUS_2 12                   /* 10 words per data frame. */

#define DISPLAY              0                     /* Command mode values. */
#define COMMAND              1

#define DISPLAY_F1           1                     /* The display screens. */
#define DISPLAY_F2           2
#define DISPLAY_F3           3
#define DISPLAY_F4           4
#define DISPLAY_F5           5
#define DISPLAY_F6           6
#define DISPLAY_F7           7
#define DISPLAY_F8           8
#define DISPLAY_F9           9
#define DISPLAY_F10         10
#define DISPLAY_F11         11
#define DISPLAY_F12         12

#define SCREEN_WIDTH 80                                     /* Characters. */
#define CURSOROFF 0                                         /* Cursor off. */
#define CURSORON 1                                           /* Cursor on. */

/* Special character codes for CRT display. */

#define DV       '\x0BA'                               /* Double vertical. */
#define DH       '\x0CD'                             /* Double horizontal. */
#define DUL      '\x0C9'                             /* Double upper left. */
#define DUR      '\x0BB'                            /* Double upper right. */
#define DLL      '\x0C8'                             /* Double lower left. */
#define DLR      '\x0BC'                            /* Double lower right. */
#define DLJ      '\x0CC'                          /* Double left junction. */
#define DRJ      '\x0B9'                         /* Double right junction. */
#define UJ12     '\x0D1'                         /* 1-to-2 upper junction. */
#define LJ12     '\x0CF'                         /* 1-to-2 lower junction. */
#define SingV    '\x0B3'                               /* Single vertical. */
#define DEGREE   '\x0F8'                                   /* Degree sign. */
#define RTARROW  '\x01A'                                   /* Right Arrow. */
#define DELTA    '\x0EB'                              /* Lower case delta. */
#define PHI      '\x0ED'                                /* Lower case phi. */
#define TILDE    '\x07E'                                         /* Tilde. */
#define INFINITY '\x0EC'                                 /* Infinity sign. */

#define  RUBOUT         8            /* Key values (ascii codes plus 128). */
#define  TAB            9
#define  ESC            27
#define  ALTX           173
#define  PGUP_KEY       201
#define  LFAR_KEY       203
#define  PGDN_KEY       209

#define  F1_KEY         187
#define  F2_KEY         188
#define  F3_KEY         189
#define  F4_KEY         190
#define  F5_KEY         191
#define  F6_KEY         192
#define  F7_KEY         193
#define  F8_KEY         194
#define  F9_KEY         195
#define  F10_KEY        196
#define  F11_KEY        261
#define  F12_KEY        262

/* A macro for arithmetic right shifts, with casting of the argument. */

#define iSAR(larg,rcount) (((long)(larg))>>rcount)

/* A macro for performing the square of a double. */

#define DSquare(x) ((x)*(x))

/* Define the mapping between logical and physical addresses for the
   GPS Builder-2(TM) card. */

#define TR(addr) (((addr&0xFC)<<8) + ((addr&0x3)<<3) + CORRELATOR)

typedef int logical;                                     /* Logical types. */

/* Select RTCMDecodingRule=1 if you want to enforce the rule that RTCM-104
   differential corrections messages are not to be used until the header
   of the next message has been completely decoded.  This would be the
   normal case.  Setting RTCMDecodingRule=0 uses messages as soon as they
   are complete, and should be done to deal pragmatically with some
   reference stations which add illegal garbage characters to pad between
   the messages. */

#define RTCMDecodingRule 0

/* Select RTCMDecodingRule=0 and SpuriousPadChars=1 if you know that
   your DGPS reference station inserts spurious pad characters between RTCM
   messages.  This is the case for early model HPC reference stations in
   Canada and Texas. */

#define SpuriousPadChars 1

/* Select EnableDiffPropCorrections=1 if you want to apply differential
   tropospheric and ionospheric models to corrections obtained from
   distant DGPS reference stations. */

#define EnableDiffPropCorrections 0

/* The following constants are included to satisfy regulations of the United
   States Export Restrictions and Munitions Control and limits the receiver
   height to 60,000 feet and velocity to 1000 knots. */

#define SPEED_LIMIT 514.0                            /* metres per second. */
#define HEIGHT_LIMIT 18000.0                                    /* meters. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -