source: pacpussensors/trunk/NMEA0183/src/VTG.cpp

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