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: rsa.cpp $
|
---|
13 | ** $Revision: 4 $
|
---|
14 | ** $Modtime: 10/10/98 2:43p $
|
---|
15 | */
|
---|
16 |
|
---|
17 |
|
---|
18 | RSA::RSA()
|
---|
19 | {
|
---|
20 | Mnemonic = "RSA";
|
---|
21 | Empty();
|
---|
22 | }
|
---|
23 |
|
---|
24 | RSA::~RSA()
|
---|
25 | {
|
---|
26 | //Mnemonic.Empty();
|
---|
27 | Empty();
|
---|
28 | }
|
---|
29 |
|
---|
30 | void RSA::Empty( void )
|
---|
31 | {
|
---|
32 | Starboard = 0.0;
|
---|
33 | IsStarboardDataValid = NMEA_Unknown;
|
---|
34 | Port = 0.0;
|
---|
35 | IsPortDataValid = NMEA_Unknown;
|
---|
36 | }
|
---|
37 |
|
---|
38 | BOOL RSA::Parse( const SENTENCE& sentence )
|
---|
39 | {
|
---|
40 | /*
|
---|
41 | ** RSA - Rudder Sensor Angle
|
---|
42 | **
|
---|
43 | ** 1 2 3 4 5
|
---|
44 | ** | | | | |
|
---|
45 | ** $--RSA,x.x,A,x.x,A*hh<CR><LF>
|
---|
46 | **
|
---|
47 | ** Field Number:
|
---|
48 | ** 1) Starboard (or single) rudder sensor, "-" means Turn To Port
|
---|
49 | ** 2) Status, A means data is valid
|
---|
50 | ** 3) Port rudder sensor
|
---|
51 | ** 4) Status, A means data is valid
|
---|
52 | ** 5) Checksum
|
---|
53 | */
|
---|
54 |
|
---|
55 | /*
|
---|
56 | ** First we check the checksum...
|
---|
57 | */
|
---|
58 |
|
---|
59 | if ( sentence.IsChecksumBad( 5 ) == True )
|
---|
60 | {
|
---|
61 | SetErrorMessage( "Invalid Checksum" );
|
---|
62 | return( FALSE );
|
---|
63 | }
|
---|
64 |
|
---|
65 | Starboard = sentence.Double( 1 );
|
---|
66 | IsStarboardDataValid = sentence.Boolean( 2 );
|
---|
67 | Port = sentence.Double( 3 );
|
---|
68 | IsPortDataValid = sentence.Boolean( 4 );
|
---|
69 |
|
---|
70 | return( TRUE );
|
---|
71 | }
|
---|
72 |
|
---|
73 | BOOL RSA::Write( SENTENCE& sentence )
|
---|
74 | {
|
---|
75 | /*
|
---|
76 | ** Let the parent do its thing
|
---|
77 | */
|
---|
78 |
|
---|
79 | RESPONSE::Write( sentence );
|
---|
80 |
|
---|
81 | sentence += Starboard;
|
---|
82 | sentence += IsStarboardDataValid;
|
---|
83 | sentence += Port;
|
---|
84 | sentence += IsPortDataValid;
|
---|
85 |
|
---|
86 | sentence.Finish();
|
---|
87 |
|
---|
88 | return( TRUE );
|
---|
89 | }
|
---|
90 |
|
---|
91 | const RSA& RSA::operator = ( const RSA& source )
|
---|
92 | {
|
---|
93 | Starboard = source.Starboard;
|
---|
94 | IsStarboardDataValid = source.IsStarboardDataValid;
|
---|
95 | Port = source.Port;
|
---|
96 | IsPortDataValid = source.IsPortDataValid;
|
---|
97 |
|
---|
98 | return( *this );
|
---|
99 | }
|
---|