source: pacpussensors/trunk/NMEA0183/src/GSA.cpp

Last change on this file 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: 4.0 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: gsa.cpp $
13** $Revision: 5 $
14** $Modtime: 10/10/98 2:42p $
15*/
16
17
18
19GSA::GSA()
20{
21 Mnemonic = "GSA";
22 Empty();
23}
24
25GSA::~GSA()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void GSA::Empty( void )
32{
33 OperatingMode = UnknownOperatingMode;
34 FixMode = FixUnknown;
35
36 int index = 0;
37
38 while( index < 12 )
39 {
40 SatelliteNumber[ index ] = 0;
41 index++;
42 }
43
44 PDOP = 0.0;
45 HDOP = 0.0;
46 VDOP = 0.0;
47}
48
49BOOL GSA::Parse( const SENTENCE& sentence )
50{
51 /*
52 ** GSA - GPS DOP and Active Satellites
53 **
54 ** 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
55 ** | | | | | | | | | | | | | | | | | |
56 ** $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,x.x,x.x,x.x*hh<CR><LF>
57 **
58 ** Field Number:
59 ** 1) Operating Mode, A = Automatic, M = Manual
60 ** 2) Fix Mode, 1 = Fix not available, 2 = 2D, 3 = 3D
61 ** 3) Satellite PRN #1
62 ** 4) Satellite PRN #2
63 ** 5) Satellite PRN #3
64 ** 6) Satellite PRN #4
65 ** 7) Satellite PRN #5
66 ** 8) Satellite PRN #6
67 ** 9) Satellite PRN #7
68 ** 10) Satellite PRN #8
69 ** 11) Satellite PRN #9
70 ** 12) Satellite PRN #10
71 ** 13) Satellite PRN #11
72 ** 14) Satellite PRN #12
73 ** 15) PDOP
74 ** 16) HDOP
75 ** 17) VDOP
76 ** 18) Checksum
77 */
78
79 /*
80 ** First we check the checksum...
81 */
82
83 if ( sentence.IsChecksumBad( 18 ) == True )
84 {
85 SetErrorMessage( "Invalid Checksum" );
86 return( FALSE );
87 }
88
89 QString field_data = sentence.Field( 1 );
90
91 if ( field_data == "A" )
92 {
93 OperatingMode = Automatic;
94 }
95 else if ( field_data == "M" )
96 {
97 OperatingMode = Manual;
98 }
99 else
100 {
101 OperatingMode = UnknownOperatingMode;
102 }
103
104 int index = sentence.Integer( 2 );
105
106 switch( index )
107 {
108 case 1:
109
110 FixMode = FixUnavailable;
111 break;
112
113 case 2:
114
115 FixMode = TwoDimensional;
116 break;
117
118 case 3:
119
120 FixMode = ThreeDimensional;
121 break;
122
123 default:
124
125 FixMode = FixUnknown;
126 break;
127 }
128
129 index = 0;
130
131 while( index < 12 )
132 {
133 SatelliteNumber[ index ] = sentence.Integer( index + 3 );
134 index++;
135 }
136
137 PDOP = sentence.Double( 15 );
138 HDOP = sentence.Double( 16 );
139 VDOP = sentence.Double( 17 );
140
141 return( TRUE );
142}
143
144BOOL GSA::Write( SENTENCE& sentence )
145{
146 /*
147 ** Let the parent do its thing
148 */
149
150 RESPONSE::Write( sentence );
151
152 switch( OperatingMode )
153 {
154 case Manual:
155
156 sentence += "M";
157 break;
158
159 case Automatic:
160
161 sentence += "A";
162 break;
163
164 default:
165
166 sentence += "";
167 break;
168 }
169
170 switch( FixMode )
171 {
172 case FixUnavailable:
173
174 sentence += "1";
175 break;
176
177 case TwoDimensional:
178
179 sentence += "2";
180 break;
181
182 case ThreeDimensional:
183
184 sentence += "3";
185 break;
186
187 default:
188
189 sentence += "";
190 break;
191 }
192
193 int index = 0;
194
195 while( index < 12 )
196 {
197 if ( SatelliteNumber[ index ] != 0 )
198 {
199 sentence += SatelliteNumber[ index ];
200 }
201 else
202 {
203 sentence += "";
204 }
205
206 index++;
207 }
208
209 sentence += PDOP;
210 sentence += HDOP;
211 sentence += VDOP;
212
213 sentence.Finish();
214
215 return( TRUE );
216}
217
218const GSA& GSA::operator = ( const GSA& source )
219{
220 OperatingMode = source.OperatingMode;
221 FixMode = source.FixMode;
222
223 int index = 0;
224
225 while( index < 12 )
226 {
227 SatelliteNumber[ index ] = source.SatelliteNumber[ index ];
228 index++;
229 }
230
231 PDOP = source.PDOP;
232 HDOP = source.HDOP;
233 VDOP = source.VDOP;
234
235 return( *this );
236}
Note: See TracBrowser for help on using the repository browser.