source: pacpussensors/trunk/NMEA0183/src/DPT.cpp@ 92

Last change on this file since 92 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: 1.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: dpt.cpp $
13** $Revision: 5 $
14** $Modtime: 10/10/98 2:46p $
15*/
16
17
18
19DPT::DPT()
20{
21 Mnemonic = "DPT";
22 Empty();
23}
24
25DPT::~DPT()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void DPT::Empty( void )
32{
33 DepthMeters = 0.0;
34 OffsetFromTransducerMeters = 0.0;
35}
36
37BOOL DPT::Parse( const SENTENCE& sentence )
38{
39 /*
40 ** DPT - Heading - Deviation & Variation
41 **
42 ** 1 2 3
43 ** | | |
44 ** $--DPT,x.x,x.x*hh<CR><LF>
45 **
46 ** Field Number:
47 ** 1) Depth, meters
48 ** 2) Offset from transducer,
49 ** positive means distance from tansducer to water line
50 ** negative means distance from transducer to keel
51 ** 3) Checksum
52 */
53
54 /*
55 ** First we check the checksum...
56 */
57
58 if ( sentence.IsChecksumBad( 3 ) == True )
59 {
60 SetErrorMessage( "Invalid Checksum" );
61 return( FALSE );
62 }
63
64 DepthMeters = sentence.Double( 1 );
65 OffsetFromTransducerMeters = sentence.Double( 2 );
66
67 return( TRUE );
68}
69
70BOOL DPT::Write( SENTENCE& sentence )
71{
72 /*
73 ** Let the parent do its thing
74 */
75
76 RESPONSE::Write( sentence );
77
78 sentence += DepthMeters;
79 sentence += OffsetFromTransducerMeters;
80
81 sentence.Finish();
82
83 return( TRUE );
84}
85
86const DPT& DPT::operator = ( const DPT& source )
87{
88 DepthMeters = source.DepthMeters;
89 OffsetFromTransducerMeters = source.OffsetFromTransducerMeters;
90
91 return( *this );
92}
Note: See TracBrowser for help on using the repository browser.