source: ntrip/trunk/BNC/RTCM3/rtcm3.cpp@ 246

Last change on this file since 246 was 246, checked in by mervart, 18 years ago

* empty log message *

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