source: pacpussensors/trunk/NMEA0183/src/ZFI.cpp@ 64

Last change on this file since 64 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.3 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: zfi.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:43p $
15*/
16
17/*
18** This Sentence Not Recommended For New Designs
19** ZFO is recommended.
20*/
21
22
23
24ZFI::ZFI()
25{
26 Mnemonic = "ZFI";
27 Empty();
28}
29
30ZFI::~ZFI()
31{
32 //Mnemonic.Empty();
33 Empty();
34}
35
36void ZFI::Empty( void )
37{
38 //UTCTimeString.Empty();
39 //ElapsedTimeString.Empty();
40 //From.Empty();
41}
42
43BOOL ZFI::Parse( const SENTENCE& sentence )
44{
45 /*
46 ** ZFI - Elapsed time from point of interest
47 **
48 ** 1 2 3 4
49 ** | | | |
50 ** $--ZFI,hhmmss.ss,hhmmss.ss,c--c*hh<CR><LF>
51 **
52 ** 1) Universal Time Coordinated (UTC)
53 ** 2) Elapsed Time
54 ** 3) Waypoint ID (From)
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 QDateTime temp_time = QDateTime::currentDateTime();
69
70 int year = temp_time.date().year();
71 int month = temp_time.date().month();
72 int day = temp_time.date().day();
73
74 UTCTimeString = sentence.Field( 1 );
75
76 char temp_number[ 3 ];
77
78 temp_number[ 2 ] = 0x00;
79
80 temp_number[ 0 ] = UTCTimeString[ 0 ].toLatin1();
81 temp_number[ 1 ] = UTCTimeString[ 1 ].toLatin1();
82
83 int hours = ::atoi( temp_number );
84
85 temp_number[ 0 ] = UTCTimeString[ 2 ].toLatin1();
86 temp_number[ 1 ] = UTCTimeString[ 3 ].toLatin1();
87
88 int minutes = ::atoi( temp_number );
89
90 temp_number[ 0 ] = UTCTimeString[ 4 ].toLatin1();
91 temp_number[ 1 ] = UTCTimeString[ 5 ].toLatin1();
92
93 int seconds = ::atoi( temp_number );
94
95 //UTCTime = CTime( year, month, day, hours, minutes, seconds );
96 UTCTime = QDateTime(QDate(year, month, day) , QTime(hours, minutes, seconds) );
97
98 ElapsedTimeString = sentence.Field( 2 );
99
100 temp_number[ 0 ] = ElapsedTimeString[ 0 ].toLatin1();
101 temp_number[ 1 ] = ElapsedTimeString[ 1 ].toLatin1();
102
103 hours = ::atoi( temp_number );
104
105 temp_number[ 0 ] = ElapsedTimeString[ 2 ].toLatin1();
106 temp_number[ 1 ] = ElapsedTimeString[ 3 ].toLatin1();
107
108 minutes = ::atoi( temp_number );
109
110 temp_number[ 0 ] = ElapsedTimeString[ 4 ].toLatin1();
111 temp_number[ 1 ] = ElapsedTimeString[ 5 ].toLatin1();
112
113 seconds = ::atoi( temp_number );
114
115 //ElapsedTime = CTime( year, month, day, hours, minutes, seconds );
116 ElapsedTime = QDateTime(QDate(year, month, day) , QTime(hours, minutes, seconds) );
117
118 From = sentence.Field( 3 );
119
120 return( TRUE );
121}
122
123BOOL ZFI::Write( SENTENCE& sentence )
124{
125 /*
126 ** Let the parent do its thing
127 */
128
129 RESPONSE::Write( sentence );
130
131 sentence += UTCTimeString;
132 sentence += ElapsedTimeString;
133 sentence += From;
134
135 sentence.Finish();
136
137 return( TRUE );
138}
139
140const ZFI& ZFI::operator = ( const ZFI& source )
141{
142 UTCTimeString = source.UTCTimeString;
143 UTCTime = source.UTCTime;
144 ElapsedTimeString = source.ElapsedTimeString;
145 ElapsedTime = source.ElapsedTime;
146 From = source.From;
147
148 return( *this );
149}
Note: See TracBrowser for help on using the repository browser.