source: pacpussensors/trunk/NMEA0183/src/IMA.cpp@ 59

Last change on this file since 59 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: 2.7 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: ima.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:44p $
15*/
16
17/*
18** This Sentence Not Recommended For New Designs
19** There is no recommended replacement.
20*/
21
22
23
24IMA::IMA()
25{
26 Mnemonic = "IMA";
27 Empty();
28}
29
30IMA::~IMA()
31{
32 //Mnemonic.Empty();
33 Empty();
34}
35
36void IMA::Empty( void )
37{
38 //VesselName.Empty();
39 //Callsign.Empty();
40 HeadingDegreesTrue = 0.0;
41 HeadingDegreesMagnetic = 0.0;
42 SpeedKnots = 0.0;
43}
44
45BOOL IMA::Parse( const SENTENCE& sentence )
46{
47 /*
48 ** IMA - Vessel Identification
49 ** 11 13
50 ** 1 2 3 4 5 6 7 8 9 10| 12|
51 ** | | | | | | | | | | | | |
52 ** $--IMA,aaaaaaaaaaaa,aaaxxxx,llll.ll,a,yyyyy.yy,a,x.x,T,x.x,M,x.x,N*hh<CR><LF>
53 **
54 ** 1) Twelve character vessel name
55 ** 2) Radio Call Sign
56 ** 3) Latitude
57 ** 4) North/South
58 ** 5) Longitude
59 ** 6) East/West
60 ** 7) Heading, degrees true
61 ** 8) T = True
62 ** 9) Heading, degrees magnetic
63 ** 10) M = Magnetic
64 ** 11) Speed
65 ** 12) N = Knots
66 ** 13) Checksum
67 */
68
69 /*
70 ** First we check the checksum...
71 */
72
73 if ( sentence.IsChecksumBad( 13 ) == True )
74 {
75 SetErrorMessage( "Invalid Checksum" );
76 return( FALSE );
77 }
78
79 VesselName = sentence.Field( 1 );
80 Callsign = sentence.Field( 2 );
81 Position.Parse( 3, 4, 5, 6, sentence );
82 HeadingDegreesTrue = sentence.Double( 7 );
83 HeadingDegreesMagnetic = sentence.Double( 9 );
84 SpeedKnots = sentence.Double( 11 );
85
86 return( TRUE );
87}
88
89BOOL IMA::Write( SENTENCE& sentence )
90{
91 /*
92 ** Let the parent do its thing
93 */
94
95 RESPONSE::Write( sentence );
96
97 sentence += VesselName;
98 sentence += Callsign;
99 sentence += Position;
100 sentence += HeadingDegreesTrue;
101 sentence += "T";
102 sentence += HeadingDegreesMagnetic;
103 sentence += "M";
104 sentence += SpeedKnots;
105 sentence += "N";
106
107 sentence.Finish();
108
109 return( TRUE );
110}
111
112const IMA& IMA::operator = ( const IMA& source )
113{
114 VesselName = source.VesselName;
115 Callsign = source.Callsign;
116 Position = source.Position;
117 HeadingDegreesTrue = source.HeadingDegreesTrue;
118 HeadingDegreesMagnetic = source.HeadingDegreesMagnetic;
119 SpeedKnots = source.SpeedKnots;
120
121 return( *this );
122}
Note: See TracBrowser for help on using the repository browser.