source: pacpussensors/trunk/NMEA0183/src/RTE.cpp

Last change on this file 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.5 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: rte.cpp $
13** $Revision: 5 $
14** $Modtime: 10/10/98 4:21p $
15*/
16
17
18RTE::RTE()
19{
20 Mnemonic = "RTE";
21 Empty();
22}
23
24RTE::~RTE()
25{
26 //Mnemonic.Empty();
27 Empty();
28}
29
30void RTE::Empty( void )
31{
32 m_TotalNumberOfMessages = 0.0;
33 m_LastMessageNumberReceived = 0.0;
34 m_MessageNumber = 0.0;
35 m_LastWaypointNumberWritten = 0;
36
37 TypeOfRoute = RouteUnknown;
38 //RouteName.Empty();
39
40 m_DeleteAllEntries();
41}
42
43BOOL RTE::Parse( const SENTENCE& sentence )
44{
45 /*
46 ** RTE - Routes
47 **
48 ** 1 2 3 4 5 x n
49 ** | | | | | | |
50 ** $--RTE,x.x,x.x,a,c--c,c--c, ..... c--c*hh<CR><LF>
51 **
52 ** Field Number:
53 ** 1) Total number of messages being transmitted
54 ** 2) Message Number
55 ** 3) Message mode
56 ** c = complete route, all waypoints
57 ** w = working route, the waypoint you just left, the waypoint you're heading to then all the rest
58 ** 4) Waypoint ID
59 ** x) More Waypoints
60 ** n) Checksum
61 */
62
63 m_DeleteAllEntries();
64
65 int field_number = 1;
66
67 m_TotalNumberOfMessages = sentence.Double( 1 );
68
69 double this_message_number = sentence.Double( 2 );
70
71 if ( this_message_number == 1.0 )
72 {
73 /*
74 ** Make sure we've got a clean list
75 */
76
77 m_DeleteAllEntries();
78 }
79
80 QString field_data = sentence.Field( 3 );
81
82 if ( field_data == "c" )
83 {
84 TypeOfRoute = CompleteRoute;
85 }
86 else if ( field_data == "w" )
87 {
88 TypeOfRoute = WorkingRoute;
89 }
90 else
91 {
92 TypeOfRoute = RouteUnknown;
93 }
94
95 RouteName = sentence.Field( 4 );
96
97 int number_of_data_fields = sentence.GetNumberOfDataFields();
98 field_number = 5;
99
100 QString * string_to_add_p = (QString *) NULL;
101
102 while( field_number < number_of_data_fields )
103 {
104 string_to_add_p = new QString;
105
106 *string_to_add_p = sentence.Field( field_number );
107
108 Waypoints.resize(Waypoints.size()+1);
109 Waypoints.insert( Waypoints.size(),string_to_add_p );
110 //Waypoints.Add( string_to_add_p );
111
112 string_to_add_p = (QString *) NULL;
113
114 field_number++;
115 }
116
117 return( TRUE );
118}
119
120BOOL RTE::Write( SENTENCE& sentence )
121{
122 /*
123 ** Let the parent do its thing
124 */
125
126 RESPONSE::Write( sentence );
127
128 sentence += m_TotalNumberOfMessages;
129 sentence += m_MessageNumber;
130
131 switch( TypeOfRoute )
132 {
133 case CompleteRoute:
134
135 sentence += "c";
136 break;
137
138 case WorkingRoute:
139
140 sentence += "w";
141 break;
142
143 default:
144
145 sentence += "";
146 break;
147 }
148
149 sentence += RouteName;
150
151 /*
152 ** To Be done
153 ** Take the number of entries in the list and write them out until we're done
154 */
155
156 sentence.Finish();
157
158 return( TRUE );
159}
160
161void RTE::m_DeleteAllEntries( void )
162{
163 int loop_index = 0;
164 int number_of_entries = Waypoints.size();
165
166 QString * entry_p = (QString *) NULL;
167
168 /*while( loop_index < number_of_entries )
169 {
170 entry_p = (QString *) Waypoints[ loop_index ];
171 Waypoints[ loop_index ] = NULL;
172 delete entry_p;
173 entry_p = (QString *) NULL;
174 loop_index++;
175 }*/
176
177 Waypoints.clear();
178}
Note: See TracBrowser for help on using the repository browser.