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