source: pacpussensors/trunk/NMEA0183/src/ZDA.cpp@ 127

Last change on this file since 127 was 59, checked in by DHERBOMEZ Gérald, 10 years ago

Integration of new modules:

  • GPS NMEA0183 decoder
  • Span CPT Decoder

Update of:

File size: 3.1 KB
Line 
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: zda.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:40p $
15*/
16
17
18
19ZDA::ZDA()
20{
21 Mnemonic = "ZDA";
22 Empty();
23}
24
25ZDA::~ZDA()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void ZDA::Empty( void )
32{
33 //UTCTime.Empty();
34 Day = 0;
35 Month = 0;
36 Year = 0;
37 LocalHourDeviation = 0;
38 LocalMinutesDeviation = 0;
39}
40
41BOOL ZDA::Parse( const SENTENCE& sentence )
42{
43 /*
44 ** ZDA - Time & Date
45 ** UTC, day, month, year and local time zone
46 **
47 ** $--ZDA,hhmmss.ss,xx,xx,xxxx,xx,xx*hh<CR><LF>
48 ** | | | | | |
49 ** | | | | | +- Local zone minutes description, same sign as local hours
50 ** | | | | +- Local zone description, 00 to +- 13 hours
51 ** | | | +- Year
52 ** | | +- Month, 01 to 12
53 ** | +- Day, 01 to 31
54 ** +- Universal Time Coordinated (UTC)
55 */
56
57 /*
58 ** First we check the checksum...
59 */
60
61 if ( sentence.IsChecksumBad( 7 ) == True )
62 {
63 SetErrorMessage( "Invalid Checksum" );
64 return( FALSE );
65 }
66
67 UTCTime = sentence.Field( 1 );
68
69 char temp_number[ 3 ];
70
71 temp_number[ 2 ] = 0x00;
72
73 temp_number[ 0 ] = UTCTime[ 0 ].toLatin1();
74 temp_number[ 1 ] = UTCTime[ 1 ].toLatin1();
75
76 int hours = ::atoi( temp_number );
77
78 temp_number[ 0 ] = UTCTime[ 2 ].toLatin1();
79 temp_number[ 1 ] = UTCTime[ 3 ].toLatin1();
80
81 int minutes = ::atoi( temp_number );
82
83 temp_number[ 0 ] = UTCTime[ 4 ].toLatin1();
84 temp_number[ 1 ] = UTCTime[ 5 ].toLatin1();
85
86 int seconds = ::atoi( temp_number );
87
88 Day = sentence.Integer( 2 );
89 Month = sentence.Integer( 3 );
90 Year = sentence.Integer( 4 );
91 LocalHourDeviation = sentence.Integer( 5 );
92 LocalMinutesDeviation = sentence.Integer( 6 );
93
94 //Time = CTime( Year, Month, Day, hours, minutes, seconds );
95 Time = QDateTime(QDate(Year, Month, Day) , QTime(hours, minutes, seconds) );
96
97 return( TRUE );
98}
99
100BOOL ZDA::Write( SENTENCE& sentence )
101{
102 /*
103 ** Let the parent do its thing
104 */
105
106 RESPONSE::Write( sentence );
107
108 sentence += UTCTime;
109 sentence += Day;
110 sentence += Month;
111 sentence += Year;
112 sentence += LocalHourDeviation;
113 sentence += LocalMinutesDeviation;
114
115 sentence.Finish();
116
117 return( TRUE );
118}
119
120const ZDA& ZDA::operator = ( const ZDA& source )
121{
122 UTCTime = source.UTCTime;
123 Time = source.Time;
124 Day = source.Day;
125 Month = source.Month;
126 Year = source.Year;
127 LocalHourDeviation = source.LocalHourDeviation;
128 LocalMinutesDeviation = source.LocalMinutesDeviation;
129
130 return( *this );
131}
Note: See TracBrowser for help on using the repository browser.