source: ntrip/trunk/BNC/RTCM3/RTCM3Decoder.cpp@ 504

Last change on this file since 504 was 504, checked in by mervart, 17 years ago

* empty log message *

File size: 5.2 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: RTCM3Decoder
30 *
31 * Purpose: RTCM3 Decoder
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Aug-2006
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include <math.h>
43
44#include "RTCM3Decoder.h"
45#include "bncconst.h"
46
47using namespace std;
48
49#ifndef isinf
50# define isinf(x) 0
51#endif
52
53#define LEAPSECONDS 14 /* only needed for approx. time */
54
55// Error Handling
56////////////////////////////////////////////////////////////////////////////
57void RTCM3Error(const char*, ...) {
58
59}
60
61// Constructor
62////////////////////////////////////////////////////////////////////////////
63RTCM3Decoder::RTCM3Decoder() : GPSDecoder() {
64 memset(&_Parser, 0, sizeof(_Parser));
65 time_t tim;
66 tim = time(0) - ((10*365+2+5)*24*60*60 + LEAPSECONDS);
67 _Parser.GPSWeek = tim/(7*24*60*60);
68 _Parser.GPSTOW = tim%(7*24*60*60);
69}
70
71// Destructor
72////////////////////////////////////////////////////////////////////////////
73RTCM3Decoder::~RTCM3Decoder() {
74}
75
76//
77////////////////////////////////////////////////////////////////////////////
78void RTCM3Decoder::Decode(char* buffer, int bufLen) {
79 for (int ii = 0; ii < bufLen; ii++) {
80
81 _Parser.Message[_Parser.MessageSize++] = buffer[ii];
82 if (_Parser.MessageSize >= _Parser.NeedBytes) {
83
84 while(int rr = RTCM3Parser(&_Parser)) {
85
86 if (!_Parser.init) {
87 HandleHeader(&_Parser);
88 _Parser.init = 1;
89 }
90
91 if (rr == 2) {
92 std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
93 }
94
95 for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
96 Observation* obs = new Observation();
97 if (_Parser.Data.satellites[ii] <= PRN_GPS_END) {
98 obs->satSys = 'G';
99 obs->satNum = _Parser.Data.satellites[ii];
100 }
101 else {
102 obs->satSys = 'R';
103 obs->satNum = _Parser.Data.satellites[ii] - PRN_GLONASS_START + 1;
104 }
105 obs->GPSWeek = _Parser.Data.week;
106 obs->GPSWeeks = _Parser.Data.timeofweek / 1000.0;
107
108 for (int jj = 0; jj < _Parser.numdatatypesGPS; jj++) {
109 int v = 0;
110 int df = _Parser.dataflag[jj];
111 int pos = _Parser.datapos[jj];
112 if ( (_Parser.Data.dataflags[ii] & df)
113 && !isnan(_Parser.Data.measdata[ii][pos])
114 && !isinf(_Parser.Data.measdata[ii][pos])) {
115 v = 1;
116 }
117 else {
118 df = _Parser.dataflagGPS[jj];
119 pos = _Parser.dataposGPS[jj];
120 if ( (_Parser.Data.dataflags[ii] & df)
121 && !isnan(_Parser.Data.measdata[ii][pos])
122 && !isinf(_Parser.Data.measdata[ii][pos])) {
123 v = 1;
124 }
125 }
126 if(!v)
127 { continue; }
128 else
129 {
130 if (_Parser.dataflag[jj] & GNSSDF_C1DATA) {
131 obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
132 }
133 else if (_Parser.dataflag[jj] & GNSSDF_C2DATA) {
134 obs->C2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
135 }
136 else if (_Parser.dataflag[jj] & GNSSDF_P1DATA) {
137 obs->P1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
138 }
139 else if (_Parser.dataflag[jj] & GNSSDF_P2DATA) {
140 obs->P2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
141 }
142 else if (df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
143 obs->L1 = _Parser.Data.measdata[ii][pos];
144 obs->SNR1 = _Parser.Data.snrL1[ii];
145 }
146 else if (df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
147 obs->L2 = _Parser.Data.measdata[ii][pos];
148 obs->SNR2 = _Parser.Data.snrL2[ii];
149 }
150 else if (df & (GNSSDF_S1CDATA|GNSSDF_S1PDATA)) {
151 obs->S1 = _Parser.Data.measdata[ii][pos];
152 }
153 else if (df & (GNSSDF_S2CDATA|GNSSDF_S2PDATA)) {
154 obs->S2 = _Parser.Data.measdata[ii][pos];
155 }
156 }
157 }
158 _obsList.push_back(obs);
159 }
160 }
161 }
162 }
163}
Note: See TracBrowser for help on using the repository browser.