source: pacpussensors/trunk/NMEA0183/src/HDM.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: 1.8 KB
RevLine 
[59]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: hdm.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:55p $
15*/
16
17/*
18** This Sentence Not Recommended For New Designs
19** Use of HDG is recommended.
20*/
21
22#ifdef _MSC_VER
23# pragma warning(disable:4996)
24#endif // _MSC_VER
25
26HDM::HDM()
27{
28 Mnemonic = "HDM";
29 Empty();
30}
31
32HDM::~HDM()
33{
34 //Mnemonic.Empty();
35 Empty();
36}
37
38void HDM::Empty( void )
39{
40 HeadingDegrees = 0.0;
41}
42
43BOOL HDM::Parse( const SENTENCE& sentence )
44{
45 /*
46 ** HDM - Heading - Deviation & Variation
47 **
48 ** 1 2 3
49 ** | | |
50 ** $--HDM,x.x,M*hh<CR><LF>
51 **
52 ** Field Number:
53 ** 1) Heading in degrees
54 ** 2) M, Magnetic Deviation
55 ** 3) Checksum
56 */
57
58 /*
59 ** First we check the checksum...
60 */
61
62 if ( sentence.IsChecksumBad( 3 ) == True )
63 {
64 SetErrorMessage( "Invalid Checksum" );
65 return( FALSE );
66 }
67
68 HeadingDegrees = sentence.Double( 1 );
69
70 return( TRUE );
71}
72
73QString HDM::PlainEnglish( void ) const
74{
75 QString return_string;
76
77 return_string = "The Magnetic heading is ";
78
79 char temp_string[ 80 ];
80
81 ::sprintf( temp_string, "%6.2lf degrees.", HeadingDegrees );
82
83 return_string += temp_string;
84
85 return( return_string );
86}
87
88BOOL HDM::Write( SENTENCE& sentence )
89{
90 /*
91 ** Let the parent do its thing
92 */
93
94 RESPONSE::Write( sentence );
95
96 sentence += HeadingDegrees;
97 sentence += "M";
98
99 sentence.Finish();
100
101 return( TRUE );
102}
103
104const HDM& HDM::operator = ( const HDM& source )
105{
106 HeadingDegrees = source.HeadingDegrees;
107
108 return( *this );
109}
Note: See TracBrowser for help on using the repository browser.