[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: rpm.cpp $
|
---|
| 13 | ** $Revision: 4 $
|
---|
| 14 | ** $Modtime: 10/10/98 2:44p $
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | RPM::RPM()
|
---|
| 19 | {
|
---|
| 20 | Mnemonic = "RPM";
|
---|
| 21 | Empty();
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | RPM::~RPM()
|
---|
| 25 | {
|
---|
| 26 | //Mnemonic.Empty();
|
---|
| 27 | Empty();
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | void RPM::Empty( void )
|
---|
| 31 | {
|
---|
| 32 | //Source.Empty();
|
---|
| 33 | SourceNumber = 0;
|
---|
| 34 | RevolutionsPerMinute = 0.0;
|
---|
| 35 | PropellerPitchPercentage = 0.0;
|
---|
| 36 | IsDataValid = NMEA_Unknown;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | BOOL RPM::Parse( const SENTENCE& sentence )
|
---|
| 40 | {
|
---|
| 41 | /*
|
---|
| 42 | ** RPM - Revolutions
|
---|
| 43 | **
|
---|
| 44 | ** 1 2 3 4 5 6
|
---|
| 45 | ** | | | | | |
|
---|
| 46 | ** $--RPM,a,x,x.x,x.x,A*hh<CR><LF>
|
---|
| 47 | **
|
---|
| 48 | ** Field Number:
|
---|
| 49 | ** 1) Sourse, S = Shaft, E = Engine
|
---|
| 50 | ** 2) Engine or shaft number
|
---|
| 51 | ** 3) Speed, Revolutions per minute
|
---|
| 52 | ** 4) Propeller pitch, % of maximum, "-" means astern
|
---|
| 53 | ** 5) Status, A means data is valid
|
---|
| 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 | Source = sentence.Field( 1 );
|
---|
| 68 | SourceNumber = sentence.Integer( 2 );
|
---|
| 69 | RevolutionsPerMinute = sentence.Double( 3 );
|
---|
| 70 | PropellerPitchPercentage = sentence.Double( 4 );
|
---|
| 71 | IsDataValid = sentence.Boolean( 5 );
|
---|
| 72 |
|
---|
| 73 | return( TRUE );
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | BOOL RPM::Write( SENTENCE& sentence )
|
---|
| 77 | {
|
---|
| 78 | /*
|
---|
| 79 | ** Let the parent do its thing
|
---|
| 80 | */
|
---|
| 81 |
|
---|
| 82 | RESPONSE::Write( sentence );
|
---|
| 83 |
|
---|
| 84 | sentence += Source;
|
---|
| 85 | sentence += SourceNumber;
|
---|
| 86 | sentence += RevolutionsPerMinute;
|
---|
| 87 | sentence += PropellerPitchPercentage;
|
---|
| 88 | sentence += IsDataValid;
|
---|
| 89 |
|
---|
| 90 | sentence.Finish();
|
---|
| 91 |
|
---|
| 92 | return( TRUE );
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | const RPM& RPM::operator = ( const RPM& source )
|
---|
| 96 | {
|
---|
| 97 | Source = source.Source;
|
---|
| 98 | SourceNumber = source.SourceNumber;
|
---|
| 99 | RevolutionsPerMinute = source.RevolutionsPerMinute;
|
---|
| 100 | PropellerPitchPercentage = source.PropellerPitchPercentage;
|
---|
| 101 | IsDataValid = source.IsDataValid;
|
---|
| 102 |
|
---|
| 103 | return( *this );
|
---|
| 104 | }
|
---|