| 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: mta.cpp $ | 
|---|
| 13 | ** $Revision: 4 $ | 
|---|
| 14 | ** $Modtime: 10/10/98 2:56p $ | 
|---|
| 15 | */ | 
|---|
| 16 |  | 
|---|
| 17 | /* | 
|---|
| 18 | ** This Sentence Not Recommended For New Designs | 
|---|
| 19 | ** XDR is recommended. | 
|---|
| 20 | */ | 
|---|
| 21 |  | 
|---|
| 22 |  | 
|---|
| 23 |  | 
|---|
| 24 | MTA::MTA() | 
|---|
| 25 | { | 
|---|
| 26 | Mnemonic = "MTA"; | 
|---|
| 27 | Empty(); | 
|---|
| 28 | } | 
|---|
| 29 |  | 
|---|
| 30 | MTA::~MTA() | 
|---|
| 31 | { | 
|---|
| 32 | //Mnemonic.Empty(); | 
|---|
| 33 | Empty(); | 
|---|
| 34 | } | 
|---|
| 35 |  | 
|---|
| 36 | void MTA::Empty( void ) | 
|---|
| 37 | { | 
|---|
| 38 | Temperature = 0.0; | 
|---|
| 39 | //UnitOfMeasurement.Empty(); | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | BOOL MTA::Parse( const SENTENCE& sentence ) | 
|---|
| 43 | { | 
|---|
| 44 | /* | 
|---|
| 45 | ** MTA - Air Temperature | 
|---|
| 46 | ** | 
|---|
| 47 | **        1   2 3 | 
|---|
| 48 | **        |   | | | 
|---|
| 49 | ** $--MTA,x.x,C*hh<CR><LF> | 
|---|
| 50 | ** | 
|---|
| 51 | ** Field Number: | 
|---|
| 52 | **  1) Degrees | 
|---|
| 53 | **  2) Unit of Measurement, Celcius | 
|---|
| 54 | **  3) Checksum | 
|---|
| 55 | */ | 
|---|
| 56 |  | 
|---|
| 57 | /* | 
|---|
| 58 | ** First we check the checksum... | 
|---|
| 59 | */ | 
|---|
| 60 |  | 
|---|
| 61 | if ( sentence.IsChecksumBad( 3 ) == True ) | 
|---|
| 62 | { | 
|---|
| 63 | SetErrorMessage( "Invalid Checksum" ); | 
|---|
| 64 | return( FALSE ); | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | Temperature       = sentence.Double( 1 ); | 
|---|
| 68 | UnitOfMeasurement = sentence.Field( 2 ); | 
|---|
| 69 |  | 
|---|
| 70 | return( TRUE ); | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | QString MTA::PlainEnglish( void ) const | 
|---|
| 74 | { | 
|---|
| 75 | QString return_string; | 
|---|
| 76 |  | 
|---|
| 77 | //return_string.Empty(); | 
|---|
| 78 |  | 
|---|
| 79 | //return_string.Format( "The air temperature is %3.1lf ", Temperature ); | 
|---|
| 80 | return_string = "The air temperature is" + QString::number( Temperature ); | 
|---|
| 81 | return_string += UnitOfMeasurement; | 
|---|
| 82 | return_string += "."; | 
|---|
| 83 |  | 
|---|
| 84 | return( return_string ); | 
|---|
| 85 | } | 
|---|
| 86 |  | 
|---|
| 87 | BOOL MTA::Write( SENTENCE& sentence ) | 
|---|
| 88 | { | 
|---|
| 89 | /* | 
|---|
| 90 | ** Let the parent do its thing | 
|---|
| 91 | */ | 
|---|
| 92 |  | 
|---|
| 93 | RESPONSE::Write( sentence ); | 
|---|
| 94 |  | 
|---|
| 95 | sentence += Temperature; | 
|---|
| 96 | sentence += UnitOfMeasurement; | 
|---|
| 97 |  | 
|---|
| 98 | sentence.Finish(); | 
|---|
| 99 |  | 
|---|
| 100 | return( TRUE ); | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|
| 103 | const MTA& MTA::operator = ( const MTA& source ) | 
|---|
| 104 | { | 
|---|
| 105 | Temperature       = source.Temperature; | 
|---|
| 106 | UnitOfMeasurement = source.UnitOfMeasurement; | 
|---|
| 107 |  | 
|---|
| 108 | return( *this ); | 
|---|
| 109 | } | 
|---|