[65] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
| 3 | * Bernese 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 "rtcm3.h"
|
---|
| 19 |
|
---|
| 20 | using namespace std;
|
---|
| 21 |
|
---|
| 22 | // Constructor
|
---|
| 23 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 24 | rtcm3::rtcm3() : GPSDecoder() {
|
---|
| 25 | memset(&_Parser, 0, sizeof(_Parser));
|
---|
| 26 | time_t tim;
|
---|
| 27 | tim = time(0) - ((10*365+2+5)*24*60*60 + LEAPSECONDS);
|
---|
| 28 | _Parser.GPSWeek = tim/(7*24*60*60);
|
---|
[71] | 29 | _Parser.GPSTOW = tim%(7*24*60*60);
|
---|
[65] | 30 | }
|
---|
| 31 |
|
---|
| 32 | // Destructor
|
---|
| 33 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 34 | rtcm3::~rtcm3() {
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | //
|
---|
| 38 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 39 | void rtcm3::Decode(char* buffer, int bufLen) {
|
---|
| 40 | for (int ii = 0; ii < bufLen; ii++) {
|
---|
[71] | 41 |
|
---|
[72] | 42 | #if 0
|
---|
| 43 | HandleByte(&_Parser, buffer[ii]);
|
---|
| 44 | continue;
|
---|
| 45 | #endif
|
---|
[71] | 46 |
|
---|
| 47 | _Parser.Message[_Parser.MessageSize++] = buffer[ii];
|
---|
[72] | 48 | if (_Parser.MessageSize >= _Parser.NeedBytes) {
|
---|
| 49 |
|
---|
| 50 | while(int rr = RTCM3Parser(&_Parser)) {
|
---|
| 51 |
|
---|
| 52 | if (!_Parser.init) {
|
---|
[71] | 53 | HandleHeader(&_Parser);
|
---|
| 54 | _Parser.init = 1;
|
---|
| 55 | }
|
---|
[72] | 56 |
|
---|
| 57 | if (rr == 2) {
|
---|
| 58 | cerr << "No valid RINEX! All values are modulo 299792.458!\n";
|
---|
| 59 | exit(1);
|
---|
[71] | 60 | }
|
---|
[72] | 61 |
|
---|
| 62 | for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
|
---|
| 63 | Observation* obs = new Observation();
|
---|
| 64 |
|
---|
| 65 | //// obs->statID =
|
---|
| 66 | obs->SVPRN = _Parser.Data.satellites[ii];
|
---|
| 67 | obs->GPSWeek = _Parser.Data.week;
|
---|
| 68 | obs->GPSWeeks = (int) (_Parser.Data.timeofweek / 1000.0);
|
---|
| 69 | obs->sec = fmod(_Parser.Data.timeofweek / 1000.0, 3600.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;
|
---|
[71] | 77 | }
|
---|
[72] | 78 |
|
---|
| 79 | if (_Parser.dataflag[jj] & GNSSDF_C1DATA) {
|
---|
| 80 | obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
| 81 | obs->pCodeIndicator = 0;
|
---|
[71] | 82 | }
|
---|
[72] | 83 | else if (_Parser.dataflag[jj] & GNSSDF_P1DATA) {
|
---|
| 84 | obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
| 85 | obs->pCodeIndicator = 1;
|
---|
| 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 | obs->SNR1 = _Parser.Data.snrL1[ii];
|
---|
| 93 | }
|
---|
| 94 | else if (_Parser.dataflag[jj] & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
|
---|
| 95 | obs->L2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
| 96 | obs->SNR2 = _Parser.Data.snrL2[ii];
|
---|
| 97 | }
|
---|
[71] | 98 | }
|
---|
[72] | 99 |
|
---|
| 100 | //// obs->cumuLossOfCont =
|
---|
| 101 |
|
---|
| 102 | m_lObsList.push_back(obs);
|
---|
[71] | 103 | }
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
[65] | 106 | }
|
---|
| 107 | }
|
---|