source: pacpussensors/trunk/NMEA0183/src/GSV.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: 3.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: gsv.cpp $
13** $Revision: 5 $
14** $Modtime: 10/10/98 2:48p $
15*/
16
17
18GSV::GSV()
19{
20 Mnemonic = "GSV";
21 Empty();
22}
23
24GSV::~GSV()
25{
26 //Mnemonic.Empty();
27 Empty();
28}
29
30void GSV::Empty( void )
31{
32
33 NumberOfSatellites = 0;
34
35 int index = 0;
36
37 while( index < 36 )
38 {
39 SatellitesInView[ index ].Empty();
40 index++;
41 }
42}
43
44BOOL GSV::Parse( const SENTENCE& sentence )
45{
46 /*
47 ** GSV - TRANSIT Position - Latitude/Longitude
48 ** Location and time of TRANSIT fix at waypoint
49 **
50 ** 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
51 ** | | | | | | | | | | | | | | | | | | | |
52 ** $--GSV,x,x,xx,xx,xx,xxx,xx,xx,xx,xxx,xx,xx,xx,xxx,xx,xx,xx,xxx,xx,*hh<CR><LF>
53 **
54 ** 1) Total number of messages, 1-9
55 ** 2) Message Number, 1-9
56 ** 3) Total number of satellites in view
57 ** 4) Satellite Number #1
58 ** 5) Elevation #1
59 ** 6) Azimuth, Degrees True #1
60 ** 7) SNR #1, NULL when not tracking
61 ** 8) Satellite Number #2
62 ** 9) Elevation #2
63 ** 10) Azimuth, Degrees True #2
64 ** 11) SNR #2, NULL when not tracking
65 ** 12) Satellite Number #3
66 ** 13) Elevation #3
67 ** 14) Azimuth, Degrees True #3
68 ** 15) SNR #3, NULL when not tracking
69 ** 16) Satellite Number #4
70 ** 17) Elevation #4
71 ** 18) Azimuth, Degrees True #4
72 ** 19) SNR #4, NULL when not tracking
73 ** 20) Checksum
74 */
75
76 /*
77 ** First we check the checksum...
78 */
79
80 if ( sentence.IsChecksumBad( 20 ) == True )
81 {
82 SetErrorMessage( "Invalid Checksum" );
83 return( FALSE );
84 }
85
86 Totalmessages = sentence.Integer( 1 );
87 //int message_number = sentence.Integer( 2 );
88 message_number = sentence.Integer( 2 );
89
90 NumberOfSatellites = sentence.Integer( 3 );
91
92 int index = 0;
93
94 int tmp = NumberOfSatellites - ( message_number - 1 ) * 4;
95 int min = ( (4 < tmp) ? 4 : tmp);
96 // while( index < (4 <? (NumberOfSatellites - ( message_number - 1 ) * 4) ) )
97 while( index < min )
98 {
99 SatellitesInView[ ( ( message_number - 1 ) * 4 ) + index ].Parse( ( index * 4 ) + 4, sentence );
100 index++;
101 }
102
103 return( TRUE );
104}
105
106BOOL GSV::Write( SENTENCE& sentence )
107{
108 /*
109 ** Let the parent do its thing
110 */
111
112 RESPONSE::Write( sentence );
113
114 /*
115 ** OK, this is a hack, I'll figure out how to do multiple messages later
116 */
117
118 sentence.Finish();
119
120 return( TRUE );
121}
122
123
124const GSV& GSV::operator = ( const GSV& source )
125{
126 NumberOfSatellites = source.NumberOfSatellites;
127
128 int index = 0;
129
130 while( index < 36 )
131 {
132 SatellitesInView[ index ] = source.SatellitesInView[ index ];
133 index++;
134 }
135 Totalmessages = source.Totalmessages;
136 message_number = source.message_number;
137 return( *this );
138}
139
140
Note: See TracBrowser for help on using the repository browser.