source: pacpussensors/trunk/NMEA0183/src/ROT.cpp@ 67

Last change on this file since 67 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: rot.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:56p $
15*/
16
17#ifdef _MSC_VER
18# pragma warning(disable:4996)
19#endif // _MSC_VER
20
21ROT::ROT()
22{
23 Mnemonic = "ROT";
24 Empty();
25}
26
27ROT::~ROT()
28{
29 //Mnemonic.Empty();
30 Empty();
31}
32
33void ROT::Empty( void )
34{
35 RateOfTurn = 0.0;
36 IsDataValid = NMEA_Unknown;
37}
38
39BOOL ROT::Parse( const SENTENCE& sentence )
40{
41 /*
42 ** ROT - Rate Of Turn
43 **
44 ** 1 2 3
45 ** | | |
46 ** $--ROT,x.x,A*hh<CR><LF>
47 **
48 ** Field Number:
49 ** 1) Rate Of Turn, degrees per minute, "-" means bow turns to port
50 ** 2) Status, A means data is valid
51 ** 3) Checksum
52 */
53
54 /*
55 ** First we check the checksum...
56 */
57
58 if ( sentence.IsChecksumBad( 3 ) == True )
59 {
60 SetErrorMessage( "Invalid Checksum" );
61 return( FALSE );
62 }
63
64 RateOfTurn = sentence.Double( 1 );
65 IsDataValid = sentence.Boolean( 2 );
66
67 return( TRUE );
68}
69
70QString ROT::PlainEnglish( void ) const
71{
72 QString return_string;
73
74 return_string = "The bow is turning to ";
75
76 char temp_string[ 80 ];
77
78 if ( RateOfTurn < 0 )
79 {
80 ::sprintf( temp_string, "Port at a rate of %4.1lf degrees per minute.", (double) (RateOfTurn * -1.0) );
81 }
82 else
83 {
84 ::sprintf( temp_string, "Starboard at a rate of %4.1lf degrees per minute.", RateOfTurn );
85 }
86
87 return_string += temp_string;
88
89 if ( IsDataValid != True )
90 {
91 if ( IsDataValid == False )
92 {
93 return_string += " However, this data is not valid.";
94 }
95 else
96 {
97 return_string += " However, this data cannot be confirmed.";
98 }
99 }
100
101 return( return_string );
102}
103
104BOOL ROT::Write( SENTENCE& sentence )
105{
106 /*
107 ** Let the parent do its thing
108 */
109
110 RESPONSE::Write( sentence );
111
112 sentence += RateOfTurn;
113 sentence += IsDataValid;
114
115 sentence.Finish();
116
117 return( TRUE );
118}
119
120const ROT& ROT::operator = ( const ROT& source )
121{
122 RateOfTurn = source.RateOfTurn;
123 IsDataValid = source.IsDataValid;
124
125 return( *this );
126}
Note: See TracBrowser for help on using the repository browser.