[306] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters,
|
---|
| 3 | // written by Leos Mervart.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2006
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Advanced Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[293] | 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
| 27 | * BKG NTRIP Client
|
---|
| 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
[306] | 30 | * Class: RTIGSDecoder
|
---|
[293] | 31 | *
|
---|
| 32 | * Purpose: RTIGS Decoder
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 24-Aug-2006
|
---|
| 37 | *
|
---|
| 38 | * Changes:
|
---|
| 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
[306] | 42 | #include "RTIGSDecoder.h"
|
---|
[293] | 43 | #include "bncconst.h"
|
---|
| 44 |
|
---|
| 45 | using namespace std;
|
---|
| 46 |
|
---|
[305] | 47 | #undef L1
|
---|
| 48 | #undef L2
|
---|
| 49 |
|
---|
[293] | 50 | // Constructor
|
---|
| 51 | ////////////////////////////////////////////////////////////////////////////
|
---|
[306] | 52 | RTIGSDecoder::RTIGSDecoder() {
|
---|
[293] | 53 | }
|
---|
| 54 |
|
---|
| 55 | // Destructor
|
---|
| 56 | ////////////////////////////////////////////////////////////////////////////
|
---|
[306] | 57 | RTIGSDecoder::~RTIGSDecoder() {
|
---|
[293] | 58 | }
|
---|
| 59 |
|
---|
| 60 | //
|
---|
| 61 | ////////////////////////////////////////////////////////////////////////////
|
---|
[306] | 62 | void RTIGSDecoder::Decode(char* buffer, int bufLen) {
|
---|
[293] | 63 |
|
---|
| 64 | // Append the incomming data to the internal buffer
|
---|
| 65 | // ------------------------------------------------
|
---|
| 66 | _buffer.append( QByteArray(buffer, bufLen) );
|
---|
| 67 |
|
---|
| 68 | // Find the beginning of the message
|
---|
| 69 | // ---------------------------------
|
---|
| 70 | bool found = false;
|
---|
| 71 | for (int ii = 0; ii < _buffer.size(); ii++) {
|
---|
| 72 | unsigned short xx;
|
---|
| 73 | memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
|
---|
[305] | 74 | if (_GPSTrans.f_IsLittleEndian) {
|
---|
| 75 | SwitchBytes( (char*) &xx, sizeof(xx) );
|
---|
| 76 | }
|
---|
[293] | 77 | if (xx == 200) {
|
---|
| 78 | _buffer = _buffer.mid(ii);
|
---|
| 79 | found = true;
|
---|
| 80 | break;
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
[305] | 83 |
|
---|
[293] | 84 | if (! found) {
|
---|
| 85 | _buffer.clear();
|
---|
| 86 | return;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[305] | 89 | unsigned char* p_buf = (unsigned char*) _buffer.data();
|
---|
[293] | 90 |
|
---|
[305] | 91 | unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
|
---|
| 92 | unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
|
---|
| 93 |
|
---|
| 94 | // Not enough new data, return
|
---|
| 95 | // ---------------------------
|
---|
| 96 | if (_buffer.size() < numbytes) {
|
---|
[293] | 97 | return;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
[305] | 100 | // Decode the epoch
|
---|
| 101 | // ----------------
|
---|
| 102 | if (messType == 200) {
|
---|
| 103 | RTIGSO_T rtigs_obs;
|
---|
| 104 | short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
|
---|
[293] | 105 |
|
---|
[305] | 106 | for (short ii = 0; ii < numObs; ii++) {
|
---|
[293] | 107 | Observation* obs = new Observation();
|
---|
[341] | 108 | obs->satSys = 'G';
|
---|
| 109 | obs->satNum = _GPSTrans.DecObs.Obs[ii].sat_prn;
|
---|
[305] | 110 | obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
|
---|
| 111 | obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
|
---|
| 112 | obs->C1 = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
|
---|
| 113 | obs->P1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
|
---|
| 114 | obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
|
---|
| 115 | obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase;
|
---|
| 116 | obs->L2 = _GPSTrans.DecObs.Obs[ii].p2_phase;
|
---|
[367] | 117 | obs->S1 = _GPSTrans.DecObs.Obs[ii].l1_sn;
|
---|
| 118 | obs->S2 = _GPSTrans.DecObs.Obs[ii].l2_sn;
|
---|
[323] | 119 | obs->SNR1 = int(ceil(_GPSTrans.DecObs.Obs[ii].l1_sn / 60.0 * 9.0));
|
---|
| 120 | obs->SNR2 = int(ceil(_GPSTrans.DecObs.Obs[ii].l2_sn / 60.0 * 9.0));
|
---|
[293] | 121 |
|
---|
| 122 | _obsList.push_back(obs);
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | // Unprocessed bytes remain in buffer
|
---|
| 127 | // ----------------------------------
|
---|
[305] | 128 | _buffer = _buffer.mid(numbytes);
|
---|
[293] | 129 | }
|
---|