source: pacpussensors/trunk/NMEA0183/src/GGA.cpp@ 59

Last change on this file since 59 was 59, checked in by DHERBOMEZ Gérald, 10 years ago

Integration of new modules:

  • GPS NMEA0183 decoder
  • Span CPT Decoder

Update of:

File size: 5.1 KB
Line 
1#include "nmea0183.h"
2//#pragma hdrstop
3
4/*
5** Author: Samuel R. Blackburn
6** Internet: sam_blackburn@pobox.com
7**
8** You can use it any way you like as long as you don't try to sell it.
9**
10** Copyright, 1996, Samuel R. Blackburn
11**
12** $Workfile: gga.cpp $
13** $Revision: 6 $
14** $Modtime: 10/12/98 6:39a $
15*/
16
17
18
19GGA::GGA()
20{
21 Mnemonic = "GGA";
22 Empty();
23}
24
25GGA::~GGA()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void GGA::Empty( void )
32{
33 //UTCTime.Empty();
34 Position.Empty();
35 GPSQuality = 0;
36 NumberOfSatellitesInUse = 0;
37 HorizontalDilutionOfPrecision = 0.0;
38 AntennaAltitudeMeters = 0.0;
39 GeoidalSeparationMeters = 0.0;
40 AgeOfDifferentialGPSDataSeconds = 0.0;
41 DifferentialReferenceStationID = 0;
42}
43
44BOOL GGA::Parse( const SENTENCE& sentence )
45{
46 /*
47 ** GGA - Global Positioning System Fix Data
48 ** Time, Position and fix related data fora GPS receiver.
49 **
50 ** 11
51 ** 1 2 3 4 5 6 7 8 9 10 | 12 13 14 15
52 ** | | | | | | | | | | | | | | |
53 ** $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh<CR><LF>
54 **
55 ** Field Number:
56 ** 1) Universal Time Coordinated (UTC)
57 ** 2) Latitude
58 ** 3) N or S (North or South)
59 ** 4) Longitude
60 ** 5) E or W (East or West)
61 ** 6) GPS Quality Indicator,
62 ** 0 - fix not available,
63 ** 1 - GPS fix,
64 ** 2 - Differential GPS fix
65 ** 7) Number of satellites in view, 00 - 12
66 ** 8) Horizontal Dilution of precision
67 ** 9) Antenna Altitude above/below mean-sea-level (geoid)
68 ** 10) Units of antenna altitude, meters
69 ** 11) Geoidal separation, the difference between the WGS-84 earth
70 ** ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level
71 ** below ellipsoid
72 ** 12) Units of geoidal separation, meters
73 ** 13) Age of differential GPS data, time in seconds since last SC104
74 ** type 1 or 9 update, null field when DGPS is not used
75 ** 14) Differential reference station ID, 0000-1023
76 ** 15) Checksum
77 */
78
79 /*
80 ** First we check the checksum...
81 */
82
83 if ( sentence.IsChecksumBad( 15 ) == True )
84 {
85 SetErrorMessage( "Invalid Checksum" );
86 return( FALSE );
87 }
88
89 UTCTime = sentence.Field( 1 );
90 Time = sentence.Time( 1 );
91 Position.Parse( 2, 3, 4, 5, sentence );
92 GPSQuality = sentence.Integer( 6 );
93 NumberOfSatellitesInUse = sentence.Integer( 7 );
94 HorizontalDilutionOfPrecision = sentence.Double( 8 );
95 AntennaAltitudeMeters = sentence.Double( 9 );
96 GeoidalSeparationMeters = sentence.Double( 11 );
97 AgeOfDifferentialGPSDataSeconds = sentence.Double( 13 );
98 DifferentialReferenceStationID = sentence.Integer( 14 );
99
100 return( TRUE );
101}
102
103QString GGA::PlainEnglish( void ) const
104{
105 QString return_string;
106
107 return_string = "At ";
108 return_string += Time.time().toString();
109 //return_string += Time.Format( "%I:%M.%S %p" );
110 return_string += " UTC, you were at ";
111 return_string += Position.PlainEnglish();
112 return_string += ", ";
113
114 switch( GPSQuality )
115 {
116 case 1:
117
118 return_string += "based upon a GPS fix";
119 break;
120
121 case 2:
122
123 return_string += "based upon a differential GPS fix";
124 break;
125
126 default:
127
128 return_string += "a GPS fix was not available";
129 break;
130 }
131
132 QString temp_string;
133 temp_string = QString::number(NumberOfSatellitesInUse) + " satellites are in use.";
134 //temp_string.Format( ", %d satellites are in use.", NumberOfSatellitesInUse );
135 return_string += temp_string;
136
137 return( return_string );
138}
139
140BOOL GGA::Write( SENTENCE& sentence )
141{
142 /*
143 ** Let the parent do its thing
144 */
145
146 RESPONSE::Write( sentence );
147
148 sentence += UTCTime;
149 sentence += Position;
150 sentence += GPSQuality;
151 sentence += NumberOfSatellitesInUse;
152 sentence += HorizontalDilutionOfPrecision;
153 sentence += AntennaAltitudeMeters;
154 sentence += "M";
155 sentence += GeoidalSeparationMeters;
156 sentence += "M";
157 sentence += AgeOfDifferentialGPSDataSeconds;
158 sentence += DifferentialReferenceStationID;
159
160 sentence.Finish();
161
162 return( TRUE );
163}
164
165const GGA& GGA::operator = ( const GGA& source )
166{
167 UTCTime = source.UTCTime;
168 Time = source.Time;
169 Position = source.Position;
170 GPSQuality = source.GPSQuality;
171 NumberOfSatellitesInUse = source.NumberOfSatellitesInUse;
172 HorizontalDilutionOfPrecision = source.HorizontalDilutionOfPrecision;
173 AntennaAltitudeMeters = source.AntennaAltitudeMeters;
174 GeoidalSeparationMeters = source.GeoidalSeparationMeters;
175 AgeOfDifferentialGPSDataSeconds = source.AgeOfDifferentialGPSDataSeconds;
176 DifferentialReferenceStationID = source.DifferentialReferenceStationID;
177
178 return( *this );
179}
Note: See TracBrowser for help on using the repository browser.