[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: rsd.cpp $
|
---|
| 13 | ** $Revision: 4 $
|
---|
| 14 | ** $Modtime: 10/10/98 2:43p $
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | RSD::RSD()
|
---|
| 20 | {
|
---|
| 21 | Mnemonic = "RSD";
|
---|
| 22 | Empty();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | RSD::~RSD()
|
---|
| 26 | {
|
---|
| 27 | //Mnemonic.Empty();
|
---|
| 28 | Empty();
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | void RSD::Empty( void )
|
---|
| 32 | {
|
---|
| 33 | Data1.Empty();
|
---|
| 34 | Data2.Empty();
|
---|
| 35 | CursorRangeFromOwnShip = 0.0;
|
---|
| 36 | CursorBearingDegreesClockwiseFromZero = 0.0;
|
---|
| 37 | RangeScale = 0.0;
|
---|
| 38 | //RangeUnits.Empty();
|
---|
| 39 | DisplayRotation = RotationUnknown;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | BOOL RSD::Parse( const SENTENCE& sentence )
|
---|
| 43 | {
|
---|
| 44 | /*
|
---|
| 45 | ** RSD - RADAR System Data
|
---|
| 46 | ** 14
|
---|
| 47 | ** 1 2 3 4 5 6 7 8 9 10 11 12 13|
|
---|
| 48 | ** | | | | | | | | | | | | | |
|
---|
| 49 | ** $--RSD,x.x,x.x,x.x,x.x,x.x,x.x,x.x,x.x,x.x,x.x,x.x,a,a*hh<CR><LF>
|
---|
| 50 | **
|
---|
| 51 | ** 14) Checksum
|
---|
| 52 | */
|
---|
| 53 |
|
---|
| 54 | /*
|
---|
| 55 | ** First we check the checksum...
|
---|
| 56 | */
|
---|
| 57 |
|
---|
| 58 | if ( sentence.IsChecksumBad( 14 ) == True )
|
---|
| 59 | {
|
---|
| 60 | SetErrorMessage( "Invalid Checksum" );
|
---|
| 61 | return( FALSE );
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | Data1.Parse( 1, sentence );
|
---|
| 65 | Data2.Parse( 5, sentence );
|
---|
| 66 | CursorRangeFromOwnShip = sentence.Double( 9 );
|
---|
| 67 | CursorBearingDegreesClockwiseFromZero = sentence.Double( 10 );
|
---|
| 68 | RangeScale = sentence.Double( 11 );
|
---|
| 69 | RangeUnits = sentence.Field( 12 );
|
---|
| 70 |
|
---|
| 71 | int temp_integer = sentence.Integer( 13 );
|
---|
| 72 |
|
---|
| 73 | switch( temp_integer )
|
---|
| 74 | {
|
---|
| 75 | case 'C':
|
---|
| 76 |
|
---|
| 77 | DisplayRotation = CourseUpRotation;
|
---|
| 78 | break;
|
---|
| 79 |
|
---|
| 80 | case 'H':
|
---|
| 81 |
|
---|
| 82 | DisplayRotation = HeadUpRotation;
|
---|
| 83 | break;
|
---|
| 84 |
|
---|
| 85 | case 'N':
|
---|
| 86 |
|
---|
| 87 | DisplayRotation = NorthUpRotation;
|
---|
| 88 | break;
|
---|
| 89 |
|
---|
| 90 | default:
|
---|
| 91 |
|
---|
| 92 | DisplayRotation = RotationUnknown;
|
---|
| 93 | break;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | return( TRUE );
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | BOOL RSD::Write( SENTENCE& sentence )
|
---|
| 100 | {
|
---|
| 101 | /*
|
---|
| 102 | ** Let the parent do its thing
|
---|
| 103 | */
|
---|
| 104 |
|
---|
| 105 | RESPONSE::Write( sentence );
|
---|
| 106 |
|
---|
| 107 | Data1.Write( sentence );
|
---|
| 108 | Data2.Write( sentence );
|
---|
| 109 | sentence += CursorRangeFromOwnShip;
|
---|
| 110 | sentence += CursorBearingDegreesClockwiseFromZero;
|
---|
| 111 | sentence += RangeScale;
|
---|
| 112 | sentence += RangeUnits;
|
---|
| 113 |
|
---|
| 114 | switch( DisplayRotation )
|
---|
| 115 | {
|
---|
| 116 | case CourseUpRotation:
|
---|
| 117 |
|
---|
| 118 | sentence += "C";
|
---|
| 119 | break;
|
---|
| 120 |
|
---|
| 121 | case HeadUpRotation:
|
---|
| 122 |
|
---|
| 123 | sentence += "H";
|
---|
| 124 | break;
|
---|
| 125 |
|
---|
| 126 | case NorthUpRotation:
|
---|
| 127 |
|
---|
| 128 | sentence += "N";
|
---|
| 129 | break;
|
---|
| 130 |
|
---|
| 131 | default:
|
---|
| 132 |
|
---|
| 133 | sentence += "";
|
---|
| 134 | break;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | sentence.Finish();
|
---|
| 138 |
|
---|
| 139 | return( TRUE );
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | const RSD& RSD::operator = ( const RSD& source )
|
---|
| 143 | {
|
---|
| 144 | Data1 = source.Data1;
|
---|
| 145 | Data2 = source.Data2;
|
---|
| 146 | CursorRangeFromOwnShip = source.CursorRangeFromOwnShip;
|
---|
| 147 | CursorBearingDegreesClockwiseFromZero = source.CursorBearingDegreesClockwiseFromZero;
|
---|
| 148 | RangeScale = source.RangeScale;
|
---|
| 149 | RangeUnits = source.RangeUnits;
|
---|
| 150 | DisplayRotation = source.DisplayRotation;
|
---|
| 151 |
|
---|
| 152 | return( *this );
|
---|
| 153 | }
|
---|