source: pacpussensors/trunk/NMEA0183/src/TTM.cpp@ 62

Last change on this file since 62 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: 4.9 KB
RevLine 
[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: ttm.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:38p $
15*/
16
17
18
19TTM::TTM()
20{
21 Mnemonic = "TTM";
22 Empty();
23}
24
25TTM::~TTM()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void TTM::Empty( void )
32{
33 TargetNumber = 0;
34 TargetDistance = 0.0;
35 BearingFromOwnShip = 0.0;
36 //BearingUnits.Empty();
37 TargetSpeed = 0.0;
38 TargetCourse = 0.0;
39 //TargetCourseUnits.Empty();
40 DistanceOfClosestPointOfApproach = 0.0;
41 NumberOfMinutesToClosestPointOfApproach = 0.0;
42 //Increasing.Empty();
43 //TargetName.Empty();
44 TargetStatus = TargetUnknown;
45}
46
47BOOL TTM::Parse( const SENTENCE& sentence )
48{
49 /*
50 ** TTM - Tracked Target Message
51 **
52 ** 11 13
53 ** 1 2 3 4 5 6 7 8 9 10| 12| 14
54 ** | | | | | | | | | | | | | |
55 ** $--TTM,xx,x.x,x.x,a,x.x,x.x,a,x.x,x.x,a,c--c,a,a*hh<CR><LF>
56 **
57 ** 1) Target Number
58 ** 2) Target Distance
59 ** 3) Bearing from own ship
60 ** 4) Bearing Units
61 ** 5) Target speed
62 ** 6) Target Course
63 ** 7) Course Units
64 ** 8) Distance of closest-point-of-approach
65 ** 9) Time until closest-point-of-approach "-" means increasing
66 ** 10) "-" means increasing
67 ** 11) Target name
68 ** 12) Target Status
69 ** 13) Reference Target
70 ** 14) Checksum
71 */
72
73 /*
74 ** First we check the checksum...
75 */
76
77 if ( sentence.IsChecksumBad( 14 ) == True )
78 {
79 SetErrorMessage( "Invalid Checksum" );
80 return( FALSE );
81 }
82
83 TargetNumber = sentence.Integer( 1 );
84 TargetDistance = sentence.Double( 2 );
85 BearingFromOwnShip = sentence.Double( 3 );
86 BearingUnits = sentence.Field( 4 );
87 TargetSpeed = sentence.Double( 5 );
88 TargetCourse = sentence.Double( 6 );
89 TargetCourseUnits = sentence.Field( 7 );
90 DistanceOfClosestPointOfApproach = sentence.Double( 8 );
91 NumberOfMinutesToClosestPointOfApproach = sentence.Double( 9 );
92 Increasing = sentence.Field( 10 );
93 TargetName = sentence.Field( 11 );
94
95 QString field_data = sentence.Field( 12 );
96
97 if ( field_data == "L" )
98 {
99 TargetStatus = TargetLost;
100 }
101 else if ( field_data == "Q" )
102 {
103 TargetStatus = TargetQuery;
104 }
105 else if ( field_data == "T" )
106 {
107 TargetStatus = TargetTracking;
108 }
109 else
110 {
111 TargetStatus = TargetUnknown;
112 }
113
114 ReferenceTarget = sentence.Field( 13 );
115
116 return( TRUE );
117}
118
119BOOL TTM::Write( SENTENCE& sentence )
120{
121 /*
122 ** Let the parent do its thing
123 */
124
125 RESPONSE::Write( sentence );
126
127 sentence += TargetNumber;
128 sentence += TargetDistance;
129 sentence += BearingFromOwnShip;
130 sentence += BearingUnits;
131 sentence += TargetSpeed;
132 sentence += TargetCourse;
133 sentence += TargetCourseUnits;
134 sentence += DistanceOfClosestPointOfApproach;
135 sentence += NumberOfMinutesToClosestPointOfApproach;
136 sentence += Increasing;
137 sentence += TargetName;
138
139 switch( TargetStatus )
140 {
141 case TargetLost:
142
143 sentence += "L";
144 break;
145
146 case TargetQuery:
147
148 sentence += "Q";
149 break;
150
151 case TargetTracking:
152
153 sentence += "T";
154 break;
155
156 default:
157
158 sentence += "";
159 break;
160 }
161
162 sentence += ReferenceTarget;
163
164 sentence.Finish();
165
166 return( TRUE );
167}
168
169const TTM& TTM::operator = ( const TTM& source )
170{
171 TargetNumber = source.TargetNumber;
172 TargetDistance = source.TargetDistance;
173 BearingFromOwnShip = source.BearingFromOwnShip;
174 BearingUnits = source.BearingUnits;
175 TargetSpeed = source.TargetSpeed;
176 TargetCourse = source.TargetCourse;
177 TargetCourseUnits = source.TargetCourseUnits;
178 DistanceOfClosestPointOfApproach = source.DistanceOfClosestPointOfApproach;
179 NumberOfMinutesToClosestPointOfApproach = source.NumberOfMinutesToClosestPointOfApproach;
180 Increasing = source.Increasing;
181 TargetName = source.TargetName;
182 TargetStatus = source.TargetStatus;
183
184 return( *this );
185}
Note: See TracBrowser for help on using the repository browser.