[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: 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 |
|
---|
| 21 | ROT::ROT()
|
---|
| 22 | {
|
---|
| 23 | Mnemonic = "ROT";
|
---|
| 24 | Empty();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | ROT::~ROT()
|
---|
| 28 | {
|
---|
| 29 | //Mnemonic.Empty();
|
---|
| 30 | Empty();
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | void ROT::Empty( void )
|
---|
| 34 | {
|
---|
| 35 | RateOfTurn = 0.0;
|
---|
| 36 | IsDataValid = NMEA_Unknown;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | BOOL 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 |
|
---|
| 70 | QString 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 |
|
---|
| 104 | BOOL 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 |
|
---|
| 120 | const ROT& ROT::operator = ( const ROT& source )
|
---|
| 121 | {
|
---|
| 122 | RateOfTurn = source.RateOfTurn;
|
---|
| 123 | IsDataValid = source.IsDataValid;
|
---|
| 124 |
|
---|
| 125 | return( *this );
|
---|
| 126 | }
|
---|