[3528] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 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.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: GPSDecoder
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Decoder Base Class
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 16-Dec-2011
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iomanip>
|
---|
| 42 | #include <cmath>
|
---|
| 43 |
|
---|
| 44 | #include "GPSDecoder.h"
|
---|
| 45 | #include "bncsettings.h"
|
---|
| 46 |
|
---|
[4439] | 47 | extern "C" {
|
---|
[4440] | 48 | #include "rtcm3torinex.h"
|
---|
[4439] | 49 | }
|
---|
[4422] | 50 |
|
---|
[3528] | 51 | using namespace std;
|
---|
| 52 |
|
---|
| 53 | // Constructor
|
---|
| 54 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 55 | GPSDecoder::GPSDecoder() {
|
---|
[3529] | 56 | _rnx = 0;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | // Initialize RINEX Writer
|
---|
| 60 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 61 | void GPSDecoder::initRinex(const QByteArray& staID, const QUrl& mountPoint,
|
---|
| 62 | const QByteArray& latitude,
|
---|
| 63 | const QByteArray& longitude, const QByteArray& nmea,
|
---|
| 64 | const QByteArray& ntripVersion) {
|
---|
| 65 | if (_rnx) {
|
---|
| 66 | return;
|
---|
| 67 | }
|
---|
[3528] | 68 | bncSettings settings;
|
---|
[3529] | 69 | if ( !settings.value("rnxPath").toString().isEmpty() ) {
|
---|
| 70 | _rnx = new bncRinex(staID, mountPoint, latitude, longitude,
|
---|
| 71 | nmea, ntripVersion);
|
---|
[3528] | 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | // Write RINEX Epoch
|
---|
| 76 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 77 | void GPSDecoder::dumpRinexEpoch(const t_obs& obs, const QByteArray& format) {
|
---|
| 78 | if (_rnx) {
|
---|
| 79 | long iSec = long(floor(obs.GPSWeeks+0.5));
|
---|
| 80 | long obsTime = obs.GPSWeek * 7*24*3600 + iSec;
|
---|
| 81 | if (_rnx->samplingRate() == 0 || iSec % _rnx->samplingRate() == 0) {
|
---|
| 82 | _rnx->deepCopy(obs);
|
---|
| 83 | }
|
---|
| 84 | _rnx->dumpEpoch(format, obsTime);
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | // Set RINEX Reconnect Flag
|
---|
| 89 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 90 | void GPSDecoder::setRinexReconnectFlag(bool flag) {
|
---|
| 91 | if (_rnx) {
|
---|
| 92 | _rnx->setReconnectFlag(flag);
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
[4392] | 95 |
|
---|
| 96 | //
|
---|
| 97 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5367] | 98 | void t_obs::setMeasdata(QString rnxStr, float rnxVers, double value) {
|
---|
| 99 |
|
---|
| 100 | if (rnxVers < 3.0) {
|
---|
| 101 | if (rnxStr == "C1") rnxStr = "C1C";
|
---|
| 102 | else if (rnxStr == "P1") rnxStr = "C1P";
|
---|
| 103 | else if (rnxStr == "C2") rnxStr = "C2C";
|
---|
| 104 | else if (rnxStr == "P2") rnxStr = "C2P";
|
---|
[4393] | 105 | }
|
---|
[5367] | 106 |
|
---|
| 107 | int ie = 0;
|
---|
| 108 | switch(rnxStr[0].toAscii()) {
|
---|
| 109 | case 'C': ie += GNSSENTRY_CODE; break;
|
---|
| 110 | case 'L': ie += GNSSENTRY_PHASE; break;
|
---|
| 111 | case 'D': ie += GNSSENTRY_DOPPLER; break;
|
---|
| 112 | case 'S': ie += GNSSENTRY_SNR; break;
|
---|
| 113 | default: return;
|
---|
| 114 | }
|
---|
| 115 | switch(rnxStr[1].toAscii()) {
|
---|
| 116 | case '1':
|
---|
| 117 | switch(rnxStr[2].toAscii()) {
|
---|
| 118 | default:
|
---|
| 119 | case 'C': ie += GNSSENTRY_TYPEC1; break;
|
---|
| 120 | case 'P': case 'W': case 'Y': ie += GNSSENTRY_TYPEP1; break;
|
---|
| 121 | case 'A': case 'B':
|
---|
| 122 | case 'S': case 'L': case 'X': ie += GNSSENTRY_TYPEC1; break;
|
---|
| 123 | case 'Z': ie += GNSSENTRY_TYPECSAIF; break;
|
---|
| 124 | }
|
---|
| 125 | break;
|
---|
| 126 | case '2':
|
---|
| 127 | switch(rnxStr[2].toAscii()) {
|
---|
| 128 | default:
|
---|
| 129 | case 'P': case 'W': case 'Y': ie += GNSSENTRY_TYPEP2; break;
|
---|
| 130 | case 'C': case 'S': case 'L': case 'X': ie += GNSSENTRY_TYPEC2; break;
|
---|
| 131 | case 'I': ie += GNSSENTRY_TYPEC5B; break;
|
---|
| 132 | }
|
---|
| 133 | break;
|
---|
| 134 | case '5':
|
---|
| 135 | ie += GNSSENTRY_TYPEC5; break;
|
---|
| 136 | case '6':
|
---|
| 137 | ie += GNSSENTRY_TYPEC6; break;
|
---|
| 138 | case '7':
|
---|
| 139 | ie += GNSSENTRY_TYPEC5B; break;
|
---|
| 140 | case '8':
|
---|
| 141 | ie += GNSSENTRY_TYPEC5AB; break;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | _codetype[ie] = rnxStr.mid(1);
|
---|
| 145 | _measdata[ie] = value;
|
---|
[4393] | 146 | }
|
---|
[4392] | 147 |
|
---|
| 148 | //
|
---|
| 149 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4403] | 150 | double t_obs::measdata(const QString& rnxStr, float rnxVers) const {
|
---|
[4415] | 151 | int ie = iEntry(rnxStr, rnxVers);
|
---|
[4403] | 152 | if (ie != -1) {
|
---|
| 153 | return _measdata[ie];
|
---|
| 154 | }
|
---|
| 155 | else {
|
---|
| 156 | return 0.0;
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
[4392] | 159 |
|
---|
[4403] | 160 | //
|
---|
| 161 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4415] | 162 | int t_obs::iEntry(QString rnxStr, float rnxVers) const {
|
---|
[4411] | 163 |
|
---|
[4415] | 164 | if (rnxVers < 3.0) {
|
---|
| 165 | if (rnxStr == "C1") rnxStr = "C1C";
|
---|
| 166 | else if (rnxStr == "P1") rnxStr = "C1P";
|
---|
| 167 | else if (rnxStr == "C2") rnxStr = "C2C";
|
---|
| 168 | else if (rnxStr == "P2") rnxStr = "C2P";
|
---|
[4412] | 169 | }
|
---|
[4404] | 170 |
|
---|
[5355] | 171 | for (int ie = 0; ie < GNSSENTRY_NUMBER; ie++) {
|
---|
[5366] | 172 | if (rnxStr.mid(1) == _codetype[ie]) {
|
---|
[5355] | 173 | if (rnxStr[0] == 'C') {
|
---|
| 174 | return ie + GNSSENTRY_CODE;
|
---|
| 175 | }
|
---|
| 176 | else if (rnxStr[0] == 'L') {
|
---|
| 177 | return ie + GNSSENTRY_PHASE;
|
---|
| 178 | }
|
---|
| 179 | else if (rnxStr[0] == 'D') {
|
---|
| 180 | return ie + GNSSENTRY_DOPPLER;
|
---|
| 181 | }
|
---|
| 182 | else if (rnxStr[0] == 'S') {
|
---|
| 183 | return ie + GNSSENTRY_SNR;
|
---|
| 184 | }
|
---|
[5357] | 185 | else {
|
---|
| 186 | return -1;
|
---|
| 187 | }
|
---|
[5355] | 188 | }
|
---|
| 189 | }
|
---|
| 190 | return -1;
|
---|
[4392] | 191 | }
|
---|
[4440] | 192 |
|
---|
| 193 | //
|
---|
| 194 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4774] | 195 | QString t_obs::rnxStr(int iEntry) const {
|
---|
[4441] | 196 | QString str(3,' ');
|
---|
| 197 | switch(iEntry & 3) {
|
---|
| 198 | case GNSSENTRY_CODE: str[0] = 'C'; break;
|
---|
| 199 | case GNSSENTRY_PHASE: str[0] = 'L'; break;
|
---|
| 200 | case GNSSENTRY_DOPPLER: str[0] = 'D'; break;
|
---|
| 201 | case GNSSENTRY_SNR: str[0] = 'S'; break;
|
---|
| 202 | }
|
---|
[5366] | 203 | if (!_codetype[iEntry].isEmpty()) {
|
---|
[4442] | 204 | str[1] = _codetype[iEntry][0];
|
---|
| 205 | str[2] = _codetype[iEntry][1];
|
---|
| 206 | }
|
---|
| 207 | return str.trimmed();
|
---|
[4440] | 208 | }
|
---|