[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: wnc.cpp $
|
---|
| 13 | ** $Revision: 4 $
|
---|
| 14 | ** $Modtime: 10/10/98 2:39p $
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | WNC::WNC()
|
---|
| 20 | {
|
---|
| 21 | Mnemonic = "WNC";
|
---|
| 22 | Empty();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | WNC::~WNC()
|
---|
| 26 | {
|
---|
| 27 | //Mnemonic.Empty();
|
---|
| 28 | Empty();
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | void WNC::Empty( void )
|
---|
| 32 | {
|
---|
| 33 | MilesDistance = 0.0;
|
---|
| 34 | KilometersDistance = 0.0;
|
---|
| 35 | //To.Empty();
|
---|
| 36 | //From.Empty();
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | BOOL WNC::Parse( const SENTENCE& sentence )
|
---|
| 40 | {
|
---|
| 41 | /*
|
---|
| 42 | ** WNC - Distance - Waypoint to Waypoint
|
---|
| 43 | **
|
---|
| 44 | ** 1 2 3 4 5 6 7
|
---|
| 45 | ** | | | | | | |
|
---|
| 46 | ** $--WNC,x.x,N,x.x,K,c--c,c--c*hh<CR><LF>
|
---|
| 47 | **
|
---|
| 48 | ** Field Number:
|
---|
| 49 | ** 1) Distance, Nautical Miles
|
---|
| 50 | ** 2) N = Nautical Miles
|
---|
| 51 | ** 3) Distance, Kilometers
|
---|
| 52 | ** 4) K = Kilometers
|
---|
| 53 | ** 5) TO Waypoint
|
---|
| 54 | ** 6) FROM Waypoint
|
---|
| 55 | ** 7) Checksum
|
---|
| 56 | */
|
---|
| 57 |
|
---|
| 58 | /*
|
---|
| 59 | ** First we check the checksum...
|
---|
| 60 | */
|
---|
| 61 |
|
---|
| 62 | if ( sentence.IsChecksumBad( 7 ) == True )
|
---|
| 63 | {
|
---|
| 64 | SetErrorMessage( "Invalid Checksum" );
|
---|
| 65 | return( FALSE );
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | MilesDistance = sentence.Double( 1 );
|
---|
| 69 | KilometersDistance = sentence.Double( 3 );
|
---|
| 70 | To = sentence.Field( 5 );
|
---|
| 71 | From = sentence.Field( 6 );
|
---|
| 72 |
|
---|
| 73 | return( TRUE );
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | BOOL WNC::Write( SENTENCE& sentence )
|
---|
| 77 | {
|
---|
| 78 | /*
|
---|
| 79 | ** Let the parent do its thing
|
---|
| 80 | */
|
---|
| 81 |
|
---|
| 82 | RESPONSE::Write( sentence );
|
---|
| 83 |
|
---|
| 84 | sentence += MilesDistance;
|
---|
| 85 | sentence += "N";
|
---|
| 86 | sentence += KilometersDistance;
|
---|
| 87 | sentence += "K";
|
---|
| 88 | sentence += To;
|
---|
| 89 | sentence += From;
|
---|
| 90 |
|
---|
| 91 | sentence.Finish();
|
---|
| 92 |
|
---|
| 93 | return( TRUE );
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | const WNC& WNC::operator = ( const WNC& source )
|
---|
| 97 | {
|
---|
| 98 | MilesDistance = source.MilesDistance;
|
---|
| 99 | KilometersDistance = source.KilometersDistance;
|
---|
| 100 | To = source.To;
|
---|
| 101 | From = source.From;
|
---|
| 102 |
|
---|
| 103 | return( *this );
|
---|
| 104 | }
|
---|