source: pacpussensors/trunk/NMEA0183/src/BWC.cpp@ 64

Last change on this file since 64 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: 2.6 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: bwc.cpp $
13** $Revision: 5 $
14** $Modtime: 10/10/98 2:45p $
15*/
16
17
18
19BWC::BWC()
20{
21 Mnemonic = "BWC";
22 Empty();
23}
24
25BWC::~BWC()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void BWC::Empty( void )
32{
33 //UTCTime.Empty();
34 BearingTrue = 0.0;
35 BearingMagnetic = 0.0;
36 NauticalMiles = 0.0;
37 //To.Empty();
38}
39
40BOOL BWC::Parse( const SENTENCE& sentence )
41{
42 /*
43 ** BWC - Bearing and Distance to Waypoint
44 ** Latitude, N/S, Longitude, E/W, UTC, Status
45 ** 11
46 ** 1 2 3 4 5 6 7 8 9 10 | 12 13
47 ** | | | | | | | | | | | | |
48 ** $--BWC,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x.x,T,x.x,M,x.x,N,c--c*hh<CR><LF>
49 **
50 ** 1) UTCTime
51 ** 2) Waypoint Latitude
52 ** 3) N = North, S = South
53 ** 4) Waypoint Longitude
54 ** 5) E = East, W = West
55 ** 6) Bearing, True
56 ** 7) T = True
57 ** 8) Bearing, Magnetic
58 ** 9) M = Magnetic
59 ** 10) Nautical Miles
60 ** 11) N = Nautical Miles
61 ** 12) Waypoint ID
62 ** 13) Checksum
63 */
64
65 /*
66 ** First we check the checksum...
67 */
68
69 if ( sentence.IsChecksumBad( 13 ) == True )
70 {
71 SetErrorMessage( "Invalid Checksum" );
72 return( FALSE );
73 }
74
75 UTCTime = sentence.Field( 1 );
76 Time = sentence.Time( 1 );
77 Position.Parse( 2, 3, 4, 5, sentence );
78 BearingTrue = sentence.Double( 6 );
79 BearingMagnetic = sentence.Double( 8 );
80 NauticalMiles = sentence.Double( 10 );
81 To = sentence.Field( 12 );
82
83 return( TRUE );
84}
85
86BOOL BWC::Write( SENTENCE& sentence )
87{
88 /*
89 ** Let the parent do its thing
90 */
91
92 RESPONSE::Write( sentence );
93
94 sentence += UTCTime;
95 sentence += Position;
96 sentence += BearingTrue;
97 sentence += "T";
98 sentence += BearingMagnetic;
99 sentence += "M";
100 sentence += NauticalMiles;
101 sentence += "N";
102 sentence += To;
103
104 sentence.Finish();
105
106 return( TRUE );
107}
108
109const BWC& BWC::operator = ( const BWC& source )
110{
111 UTCTime = source.UTCTime;
112 Time = source.Time;
113 Position = source.Position;
114 BearingTrue = source.BearingTrue;
115 BearingMagnetic = source.BearingMagnetic;
116 NauticalMiles = source.NauticalMiles;
117 To = source.To;
118
119 return( *this );
120}
Note: See TracBrowser for help on using the repository browser.