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

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

* empty log message *

File size: 3.1 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: RTCM3Decoder
7 *
8 * Purpose: RTCM3 Decoder
9 *
10 * Author: L. Mervart
11 *
12 * Created: 24-Aug-2006
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19#include <math.h>
20
21#include "RTCM3Decoder.h"
22#include "bncconst.h"
23
24using namespace std;
25
26#ifndef isinf
27# define isinf(x) 0
28#endif
29
30// Constructor
31////////////////////////////////////////////////////////////////////////////
32RTCM3Decoder::RTCM3Decoder() : GPSDecoder() {
33 memset(&_Parser, 0, sizeof(_Parser));
34 time_t tim;
35 tim = time(0) - ((10*365+2+5)*24*60*60 + LEAPSECONDS);
36 _Parser.GPSWeek = tim/(7*24*60*60);
37 _Parser.GPSTOW = tim%(7*24*60*60);
38}
39
40// Destructor
41////////////////////////////////////////////////////////////////////////////
42RTCM3Decoder::~RTCM3Decoder() {
43}
44
45//
46////////////////////////////////////////////////////////////////////////////
47void RTCM3Decoder::Decode(char* buffer, int bufLen) {
48 for (int ii = 0; ii < bufLen; ii++) {
49
50 _Parser.Message[_Parser.MessageSize++] = buffer[ii];
51 if (_Parser.MessageSize >= _Parser.NeedBytes) {
52
53 while(int rr = RTCM3Parser(&_Parser)) {
54
55 if (!_Parser.init) {
56 HandleHeader(&_Parser);
57 _Parser.init = 1;
58 }
59
60 if (rr == 2) {
61 std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
62 exit(1);
63 }
64
65 for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
66 Observation* obs = new Observation();
67 obs->SVPRN = _Parser.Data.satellites[ii];
68 obs->GPSWeek = _Parser.Data.week;
69 obs->GPSWeeks = _Parser.Data.timeofweek / 1000.0;
70
71 for (int jj = 0; jj < _Parser.numdatatypes; jj++) {
72
73 if ( !(_Parser.Data.dataflags[ii] & _Parser.dataflag[jj])
74 || isnan(_Parser.Data.measdata[ii][_Parser.datapos[jj]])
75 || isinf(_Parser.Data.measdata[ii][_Parser.datapos[jj]]) ) {
76 continue;
77 }
78
79 if (_Parser.dataflag[jj] & GNSSDF_C1DATA) {
80 obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
81 }
82 else if (_Parser.dataflag[jj] & GNSSDF_P1DATA) {
83 obs->P1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
84 }
85 else if (_Parser.dataflag[jj] & GNSSDF_P2DATA) {
86 obs->P2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
87 }
88 else if (_Parser.dataflag[jj] & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
89 obs->L1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
90 obs->SNR1 = _Parser.Data.snrL1[ii];
91 }
92 else if (_Parser.dataflag[jj] & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
93 obs->L2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
94 obs->SNR2 = _Parser.Data.snrL2[ii];
95 }
96 }
97 _obsList.push_back(obs);
98 }
99 }
100 }
101 }
102}
Note: See TracBrowser for help on using the repository browser.