| 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: RTCM3coDecoder
|
|---|
| 30 | *
|
|---|
| 31 | * Purpose: RTCM3 Clock Orbit Decoder
|
|---|
| 32 | *
|
|---|
| 33 | * Author: L. Mervart
|
|---|
| 34 | *
|
|---|
| 35 | * Created: 05-May-2008
|
|---|
| 36 | *
|
|---|
| 37 | * Changes:
|
|---|
| 38 | *
|
|---|
| 39 | * -----------------------------------------------------------------------*/
|
|---|
| 40 |
|
|---|
| 41 | #include <stdio.h>
|
|---|
| 42 | #include <math.h>
|
|---|
| 43 |
|
|---|
| 44 | #include "RTCM3coDecoder.h"
|
|---|
| 45 | #include "bncutils.h"
|
|---|
| 46 | #include "bncrinex.h"
|
|---|
| 47 | #include "bnccore.h"
|
|---|
| 48 | #include "bncsettings.h"
|
|---|
| 49 | #include "bnctime.h"
|
|---|
| 50 |
|
|---|
| 51 | using namespace std;
|
|---|
| 52 |
|
|---|
| 53 | // Constructor
|
|---|
| 54 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 55 | RTCM3coDecoder::RTCM3coDecoder(const QString& staID) {
|
|---|
| 56 |
|
|---|
| 57 | _staID = staID;
|
|---|
| 58 |
|
|---|
| 59 | // File Output
|
|---|
| 60 | // -----------
|
|---|
| 61 | bncSettings settings;
|
|---|
| 62 | QString path = settings.value("corrPath").toString();
|
|---|
| 63 | if (!path.isEmpty()) {
|
|---|
| 64 | expandEnvVar(path);
|
|---|
| 65 | if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
|
|---|
| 66 | path += QDir::separator();
|
|---|
| 67 | }
|
|---|
| 68 | _fileNameSkl = path + staID;
|
|---|
| 69 | }
|
|---|
| 70 | _out = 0;
|
|---|
| 71 |
|
|---|
| 72 | connect(this, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
|---|
| 73 | BNC_CORE, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
|---|
| 74 |
|
|---|
| 75 | connect(this, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
|---|
| 76 | BNC_CORE, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
|---|
| 77 |
|
|---|
| 78 | connect(this, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
|
|---|
| 79 | BNC_CORE, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
|---|
| 80 |
|
|---|
| 81 | connect(this, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)),
|
|---|
| 82 | BNC_CORE, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)));
|
|---|
| 83 |
|
|---|
| 84 | connect(this, SIGNAL(newTec(t_vTec)),
|
|---|
| 85 | BNC_CORE, SLOT(slotNewTec(t_vTec)));
|
|---|
| 86 |
|
|---|
| 87 | connect(this, SIGNAL(providerIDChanged(QString)),
|
|---|
| 88 | BNC_CORE, SIGNAL(providerIDChanged(QString)));
|
|---|
| 89 |
|
|---|
| 90 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
|---|
| 91 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| 92 |
|
|---|
| 93 | reset();
|
|---|
| 94 |
|
|---|
| 95 | _providerID[0] = -1;
|
|---|
| 96 | _providerID[1] = -1;
|
|---|
| 97 | _providerID[2] = -1;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | // Destructor
|
|---|
| 101 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 102 | RTCM3coDecoder::~RTCM3coDecoder() {
|
|---|
| 103 | delete _out;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | //
|
|---|
| 107 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 108 | void RTCM3coDecoder::reset() {
|
|---|
| 109 | memset(&_clkOrb, 0, sizeof(_clkOrb));
|
|---|
| 110 | memset(&_codeBias, 0, sizeof(_codeBias));
|
|---|
| 111 | memset(&_phaseBias, 0, sizeof(_phaseBias));
|
|---|
| 112 | memset(&_vTEC, 0, sizeof(_vTEC));
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // Reopen Output File
|
|---|
| 116 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 117 | void RTCM3coDecoder::reopen() {
|
|---|
| 118 |
|
|---|
| 119 | if (!_fileNameSkl.isEmpty()) {
|
|---|
| 120 |
|
|---|
| 121 | bncSettings settings;
|
|---|
| 122 |
|
|---|
| 123 | QDateTime datTim = currentDateAndTimeGPS();
|
|---|
| 124 |
|
|---|
| 125 | QString hlpStr = bncRinex::nextEpochStr(datTim,
|
|---|
| 126 | settings.value("corrIntr").toString());
|
|---|
| 127 |
|
|---|
| 128 | QString fileNameHlp = _fileNameSkl
|
|---|
| 129 | + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'))
|
|---|
| 130 | + hlpStr + datTim.toString(".yyC");
|
|---|
| 131 |
|
|---|
| 132 | if (_fileName == fileNameHlp) {
|
|---|
| 133 | return;
|
|---|
| 134 | }
|
|---|
| 135 | else {
|
|---|
| 136 | _fileName = fileNameHlp;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | delete _out;
|
|---|
| 140 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
|---|
| 141 | _out = new ofstream( _fileName.toAscii().data(), ios_base::out | ios_base::app );
|
|---|
| 142 | }
|
|---|
| 143 | else {
|
|---|
| 144 | _out = new ofstream( _fileName.toAscii().data() );
|
|---|
| 145 | }
|
|---|
| 146 | }
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | //
|
|---|
| 150 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 151 | t_irc RTCM3coDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
|
|---|
| 152 |
|
|---|
| 153 | errmsg.clear();
|
|---|
| 154 |
|
|---|
| 155 | _buffer.append(QByteArray(buffer,bufLen));
|
|---|
| 156 |
|
|---|
| 157 | t_irc retCode = failure;
|
|---|
| 158 |
|
|---|
| 159 | while(_buffer.size()) {
|
|---|
| 160 |
|
|---|
| 161 | struct ClockOrbit clkOrbSav;
|
|---|
| 162 | struct CodeBias codeBiasSav;
|
|---|
| 163 | struct PhaseBias phaseBiasSav;
|
|---|
| 164 | struct VTEC vTECSav;
|
|---|
| 165 | memcpy(&clkOrbSav, &_clkOrb, sizeof(clkOrbSav)); // save state
|
|---|
| 166 | memcpy(&codeBiasSav, &_codeBias, sizeof(codeBiasSav));
|
|---|
| 167 | memcpy(&phaseBiasSav, &_phaseBias, sizeof(phaseBiasSav));
|
|---|
| 168 | memcpy(&vTECSav, &_vTEC, sizeof(vTECSav));
|
|---|
| 169 |
|
|---|
| 170 | int bytesused = 0;
|
|---|
| 171 | GCOB_RETURN irc = GetSSR(&_clkOrb, &_codeBias, &_vTEC, &_phaseBias,
|
|---|
| 172 | _buffer.data(), _buffer.size(), &bytesused);
|
|---|
| 173 |
|
|---|
| 174 | if (irc <= -30) { // not enough data - restore state and exit loop
|
|---|
| 175 | memcpy(&_clkOrb, &clkOrbSav, sizeof(clkOrbSav));
|
|---|
| 176 | memcpy(&_codeBias, &codeBiasSav, sizeof(codeBiasSav));
|
|---|
| 177 | memcpy(&_phaseBias, &phaseBiasSav, sizeof(phaseBiasSav));
|
|---|
| 178 | memcpy(&_vTEC, &vTECSav, sizeof(vTECSav));
|
|---|
| 179 | break;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | else if (irc < 0) { // error - skip 1 byte and retry
|
|---|
| 183 | reset();
|
|---|
| 184 | _buffer = _buffer.mid(bytesused ? bytesused : 1);
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | else { // OK or MESSAGEFOLLOWS
|
|---|
| 188 | _buffer = _buffer.mid(bytesused);
|
|---|
| 189 |
|
|---|
| 190 | if (irc == GCOBR_OK || irc == GCOBR_MESSAGEFOLLOWS ) {
|
|---|
| 191 |
|
|---|
| 192 | setEpochTime(); // sets _lastTime
|
|---|
| 193 |
|
|---|
| 194 | if (_lastTime.valid()) {
|
|---|
| 195 | reopen();
|
|---|
| 196 | checkProviderID();
|
|---|
| 197 | sendResults();
|
|---|
| 198 | retCode = success;
|
|---|
| 199 | }
|
|---|
| 200 | else {
|
|---|
| 201 | retCode = failure;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | reset();
|
|---|
| 205 | }
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | return retCode;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | //
|
|---|
| 213 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 214 | void RTCM3coDecoder::sendResults() {
|
|---|
| 215 |
|
|---|
| 216 | // Orbit and clock corrections of all satellites
|
|---|
| 217 | // ---------------------------------------------
|
|---|
| 218 | for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) {
|
|---|
| 219 | char sysCh = ' ';
|
|---|
| 220 | if (ii < _clkOrb.NumberOfSat[CLOCKORBIT_SATGPS]) {
|
|---|
| 221 | sysCh = 'G';
|
|---|
| 222 | }
|
|---|
| 223 | else if (ii >= CLOCKORBIT_NUMGPS) {
|
|---|
| 224 | sysCh = 'R';
|
|---|
| 225 | }
|
|---|
| 226 | else {
|
|---|
| 227 | continue;
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | // Orbit correction
|
|---|
| 231 | // ----------------
|
|---|
| 232 | if ( _clkOrb.messageType == COTYPE_GPSCOMBINED ||
|
|---|
| 233 | _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
|
|---|
| 234 | _clkOrb.messageType == COTYPE_GPSORBIT ||
|
|---|
| 235 | _clkOrb.messageType == COTYPE_GLONASSORBIT ) {
|
|---|
| 236 |
|
|---|
| 237 | t_orbCorr orbCorr;
|
|---|
| 238 | orbCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID);
|
|---|
| 239 | orbCorr._staID = _staID.toStdString();
|
|---|
| 240 | orbCorr._iod = _clkOrb.Sat[ii].IOD;
|
|---|
| 241 | orbCorr._time = _lastTime;
|
|---|
| 242 | orbCorr._updateInt = _clkOrb.UpdateInterval;
|
|---|
| 243 | orbCorr._system = 'R';
|
|---|
| 244 | orbCorr._xr[0] = _clkOrb.Sat[ii].Orbit.DeltaRadial;
|
|---|
| 245 | orbCorr._xr[1] = _clkOrb.Sat[ii].Orbit.DeltaAlongTrack;
|
|---|
| 246 | orbCorr._xr[2] = _clkOrb.Sat[ii].Orbit.DeltaCrossTrack;
|
|---|
| 247 | orbCorr._dotXr[0] = _clkOrb.Sat[ii].Orbit.DotDeltaRadial;
|
|---|
| 248 | orbCorr._dotXr[1] = _clkOrb.Sat[ii].Orbit.DotDeltaAlongTrack;
|
|---|
| 249 | orbCorr._dotXr[2] = _clkOrb.Sat[ii].Orbit.DotDeltaCrossTrack;
|
|---|
| 250 |
|
|---|
| 251 | _orbCorrections[_lastTime].push_back(orbCorr);
|
|---|
| 252 |
|
|---|
| 253 | _IODs[orbCorr._prn] = _clkOrb.Sat[ii].IOD;
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | // Clock Corrections
|
|---|
| 257 | // -----------------
|
|---|
| 258 | if ( _clkOrb.messageType == COTYPE_GPSCOMBINED ||
|
|---|
| 259 | _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
|
|---|
| 260 | _clkOrb.messageType == COTYPE_GPSCLOCK ||
|
|---|
| 261 | _clkOrb.messageType == COTYPE_GLONASSCLOCK ) {
|
|---|
| 262 |
|
|---|
| 263 | t_clkCorr clkCorr;
|
|---|
| 264 | clkCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID);
|
|---|
| 265 | clkCorr._staID = _staID.toStdString();
|
|---|
| 266 | clkCorr._time = _lastTime;
|
|---|
| 267 | clkCorr._updateInt = _clkOrb.UpdateInterval;
|
|---|
| 268 | clkCorr._dClk = _clkOrb.Sat[ii].Clock.DeltaA0 / t_CST::c;
|
|---|
| 269 | clkCorr._dotDClk = _clkOrb.Sat[ii].Clock.DeltaA1 / t_CST::c;
|
|---|
| 270 | clkCorr._dotDotDClk = _clkOrb.Sat[ii].Clock.DeltaA2 / t_CST::c;
|
|---|
| 271 |
|
|---|
| 272 | _lastClkCorrections[clkCorr._prn] = clkCorr;
|
|---|
| 273 |
|
|---|
| 274 | if (_IODs.contains(clkCorr._prn)) {
|
|---|
| 275 | clkCorr._iod = _IODs[clkCorr._prn];
|
|---|
| 276 | _clkCorrections[_lastTime].push_back(clkCorr);
|
|---|
| 277 | }
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | // High-Resolution Clocks
|
|---|
| 281 | // ----------------------
|
|---|
| 282 | if ( _clkOrb.messageType == COTYPE_GPSHR ||
|
|---|
| 283 | _clkOrb.messageType == COTYPE_GLONASSHR ) {
|
|---|
| 284 |
|
|---|
| 285 | t_prn prn(sysCh, _clkOrb.Sat[ii].ID);
|
|---|
| 286 | if (_lastClkCorrections.contains(prn)) {
|
|---|
| 287 | t_clkCorr clkCorr;
|
|---|
| 288 | clkCorr = _lastClkCorrections[prn];
|
|---|
| 289 | clkCorr._time = _lastTime;
|
|---|
| 290 | clkCorr._updateInt = _clkOrb.UpdateInterval;
|
|---|
| 291 | clkCorr._dClk += _clkOrb.Sat[ii].hrclock / t_CST::c;
|
|---|
| 292 | if (_IODs.contains(clkCorr._prn)) {
|
|---|
| 293 | clkCorr._iod = _IODs[clkCorr._prn];
|
|---|
| 294 | _clkCorrections[_lastTime].push_back(clkCorr);
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 | }
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | // Code Biases
|
|---|
| 301 | // -----------
|
|---|
| 302 | for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) {
|
|---|
| 303 | char sysCh = ' ';
|
|---|
| 304 | if (ii < _codeBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
|
|---|
| 305 | sysCh = 'G';
|
|---|
| 306 | }
|
|---|
| 307 | else if (ii >= CLOCKORBIT_NUMGPS) {
|
|---|
| 308 | sysCh = 'R';
|
|---|
| 309 | }
|
|---|
| 310 | else {
|
|---|
| 311 | continue;
|
|---|
| 312 | }
|
|---|
| 313 | t_satCodeBias satCodeBias;
|
|---|
| 314 | satCodeBias._prn.set(sysCh, _codeBias.Sat[ii].ID);
|
|---|
| 315 | satCodeBias._staID = _staID.toStdString();
|
|---|
| 316 | satCodeBias._time = _lastTime;
|
|---|
| 317 | satCodeBias._updateInt = _codeBias.UpdateInterval;
|
|---|
| 318 | for (unsigned jj = 0; jj < _codeBias.Sat[ii].NumberOfCodeBiases; jj++) {
|
|---|
| 319 | const CodeBias::BiasSat::CodeBiasEntry& biasEntry = _codeBias.Sat[ii].Biases[jj];
|
|---|
| 320 | t_frqCodeBias frqCodeBias;
|
|---|
| 321 | frqCodeBias._rnxType2ch = codeTypeToRnxType(sysCh, biasEntry.Type);
|
|---|
| 322 | frqCodeBias._value = biasEntry.Bias;
|
|---|
| 323 | if (!frqCodeBias._rnxType2ch.empty()) {
|
|---|
| 324 | satCodeBias._bias.push_back(frqCodeBias);
|
|---|
| 325 | }
|
|---|
| 326 | }
|
|---|
| 327 | _codeBiases[_lastTime].push_back(satCodeBias);
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | // Phase Biases
|
|---|
| 331 | // -----------
|
|---|
| 332 | for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) {
|
|---|
| 333 | char sysCh = ' ';
|
|---|
| 334 | if (ii < _phaseBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
|
|---|
| 335 | sysCh = 'G';
|
|---|
| 336 | }
|
|---|
| 337 | else if (ii >= CLOCKORBIT_NUMGPS) {
|
|---|
| 338 | sysCh = 'R';
|
|---|
| 339 | }
|
|---|
| 340 | else {
|
|---|
| 341 | continue;
|
|---|
| 342 | }
|
|---|
| 343 | t_satPhaseBias satPhaseBias;
|
|---|
| 344 | satPhaseBias._prn.set(sysCh, _phaseBias.Sat[ii].ID);
|
|---|
| 345 | satPhaseBias._staID = _staID.toStdString();
|
|---|
| 346 | satPhaseBias._time = _lastTime;
|
|---|
| 347 | satPhaseBias._updateInt = _phaseBias.UpdateInterval;
|
|---|
| 348 | satPhaseBias._yawDeg = _phaseBias.Sat[ii].YawAngle * 180.0 / M_PI;
|
|---|
| 349 | satPhaseBias._yawDegRate = _phaseBias.Sat[ii].YawRate * 180.0 / M_PI;
|
|---|
| 350 | for (unsigned jj = 0; jj < _phaseBias.Sat[ii].NumberOfPhaseBiases; jj++) {
|
|---|
| 351 | const PhaseBias::PhaseBiasSat::PhaseBiasEntry& biasEntry = _phaseBias.Sat[ii].Biases[jj];
|
|---|
| 352 | t_frqPhaseBias frqPhaseBias;
|
|---|
| 353 | frqPhaseBias._rnxType2ch = codeTypeToRnxType(sysCh, biasEntry.Type);
|
|---|
| 354 | frqPhaseBias._value = biasEntry.Bias;
|
|---|
| 355 | frqPhaseBias._fixIndicator = biasEntry.SignalIntegerIndicator;
|
|---|
| 356 | frqPhaseBias._fixWideLaneIndicator = biasEntry.SignalsWideLaneIntegerIndicator;
|
|---|
| 357 | frqPhaseBias._jumpCounter = biasEntry.SignalDiscontinuityCounter;
|
|---|
| 358 | if (!frqPhaseBias._rnxType2ch.empty()) {
|
|---|
| 359 | satPhaseBias._bias.push_back(frqPhaseBias);
|
|---|
| 360 | }
|
|---|
| 361 | }
|
|---|
| 362 | _phaseBiases[_lastTime].push_back(satPhaseBias);
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | // Ionospheric Model
|
|---|
| 366 | // -----------------
|
|---|
| 367 | if (_vTEC.NumLayers > 0) {
|
|---|
| 368 | _vTecMap[_lastTime]._time = _lastTime;
|
|---|
| 369 | _vTecMap[_lastTime]._updateInt = _vTEC.UpdateInterval;
|
|---|
| 370 | _vTecMap[_lastTime]._staID = _staID.toStdString();
|
|---|
| 371 | for (unsigned ii = 0; ii < _vTEC.NumLayers; ii++) {
|
|---|
| 372 | const VTEC::IonoLayers& ionoLayer = _vTEC.Layers[ii];
|
|---|
| 373 | t_vTecLayer layer;
|
|---|
| 374 | layer._height = ionoLayer.Height;
|
|---|
| 375 | layer._C.ReSize(ionoLayer.Degree, ionoLayer.Order);
|
|---|
| 376 | layer._S.ReSize(ionoLayer.Degree, ionoLayer.Order);
|
|---|
| 377 | for (unsigned iDeg = 0; iDeg < ionoLayer.Degree; iDeg++) {
|
|---|
| 378 | for (unsigned iOrd = 0; iOrd < ionoLayer.Order; iOrd++) {
|
|---|
| 379 | layer._C[iDeg][iOrd] = ionoLayer.Cosinus[iDeg][iOrd];
|
|---|
| 380 | layer._S[iDeg][iOrd] = ionoLayer.Sinus[iDeg][iOrd];
|
|---|
| 381 | }
|
|---|
| 382 | }
|
|---|
| 383 | _vTecMap[_lastTime]._layers.push_back(layer);
|
|---|
| 384 | }
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | // Dump all older epochs
|
|---|
| 388 | // ---------------------
|
|---|
| 389 | QMutableMapIterator<bncTime, QList<t_orbCorr> > itOrb(_orbCorrections);
|
|---|
| 390 | while (itOrb.hasNext()) {
|
|---|
| 391 | itOrb.next();
|
|---|
| 392 | if (itOrb.key() < _lastTime) {
|
|---|
| 393 | emit newOrbCorrections(itOrb.value());
|
|---|
| 394 | t_orbCorr::writeEpoch(_out, itOrb.value());
|
|---|
| 395 | itOrb.remove();
|
|---|
| 396 | }
|
|---|
| 397 | }
|
|---|
| 398 | QMutableMapIterator<bncTime, QList<t_clkCorr> > itClk(_clkCorrections);
|
|---|
| 399 | while (itClk.hasNext()) {
|
|---|
| 400 | itClk.next();
|
|---|
| 401 | if (itClk.key() < _lastTime) {
|
|---|
| 402 | emit newClkCorrections(itClk.value());
|
|---|
| 403 | t_clkCorr::writeEpoch(_out, itClk.value());
|
|---|
| 404 | itClk.remove();
|
|---|
| 405 | }
|
|---|
| 406 | }
|
|---|
| 407 | QMutableMapIterator<bncTime, QList<t_satCodeBias> > itCB(_codeBiases);
|
|---|
| 408 | while (itCB.hasNext()) {
|
|---|
| 409 | itCB.next();
|
|---|
| 410 | if (itCB.key() < _lastTime) {
|
|---|
| 411 | emit newCodeBiases(itCB.value());
|
|---|
| 412 | t_satCodeBias::writeEpoch(_out, itCB.value());
|
|---|
| 413 | itCB.remove();
|
|---|
| 414 | }
|
|---|
| 415 | }
|
|---|
| 416 | QMutableMapIterator<bncTime, QList<t_satPhaseBias> > itPB(_phaseBiases);
|
|---|
| 417 | while (itPB.hasNext()) {
|
|---|
| 418 | itPB.next();
|
|---|
| 419 | if (itPB.key() < _lastTime) {
|
|---|
| 420 | emit newPhaseBiases(itPB.value());
|
|---|
| 421 | t_satPhaseBias::writeEpoch(_out, itPB.value());
|
|---|
| 422 | itPB.remove();
|
|---|
| 423 | }
|
|---|
| 424 | }
|
|---|
| 425 | QMutableMapIterator<bncTime, t_vTec> itTec(_vTecMap);
|
|---|
| 426 | while (itTec.hasNext()) {
|
|---|
| 427 | itTec.next();
|
|---|
| 428 | if (itTec.key() < _lastTime) {
|
|---|
| 429 | emit newTec(itTec.value());
|
|---|
| 430 | t_vTec::write(_out, itTec.value());
|
|---|
| 431 | itTec.remove();
|
|---|
| 432 | }
|
|---|
| 433 | }
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | //
|
|---|
| 437 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 438 | void RTCM3coDecoder::checkProviderID() {
|
|---|
| 439 |
|
|---|
| 440 | if (_clkOrb.SSRProviderID == 0 && _clkOrb.SSRSolutionID == 0 && _clkOrb.SSRIOD == 0) {
|
|---|
| 441 | return;
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 | int newProviderID[3];
|
|---|
| 445 | newProviderID[0] = _clkOrb.SSRProviderID;
|
|---|
| 446 | newProviderID[1] = _clkOrb.SSRSolutionID;
|
|---|
| 447 | newProviderID[2] = _clkOrb.SSRIOD;
|
|---|
| 448 |
|
|---|
| 449 | bool alreadySet = false;
|
|---|
| 450 | bool different = false;
|
|---|
| 451 |
|
|---|
| 452 | for (unsigned ii = 0; ii < 3; ii++) {
|
|---|
| 453 | if (_providerID[ii] != -1) {
|
|---|
| 454 | alreadySet = true;
|
|---|
| 455 | }
|
|---|
| 456 | if (_providerID[ii] != newProviderID[ii]) {
|
|---|
| 457 | different = true;
|
|---|
| 458 | }
|
|---|
| 459 | _providerID[ii] = newProviderID[ii];
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | if (alreadySet && different) {
|
|---|
| 463 | emit newMessage("RTCM3coDecoder: Provider Changed " + _staID.toAscii() + "\n", true);
|
|---|
| 464 | emit providerIDChanged(_staID);
|
|---|
| 465 | }
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | //
|
|---|
| 469 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 470 | void RTCM3coDecoder::setEpochTime() {
|
|---|
| 471 |
|
|---|
| 472 | _lastTime.reset();
|
|---|
| 473 |
|
|---|
| 474 | double epoSecGPS = -1.0;
|
|---|
| 475 | double epoSecGlo = -1.0;
|
|---|
| 476 | if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
|
|---|
| 477 | epoSecGPS = _clkOrb.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
|
|---|
| 478 | }
|
|---|
| 479 | else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
|
|---|
| 480 | epoSecGPS = _codeBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
|
|---|
| 481 | }
|
|---|
| 482 | else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
|
|---|
| 483 | epoSecGPS = _phaseBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
|
|---|
| 484 | }
|
|---|
| 485 | else if (_vTEC.NumLayers > 0) {
|
|---|
| 486 | epoSecGPS = _vTEC.EpochTime; // 0 .. 604799 s
|
|---|
| 487 | }
|
|---|
| 488 | else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
|
|---|
| 489 | epoSecGlo = _clkOrb.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
|
|---|
| 490 | }
|
|---|
| 491 | else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
|
|---|
| 492 | epoSecGlo = _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
|
|---|
| 493 | }
|
|---|
| 494 | else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
|
|---|
| 495 | epoSecGlo = _phaseBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | // Retrieve current time
|
|---|
| 499 | // ---------------------
|
|---|
| 500 | int currentWeek = 0;
|
|---|
| 501 | double currentSec = 0.0;
|
|---|
| 502 | currentGPSWeeks(currentWeek, currentSec);
|
|---|
| 503 | bncTime currentTime(currentWeek, currentSec);
|
|---|
| 504 |
|
|---|
| 505 | // Set _lastTime close to currentTime
|
|---|
| 506 | // ----------------------------------
|
|---|
| 507 | if (epoSecGPS != -1) {
|
|---|
| 508 | _lastTime.set(currentWeek, epoSecGPS);
|
|---|
| 509 | }
|
|---|
| 510 | else if (epoSecGlo != -1) {
|
|---|
| 511 | QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
|
|---|
| 512 | epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
|
|---|
| 513 | _lastTime.set(currentWeek, epoSecGlo);
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | if (_lastTime.valid()) {
|
|---|
| 517 | double maxDiff = 12 * 3600.0;
|
|---|
| 518 | while (_lastTime < currentTime - maxDiff) {
|
|---|
| 519 | _lastTime = _lastTime + maxDiff;
|
|---|
| 520 | }
|
|---|
| 521 | while (_lastTime > currentTime + maxDiff) {
|
|---|
| 522 | _lastTime = _lastTime - maxDiff;
|
|---|
| 523 | }
|
|---|
| 524 | }
|
|---|
| 525 | }
|
|---|
| 526 |
|
|---|
| 527 | //
|
|---|
| 528 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 529 | string RTCM3coDecoder::codeTypeToRnxType(char system, CodeType type) const {
|
|---|
| 530 | if (system == 'G') {
|
|---|
| 531 | switch (type) {
|
|---|
| 532 | case CODETYPEGPS_L1_CA: return "1C";
|
|---|
| 533 | case CODETYPEGPS_L1_P: return "1P";
|
|---|
| 534 | case CODETYPEGPS_L1_Z: return "1W";
|
|---|
| 535 | case CODETYPEGPS_L2_CA: return "2C";
|
|---|
| 536 | case CODETYPEGPS_SEMI_CODELESS: return "?N"; // which carrier ?
|
|---|
| 537 | case CODETYPEGPS_L2_CM: return "2S";
|
|---|
| 538 | case CODETYPEGPS_L2_CL: return "2L";
|
|---|
| 539 | case CODETYPEGPS_L2_CML: return "2X";
|
|---|
| 540 | case CODETYPEGPS_L2_P: return "2P";
|
|---|
| 541 | case CODETYPEGPS_L2_Z: return "2W";
|
|---|
| 542 | case CODETYPEGPS_L5_I: return "5I";
|
|---|
| 543 | case CODETYPEGPS_L5_Q: return "5Q";
|
|---|
| 544 | default: return "";
|
|---|
| 545 | }
|
|---|
| 546 | }
|
|---|
| 547 | else if (system == 'R') {
|
|---|
| 548 | switch (type) {
|
|---|
| 549 | case CODETYPEGLONASS_L1_CA: return "1C";
|
|---|
| 550 | case CODETYPEGLONASS_L1_P: return "1P";
|
|---|
| 551 | case CODETYPEGLONASS_L2_CA: return "2C";
|
|---|
| 552 | case CODETYPEGLONASS_L2_P: return "2P";
|
|---|
| 553 | default: return "";
|
|---|
| 554 | }
|
|---|
| 555 | }
|
|---|
| 556 | else if (system == 'E') {
|
|---|
| 557 | switch (type) {
|
|---|
| 558 | case CODETYPEGALILEO_E1_A: return "1A";
|
|---|
| 559 | case CODETYPEGALILEO_E1_B: return "1B";
|
|---|
| 560 | case CODETYPEGALILEO_E1_C: return "1C";
|
|---|
| 561 | case CODETYPEGALILEO_E5A_I: return "5I";
|
|---|
| 562 | case CODETYPEGALILEO_E5A_Q: return "5Q";
|
|---|
| 563 | case CODETYPEGALILEO_E5B_I: return "7I";
|
|---|
| 564 | case CODETYPEGALILEO_E5B_Q: return "7Q";
|
|---|
| 565 | case CODETYPEGALILEO_E5_I: return "8I";
|
|---|
| 566 | case CODETYPEGALILEO_E5_Q: return "8Q";
|
|---|
| 567 | case CODETYPEGALILEO_E6_A: return "6A";
|
|---|
| 568 | case CODETYPEGALILEO_E6_B: return "6B";
|
|---|
| 569 | case CODETYPEGALILEO_E6_C: return "6C";
|
|---|
| 570 | default: return "";
|
|---|
| 571 | }
|
|---|
| 572 | }
|
|---|
| 573 | else if (system == 'J') {
|
|---|
| 574 | switch (type) {
|
|---|
| 575 | case CODETYPEQZSS_L1_CA: return "1C";
|
|---|
| 576 | case CODETYPEQZSS_L1C_D: return "1S";
|
|---|
| 577 | case CODETYPEQZSS_L1C_P: return "1L";
|
|---|
| 578 | case CODETYPEQZSS_L1C_DP: return "1X";
|
|---|
| 579 | case CODETYPEQZSS_L2_CM: return "2S";
|
|---|
| 580 | case CODETYPEQZSS_L2_CL: return "2L";
|
|---|
| 581 | case CODETYPEQZSS_L2_CML: return "2X";
|
|---|
| 582 | case CODETYPEQZSS_L5_I: return "5I";
|
|---|
| 583 | case CODETYPEQZSS_L5_Q: return "5Q";
|
|---|
| 584 | case CODETYPEQZSS_L5_IQ: return "5X";
|
|---|
| 585 | case CODETYPEQZSS_LEX_S: return "6S";
|
|---|
| 586 | case CODETYPEQZSS_LEX_L: return "6L";
|
|---|
| 587 | case CODETYPEQZSS_LEX_SL: return "6X";
|
|---|
| 588 | default: return "";
|
|---|
| 589 | }
|
|---|
| 590 | }
|
|---|
| 591 | else if (system == 'S') {
|
|---|
| 592 | switch (type) {
|
|---|
| 593 | case CODETYPE_SBAS_L1_CA: return "1C";
|
|---|
| 594 | case CODETYPE_SBAS_L5_I: return "5I";
|
|---|
| 595 | case CODETYPE_SBAS_L5_Q: return "5Q";
|
|---|
| 596 | case CODETYPE_SBAS_L5_IQ: return "5X";
|
|---|
| 597 | default: return "";
|
|---|
| 598 | }
|
|---|
| 599 | }
|
|---|
| 600 | else if (system == 'C') {
|
|---|
| 601 | switch (type) {
|
|---|
| 602 | case CODETYPE_BDS_B1_I: return "1I";
|
|---|
| 603 | case CODETYPE_BDS_B1_Q: return "1Q";
|
|---|
| 604 | case CODETYPE_BDS_B1_IQ: return "1X";
|
|---|
| 605 | case CODETYPE_BDS_B2_I: return "7I";
|
|---|
| 606 | case CODETYPE_BDS_B2_Q: return "7Q";
|
|---|
| 607 | case CODETYPE_BDS_B2_IQ: return "7X";
|
|---|
| 608 | case CODETYPE_BDS_B3_I: return "6I";
|
|---|
| 609 | case CODETYPE_BDS_B3_Q: return "6Q";
|
|---|
| 610 | case CODETYPE_BDS_B3_IQ: return "6X";
|
|---|
| 611 | default: return "";
|
|---|
| 612 | }
|
|---|
| 613 | }
|
|---|
| 614 | return "";
|
|---|
| 615 | };
|
|---|