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