source: pacpussensors/trunk/NMEA0183/src/RMB.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: rmb.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:43p $
15*/
16
17
18RMB::RMB()
19{
20 Mnemonic = "RMB";
21 Empty();
22}
23
24RMB::~RMB()
25{
26 //Mnemonic.Empty();
27 Empty();
28}
29
30void RMB::Empty( void )
31{
32 IsDataValid = NMEA_Unknown;
33 CrossTrackError = 0.0;
34 DirectionToSteer = LR_Unknown;
35 //To.Empty();
36 //From.Empty();
37 DestinationPosition;
38 RangeToDestinationNauticalMiles = 0.0;
39 BearingToDestinationDegreesTrue = 0.0;
40 DestinationClosingVelocityKnots = 0.0;
41 IsArrivalCircleEntered = NMEA_Unknown;
42}
43
44BOOL RMB::Parse( const SENTENCE& sentence )
45{
46 /*
47 ** RMB - Recommended Minimum Navigation Information
48 ** 14
49 ** 1 2 3 4 5 6 7 8 9 10 11 12 13|
50 ** | | | | | | | | | | | | | |
51 ** $--RMB,A,x.x,a,c--c,c--c,llll.ll,a,yyyyy.yy,a,x.x,x.x,x.x,A*hh<CR><LF>
52 **
53 ** Field Number:
54 ** 1) Status, V = Navigation receiver warning
55 ** 2) Cross Track error - nautical miles
56 ** 3) Direction to Steer, Left or Right
57 ** 4) TO Waypoint ID
58 ** 5) FROM Waypoint ID
59 ** 6) Destination Waypoint Latitude
60 ** 7) N or S
61 ** 8) Destination Waypoint Longitude
62 ** 9) E or W
63 ** 10) Range to destination in nautical miles
64 ** 11) Bearing to destination in degrees True
65 ** 12) Destination closing velocity in knots
66 ** 13) Arrival Status, A = Arrival Circle Entered
67 ** 14) Checksum
68 */
69
70 /*
71 ** First we check the checksum...
72 */
73
74 NMEA0183_BOOLEAN check = sentence.IsChecksumBad( 14 );
75
76 if ( check == True )
77 {
78 SetErrorMessage( "Invalid Checksum" );
79 return( FALSE );
80 }
81
82 if ( check == NMEA_Unknown )
83 {
84 SetErrorMessage( "Missing Checksum" );
85 return( FALSE );
86 }
87
88 IsDataValid = sentence.Boolean( 1 );
89 CrossTrackError = sentence.Double( 2 );
90 DirectionToSteer = sentence.LeftOrRight( 3 );
91 From = sentence.Field( 4 );
92 To = sentence.Field( 5 );
93 DestinationPosition.Parse( 6, 7, 8, 9, sentence );
94 RangeToDestinationNauticalMiles = sentence.Double( 10 );
95 BearingToDestinationDegreesTrue = sentence.Double( 11 );
96 DestinationClosingVelocityKnots = sentence.Double( 12 );
97 IsArrivalCircleEntered = sentence.Boolean( 13 );
98
99 return( TRUE );
100}
101
102BOOL RMB::Write( SENTENCE& sentence )
103{
104 /*
105 ** Let the parent do its thing
106 */
107
108 RESPONSE::Write( sentence );
109
110 sentence += IsDataValid;
111 sentence += CrossTrackError;
112 sentence += DirectionToSteer;
113 sentence += From;
114 sentence += To;
115 sentence += DestinationPosition;
116 sentence += RangeToDestinationNauticalMiles;
117 sentence += BearingToDestinationDegreesTrue;
118 sentence += DestinationClosingVelocityKnots;
119 sentence += IsArrivalCircleEntered;
120
121 sentence.Finish();
122
123 return( TRUE );
124}
125
126const RMB& RMB::operator = ( const RMB& source )
127{
128 IsDataValid = source.IsDataValid;
129 CrossTrackError = source.CrossTrackError;
130 DirectionToSteer = source.DirectionToSteer;
131 From = source.From;
132 To = source.To;
133 DestinationPosition = source.DestinationPosition;
134 RangeToDestinationNauticalMiles = source.RangeToDestinationNauticalMiles;
135 BearingToDestinationDegreesTrue = source.BearingToDestinationDegreesTrue;
136 DestinationClosingVelocityKnots = source.DestinationClosingVelocityKnots;
137 IsArrivalCircleEntered = source.IsArrivalCircleEntered;
138
139 return( *this );
140}
Note: See TracBrowser for help on using the repository browser.