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: rmc.cpp $
|
---|
13 | ** $Revision: 5 $
|
---|
14 | ** $Modtime: 10/12/98 6:43a $
|
---|
15 | */
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 | RMC::RMC()
|
---|
20 | {
|
---|
21 | Mnemonic = "RMC";
|
---|
22 | Empty();
|
---|
23 | }
|
---|
24 |
|
---|
25 | RMC::~RMC()
|
---|
26 | {
|
---|
27 | //Mnemonic.Empty();
|
---|
28 | Empty();
|
---|
29 | }
|
---|
30 |
|
---|
31 | void RMC::Empty( void )
|
---|
32 | {
|
---|
33 | //UTCTime.Empty();
|
---|
34 | IsDataValid = NMEA_Unknown;
|
---|
35 | SpeedOverGroundKnots = 0.0;
|
---|
36 | Position.Empty();
|
---|
37 | TrackMadeGoodDegreesTrue = 0.0;
|
---|
38 | //Date.Empty();
|
---|
39 | MagneticVariation = 0.0;
|
---|
40 | MagneticVariationDirection = EW_Unknown;
|
---|
41 | }
|
---|
42 |
|
---|
43 | BOOL RMC::Parse( const SENTENCE& sentence )
|
---|
44 | {
|
---|
45 | /*
|
---|
46 | ** RMC - Recommended Minimum Navigation Information
|
---|
47 | ** 12
|
---|
48 | ** 1 2 3 4 5 6 7 8 9 10 11| 13
|
---|
49 | ** | | | | | | | | | | | | |
|
---|
50 | ** $--RMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,xxxx,x.x,a,a*hh<CR><LF>
|
---|
51 | **
|
---|
52 | ** Field Number:
|
---|
53 | ** 1) UTC Time
|
---|
54 | ** 2) Status, V = Navigation receiver warning
|
---|
55 | ** 3) Latitude
|
---|
56 | ** 4) N or S
|
---|
57 | ** 5) Longitude
|
---|
58 | ** 6) E or W
|
---|
59 | ** 7) Speed over ground, knots
|
---|
60 | ** 8) Track made good, degrees true
|
---|
61 | ** 9) Date, ddmmyy
|
---|
62 | ** 10) Magnetic Variation, degrees
|
---|
63 | ** 11) E or W
|
---|
64 | ** 12) Mode indication (special AG132)
|
---|
65 | ** 13) Checksum
|
---|
66 | */
|
---|
67 |
|
---|
68 | /*
|
---|
69 | ** First we check the checksum...
|
---|
70 | */
|
---|
71 |
|
---|
72 | // looking for the checksum automatically if param is 0
|
---|
73 | NMEA0183_BOOLEAN check = sentence.IsChecksumBad( 0 );
|
---|
74 |
|
---|
75 | if ( check == True )
|
---|
76 | {
|
---|
77 | SetErrorMessage( "Invalid Checksum" );
|
---|
78 | return( FALSE );
|
---|
79 | }
|
---|
80 |
|
---|
81 | if ( check == NMEA_Unknown )
|
---|
82 | {
|
---|
83 | SetErrorMessage( "Missing Checksum" );
|
---|
84 | return( FALSE );
|
---|
85 | }
|
---|
86 |
|
---|
87 | UTCTime = sentence.Field( 1 );
|
---|
88 | Time = sentence.Time( 1 );
|
---|
89 | IsDataValid = sentence.Boolean( 2 );
|
---|
90 | Position.Parse( 3, 4, 5, 6, sentence );
|
---|
91 | SpeedOverGroundKnots = sentence.Double( 7 );
|
---|
92 | TrackMadeGoodDegreesTrue = sentence.Double( 8 );
|
---|
93 | Date = sentence.Field( 9 );
|
---|
94 | MagneticVariation = sentence.Double( 10 );
|
---|
95 | MagneticVariationDirection = sentence.EastOrWest( 11 );
|
---|
96 | if (sentence.GetNumberOfDataFields() == 12)
|
---|
97 | ModeIndication = sentence.Field(12);
|
---|
98 |
|
---|
99 | return( TRUE );
|
---|
100 | }
|
---|
101 |
|
---|
102 | QString RMC::PlainEnglish( void ) const
|
---|
103 | {
|
---|
104 | QString return_string;
|
---|
105 |
|
---|
106 | //return_string.Empty();
|
---|
107 |
|
---|
108 | return_string = "At ";
|
---|
109 | //return_string += Time.Format( "%I:%M.%S %p" );
|
---|
110 | return_string = Time.time().toString();
|
---|
111 | return_string += " UTC, you were at ";
|
---|
112 | return_string += Position.PlainEnglish();
|
---|
113 | return_string += ", making ";
|
---|
114 |
|
---|
115 | QString temp_string;
|
---|
116 |
|
---|
117 | //temp_string.Format( "%lf", SpeedOverGroundKnots );
|
---|
118 | temp_string = QString::number(SpeedOverGroundKnots);
|
---|
119 |
|
---|
120 |
|
---|
121 | return_string += temp_string;
|
---|
122 | return_string += " knots, track made good ";
|
---|
123 |
|
---|
124 | //temp_string.Format( "%lf", TrackMadeGoodDegreesTrue );
|
---|
125 | temp_string = QString::number( TrackMadeGoodDegreesTrue );
|
---|
126 | return_string += temp_string;
|
---|
127 | return_string += " degrees true.";
|
---|
128 |
|
---|
129 | return( return_string );
|
---|
130 | }
|
---|
131 |
|
---|
132 | BOOL RMC::Write( SENTENCE& sentence )
|
---|
133 | {
|
---|
134 | /*
|
---|
135 | ** Let the parent do its thing
|
---|
136 | */
|
---|
137 |
|
---|
138 | RESPONSE::Write( sentence );
|
---|
139 |
|
---|
140 | sentence += UTCTime;
|
---|
141 | sentence += IsDataValid;
|
---|
142 | sentence += Position;
|
---|
143 | sentence += SpeedOverGroundKnots;
|
---|
144 | sentence += TrackMadeGoodDegreesTrue;
|
---|
145 | sentence += Date;
|
---|
146 | sentence += MagneticVariation;
|
---|
147 | sentence += MagneticVariationDirection;
|
---|
148 |
|
---|
149 | sentence.Finish();
|
---|
150 |
|
---|
151 | return( TRUE );
|
---|
152 | }
|
---|
153 |
|
---|
154 | const RMC& RMC::operator = ( const RMC& source )
|
---|
155 | {
|
---|
156 | UTCTime = source.UTCTime;
|
---|
157 | Time = source.Time;
|
---|
158 | IsDataValid = source.IsDataValid;
|
---|
159 | Position = source.Position;
|
---|
160 | SpeedOverGroundKnots = source.SpeedOverGroundKnots;
|
---|
161 | TrackMadeGoodDegreesTrue = source.TrackMadeGoodDegreesTrue;
|
---|
162 | Date = source.Date;
|
---|
163 | MagneticVariation = source.MagneticVariation;
|
---|
164 | MagneticVariationDirection = source.MagneticVariationDirection;
|
---|
165 |
|
---|
166 | return( *this );
|
---|
167 | }
|
---|