source: ntrip/branches/BNC_2.12/src/RTCM3/RTCM3coDecoder.cpp@ 8840

Last change on this file since 8840 was 8840, checked in by stuerze, 5 years ago

update with respect to BDS signal mapping IDs as far as consistent with RINEX v3.04

File size: 28.0 KB
RevLine 
[866]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 *
[6215]37 * Changes:
[866]38 *
39 * -----------------------------------------------------------------------*/
40
[868]41#include <stdio.h>
[920]42#include <math.h>
[868]43
[866]44#include "RTCM3coDecoder.h"
[918]45#include "bncutils.h"
[934]46#include "bncrinex.h"
[5070]47#include "bnccore.h"
[1535]48#include "bncsettings.h"
[4428]49#include "bnctime.h"
[866]50
51using namespace std;
52
53// Constructor
54////////////////////////////////////////////////////////////////////////////
[970]55RTCM3coDecoder::RTCM3coDecoder(const QString& staID) {
[934]56
[970]57 _staID = staID;
58
[934]59 // File Output
60 // -----------
[1535]61 bncSettings settings;
[934]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 }
[970]68 _fileNameSkl = path + staID;
[934]69 }
[6141]70 _out = 0;
[934]71
[6215]72 connect(this, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
[6141]73 BNC_CORE, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
[1828]74
[6215]75 connect(this, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
[6141]76 BNC_CORE, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
77
[6486]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
[6215]87 connect(this, SIGNAL(providerIDChanged(QString)),
[5577]88 BNC_CORE, SIGNAL(providerIDChanged(QString)));
89
[6215]90 connect(this, SIGNAL(newMessage(QByteArray,bool)),
[5068]91 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
[4428]92
[6467]93 reset();
[5576]94
95 _providerID[0] = -1;
96 _providerID[1] = -1;
97 _providerID[2] = -1;
[866]98}
99
100// Destructor
101////////////////////////////////////////////////////////////////////////////
102RTCM3coDecoder::~RTCM3coDecoder() {
[935]103 delete _out;
[7641]104 _IODs.clear();
105 _orbCorrections.clear();
106 _clkCorrections.clear();
107 _lastClkCorrections.clear();
108 _codeBiases.clear();
109 _phaseBiases.clear();
110 _vTecMap.clear();
[866]111}
112
[7641]113//
[6467]114////////////////////////////////////////////////////////////////////////////
115void RTCM3coDecoder::reset() {
116 memset(&_clkOrb, 0, sizeof(_clkOrb));
117 memset(&_codeBias, 0, sizeof(_codeBias));
118 memset(&_phaseBias, 0, sizeof(_phaseBias));
119 memset(&_vTEC, 0, sizeof(_vTEC));
120}
121
[934]122// Reopen Output File
[6215]123////////////////////////////////////////////////////////////////////////
[6141]124void RTCM3coDecoder::reopen() {
[934]125
[6141]126 if (!_fileNameSkl.isEmpty()) {
[934]127
[1535]128 bncSettings settings;
[934]129
[1154]130 QDateTime datTim = currentDateAndTimeGPS();
[934]131
132 QString hlpStr = bncRinex::nextEpochStr(datTim,
[7179]133 settings.value("corrIntr").toString(), false);
[934]134
[6215]135 QString fileNameHlp = _fileNameSkl
[934]136 + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'))
[938]137 + hlpStr + datTim.toString(".yyC");
[934]138
[6141]139 if (_fileName == fileNameHlp) {
[934]140 return;
141 }
142 else {
[6141]143 _fileName = fileNameHlp;
[934]144 }
145
[6141]146 delete _out;
[1727]147 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
[6141]148 _out = new ofstream( _fileName.toAscii().data(), ios_base::out | ios_base::app );
[1727]149 }
150 else {
[6141]151 _out = new ofstream( _fileName.toAscii().data() );
[1727]152 }
[934]153 }
154}
155
[6215]156//
[866]157////////////////////////////////////////////////////////////////////////////
[1227]158t_irc RTCM3coDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
[868]159
[1218]160 errmsg.clear();
161
[1227]162 _buffer.append(QByteArray(buffer,bufLen));
[868]163
[1023]164 t_irc retCode = failure;
165
[1832]166 while(_buffer.size()) {
167
[6454]168 struct ClockOrbit clkOrbSav;
169 struct CodeBias codeBiasSav;
170 struct PhaseBias phaseBiasSav;
171 struct VTEC vTECSav;
172 memcpy(&clkOrbSav, &_clkOrb, sizeof(clkOrbSav)); // save state
173 memcpy(&codeBiasSav, &_codeBias, sizeof(codeBiasSav));
174 memcpy(&phaseBiasSav, &_phaseBias, sizeof(phaseBiasSav));
175 memcpy(&vTECSav, &_vTEC, sizeof(vTECSav));
176
[879]177 int bytesused = 0;
[7641]178 GCOB_RETURN irc = GetSSR(&_clkOrb, &_codeBias, &_vTEC, &_phaseBias,
[6454]179 _buffer.data(), _buffer.size(), &bytesused);
[1829]180
[1833]181 if (irc <= -30) { // not enough data - restore state and exit loop
[6454]182 memcpy(&_clkOrb, &clkOrbSav, sizeof(clkOrbSav));
183 memcpy(&_codeBias, &codeBiasSav, sizeof(codeBiasSav));
184 memcpy(&_phaseBias, &phaseBiasSav, sizeof(phaseBiasSav));
185 memcpy(&_vTEC, &vTECSav, sizeof(vTECSav));
[1833]186 break;
[869]187 }
[1832]188
[1833]189 else if (irc < 0) { // error - skip 1 byte and retry
[6467]190 reset();
[1842]191 _buffer = _buffer.mid(bytesused ? bytesused : 1);
[1833]192 }
193
194 else { // OK or MESSAGEFOLLOWS
[1828]195 _buffer = _buffer.mid(bytesused);
196
[6467]197 if (irc == GCOBR_OK || irc == GCOBR_MESSAGEFOLLOWS ) {
[2435]198
[6556]199 setEpochTime(); // sets _lastTime
[7641]200
201 if (_lastTime.valid()) {
[6467]202 reopen();
203 checkProviderID();
204 sendResults();
205 retCode = success;
[919]206 }
[6467]207 else {
208 retCode = failure;
[1829]209 }
[918]210
[6467]211 reset();
[869]212 }
[1829]213 }
[1833]214 }
[1832]215
[1829]216 return retCode;
[866]217}
[934]218
[6215]219//
[934]220////////////////////////////////////////////////////////////////////////////
[6141]221void RTCM3coDecoder::sendResults() {
[934]222
[6455]223 // Orbit and clock corrections of all satellites
224 // ---------------------------------------------
[6854]225 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
226 + CLOCKORBIT_NUMGLONASS
227 + CLOCKORBIT_NUMGALILEO
228 + CLOCKORBIT_NUMQZSS
229 + CLOCKORBIT_NUMSBAS
230 + _clkOrb.NumberOfSat[CLOCKORBIT_SATBDS];
231 ii++) {
[3022]232 char sysCh = ' ';
[7005]233 int flag = 0;
[6454]234 if (ii < _clkOrb.NumberOfSat[CLOCKORBIT_SATGPS]) {
[3022]235 sysCh = 'G';
236 }
[6854]237 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]238 ii < CLOCKORBIT_OFFSETGLONASS + _clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[3022]239 sysCh = 'R';
240 }
[6854]241 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]242 ii < CLOCKORBIT_OFFSETGALILEO + _clkOrb.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]243 sysCh = 'E';
[7005]244 flag = 1; // I/NAV clock has been chosen as reference clock for Galileo SSR corrections
[6854]245 }
246 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]247 ii < CLOCKORBIT_OFFSETQZSS + _clkOrb.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]248 sysCh = 'J';
249 }
250 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]251 ii < CLOCKORBIT_OFFSETSBAS + _clkOrb.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]252 sysCh = 'S';
253 }
254 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]255 ii < CLOCKORBIT_OFFSETBDS + _clkOrb.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]256 sysCh = 'C';
257 }
[6141]258 else {
259 continue;
260 }
261 // Orbit correction
262 // ----------------
[6454]263 if ( _clkOrb.messageType == COTYPE_GPSCOMBINED ||
264 _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
[6854]265 _clkOrb.messageType == COTYPE_GALILEOCOMBINED ||
266 _clkOrb.messageType == COTYPE_QZSSCOMBINED ||
267 _clkOrb.messageType == COTYPE_SBASCOMBINED ||
268 _clkOrb.messageType == COTYPE_BDSCOMBINED ||
269 _clkOrb.messageType == COTYPE_GPSORBIT ||
270 _clkOrb.messageType == COTYPE_GLONASSORBIT ||
271 _clkOrb.messageType == COTYPE_GALILEOORBIT ||
272 _clkOrb.messageType == COTYPE_QZSSORBIT ||
273 _clkOrb.messageType == COTYPE_SBASORBIT ||
274 _clkOrb.messageType == COTYPE_BDSORBIT ) {
[3022]275
[6141]276 t_orbCorr orbCorr;
[8312]277 orbCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID, flag);
[6564]278 orbCorr._staID = _staID.toStdString();
[6556]279 orbCorr._iod = _clkOrb.Sat[ii].IOD;
280 orbCorr._time = _lastTime;
281 orbCorr._updateInt = _clkOrb.UpdateInterval;
[6854]282 orbCorr._system = sysCh;
[6556]283 orbCorr._xr[0] = _clkOrb.Sat[ii].Orbit.DeltaRadial;
284 orbCorr._xr[1] = _clkOrb.Sat[ii].Orbit.DeltaAlongTrack;
285 orbCorr._xr[2] = _clkOrb.Sat[ii].Orbit.DeltaCrossTrack;
286 orbCorr._dotXr[0] = _clkOrb.Sat[ii].Orbit.DotDeltaRadial;
287 orbCorr._dotXr[1] = _clkOrb.Sat[ii].Orbit.DotDeltaAlongTrack;
288 orbCorr._dotXr[2] = _clkOrb.Sat[ii].Orbit.DotDeltaCrossTrack;
[3022]289
[7652]290 _orbCorrections[_lastTime].append(orbCorr);
[3022]291
[6471]292 _IODs[orbCorr._prn] = _clkOrb.Sat[ii].IOD;
[6141]293 }
[3022]294
[6455]295 // Clock Corrections
296 // -----------------
[6454]297 if ( _clkOrb.messageType == COTYPE_GPSCOMBINED ||
298 _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
[6854]299 _clkOrb.messageType == COTYPE_GALILEOCOMBINED ||
300 _clkOrb.messageType == COTYPE_QZSSCOMBINED ||
301 _clkOrb.messageType == COTYPE_SBASCOMBINED ||
302 _clkOrb.messageType == COTYPE_BDSCOMBINED ||
303 _clkOrb.messageType == COTYPE_GPSCLOCK ||
304 _clkOrb.messageType == COTYPE_GLONASSCLOCK ||
305 _clkOrb.messageType == COTYPE_GALILEOCLOCK ||
306 _clkOrb.messageType == COTYPE_QZSSCLOCK ||
307 _clkOrb.messageType == COTYPE_SBASCLOCK ||
308 _clkOrb.messageType == COTYPE_BDSCLOCK) {
[3022]309
[6141]310 t_clkCorr clkCorr;
[8312]311 clkCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID, flag);
[6564]312 clkCorr._staID = _staID.toStdString();
[6141]313 clkCorr._time = _lastTime;
[6556]314 clkCorr._updateInt = _clkOrb.UpdateInterval;
[7014]315 clkCorr._dClk = _clkOrb.Sat[ii].Clock.DeltaA0 / t_CST::c;
316 clkCorr._dotDClk = _clkOrb.Sat[ii].Clock.DeltaA1 / t_CST::c;
317 clkCorr._dotDotDClk = _clkOrb.Sat[ii].Clock.DeltaA2 / t_CST::c;
[3022]318
[6471]319 _lastClkCorrections[clkCorr._prn] = clkCorr;
320
321 if (_IODs.contains(clkCorr._prn)) {
322 clkCorr._iod = _IODs[clkCorr._prn];
[7652]323 _clkCorrections[_lastTime].append(clkCorr);
[3022]324 }
325 }
[6141]326
327 // High-Resolution Clocks
328 // ----------------------
[6454]329 if ( _clkOrb.messageType == COTYPE_GPSHR ||
[6854]330 _clkOrb.messageType == COTYPE_GLONASSHR ||
331 _clkOrb.messageType == COTYPE_GALILEOHR ||
332 _clkOrb.messageType == COTYPE_QZSSHR ||
333 _clkOrb.messageType == COTYPE_SBASHR ||
334 _clkOrb.messageType == COTYPE_BDSHR) {
[7005]335 t_prn prn(sysCh, _clkOrb.Sat[ii].ID, flag);
[6471]336 if (_lastClkCorrections.contains(prn)) {
337 t_clkCorr clkCorr;
[6556]338 clkCorr = _lastClkCorrections[prn];
339 clkCorr._time = _lastTime;
340 clkCorr._updateInt = _clkOrb.UpdateInterval;
341 clkCorr._dClk += _clkOrb.Sat[ii].hrclock / t_CST::c;
[6471]342 if (_IODs.contains(clkCorr._prn)) {
343 clkCorr._iod = _IODs[clkCorr._prn];
[6497]344 _clkCorrections[_lastTime].push_back(clkCorr);
[6471]345 }
346 }
[6141]347 }
[3022]348 }
349
[6455]350 // Code Biases
351 // -----------
[6854]352 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
353 + CLOCKORBIT_NUMGLONASS
354 + CLOCKORBIT_NUMGALILEO
355 + CLOCKORBIT_NUMQZSS
356 + CLOCKORBIT_NUMSBAS
357 + _codeBias.NumberOfSat[CLOCKORBIT_SATBDS];
358 ii++) {
[6141]359 char sysCh = ' ';
[6454]360 if (ii < _codeBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
[6141]361 sysCh = 'G';
[3022]362 }
[6854]363 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]364 ii < CLOCKORBIT_OFFSETGLONASS + _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[6141]365 sysCh = 'R';
[3022]366 }
[6854]367 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]368 ii < CLOCKORBIT_OFFSETGALILEO + _codeBias.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]369 sysCh = 'E';
370 }
371 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]372 ii < CLOCKORBIT_OFFSETQZSS + _codeBias.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]373 sysCh = 'J';
374 }
375 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]376 ii < CLOCKORBIT_OFFSETSBAS + _codeBias.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]377 sysCh = 'S';
378 }
379 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]380 ii < CLOCKORBIT_OFFSETBDS + _codeBias.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]381 sysCh = 'C';
382 }
[6141]383 else {
384 continue;
385 }
[6463]386 t_satCodeBias satCodeBias;
[8312]387 satCodeBias._prn.set(sysCh, _codeBias.Sat[ii].ID);
[6564]388 satCodeBias._staID = _staID.toStdString();
[6556]389 satCodeBias._time = _lastTime;
390 satCodeBias._updateInt = _codeBias.UpdateInterval;
[6454]391 for (unsigned jj = 0; jj < _codeBias.Sat[ii].NumberOfCodeBiases; jj++) {
[6472]392 const CodeBias::BiasSat::CodeBiasEntry& biasEntry = _codeBias.Sat[ii].Biases[jj];
393 t_frqCodeBias frqCodeBias;
[7850]394 frqCodeBias._rnxType2ch.assign(codeTypeToRnxType(sysCh, biasEntry.Type));
[6472]395 frqCodeBias._value = biasEntry.Bias;
[6474]396 if (!frqCodeBias._rnxType2ch.empty()) {
397 satCodeBias._bias.push_back(frqCodeBias);
398 }
[6141]399 }
[7652]400 _codeBiases[_lastTime].append(satCodeBias);
[3022]401 }
402
[6487]403 // Phase Biases
404 // -----------
[6854]405 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
406 + CLOCKORBIT_NUMGLONASS
407 + CLOCKORBIT_NUMGALILEO
408 + CLOCKORBIT_NUMQZSS
409 + CLOCKORBIT_NUMSBAS
410 + _phaseBias.NumberOfSat[CLOCKORBIT_SATBDS];
411 ii++) {
[6487]412 char sysCh = ' ';
413 if (ii < _phaseBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
414 sysCh = 'G';
415 }
[6854]416 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]417 ii < CLOCKORBIT_OFFSETGLONASS + _phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[6487]418 sysCh = 'R';
419 }
[6854]420 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]421 ii < CLOCKORBIT_OFFSETGALILEO + _phaseBias.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]422 sysCh = 'E';
423 }
424 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]425 ii < CLOCKORBIT_OFFSETQZSS + _phaseBias.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]426 sysCh = 'J';
427 }
428 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]429 ii < CLOCKORBIT_OFFSETSBAS + _phaseBias.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]430 sysCh = 'S';
431 }
432 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]433 ii < CLOCKORBIT_OFFSETBDS + _phaseBias.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]434 sysCh = 'C';
435 }
[6487]436 else {
437 continue;
438 }
439 t_satPhaseBias satPhaseBias;
[8312]440 satPhaseBias._prn.set(sysCh, _phaseBias.Sat[ii].ID);
[6564]441 satPhaseBias._staID = _staID.toStdString();
[6488]442 satPhaseBias._time = _lastTime;
[6556]443 satPhaseBias._updateInt = _phaseBias.UpdateInterval;
[6857]444 satPhaseBias._dispBiasConstistInd = _phaseBias.DispersiveBiasConsistencyIndicator;
445 satPhaseBias._MWConsistInd = _phaseBias.MWConsistencyIndicator;
[6488]446 satPhaseBias._yawDeg = _phaseBias.Sat[ii].YawAngle * 180.0 / M_PI;
447 satPhaseBias._yawDegRate = _phaseBias.Sat[ii].YawRate * 180.0 / M_PI;
[6487]448 for (unsigned jj = 0; jj < _phaseBias.Sat[ii].NumberOfPhaseBiases; jj++) {
449 const PhaseBias::PhaseBiasSat::PhaseBiasEntry& biasEntry = _phaseBias.Sat[ii].Biases[jj];
450 t_frqPhaseBias frqPhaseBias;
[7850]451 frqPhaseBias._rnxType2ch.assign(codeTypeToRnxType(sysCh, biasEntry.Type));
[6488]452 frqPhaseBias._value = biasEntry.Bias;
453 frqPhaseBias._fixIndicator = biasEntry.SignalIntegerIndicator;
454 frqPhaseBias._fixWideLaneIndicator = biasEntry.SignalsWideLaneIntegerIndicator;
455 frqPhaseBias._jumpCounter = biasEntry.SignalDiscontinuityCounter;
[6487]456 if (!frqPhaseBias._rnxType2ch.empty()) {
457 satPhaseBias._bias.push_back(frqPhaseBias);
458 }
459 }
[7652]460 _phaseBiases[_lastTime].append(satPhaseBias);
[6487]461 }
462
[6490]463 // Ionospheric Model
464 // -----------------
465 if (_vTEC.NumLayers > 0) {
[6497]466 _vTecMap[_lastTime]._time = _lastTime;
[6556]467 _vTecMap[_lastTime]._updateInt = _vTEC.UpdateInterval;
[6564]468 _vTecMap[_lastTime]._staID = _staID.toStdString();
[6491]469 for (unsigned ii = 0; ii < _vTEC.NumLayers; ii++) {
470 const VTEC::IonoLayers& ionoLayer = _vTEC.Layers[ii];
471 t_vTecLayer layer;
472 layer._height = ionoLayer.Height;
[6878]473 layer._C.ReSize(ionoLayer.Degree+1, ionoLayer.Order+1);
474 layer._S.ReSize(ionoLayer.Degree+1, ionoLayer.Order+1);
475 for (unsigned iDeg = 0; iDeg <= ionoLayer.Degree; iDeg++) {
476 for (unsigned iOrd = 0; iOrd <= ionoLayer.Order; iOrd++) {
[6491]477 layer._C[iDeg][iOrd] = ionoLayer.Cosinus[iDeg][iOrd];
478 layer._S[iDeg][iOrd] = ionoLayer.Sinus[iDeg][iOrd];
479 }
480 }
[6497]481 _vTecMap[_lastTime]._layers.push_back(layer);
[6491]482 }
[6490]483 }
484
[6455]485 // Dump all older epochs
486 // ---------------------
487 QMutableMapIterator<bncTime, QList<t_orbCorr> > itOrb(_orbCorrections);
488 while (itOrb.hasNext()) {
489 itOrb.next();
490 if (itOrb.key() < _lastTime) {
491 emit newOrbCorrections(itOrb.value());
[6456]492 t_orbCorr::writeEpoch(_out, itOrb.value());
[6455]493 itOrb.remove();
[7641]494 }
[6141]495 }
[6455]496 QMutableMapIterator<bncTime, QList<t_clkCorr> > itClk(_clkCorrections);
497 while (itClk.hasNext()) {
498 itClk.next();
499 if (itClk.key() < _lastTime) {
500 emit newClkCorrections(itClk.value());
[6456]501 t_clkCorr::writeEpoch(_out, itClk.value());
[6455]502 itClk.remove();
[7641]503 }
[6141]504 }
[6474]505 QMutableMapIterator<bncTime, QList<t_satCodeBias> > itCB(_codeBiases);
506 while (itCB.hasNext()) {
507 itCB.next();
508 if (itCB.key() < _lastTime) {
509 emit newCodeBiases(itCB.value());
[6475]510 t_satCodeBias::writeEpoch(_out, itCB.value());
[6474]511 itCB.remove();
[7641]512 }
[6474]513 }
[6487]514 QMutableMapIterator<bncTime, QList<t_satPhaseBias> > itPB(_phaseBiases);
515 while (itPB.hasNext()) {
516 itPB.next();
517 if (itPB.key() < _lastTime) {
518 emit newPhaseBiases(itPB.value());
519 t_satPhaseBias::writeEpoch(_out, itPB.value());
520 itPB.remove();
[7641]521 }
[6487]522 }
[6490]523 QMutableMapIterator<bncTime, t_vTec> itTec(_vTecMap);
524 while (itTec.hasNext()) {
525 itTec.next();
526 if (itTec.key() < _lastTime) {
527 emit newTec(itTec.value());
528 t_vTec::write(_out, itTec.value());
529 itTec.remove();
[7641]530 }
[6490]531 }
[3022]532}
[5576]533
[6215]534//
[5576]535////////////////////////////////////////////////////////////////////////////
536void RTCM3coDecoder::checkProviderID() {
537
[6454]538 if (_clkOrb.SSRProviderID == 0 && _clkOrb.SSRSolutionID == 0 && _clkOrb.SSRIOD == 0) {
[5576]539 return;
540 }
541
542 int newProviderID[3];
[6454]543 newProviderID[0] = _clkOrb.SSRProviderID;
544 newProviderID[1] = _clkOrb.SSRSolutionID;
545 newProviderID[2] = _clkOrb.SSRIOD;
[5576]546
547 bool alreadySet = false;
548 bool different = false;
549
550 for (unsigned ii = 0; ii < 3; ii++) {
551 if (_providerID[ii] != -1) {
552 alreadySet = true;
553 }
554 if (_providerID[ii] != newProviderID[ii]) {
555 different = true;
556 }
557 _providerID[ii] = newProviderID[ii];
558 }
[6215]559
[5576]560 if (alreadySet && different) {
[7967]561 emit newMessage("RTCM3coDecoder: Provider Changed: " + _staID.toAscii(), true);
[5577]562 emit providerIDChanged(_staID);
[5576]563 }
564}
[6467]565
566//
567////////////////////////////////////////////////////////////////////////////
[6556]568void RTCM3coDecoder::setEpochTime() {
[6467]569
570 _lastTime.reset();
571
[6854]572 double epoSecGPS = -1.0;
573 double epoSecGlo = -1.0;
574 double epoSecGal = -1.0;
575 double epoSecQzss = -1.0;
576 double epoSecSbas = -1.0;
577 double epoSecBds = -1.0;
[6467]578 if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[6553]579 epoSecGPS = _clkOrb.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6467]580 }
581 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[7641]582 epoSecGPS = _codeBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6467]583 }
[6470]584 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[7641]585 epoSecGPS = _phaseBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6470]586 }
587 else if (_vTEC.NumLayers > 0) {
[7641]588 epoSecGPS = _vTEC.EpochTime; // 0 .. 604799 s
[6470]589 }
[6467]590 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
[6470]591 epoSecGlo = _clkOrb.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
[6467]592 }
593 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
[6470]594 epoSecGlo = _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
[6467]595 }
[6470]596 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
597 epoSecGlo = _phaseBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
598 }
[6854]599 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
600 epoSecGal = _clkOrb.EpochTime[CLOCKORBIT_SATGALILEO];
601 }
602 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
603 epoSecGal = _codeBias.EpochTime[CLOCKORBIT_SATGALILEO];
604 }
605 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
606 epoSecGal = _phaseBias.EpochTime[CLOCKORBIT_SATGALILEO];
607 }
608 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
609 epoSecQzss = _clkOrb.EpochTime[CLOCKORBIT_SATQZSS];
610 }
611 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
612 epoSecQzss = _codeBias.EpochTime[CLOCKORBIT_SATQZSS];
613 }
614 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
615 epoSecQzss = _phaseBias.EpochTime[CLOCKORBIT_SATQZSS];
616 }
617 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
618 epoSecSbas = _clkOrb.EpochTime[CLOCKORBIT_SATSBAS];
619 }
620 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
621 epoSecSbas = _codeBias.EpochTime[CLOCKORBIT_SATSBAS];
622 }
623 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
624 epoSecSbas = _phaseBias.EpochTime[CLOCKORBIT_SATSBAS];
625 }
626 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
627 epoSecBds = _clkOrb.EpochTime[CLOCKORBIT_SATBDS];
628 }
629 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
630 epoSecBds = _codeBias.EpochTime[CLOCKORBIT_SATBDS];
631 }
632 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
633 epoSecBds = _phaseBias.EpochTime[CLOCKORBIT_SATBDS];
634 }
[6467]635
636 // Retrieve current time
637 // ---------------------
638 int currentWeek = 0;
639 double currentSec = 0.0;
640 currentGPSWeeks(currentWeek, currentSec);
641 bncTime currentTime(currentWeek, currentSec);
642
643 // Set _lastTime close to currentTime
644 // ----------------------------------
645 if (epoSecGPS != -1) {
646 _lastTime.set(currentWeek, epoSecGPS);
647 }
648 else if (epoSecGlo != -1) {
649 QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
650 epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
651 _lastTime.set(currentWeek, epoSecGlo);
[6468]652 }
[6854]653 else if (epoSecGal != -1) {
654 _lastTime.set(currentWeek, epoSecGal);
655 }
656 else if (epoSecQzss != -1) {
657 _lastTime.set(currentWeek, epoSecQzss);
658 }
659 else if (epoSecSbas != -1) {
660 _lastTime.set(currentWeek, epoSecSbas);
661 }
662 else if (epoSecBds != -1) {
663 epoSecBds += 14.0;
[7711]664 if (epoSecBds > 604800.0) {
665 epoSecBds -= 7.0*24.0*60.0*60.0;
666 }
[6854]667 _lastTime.set(currentWeek, epoSecBds);
668 }
[6468]669
670 if (_lastTime.valid()) {
[6469]671 double maxDiff = 12 * 3600.0;
672 while (_lastTime < currentTime - maxDiff) {
673 _lastTime = _lastTime + maxDiff;
[6467]674 }
[6469]675 while (_lastTime > currentTime + maxDiff) {
676 _lastTime = _lastTime - maxDiff;
[6467]677 }
678 }
679}
[6472]680
681//
682////////////////////////////////////////////////////////////////////////////
683string RTCM3coDecoder::codeTypeToRnxType(char system, CodeType type) const {
684 if (system == 'G') {
685 switch (type) {
[8009]686 case CODETYPEGPS_L1_CA: return "1C";
687 case CODETYPEGPS_L1_P: return "1P";
688 case CODETYPEGPS_L1_Z: return "1W";
[8628]689 case CODETYPEGPS_L1_Y: return "1Y";
690 case CODETYPEGPS_L1_M: return "1M";
[8009]691 case CODETYPEGPS_L2_CA: return "2C";
692 case CODETYPEGPS_SEMI_CODELESS: return "2D";
[8628]693 case CODETYPEGPS_L2C_M: return "2S";
694 case CODETYPEGPS_L2C_L: return "2L";
695 case CODETYPEGPS_L2C_ML: return "2X";
[8009]696 case CODETYPEGPS_L2_P: return "2P";
697 case CODETYPEGPS_L2_Z: return "2W";
[8628]698 case CODETYPEGPS_L2_Y: return "2Y";
699 case CODETYPEGPS_L2_M: return "2M";
[8009]700 case CODETYPEGPS_L5_I: return "5I";
701 case CODETYPEGPS_L5_Q: return "5Q";
702 case CODETYPEGPS_L5_IQ: return "5X";
703 case CODETYPEGPS_L1C_D: return "1S";
704 case CODETYPEGPS_L1C_P: return "1L";
705 case CODETYPEGPS_L1C_DP: return "1X";
706 default: return "";
[6472]707 }
708 }
709 else if (system == 'R') {
710 switch (type) {
[8009]711 case CODETYPEGLONASS_L1_CA: return "1C";
712 case CODETYPEGLONASS_L1_P: return "1P";
713 case CODETYPEGLONASS_L2_CA: return "2C";
714 case CODETYPEGLONASS_L2_P: return "2P";
[8628]715 case CODETYPEGLONASS_L1a_OCd: return "4A";
716 case CODETYPEGLONASS_L1a_OCp: return "4B";
717 case CODETYPEGLONASS_L1a_OCdp: return "4X";
718 case CODETYPEGLONASS_L2a_CSI: return "6A";
719 case CODETYPEGLONASS_L2a_OCp: return "6B";
720 case CODETYPEGLONASS_L2a_CSIOCp:return "6X";
[8029]721 case CODETYPEGLONASS_L3_I: return "3I";
722 case CODETYPEGLONASS_L3_Q: return "3Q";
[8312]723 case CODETYPEGLONASS_L3_IQ: return "3X";
[8009]724 default: return "";
[6472]725 }
726 }
727 else if (system == 'E') {
728 switch (type) {
[8009]729 case CODETYPEGALILEO_E1_A: return "1A";
730 case CODETYPEGALILEO_E1_B: return "1B";
731 case CODETYPEGALILEO_E1_C: return "1C";
732 case CODETYPEGALILEO_E1_BC: return "1X";
733 case CODETYPEGALILEO_E1_ABC: return "1Z";
734 case CODETYPEGALILEO_E5A_I: return "5I";
735 case CODETYPEGALILEO_E5A_Q: return "5Q";
736 case CODETYPEGALILEO_E5A_IQ: return "5X";
737 case CODETYPEGALILEO_E5B_I: return "7I";
738 case CODETYPEGALILEO_E5B_Q: return "7Q";
739 case CODETYPEGALILEO_E5B_IQ: return "7X";
740 case CODETYPEGALILEO_E5_I: return "8I";
741 case CODETYPEGALILEO_E5_Q: return "8Q";
742 case CODETYPEGALILEO_E5_IQ: return "8X";
743 case CODETYPEGALILEO_E6_A: return "6A";
744 case CODETYPEGALILEO_E6_B: return "6B";
745 case CODETYPEGALILEO_E6_C: return "6C";
746 case CODETYPEGALILEO_E6_BC: return "6X";
747 case CODETYPEGALILEO_E6_ABC: return "6Z";
748 default: return "";
[6472]749 }
750 }
751 else if (system == 'J') {
752 switch (type) {
[8009]753 case CODETYPEQZSS_L1_CA: return "1C";
754 case CODETYPEQZSS_L1C_D: return "1S";
755 case CODETYPEQZSS_L1C_P: return "1L";
756 case CODETYPEQZSS_L2C_M: return "2S";
757 case CODETYPEQZSS_L2C_L: return "2L";
758 case CODETYPEQZSS_L2C_ML: return "2X";
759 case CODETYPEQZSS_L5_I: return "5I";
760 case CODETYPEQZSS_L5_Q: return "5Q";
761 case CODETYPEQZSS_L5_IQ: return "5X";
[8628]762 case CODETYPEQZSS_L6_D: return "6S";
763 case CODETYPEQZSS_L6_P: return "6L";
764 case CODETYPEQZSS_L6_DP: return "6X";
765 case CODETYPEQZSS_L1C_DP: return "1X";
766 case CODETYPEQZSS_L1_S: return "1Z";
767 case CODETYPEQZSS_L5_D: return "5D";
768 case CODETYPEQZSS_L5_P: return "5P";
769 case CODETYPEQZSS_L5_DP: return "5Z";
770 case CODETYPEQZSS_L6_E: return "6E";
771 case CODETYPEQZSS_L6_DE: return "6Z";
[8009]772 default: return "";
[6472]773 }
774 }
775 else if (system == 'S') {
776 switch (type) {
[8009]777 case CODETYPE_SBAS_L1_CA: return "1C";
778 case CODETYPE_SBAS_L5_I: return "5I";
779 case CODETYPE_SBAS_L5_Q: return "5Q";
780 case CODETYPE_SBAS_L5_IQ: return "5X";
781 default: return "";
[6472]782 }
783 }
784 else if (system == 'C') {
785 switch (type) {
[8009]786 case CODETYPE_BDS_B1_I: return "2I";
787 case CODETYPE_BDS_B1_Q: return "2Q";
788 case CODETYPE_BDS_B1_IQ: return "2X";
[8628]789 case CODETYPE_BDS_B3_I: return "6I";
790 case CODETYPE_BDS_B3_Q: return "6Q";
791 case CODETYPE_BDS_B3_IQ: return "6X";
[8009]792 case CODETYPE_BDS_B2_I: return "7I";
793 case CODETYPE_BDS_B2_Q: return "7Q";
794 case CODETYPE_BDS_B2_IQ: return "7X";
[8840]795 case CODETYPE_BDS_B2a_D: return "1D";
796 case CODETYPE_BDS_B2a_P: return "1P";
797 case CODETYPE_BDS_B2a_DP: return "1X";
798 case CODETYPE_BDS_B1C_D: return "5D";
799 case CODETYPE_BDS_B1C_P: return "5P";
800 case CODETYPE_BDS_B1C_DP: return "5X";
[8009]801 default: return "";
[6472]802 }
803 }
804 return "";
805};
Note: See TracBrowser for help on using the repository browser.