[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: osd.cpp $
|
---|
| 13 | ** $Revision: 4 $
|
---|
| 14 | ** $Modtime: 10/10/98 2:42p $
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | OSD::OSD()
|
---|
| 20 | {
|
---|
| 21 | Mnemonic = "OSD";
|
---|
| 22 | Empty();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | OSD::~OSD()
|
---|
| 26 | {
|
---|
| 27 | //Mnemonic.Empty();
|
---|
| 28 | Empty();
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | void OSD::Empty( void )
|
---|
| 32 | {
|
---|
| 33 | HeadingDegreesTrue = 0.0;
|
---|
| 34 | IsHeadingValid = NMEA_Unknown;
|
---|
| 35 | VesselCourseDegreesTrue = 0.0;
|
---|
| 36 | VesselCourseReference = ReferenceUnknown;
|
---|
| 37 | VesselSpeed = 0.0;
|
---|
| 38 | VesselSpeedReference = ReferenceUnknown;
|
---|
| 39 | VesselSetDegreesTrue = 0.0;
|
---|
| 40 | VesselDriftSpeed = 0.0;
|
---|
| 41 | //VesselDriftSpeedUnits.Empty();
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | BOOL OSD::Parse( const SENTENCE& sentence )
|
---|
| 45 | {
|
---|
| 46 | /*
|
---|
| 47 | ** OSD - Own Ship Data
|
---|
| 48 | **
|
---|
| 49 | ** 1 2 3 4 5 6 7 8 9 10
|
---|
| 50 | ** | | | | | | | | | |
|
---|
| 51 | ** $--OSD,x.x,A,x.x,a,x.x,a,x.x,x.x,a*hh<CR><LF>
|
---|
| 52 | **
|
---|
| 53 | ** 1) Heading, degrees true
|
---|
| 54 | ** 2) Status, A = Data Valid
|
---|
| 55 | ** 3) Vessel Course, degrees True
|
---|
| 56 | ** 4) Course Reference
|
---|
| 57 | ** 5) Vessel Speed
|
---|
| 58 | ** 6) Speed Reference
|
---|
| 59 | ** 7) Vessel Set, degrees True
|
---|
| 60 | ** 8) Vessel drift (speed)
|
---|
| 61 | ** 9) Speed Units
|
---|
| 62 | ** 10) Checksum
|
---|
| 63 | */
|
---|
| 64 |
|
---|
| 65 | /*
|
---|
| 66 | ** First we check the checksum...
|
---|
| 67 | */
|
---|
| 68 |
|
---|
| 69 | if ( sentence.IsChecksumBad( 10 ) == True )
|
---|
| 70 | {
|
---|
| 71 | SetErrorMessage( "Invalid Checksum" );
|
---|
| 72 | return( FALSE );
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | HeadingDegreesTrue = sentence.Double( 1 );
|
---|
| 76 | IsHeadingValid = sentence.Boolean( 2 );
|
---|
| 77 | VesselCourseDegreesTrue = sentence.Double( 3 );
|
---|
| 78 | VesselCourseReference = sentence.Reference( 4 );
|
---|
| 79 | VesselSpeed = sentence.Double( 5 );
|
---|
| 80 | VesselSpeedReference = sentence.Reference( 6 );
|
---|
| 81 | VesselSetDegreesTrue = sentence.Double( 7 );
|
---|
| 82 | VesselDriftSpeed = sentence.Double( 8 );
|
---|
| 83 | VesselDriftSpeedUnits = sentence.Field( 9 );
|
---|
| 84 |
|
---|
| 85 | return( TRUE );
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | BOOL OSD::Write( SENTENCE& sentence )
|
---|
| 89 | {
|
---|
| 90 | /*
|
---|
| 91 | ** Let the parent do its thing
|
---|
| 92 | */
|
---|
| 93 |
|
---|
| 94 | RESPONSE::Write( sentence );
|
---|
| 95 |
|
---|
| 96 | sentence += HeadingDegreesTrue;
|
---|
| 97 | sentence += IsHeadingValid;
|
---|
| 98 | sentence += VesselCourseDegreesTrue;
|
---|
| 99 | sentence += VesselCourseReference;
|
---|
| 100 | sentence += VesselSpeed;
|
---|
| 101 | sentence += VesselSpeedReference;
|
---|
| 102 | sentence += VesselSetDegreesTrue;
|
---|
| 103 | sentence += VesselDriftSpeed;
|
---|
| 104 | sentence += VesselDriftSpeedUnits;
|
---|
| 105 |
|
---|
| 106 | sentence.Finish();
|
---|
| 107 |
|
---|
| 108 | return( TRUE );
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | const OSD& OSD::operator = ( const OSD& source )
|
---|
| 112 | {
|
---|
| 113 | HeadingDegreesTrue = source.HeadingDegreesTrue;
|
---|
| 114 | IsHeadingValid = source.IsHeadingValid;
|
---|
| 115 | VesselCourseDegreesTrue = source.VesselCourseDegreesTrue;
|
---|
| 116 | VesselCourseReference = source.VesselCourseReference;
|
---|
| 117 | VesselSpeed = source.VesselSpeed;
|
---|
| 118 | VesselSpeedReference = source.VesselSpeedReference;
|
---|
| 119 | VesselSetDegreesTrue = source.VesselSetDegreesTrue;
|
---|
| 120 | VesselDriftSpeed = source.VesselDriftSpeed;
|
---|
| 121 | VesselDriftSpeedUnits = source.VesselDriftSpeedUnits;
|
---|
| 122 |
|
---|
| 123 | return( *this );
|
---|
| 124 | }
|
---|