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