[297] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[242] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[297] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[297] | 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.
|
---|
[242] | 24 |
|
---|
[464] | 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: RTCM2Decoder
|
---|
| 30 | *
|
---|
| 31 | * Purpose: RTCM2 Decoder
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Aug-2006
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[242] | 41 | #include "../bncutils.h"
|
---|
| 42 | #include "GPSDecoder.h"
|
---|
[243] | 43 | #include "RTCM2Decoder.h"
|
---|
[242] | 44 |
|
---|
| 45 | using namespace std;
|
---|
| 46 |
|
---|
| 47 | //
|
---|
| 48 | // Constructor
|
---|
| 49 | //
|
---|
| 50 |
|
---|
[1029] | 51 | RTCM2Decoder::RTCM2Decoder() {
|
---|
| 52 |
|
---|
[242] | 53 | }
|
---|
| 54 |
|
---|
| 55 | //
|
---|
| 56 | // Destructor
|
---|
| 57 | //
|
---|
| 58 |
|
---|
| 59 | RTCM2Decoder::~RTCM2Decoder() {
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | //
|
---|
| 63 |
|
---|
[649] | 64 | t_irc RTCM2Decoder::Decode(char* buffer, int bufLen) {
|
---|
[242] | 65 |
|
---|
| 66 | _buffer.append(buffer, bufLen);
|
---|
| 67 | int refWeek;
|
---|
| 68 | double refSecs;
|
---|
| 69 | currentGPSWeeks(refWeek, refSecs);
|
---|
[702] | 70 | bool decoded = false;
|
---|
[242] | 71 |
|
---|
| 72 | while(true) {
|
---|
| 73 | _PP.getPacket(_buffer);
|
---|
| 74 | if (!_PP.valid()) {
|
---|
[702] | 75 | if (decoded) {
|
---|
| 76 | return success;
|
---|
| 77 | } else {
|
---|
| 78 | return failure;
|
---|
| 79 | }
|
---|
[242] | 80 | }
|
---|
| 81 |
|
---|
| 82 | if ( _PP.ID()==18 || _PP.ID()==19 ) {
|
---|
| 83 |
|
---|
| 84 | _ObsBlock.extract(_PP);
|
---|
| 85 |
|
---|
| 86 | if (_ObsBlock.valid()) {
|
---|
[702] | 87 | decoded = true;
|
---|
[242] | 88 |
|
---|
| 89 | int epochWeek;
|
---|
| 90 | double epochSecs;
|
---|
| 91 | _ObsBlock.resolveEpoch(refWeek, refSecs, epochWeek, epochSecs);
|
---|
| 92 |
|
---|
| 93 | for (int iSat=0; iSat < _ObsBlock.nSat; iSat++) {
|
---|
[622] | 94 | p_obs obs = new t_obs();
|
---|
[627] | 95 | _obsList.push_back(obs);
|
---|
[341] | 96 | if (_ObsBlock.PRN[iSat] > 100) {
|
---|
[1029] | 97 | obs->_o.satNum = _ObsBlock.PRN[iSat] % 100;
|
---|
| 98 | obs->_o.satSys = 'R';
|
---|
| 99 | }
|
---|
| 100 | else {
|
---|
| 101 | obs->_o.satNum = _ObsBlock.PRN[iSat];
|
---|
| 102 | obs->_o.satSys = 'G';
|
---|
| 103 | }
|
---|
| 104 | obs->_o.GPSWeek = epochWeek;
|
---|
| 105 | obs->_o.GPSWeeks = epochSecs;
|
---|
| 106 | obs->_o.C1 = _ObsBlock.rng_C1[iSat];
|
---|
| 107 | obs->_o.P1 = _ObsBlock.rng_P1[iSat];
|
---|
| 108 | obs->_o.P2 = _ObsBlock.rng_P2[iSat];
|
---|
| 109 | obs->_o.L1 = _ObsBlock.resolvedPhase_L1(iSat);
|
---|
| 110 | obs->_o.L2 = _ObsBlock.resolvedPhase_L2(iSat);
|
---|
[242] | 111 | }
|
---|
| 112 | _ObsBlock.clear();
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
[649] | 116 | return success;
|
---|
[242] | 117 | }
|
---|
| 118 |
|
---|