source: pacpussensors/trunk/NMEA0183/src/BOD.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: bod.cpp $
13** $Revision: 6 $
14** $Modtime: 10/10/98 2:55p $
15*/
16
17#ifdef _MSC_VER
18# pragma warning(disable:4996)
19#endif // _MSC_VER
20
21BOD::BOD()
22{
23 Mnemonic = "BOD";
24 Empty();
25}
26
27BOD::~BOD()
28{
29 //Mnemonic.Empty();
30 Empty();
31}
32
33void BOD::Empty( void )
34{
35 BearingTrue = 0.0;
36 BearingMagnetic = 0.0;
37 //To.Empty();
38 //From.Empty();
39}
40
41BOOL BOD::Parse( const SENTENCE& sentence )
42{
43 /*
44 ** BOD - Bearing - Origin Waypoint to Destination Waypoint
45 **
46 ** 1 2 3 4 5 6 7
47 ** | | | | | | |
48 ** $--BOD,x.x,T,x.x,M,c--c,c--c*hh<CR><LF>
49 **
50 ** Field Number:
51 ** 1) Bearing Degrees, TRUE
52 ** 2) T = True
53 ** 3) Bearing Degrees, Magnetic
54 ** 4) M = Magnetic
55 ** 5) TO Waypoint
56 ** 6) FROM Waypoint
57 ** 7) Checksum
58 */
59
60 /*
61 ** First we check the checksum...
62 */
63
64 if ( sentence.IsChecksumBad( 7 ) == True )
65 {
66 SetErrorMessage( "Invalid Checksum" );
67 return( FALSE );
68 }
69
70 BearingTrue = sentence.Double( 1 );
71 BearingMagnetic = sentence.Double( 3 );
72 To = sentence.Field( 5 );
73 From = sentence.Field( 6 );
74
75 return( TRUE );
76}
77
78QString BOD::PlainEnglish( void ) const
79{
80 QString return_string;
81
82 //return_string.Empty();
83
84 return_string = "You are bearing ";
85
86 char temp_string [ 22 ];
87
88 ::sprintf( temp_string, "%5.2f", BearingTrue );
89
90 return_string += temp_string;
91 return_string += " degrees true (";
92
93 ::sprintf( temp_string, "%5.2f", BearingMagnetic );
94
95 return_string += temp_string;
96 return_string += " degrees magnetic).";
97
98 return( return_string );
99}
100
101BOOL BOD::Write( SENTENCE& sentence )
102{
103 /*
104 ** Let the parent do its thing
105 */
106
107 RESPONSE::Write( sentence );
108
109 sentence += BearingTrue;
110 sentence += "T";
111 sentence += BearingMagnetic;
112 sentence += "M";
113 sentence += To;
114 sentence += From;
115
116 sentence.Finish();
117
118 return( TRUE );
119}
120
121const BOD& BOD::operator = ( const BOD& source )
122{
123 BearingTrue = source.BearingTrue;
124 BearingMagnetic = source.BearingMagnetic;
125 To = source.To;
126 From = source.From;
127
128 return( *this );
129}
Note: See TracBrowser for help on using the repository browser.