[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: zte.cpp $
|
---|
| 13 | ** $Revision: 4 $
|
---|
| 14 | ** $Modtime: 10/10/98 2:38p $
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 | /*
|
---|
| 18 | ** This Sentence Not Recommended For New Designs
|
---|
| 19 | ** ZTG is recommended.
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | ZTE::ZTE()
|
---|
| 25 | {
|
---|
| 26 | Mnemonic = "ZTE";
|
---|
| 27 | Empty();
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | ZTE::~ZTE()
|
---|
| 31 | {
|
---|
| 32 | //Mnemonic.Empty();
|
---|
| 33 | Empty();
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | void ZTE::Empty( void )
|
---|
| 37 | {
|
---|
| 38 | //UTCTimeString.Empty();
|
---|
| 39 | //TimeToGoString.Empty();
|
---|
| 40 | //To.Empty();
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | BOOL ZTE::Parse( const SENTENCE& sentence )
|
---|
| 44 | {
|
---|
| 45 | /*
|
---|
| 46 | ** ZTE - Estimated time to event
|
---|
| 47 | **
|
---|
| 48 | ** 1 2 3 4
|
---|
| 49 | ** | | | |
|
---|
| 50 | ** $--ZTE,hhmmss.ss,hhmmss.ss,c--c*hh<CR><LF>
|
---|
| 51 | **
|
---|
| 52 | ** 1) Universal Time Coordinated (UTC)
|
---|
| 53 | ** 2) Arrival Time
|
---|
| 54 | ** 3) Waypoint ID (To)
|
---|
| 55 | ** 4) Checksum
|
---|
| 56 | */
|
---|
| 57 |
|
---|
| 58 | /*
|
---|
| 59 | ** First we check the checksum...
|
---|
| 60 | */
|
---|
| 61 |
|
---|
| 62 | if ( sentence.IsChecksumBad( 4 ) == True )
|
---|
| 63 | {
|
---|
| 64 | SetErrorMessage( "Invalid Checksum" );
|
---|
| 65 | return( FALSE );
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | QDateTime temp_time = QDateTime::currentDateTime();
|
---|
| 70 |
|
---|
| 71 | int year = temp_time.date().year();
|
---|
| 72 | int month = temp_time.date().month();
|
---|
| 73 | int day = temp_time.date().day();
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | UTCTimeString = sentence.Field( 1 );
|
---|
| 77 |
|
---|
| 78 | char temp_number[ 3 ];
|
---|
| 79 |
|
---|
| 80 | temp_number[ 2 ] = 0x00;
|
---|
| 81 |
|
---|
| 82 | temp_number[ 0 ] = UTCTimeString[ 0 ].toLatin1();
|
---|
| 83 | temp_number[ 1 ] = UTCTimeString[ 1 ].toLatin1();
|
---|
| 84 |
|
---|
| 85 | int hours = ::atoi( temp_number );
|
---|
| 86 |
|
---|
| 87 | temp_number[ 0 ] = UTCTimeString[ 2 ].toLatin1();
|
---|
| 88 | temp_number[ 1 ] = UTCTimeString[ 3 ].toLatin1();
|
---|
| 89 |
|
---|
| 90 | int minutes = ::atoi( temp_number );
|
---|
| 91 |
|
---|
| 92 | temp_number[ 0 ] = UTCTimeString[ 4 ].toLatin1();
|
---|
| 93 | temp_number[ 1 ] = UTCTimeString[ 5 ].toLatin1();
|
---|
| 94 |
|
---|
| 95 | int seconds = ::atoi( temp_number );
|
---|
| 96 |
|
---|
| 97 | //UTCTime = CTime( year, month, day, hours, minutes, seconds );
|
---|
| 98 | UTCTime = QDateTime(QDate(year, month, day) , QTime(hours, minutes, seconds) );
|
---|
| 99 |
|
---|
| 100 | TimeToGoString = sentence.Field( 2 );
|
---|
| 101 |
|
---|
| 102 | temp_number[ 0 ] = TimeToGoString[ 0 ].toLatin1();
|
---|
| 103 | temp_number[ 1 ] = TimeToGoString[ 1 ].toLatin1();
|
---|
| 104 |
|
---|
| 105 | hours = ::atoi( temp_number );
|
---|
| 106 |
|
---|
| 107 | temp_number[ 0 ] = TimeToGoString[ 2 ].toLatin1();
|
---|
| 108 | temp_number[ 1 ] = TimeToGoString[ 3 ].toLatin1();
|
---|
| 109 |
|
---|
| 110 | minutes = ::atoi( temp_number );
|
---|
| 111 |
|
---|
| 112 | temp_number[ 0 ] = TimeToGoString[ 4 ].toLatin1();
|
---|
| 113 | temp_number[ 1 ] = TimeToGoString[ 5 ].toLatin1();
|
---|
| 114 |
|
---|
| 115 | seconds = ::atoi( temp_number );
|
---|
| 116 |
|
---|
| 117 | //TimeToGo = CTime( year, month, day, hours, minutes, seconds );
|
---|
| 118 | TimeToGo = QDateTime(QDate(year, month, day) , QTime(hours, minutes, seconds) );
|
---|
| 119 |
|
---|
| 120 | To = sentence.Field( 3 );
|
---|
| 121 |
|
---|
| 122 | return( TRUE );
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | BOOL ZTE::Write( SENTENCE& sentence )
|
---|
| 126 | {
|
---|
| 127 | /*
|
---|
| 128 | ** Let the parent do its thing
|
---|
| 129 | */
|
---|
| 130 |
|
---|
| 131 | RESPONSE::Write( sentence );
|
---|
| 132 |
|
---|
| 133 | sentence += UTCTimeString;
|
---|
| 134 | sentence += TimeToGoString;
|
---|
| 135 | sentence += To;
|
---|
| 136 |
|
---|
| 137 | sentence.Finish();
|
---|
| 138 |
|
---|
| 139 | return( TRUE );
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | const ZTE& ZTE::operator = ( const ZTE& source )
|
---|
| 143 | {
|
---|
| 144 | UTCTimeString = source.UTCTimeString;
|
---|
| 145 | UTCTime = source.UTCTime;
|
---|
| 146 | TimeToGoString = source.TimeToGoString;
|
---|
| 147 | TimeToGo = source.TimeToGo;
|
---|
| 148 | To = source.To;
|
---|
| 149 |
|
---|
| 150 | return( *this );
|
---|
| 151 | }
|
---|