[59] | 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: rma.cpp $
|
---|
| 13 | ** $Revision: 4 $
|
---|
| 14 | ** $Modtime: 10/10/98 2:43p $
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | RMA::RMA()
|
---|
| 20 | {
|
---|
| 21 | Mnemonic = "RMA";
|
---|
| 22 | Empty();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | RMA::~RMA()
|
---|
| 26 | {
|
---|
| 27 | //Mnemonic.Empty();
|
---|
| 28 | Empty();
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | void RMA::Empty( void )
|
---|
| 32 | {
|
---|
| 33 | IsDataValid = NMEA_Unknown;
|
---|
| 34 | TimeDifferenceA = 0.0;
|
---|
| 35 | TimeDifferenceB = 0.0;
|
---|
| 36 | SpeedOverGroundKnots = 0.0;
|
---|
| 37 | TrackMadeGoodDegreesTrue = 0.0;
|
---|
| 38 | MagneticVariation = 0.0;
|
---|
| 39 | MagneticVariationDirection = EW_Unknown;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | BOOL RMA::Parse( const SENTENCE& sentence )
|
---|
| 43 | {
|
---|
| 44 | /*
|
---|
| 45 | ** RMA - Recommended Minimum Navigation Information
|
---|
| 46 | ** 12
|
---|
| 47 | ** 1 2 3 4 5 6 7 8 9 10 11|
|
---|
| 48 | ** | | | | | | | | | | | |
|
---|
| 49 | ** $--RMA,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,x.x,x.x,x.x,a*hh<CR><LF>
|
---|
| 50 | **
|
---|
| 51 | ** Field Number:
|
---|
| 52 | ** 1) Blink Warning
|
---|
| 53 | ** 2) Latitude
|
---|
| 54 | ** 3) N or S
|
---|
| 55 | ** 4) Longitude
|
---|
| 56 | ** 5) E or W
|
---|
| 57 | ** 6) Time Difference A, uS
|
---|
| 58 | ** 7) Time Difference B, uS
|
---|
| 59 | ** 8) Speed Over Ground, Knots
|
---|
| 60 | ** 9) Track Made Good, degrees true
|
---|
| 61 | ** 10) Magnetic Variation, degrees
|
---|
| 62 | ** 11) E or W
|
---|
| 63 | ** 12) Checksum
|
---|
| 64 | */
|
---|
| 65 |
|
---|
| 66 | /*
|
---|
| 67 | ** First we check the checksum...
|
---|
| 68 | */
|
---|
| 69 |
|
---|
| 70 | NMEA0183_BOOLEAN check = sentence.IsChecksumBad( 12 );
|
---|
| 71 |
|
---|
| 72 | if ( check == True )
|
---|
| 73 | {
|
---|
| 74 | SetErrorMessage( "Invalid Checksum" );
|
---|
| 75 | return( FALSE );
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | if ( check == NMEA_Unknown )
|
---|
| 79 | {
|
---|
| 80 | SetErrorMessage( "Missing Checksum" );
|
---|
| 81 | return( FALSE );
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | IsDataValid = sentence.Boolean( 1 );
|
---|
| 85 | Position.Parse( 2, 3, 4, 5, sentence );
|
---|
| 86 | TimeDifferenceA = sentence.Double( 6 );
|
---|
| 87 | TimeDifferenceB = sentence.Double( 7 );
|
---|
| 88 | SpeedOverGroundKnots = sentence.Double( 8 );
|
---|
| 89 | TrackMadeGoodDegreesTrue = sentence.Double( 9 );
|
---|
| 90 | MagneticVariation = sentence.Double( 10 );
|
---|
| 91 | MagneticVariationDirection = sentence.EastOrWest( 11 );
|
---|
| 92 |
|
---|
| 93 | return( TRUE );
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | BOOL RMA::Write( SENTENCE& sentence )
|
---|
| 97 | {
|
---|
| 98 | /*
|
---|
| 99 | ** Let the parent do its thing
|
---|
| 100 | */
|
---|
| 101 |
|
---|
| 102 | RESPONSE::Write( sentence );
|
---|
| 103 |
|
---|
| 104 | sentence += IsDataValid;
|
---|
| 105 | sentence += Position;
|
---|
| 106 | sentence += TimeDifferenceA;
|
---|
| 107 | sentence += TimeDifferenceB;
|
---|
| 108 | sentence += SpeedOverGroundKnots;
|
---|
| 109 | sentence += TrackMadeGoodDegreesTrue;
|
---|
| 110 | sentence += MagneticVariation;
|
---|
| 111 | sentence += MagneticVariationDirection;
|
---|
| 112 |
|
---|
| 113 | sentence.Finish();
|
---|
| 114 |
|
---|
| 115 | return( TRUE );
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | const RMA& RMA::operator = ( const RMA& source )
|
---|
| 119 | {
|
---|
| 120 | IsDataValid = source.IsDataValid;
|
---|
| 121 | Position = source.Position;
|
---|
| 122 | TimeDifferenceA = source.TimeDifferenceA;
|
---|
| 123 | TimeDifferenceB = source.TimeDifferenceB;
|
---|
| 124 | SpeedOverGroundKnots = source.SpeedOverGroundKnots;
|
---|
| 125 | TrackMadeGoodDegreesTrue = source.TrackMadeGoodDegreesTrue;
|
---|
| 126 | MagneticVariation = source.MagneticVariation;
|
---|
| 127 | MagneticVariationDirection = source.MagneticVariationDirection;
|
---|
| 128 |
|
---|
| 129 | return( *this );
|
---|
| 130 | }
|
---|