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