source: pacpussensors/trunk/NMEA0183/src/APB.cpp@ 109

Last change on this file since 109 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: apb.cpp $
13** $Revision: 5 $
14** $Modtime: 10/10/98 2:41p $
15*/
16
17
18
19APB::APB()
20{
21 Mnemonic = "APB";
22 Empty();
23}
24
25APB::~APB()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void APB::Empty( void )
32{
33 CrossTrackErrorMagnitude = 0.0;
34 DirectionToSteer = LR_Unknown;
35 //CrossTrackUnits.Empty();
36 //To.Empty();
37 IsArrivalCircleEntered = NMEA_Unknown;
38 IsPerpendicular = NMEA_Unknown;
39}
40
41BOOL APB::Parse( const SENTENCE& sentence )
42{
43 QString field_data;
44
45 /*
46 ** APB - Autopilot Sentence "B"
47 ** 13 15
48 ** 1 2 3 4 5 6 7 8 9 10 11 12| 14|
49 ** | | | | | | | | | | | | | | |
50 ** $--APB,A,A,x.x,a,N,A,A,x.x,a,c--c,x.x,a,x.x,a*hh<CR><LF>
51 **
52 ** 1) Status
53 ** V = LORAN-C Blink or SNR warning
54 ** V = general warning flag or other navigation systems when a reliable
55 ** fix is not available
56 ** 2) Status
57 ** V = Loran-C Cycle Lock warning flag
58 ** A = OK or not used
59 ** 3) Cross Track Error Magnitude
60 ** 4) Direction to steer, L or R
61 ** 5) Cross Track Units, N = Nautical Miles
62 ** 6) Status
63 ** A = Arrival Circle Entered
64 ** 7) Status
65 ** A = Perpendicular passed at waypoint
66 ** 8) Bearing origin to destination
67 ** 9) M = Magnetic, T = True
68 ** 10) Destination Waypoint ID
69 ** 11) Bearing, present position to Destination
70 ** 12) M = Magnetic, T = True
71 ** 13) Heading to steer to destination waypoint
72 ** 14) M = Magnetic, T = True
73 ** 15) Checksum
74 */
75
76 /*
77 ** First we check the checksum...
78 */
79
80 if ( sentence.IsChecksumBad( 15 ) == True )
81 {
82 SetErrorMessage( "Invalid Checksum" );
83 return( FALSE );
84 }
85
86 /*
87 ** Line has already been checked for checksum validity
88 */
89
90 IsLoranBlinkOK = sentence.Boolean( 1 );
91 IsLoranCCycleLockOK = sentence.Boolean( 2 );
92 CrossTrackErrorMagnitude = sentence.Double( 3 );
93 DirectionToSteer = sentence.LeftOrRight( 4 );
94 CrossTrackUnits = sentence.Field( 5 );
95 IsArrivalCircleEntered = sentence.Boolean( 6 );
96 IsPerpendicular = sentence.Boolean( 7 );
97 BearingOriginToDestination = sentence.Double( 8 );
98 BearingOriginToDestinationUnits = sentence.Field( 9 );
99 To = sentence.Field( 10 );
100 BearingPresentPositionToDestination = sentence.Double( 11 );
101 BearingPresentPositionToDestinationUnits = sentence.Field( 12 );
102 HeadingToSteer = sentence.Double( 13 );
103 HeadingToSteerUnits = sentence.Field( 14 );
104
105 return( TRUE );
106}
107
108BOOL APB::Write( SENTENCE& sentence )
109{
110 /*
111 ** Let the parent do its thing
112 */
113
114 RESPONSE::Write( sentence );
115
116 sentence += IsLoranBlinkOK;
117 sentence += IsLoranCCycleLockOK;
118 sentence += CrossTrackErrorMagnitude;
119 sentence += DirectionToSteer;
120 sentence += CrossTrackUnits;
121 sentence += IsArrivalCircleEntered;
122 sentence += IsPerpendicular;
123 sentence += BearingOriginToDestination;
124 sentence += BearingOriginToDestinationUnits;
125 sentence += To;
126 sentence += BearingPresentPositionToDestination;
127 sentence += BearingPresentPositionToDestinationUnits;
128 sentence += HeadingToSteer;
129 sentence += HeadingToSteerUnits;
130
131 sentence.Finish();
132
133 return( TRUE );
134}
135
136const APB& APB::operator = ( const APB& source )
137{
138 IsLoranBlinkOK = source.IsLoranBlinkOK;
139 IsLoranCCycleLockOK = source.IsLoranCCycleLockOK;
140 CrossTrackErrorMagnitude = source.CrossTrackErrorMagnitude;
141 DirectionToSteer = source.DirectionToSteer;
142 CrossTrackUnits = source.CrossTrackUnits;
143 IsArrivalCircleEntered = source.IsArrivalCircleEntered;
144 IsPerpendicular = source.IsPerpendicular;
145 BearingOriginToDestination = source.BearingOriginToDestination;
146 BearingOriginToDestinationUnits = source.BearingOriginToDestinationUnits;
147 To = source.To;
148 BearingPresentPositionToDestination = source.BearingPresentPositionToDestination;
149 BearingPresentPositionToDestinationUnits = source.BearingPresentPositionToDestinationUnits;
150 HeadingToSteer = source.HeadingToSteer;
151 HeadingToSteerUnits = source.HeadingToSteerUnits;
152
153 return( *this );
154}
Note: See TracBrowser for help on using the repository browser.