source: pacpussensors/trunk/NMEA0183/src/HDG.cpp@ 80

Last change on this file since 80 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.5 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: hdg.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:44p $
15*/
16
17
18HDG::HDG()
19{
20 Mnemonic = "HDG";
21 Empty();
22}
23
24HDG::~HDG()
25{
26 //Mnemonic.Empty();
27 Empty();
28}
29
30void HDG::Empty( void )
31{
32 MagneticSensorHeadingDegrees = 0.0;
33 MagneticDeviationDegrees = 0.0;
34 MagneticDeviationDirection = EW_Unknown;
35 MagneticVariationDegrees = 0.0;
36 MagneticVariationDirection = EW_Unknown;
37}
38
39BOOL HDG::Parse( const SENTENCE& sentence )
40{
41 /*
42 ** HDG - Heading - Deviation & Variation
43 **
44 ** 1 2 3 4 5 6
45 ** | | | | | |
46 ** $--HDG,x.x,x.x,a,x.x,a*hh<CR><LF>
47 **
48 ** Field Number:
49 ** 1) Magnetic Sensor heading in degrees
50 ** 2) Magnetic Deviation, degrees
51 ** 3) Magnetic Deviation direction, E = Easterly, W = Westerly
52 ** 4) Magnetic Variation degrees
53 ** 5) Magnetic Variation direction, E = Easterly, W = Westerly
54 ** 6) Checksum
55 */
56
57 /*
58 ** First we check the checksum...
59 */
60
61 if ( sentence.IsChecksumBad( 6 ) == True )
62 {
63 SetErrorMessage( "Invalid Checksum" );
64 return( FALSE );
65 }
66
67 MagneticSensorHeadingDegrees = sentence.Double( 1 );
68 MagneticDeviationDegrees = sentence.Double( 2 );
69 MagneticDeviationDirection = sentence.EastOrWest( 3 );
70 MagneticVariationDegrees = sentence.Double( 4 );
71 MagneticVariationDirection = sentence.EastOrWest( 5 );
72
73 return( TRUE );
74}
75
76BOOL HDG::Write( SENTENCE& sentence )
77{
78 /*
79 ** Let the parent do its thing
80 */
81
82 RESPONSE::Write( sentence );
83
84 sentence += MagneticSensorHeadingDegrees;
85 sentence += MagneticDeviationDegrees;
86 sentence += MagneticDeviationDirection;
87 sentence += MagneticVariationDegrees;
88 sentence += MagneticVariationDirection;
89
90 sentence.Finish();
91
92 return( TRUE );
93}
94
95const HDG& HDG::operator = ( const HDG& source )
96{
97 MagneticSensorHeadingDegrees = source.MagneticSensorHeadingDegrees;
98 MagneticDeviationDegrees = source.MagneticDeviationDegrees;
99 MagneticDeviationDirection = source.MagneticDeviationDirection;
100 MagneticVariationDegrees = source.MagneticVariationDegrees;
101 MagneticVariationDirection = source.MagneticVariationDirection;
102
103 return( *this );
104}
Note: See TracBrowser for help on using the repository browser.