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

📄 dgpslistener.h

📁 Gps 数据采集
💻 H
📖 第 1 页 / 共 3 页
字号:
// File: DGPSListener.h (to be included by DGPSListener.cpp)

// Written by Walter Piechulla in April 2000

// Sam Blackburn's prologue about Geodesy Foundation Classes:
// http://ourworld.compuserve.com/homepages/Sam_Blackburn/homepage.htm

// Definitions
// Ellipsoid
//  A flattened sphere. Take a basketball (a sphere), let some air out of it then
//  stand on it. You now have an ellipsoid. The basketball is flat on the bottom
//  and the top but still round in the middle.
// Equator
//  0 degrees Latitude
// Flattening
//  This is a ratio between polar radius and equatorial radius. Other names for
//  flattening are elliptocyte or oblateness.
// Latitude
//  The lines that run around the Earth like belts. They measure up/down angles.
// Longituide
//  The lines that slice the Earth like an orange from top to bottom. They
//  measure left/right angles.
// Meridian
//   One of the imaginary circles on the earth's surface passing through the north
//   and south poles 
// Pi
//  The most famous constant. It is a ratio.
//  It is the Circumference of a circle divided by
//  the diameter of the circle. It is 3.14 (or roughly 22 divivded by 7).
// Prime Meridian 
//  0 degrees Longitude
// Radian
//  The unit of measurement of a circle. It is a ratio.
//  It's kind of hard to explain what
//  a radian is so let me give you an example. Take the basketball and cut
//  a length of string equal to the radius (i.e. half the width) of the
//  ball. Now, lay this string on top of the ball. See how it forms an arc?
//  Now, draw a line from each end of the string to the center of the ball.
//  The angle of these two lines at the center of the ball is roughly
//  57.2958 degrees. This is true no matter what the size of the ball is.
//  Why? Because as the size of the ball increases, so does the radius.
//  So, a radian can be considered as a relationship between the radius of
//  a sphere (ball) and the circumference of the sphere. Now, there's something
//  interesting about the number of degrees in a radian (52.2958). It is
//  equal to 180 divided by Pi. Yup! Go Figure! OK. Now we're getting somewhere.
//  To find the length of the arc when all you have is the number of radians
//  in the angle at the center of the sphere, you multiply the radius times
//  the number of radians. It's that simple (on a perfect sphere anyway).

// Geodetic Datum - description of the shape of the earth

// Reference Ellipsoid - A flattened sphere. Let some air out of
// a basketball, then stand on it. The ball is now an ellipsoid.
// Your feet are standing on the North Pole and the floor is the
// South Pole.

// Ellipsoids are described by their polar and equatorial radii.
// Polar radius is also known as semi-minor axis.
// Equatorial radius is also know as semi-major axis.
// All other items of interest about the ellipsoid are derived
// from these two data.
// Flattening is ( Equatorial radius - Polar radius ) / Equatorial radius
// There's another thing called First Eccentricity Squared, this is computed
// by ( 2 * Flattening ) - ( Flattening squared ).

// Coordinates - a means of expressing a point in space
//
// Cartesian coordinates are X, Y, and Z coordinates. These are always
// expressed in distances from 0, 0, 0 (i,e, the center of the earth).
//
// Polar coordinates are theta (often seen as a letter O with a line
// through its middle running left-to-right), phi (often seen as a
// letter O with a line through its middle running top-to-bottom), and
// r (a distance).
// These are two angles and a distance. The angles are measured from
// a common origin (the center of the earth). Theta is the plane that
// runs through the equator, phi runs through the poles. R is the 
// distance along the line running along the phi angle. For simplicity
// sake, we will refer to theta as Equatorial angle, phi as the
// polar angle, and r as Polar Distance.
//
// Converting coordinates
//
// You can convert from polar to cartesian cordinates using the following
// formula:
// X = Polar distance * cosine of Polar angle * cosine of Equatorial angle
// Y = Polar distance * cosine of Polar angle * sine of Equatorial angle
// Z = Polar distance * sine of Polar angle

// Applying this to the real world
//
// Cartesian coordinates ar commonly refered to an ECEF X,Y,Z coordinates.
// This means Earth Centered, Earth Fixed. The 0,0,0 coordinate is the
// center of the earth. The X axis runs towards the Prime Meridian.
// The Y axis runs towards the equator and the Z axis runs toward
// the poles. Positive Z numbers go towards the North pole while
// negative numbers go towards the South Pole. Positive 

// Computing Distance
//
// If you have two cartesian coordinates, you can compute a line
// of sight (as the bullet flies, aiming a laser, pointing in a straight line)
// by this formula (some guy named Pythagoras figured this out):
// SQRT( ( X1 - X2 ) ^ 2 + ( Y1 - Y2 ) ^ 2 + ( Z1 - Z2 ) ^ 2 )
//
// or in pseudo code:
//
// cartesian_coordinate first_location;
// cartesian_coordinate second_location;
//
// double temp_x;
// double temp_y;
// double temp_z;
//
// temp_x = first_location.X - second_location.X;
// temp_y = first_location.Y - second_location.Y;
// temp_z = first_location.Z - second_location.Z;
//
// temp_x = temp_x * temp_x; // square them
// temp_y = temp_y * temp_y;
// temp_z = temp_z * temp_z;
//
// double temp_double;
//
// temp_double = temp_x + temp_y + temp_z;
//
// double distance;
//
// distance = sqrt( temp_double );
//
// While this will give you distance, it will not give you direction.

// End of Sam Blackburn's prologue

#include <math.h>

#define IDR_MTTTYMENU                   101
#define IDR_MTTTYACCELERATOR            102
#define IDI_APPICON                     103
#define IDD_TOOLBARSETTINGS             103
#define ID_TTYWINDOW                    103
#define IDD_ABOUT                       104
#define IDD_STATUSDIALOG                105
#define IDD_COMMEVENTSDLG               107
#define IDD_FLOWCONTROLDLG              108
#define IDI_APPICON2                    109
#define IDI_APPICON3                    110
#define IDD_TIMEOUTSDLG                 110
#define IDI_APPICON4                    111
#define IDD_GETADWORD                   111
#define IDC_PORTCOMBO                   1000
#define IDC_BAUDCOMBO                   1001
#define IDC_PARITYCOMBO                 1002
#define IDC_DATABITSCOMBO               1003
#define IDC_STOPBITSCOMBO               1004
#define IDC_STATCTS                     1004
#define IDC_STATDSR                     1005
#define IDC_STATRING                    1006
#define IDC_STATRLSD                    1007
#define IDC_LOCALECHOCHK                1008
#define IDC_DISPLAYERRORSCHK            1009
#define IDC_FONTBTN                     1010
#define IDC_ABORTBTN                    1011
#define IDC_TRANSFERPROGRESS            1013
#define IDC_MODEMSTATUSGRP              1018
#define IDC_COMMEVENTSBTN               1019
#define IDC_EVBREAKBTN                  1020
#define IDC_EVCTSBTN                    1021
#define IDC_EVDSRBTN                    1022
#define IDC_EVERRBTN                    1023
#define IDC_EVRINGBTN                   1024
#define IDC_EVRLSDBTN                   1025
#define IDC_EVRXCHARBTN                 1026
#define IDC_EVRXFLAGBTN                 1027
#define IDC_EVTXEMPTYBTN                1028
#define IDC_FLAGEDIT                    1029
#define IDC_DEFAULTSBTN                 1030
#define IDC_LFBTN                       1032
#define IDC_AUTOWRAPCHK                 1033
#define IDC_STATUSEDIT                  1034
#define IDC_FLAGCHAR                    1036
#define IDC_FLOWCONTROLBTN              1039
#define IDC_CTSOUTCHK                   1040
#define IDC_DSROUTCHK                   1041
#define IDC_DTRCONTROLCOMBO             1043
#define IDC_DSRINCHK                    1044
#define IDC_XONXOFFOUTCHK               1045
#define IDC_XONXOFFINCHK                1046
#define IDC_XONLIMITEDIT                1047
#define IDC_XOFFLIMITEDIT               1048
#define IDC_XONCHAREDIT                 1049
#define IDC_XOFFCHAREDIT                1050
#define IDC_RTSCONTROLCOMBO             1051
#define IDC_RTSCTSBTN                   1052
#define IDC_XOFFXONBTN                  1053
#define IDC_XONCHARDISP                 1054
#define IDC_XOFFCHARDISP                1055
#define IDC_PICTURE                     1056
#define IDC_DTRDSRBTN                   1056
#define IDC_TIMEOUTSBTN                 1057
#define IDC_READINTERVALEDIT            1058
#define IDC_READMULTIPLIEREDIT          1059
#define IDC_READCONSTANTEDIT            1060
#define IDC_WRITEMULTIPLIEREDIT         1061
#define IDC_WRITECONSTANTEDIT           1062
#define IDC_NONEBTN                     1064
#define IDC_OSVERSIONINFO               1065
#define IDC_TXAFTERXOFFSENTCHK          1066
#define IDC_CTSHOLDCHK                  1067
#define IDC_DSRHOLDCHK                  1068
#define IDC_RLSDHOLDCHK                 1069
#define IDC_XOFFHOLDCHK                 1070
#define IDC_XOFFSENTCHK                 1071
#define IDC_EOFSENTCHK                  1072
#define IDC_TXIMCHK                     1073
#define IDC_TXCHAREDIT                  1074
#define IDC_RXCHAREDIT                  1075
#define IDC_NOREADINGCHK                1076
#define IDC_NOWRITINGCHK                1077
#define IDC_NOSTATUSCHK                 1078
#define IDC_NOEVENTSCHK                 1079
#define IDC_DWORDSTATIC                 1081
#define IDC_DWORDEDIT                   1082
#define IDC_DISPLAYTIMEOUTS             1083
#define ID_FILE_EXIT                    40001
#define ID_HELP_ABOUTMTTTY              40002
#define ID_FILE_CONNECT                 40004
#define ID_FILE_DISCONNECT              40005
#define ID_TTY_CLEAR                    40008
#define ID_TRANSFER_SENDFILETEXT        40010
#define ID_TRANSFER_RECEIVEFILETEXT     40011
#define ID_TRANSFER_SENDREPEATEDLY      40012
#define ID_TRANSFER_ABORTSENDING        40016
#define ID_TRANSFER_ABORTREPEATEDSENDING 40018
#define ID_BLACKBOX_DUMPRAW             40020 
#define ID_BLACKBOX_DUMPCOOKED          40021
#define ID_BLACKBOX_STOPSCREENDUMP      40022
#define ID_BLACKBOX_CAPTURERAW          40023
#define ID_BLACKBOX_CAPTURECOOKED       40024
#define IDC_STATIC                      65535

// constant definitions

// hard coded maximum number of ports
#define MAXPORTS        4

// terminal size
#define MAXROWS         50
#define MAXCOLS         80

// cursor states
#define CS_HIDE         0x00
#define CS_SHOW         0x01

// ascii definitions
#define ASCII_BEL       0x07
#define ASCII_BS        0x08
#define ASCII_LF        0x0A
#define ASCII_CR        0x0D
#define ASCII_XON       0x11
#define ASCII_XOFF      0x13

// data structures
struct TTYInfoStruct
{
  HANDLE  hCommPort, hReaderStatus, hWriter ;
  DWORD   dwEventFlags;
  CHAR    Screen[MAXCOLS * MAXROWS];
  CHAR    chFlag, chXON, chXOFF;
  WORD    wXONLimit, wXOFFLimit;
  DWORD   fRtsControl;
  DWORD   fDtrControl;
  BOOL    fConnected, fTransferring, fRepeating,
          fLocalEcho, fNewLine,
          fDisplayErrors, fAutowrap,
          fCTSOutFlow, fDSROutFlow, fDSRInFlow, 
          fXonXoffOutFlow, fXonXoffInFlow,
          fTXafterXoffSent,
          fNoReading, fNoWriting, fNoEvents, fNoStatus,
          fDisplayTimeouts;
  BYTE    bPort, bByteSize, bParity, bStopBits ;
  DWORD   dwBaudRate ;
  WORD    wCursorState ;
  HFONT   hTTYFont ;
  LOGFONT lfTTYFont ;
  DWORD   rgbFGColor ;
  COMMTIMEOUTS timeoutsorig;
  COMMTIMEOUTS timeoutsnew;
  int     xSize, ySize, xScroll, yScroll, xOffset, yOffset,
          nColumn, nRow, xChar, yChar , nCharPos;

} TTYInfo;


// macros ( for easier readability )
#define COMDEV( x )         (x.hCommPort)
#define CURSORSTATE( x )    (x.wCursorState)
#define PORT( x )           (x.bPort)
#define SCREEN( x )         (x.Screen)
#define CONNECTED( x )      (x.fConnected)
#define TRANSFERRING( x )   (x.fTransferring)
#define REPEATING( x )      (x.fRepeating)
#define LOCALECHO( x )      (x.fLocalEcho)
#define NEWLINE( x )        (x.fNewLine)
#define AUTOWRAP( x )       (x.fAutowrap)
#define BYTESIZE( x )       (x.bByteSize)
#define PARITY( x )         (x.bParity)
#define STOPBITS( x )       (x.bStopBits)
#define BAUDRATE( x )       (x.dwBaudRate)
#define HTTYFONT( x )       (x.hTTYFont)
#define LFTTYFONT( x )      (x.lfTTYFont)
#define FGCOLOR( x )        (x.rgbFGColor)
#define XSIZE( x )          (x.xSize)
#define YSIZE( x )          (x.ySize)
#define XSCROLL( x )        (x.xScroll)
#define YSCROLL( x )        (x.yScroll)
#define XOFFSET( x )        (x.xOffset)
#define YOFFSET( x )        (x.yOffset)
#define COLUMN( x )         (x.nColumn)
#define ROW( x )            (x.nRow)
#define XCHAR( x )          (x.xChar)
#define YCHAR( x )          (x.yChar)
#define DISPLAYERRORS( x )  (x.fDisplayErrors)
#define TIMEOUTSORIG( x )   (x.timeoutsorig)
#define TIMEOUTSNEW( x )    (x.timeoutsnew)
#define WRITERTHREAD( x )   (x.hWriter)
#define READSTATTHREAD( x ) (x.hReaderStatus)
#define EVENTFLAGS( x )     (x.dwEventFlags)
#define FLAGCHAR( x )       (x.chFlag)
#define SCREENCHAR( x, col, row )   (x.Screen[row * MAXCOLS + col])

#define DTRCONTROL( x )     (x.fDtrControl)
#define RTSCONTROL( x )     (x.fRtsControl)
#define XONCHAR( x )        (x.chXON)
#define XOFFCHAR( x )       (x.chXOFF)
#define XONLIMIT( x )       (x.wXONLimit)

⌨️ 快捷键说明

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