source: pacpussensors/trunk/NMEA0183/src/SFI.cpp@ 85

Last change on this file since 85 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
RevLine 
[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: sfi.cpp $
13** $Revision: 4 $
14** $Modtime: 10/10/98 2:37p $
15*/
16
17
18
19SFI::SFI()
20{
21 Mnemonic = "SFI";
22 Empty();
23}
24
25SFI::~SFI()
26{
27 //Mnemonic.Empty();
28 Empty();
29}
30
31void SFI::Empty( void )
32{
33 TotalMessages = 0.0;
34 MessageNumber = 0.0;
35
36 int index = 0;
37
38 while( index < 6 )
39 {
40 Frequencies[ index ].Empty();
41 index++;
42 }
43
44}
45
46BOOL SFI::Parse( const SENTENCE& sentence )
47{
48 /*
49 ** SFI - Scanning Frequency Information
50 **
51 ** 1 2 3 4 x
52 ** | | | | |
53 ** $--SFI,x.x,x.x,xxxxxx,c .......... xxxxxx,c*hh<CR><LF>
54 **
55 ** 1) Total Number Of Messages
56 ** 2) Message Number
57 ** 3) Frequency 1
58 ** 4) Mode 1
59 ** x) Checksum
60 */
61
62 /*
63 ** First we check the checksum...
64 */
65
66 int number_of_data_fields = sentence.GetNumberOfDataFields();
67
68 if ( sentence.IsChecksumBad( number_of_data_fields + 1 ) == True )
69 {
70 SetErrorMessage( "Invalid Checksum" );
71 return( FALSE );
72 }
73
74 TotalMessages = sentence.Double( 1 );
75 MessageNumber = sentence.Double( 2 );
76
77 /*
78 ** Clear out any old data
79 */
80
81 int index = 0;
82
83 while( index < 6 )
84 {
85 Frequencies[ index ].Empty();
86 index++;
87 }
88
89 int number_of_frequencies = ( number_of_data_fields - 2 ) / 2;
90 int frequency_number = 0;
91
92 /*
93 ** index is the number of data fields before the frequency/mode +
94 ** the frequency number times the number of fields in a FREQUENC_AND_MODE
95 */
96
97 while( frequency_number < number_of_frequencies )
98 {
99 index = 2 + ( frequency_number * 2 );
100
101 Frequencies[ frequency_number ].Parse( index, sentence );
102
103 frequency_number++;
104 }
105
106 return( TRUE );
107}
108
109BOOL SFI::Write( SENTENCE& sentence )
110{
111 /*
112 ** Let the parent do its thing
113 */
114
115 RESPONSE::Write( sentence );
116
117 sentence += TotalMessages;
118 sentence += MessageNumber;
119
120 int index = 0;
121
122 while( index < 6 )
123 {
124 Frequencies[ index ].Write( sentence );
125 index++;
126 }
127
128 sentence.Finish();
129
130 return( TRUE );
131}
132
133const SFI& SFI::operator = ( const SFI& source )
134{
135 TotalMessages = source.TotalMessages;
136 MessageNumber = source.MessageNumber;
137
138 int index = 0;
139
140 while( index < 6 )
141 {
142 Frequencies[ index ] = source.Frequencies[ index ];
143 index++;
144 }
145
146 return( *this );
147}
Note: See TracBrowser for help on using the repository browser.