source: ntrip/trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp@ 7647

Last change on this file since 7647 was 7641, checked in by stuerze, 9 years ago

some code cleanup

File size: 26.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;
[7005]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
[6497]290 _orbCorrections[_lastTime].push_back(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;
[7005]311 clkCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID, flag);
312
[6564]313 clkCorr._staID = _staID.toStdString();
[6141]314 clkCorr._time = _lastTime;
[6556]315 clkCorr._updateInt = _clkOrb.UpdateInterval;
[7014]316 clkCorr._dClk = _clkOrb.Sat[ii].Clock.DeltaA0 / t_CST::c;
317 clkCorr._dotDClk = _clkOrb.Sat[ii].Clock.DeltaA1 / t_CST::c;
318 clkCorr._dotDotDClk = _clkOrb.Sat[ii].Clock.DeltaA2 / t_CST::c;
[3022]319
[6471]320 _lastClkCorrections[clkCorr._prn] = clkCorr;
321
322 if (_IODs.contains(clkCorr._prn)) {
323 clkCorr._iod = _IODs[clkCorr._prn];
[6497]324 _clkCorrections[_lastTime].push_back(clkCorr);
[3022]325 }
326 }
[6141]327
328 // High-Resolution Clocks
329 // ----------------------
[6454]330 if ( _clkOrb.messageType == COTYPE_GPSHR ||
[6854]331 _clkOrb.messageType == COTYPE_GLONASSHR ||
332 _clkOrb.messageType == COTYPE_GALILEOHR ||
333 _clkOrb.messageType == COTYPE_QZSSHR ||
334 _clkOrb.messageType == COTYPE_SBASHR ||
335 _clkOrb.messageType == COTYPE_BDSHR) {
[7005]336 t_prn prn(sysCh, _clkOrb.Sat[ii].ID, flag);
[6471]337 if (_lastClkCorrections.contains(prn)) {
338 t_clkCorr clkCorr;
[6556]339 clkCorr = _lastClkCorrections[prn];
340 clkCorr._time = _lastTime;
341 clkCorr._updateInt = _clkOrb.UpdateInterval;
342 clkCorr._dClk += _clkOrb.Sat[ii].hrclock / t_CST::c;
[6471]343 if (_IODs.contains(clkCorr._prn)) {
344 clkCorr._iod = _IODs[clkCorr._prn];
[6497]345 _clkCorrections[_lastTime].push_back(clkCorr);
[6471]346 }
347 }
[6141]348 }
[3022]349 }
350
[6455]351 // Code Biases
352 // -----------
[6854]353 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
354 + CLOCKORBIT_NUMGLONASS
355 + CLOCKORBIT_NUMGALILEO
356 + CLOCKORBIT_NUMQZSS
357 + CLOCKORBIT_NUMSBAS
358 + _codeBias.NumberOfSat[CLOCKORBIT_SATBDS];
359 ii++) {
[6141]360 char sysCh = ' ';
[6454]361 if (ii < _codeBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
[6141]362 sysCh = 'G';
[3022]363 }
[6854]364 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]365 ii < CLOCKORBIT_OFFSETGLONASS + _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[6141]366 sysCh = 'R';
[3022]367 }
[6854]368 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]369 ii < CLOCKORBIT_OFFSETGALILEO + _codeBias.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]370 sysCh = 'E';
371 }
372 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]373 ii < CLOCKORBIT_OFFSETQZSS + _codeBias.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]374 sysCh = 'J';
375 }
376 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]377 ii < CLOCKORBIT_OFFSETSBAS + _codeBias.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]378 sysCh = 'S';
379 }
380 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]381 ii < CLOCKORBIT_OFFSETBDS + _codeBias.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]382 sysCh = 'C';
383 }
[6141]384 else {
385 continue;
386 }
[6463]387 t_satCodeBias satCodeBias;
388 satCodeBias._prn.set(sysCh, _codeBias.Sat[ii].ID);
[6564]389 satCodeBias._staID = _staID.toStdString();
[6556]390 satCodeBias._time = _lastTime;
391 satCodeBias._updateInt = _codeBias.UpdateInterval;
[6454]392 for (unsigned jj = 0; jj < _codeBias.Sat[ii].NumberOfCodeBiases; jj++) {
[6472]393 const CodeBias::BiasSat::CodeBiasEntry& biasEntry = _codeBias.Sat[ii].Biases[jj];
394 t_frqCodeBias frqCodeBias;
395 frqCodeBias._rnxType2ch = codeTypeToRnxType(sysCh, biasEntry.Type);
396 frqCodeBias._value = biasEntry.Bias;
[6474]397 if (!frqCodeBias._rnxType2ch.empty()) {
398 satCodeBias._bias.push_back(frqCodeBias);
399 }
[6141]400 }
[6497]401 _codeBiases[_lastTime].push_back(satCodeBias);
[3022]402 }
403
[6487]404 // Phase Biases
405 // -----------
[6854]406 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
407 + CLOCKORBIT_NUMGLONASS
408 + CLOCKORBIT_NUMGALILEO
409 + CLOCKORBIT_NUMQZSS
410 + CLOCKORBIT_NUMSBAS
411 + _phaseBias.NumberOfSat[CLOCKORBIT_SATBDS];
412 ii++) {
[6487]413 char sysCh = ' ';
414 if (ii < _phaseBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
415 sysCh = 'G';
416 }
[6854]417 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]418 ii < CLOCKORBIT_OFFSETGLONASS + _phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[6487]419 sysCh = 'R';
420 }
[6854]421 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]422 ii < CLOCKORBIT_OFFSETGALILEO + _phaseBias.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]423 sysCh = 'E';
424 }
425 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]426 ii < CLOCKORBIT_OFFSETQZSS + _phaseBias.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]427 sysCh = 'J';
428 }
429 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]430 ii < CLOCKORBIT_OFFSETSBAS + _phaseBias.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]431 sysCh = 'S';
432 }
433 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]434 ii < CLOCKORBIT_OFFSETBDS + _phaseBias.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]435 sysCh = 'C';
436 }
[6487]437 else {
438 continue;
439 }
440 t_satPhaseBias satPhaseBias;
441 satPhaseBias._prn.set(sysCh, _phaseBias.Sat[ii].ID);
[6564]442 satPhaseBias._staID = _staID.toStdString();
[6488]443 satPhaseBias._time = _lastTime;
[6556]444 satPhaseBias._updateInt = _phaseBias.UpdateInterval;
[6857]445 satPhaseBias._dispBiasConstistInd = _phaseBias.DispersiveBiasConsistencyIndicator;
446 satPhaseBias._MWConsistInd = _phaseBias.MWConsistencyIndicator;
[6488]447 satPhaseBias._yawDeg = _phaseBias.Sat[ii].YawAngle * 180.0 / M_PI;
448 satPhaseBias._yawDegRate = _phaseBias.Sat[ii].YawRate * 180.0 / M_PI;
[6487]449 for (unsigned jj = 0; jj < _phaseBias.Sat[ii].NumberOfPhaseBiases; jj++) {
450 const PhaseBias::PhaseBiasSat::PhaseBiasEntry& biasEntry = _phaseBias.Sat[ii].Biases[jj];
451 t_frqPhaseBias frqPhaseBias;
[6488]452 frqPhaseBias._rnxType2ch = codeTypeToRnxType(sysCh, biasEntry.Type);
453 frqPhaseBias._value = biasEntry.Bias;
454 frqPhaseBias._fixIndicator = biasEntry.SignalIntegerIndicator;
455 frqPhaseBias._fixWideLaneIndicator = biasEntry.SignalsWideLaneIntegerIndicator;
456 frqPhaseBias._jumpCounter = biasEntry.SignalDiscontinuityCounter;
[6487]457 if (!frqPhaseBias._rnxType2ch.empty()) {
458 satPhaseBias._bias.push_back(frqPhaseBias);
459 }
460 }
[6497]461 _phaseBiases[_lastTime].push_back(satPhaseBias);
[6487]462 }
463
[6490]464 // Ionospheric Model
465 // -----------------
466 if (_vTEC.NumLayers > 0) {
[6497]467 _vTecMap[_lastTime]._time = _lastTime;
[6556]468 _vTecMap[_lastTime]._updateInt = _vTEC.UpdateInterval;
[6564]469 _vTecMap[_lastTime]._staID = _staID.toStdString();
[6491]470 for (unsigned ii = 0; ii < _vTEC.NumLayers; ii++) {
471 const VTEC::IonoLayers& ionoLayer = _vTEC.Layers[ii];
472 t_vTecLayer layer;
473 layer._height = ionoLayer.Height;
[6878]474 layer._C.ReSize(ionoLayer.Degree+1, ionoLayer.Order+1);
475 layer._S.ReSize(ionoLayer.Degree+1, ionoLayer.Order+1);
476 for (unsigned iDeg = 0; iDeg <= ionoLayer.Degree; iDeg++) {
477 for (unsigned iOrd = 0; iOrd <= ionoLayer.Order; iOrd++) {
[6491]478 layer._C[iDeg][iOrd] = ionoLayer.Cosinus[iDeg][iOrd];
479 layer._S[iDeg][iOrd] = ionoLayer.Sinus[iDeg][iOrd];
480 }
481 }
[6497]482 _vTecMap[_lastTime]._layers.push_back(layer);
[6491]483 }
[6490]484 }
485
[6455]486 // Dump all older epochs
487 // ---------------------
488 QMutableMapIterator<bncTime, QList<t_orbCorr> > itOrb(_orbCorrections);
489 while (itOrb.hasNext()) {
490 itOrb.next();
491 if (itOrb.key() < _lastTime) {
492 emit newOrbCorrections(itOrb.value());
[6456]493 t_orbCorr::writeEpoch(_out, itOrb.value());
[6455]494 itOrb.remove();
[7641]495 }
[6141]496 }
[6455]497 QMutableMapIterator<bncTime, QList<t_clkCorr> > itClk(_clkCorrections);
498 while (itClk.hasNext()) {
499 itClk.next();
500 if (itClk.key() < _lastTime) {
501 emit newClkCorrections(itClk.value());
[6456]502 t_clkCorr::writeEpoch(_out, itClk.value());
[6455]503 itClk.remove();
[7641]504 }
[6141]505 }
[6474]506 QMutableMapIterator<bncTime, QList<t_satCodeBias> > itCB(_codeBiases);
507 while (itCB.hasNext()) {
508 itCB.next();
509 if (itCB.key() < _lastTime) {
510 emit newCodeBiases(itCB.value());
[6475]511 t_satCodeBias::writeEpoch(_out, itCB.value());
[6474]512 itCB.remove();
[7641]513 }
[6474]514 }
[6487]515 QMutableMapIterator<bncTime, QList<t_satPhaseBias> > itPB(_phaseBiases);
516 while (itPB.hasNext()) {
517 itPB.next();
518 if (itPB.key() < _lastTime) {
519 emit newPhaseBiases(itPB.value());
520 t_satPhaseBias::writeEpoch(_out, itPB.value());
521 itPB.remove();
[7641]522 }
[6487]523 }
[6490]524 QMutableMapIterator<bncTime, t_vTec> itTec(_vTecMap);
525 while (itTec.hasNext()) {
526 itTec.next();
527 if (itTec.key() < _lastTime) {
528 emit newTec(itTec.value());
529 t_vTec::write(_out, itTec.value());
530 itTec.remove();
[7641]531 }
[6490]532 }
[3022]533}
[5576]534
[6215]535//
[5576]536////////////////////////////////////////////////////////////////////////////
537void RTCM3coDecoder::checkProviderID() {
538
[6454]539 if (_clkOrb.SSRProviderID == 0 && _clkOrb.SSRSolutionID == 0 && _clkOrb.SSRIOD == 0) {
[5576]540 return;
541 }
542
543 int newProviderID[3];
[6454]544 newProviderID[0] = _clkOrb.SSRProviderID;
545 newProviderID[1] = _clkOrb.SSRSolutionID;
546 newProviderID[2] = _clkOrb.SSRIOD;
[5576]547
548 bool alreadySet = false;
549 bool different = false;
550
551 for (unsigned ii = 0; ii < 3; ii++) {
552 if (_providerID[ii] != -1) {
553 alreadySet = true;
554 }
555 if (_providerID[ii] != newProviderID[ii]) {
556 different = true;
557 }
558 _providerID[ii] = newProviderID[ii];
559 }
[6215]560
[5576]561 if (alreadySet && different) {
[5580]562 emit newMessage("RTCM3coDecoder: Provider Changed " + _staID.toAscii() + "\n", true);
[5577]563 emit providerIDChanged(_staID);
[5576]564 }
565}
[6467]566
567//
568////////////////////////////////////////////////////////////////////////////
[6556]569void RTCM3coDecoder::setEpochTime() {
[6467]570
571 _lastTime.reset();
572
[6854]573 double epoSecGPS = -1.0;
574 double epoSecGlo = -1.0;
575 double epoSecGal = -1.0;
576 double epoSecQzss = -1.0;
577 double epoSecSbas = -1.0;
578 double epoSecBds = -1.0;
[6467]579 if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[6553]580 epoSecGPS = _clkOrb.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6467]581 }
582 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[7641]583 epoSecGPS = _codeBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6467]584 }
[6470]585 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[7641]586 epoSecGPS = _phaseBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6470]587 }
588 else if (_vTEC.NumLayers > 0) {
[7641]589 epoSecGPS = _vTEC.EpochTime; // 0 .. 604799 s
[6470]590 }
[6467]591 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
[6470]592 epoSecGlo = _clkOrb.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
[6467]593 }
594 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
[6470]595 epoSecGlo = _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
[6467]596 }
[6470]597 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
598 epoSecGlo = _phaseBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
599 }
[6854]600 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
601 epoSecGal = _clkOrb.EpochTime[CLOCKORBIT_SATGALILEO];
602 }
603 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
604 epoSecGal = _codeBias.EpochTime[CLOCKORBIT_SATGALILEO];
605 }
606 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
607 epoSecGal = _phaseBias.EpochTime[CLOCKORBIT_SATGALILEO];
608 }
609 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
610 epoSecQzss = _clkOrb.EpochTime[CLOCKORBIT_SATQZSS];
611 }
612 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
613 epoSecQzss = _codeBias.EpochTime[CLOCKORBIT_SATQZSS];
614 }
615 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
616 epoSecQzss = _phaseBias.EpochTime[CLOCKORBIT_SATQZSS];
617 }
618 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
619 epoSecSbas = _clkOrb.EpochTime[CLOCKORBIT_SATSBAS];
620 }
621 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
622 epoSecSbas = _codeBias.EpochTime[CLOCKORBIT_SATSBAS];
623 }
624 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
625 epoSecSbas = _phaseBias.EpochTime[CLOCKORBIT_SATSBAS];
626 }
627 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
628 epoSecBds = _clkOrb.EpochTime[CLOCKORBIT_SATBDS];
629 }
630 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
631 epoSecBds = _codeBias.EpochTime[CLOCKORBIT_SATBDS];
632 }
633 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
634 epoSecBds = _phaseBias.EpochTime[CLOCKORBIT_SATBDS];
635 }
[6467]636
637 // Retrieve current time
638 // ---------------------
639 int currentWeek = 0;
640 double currentSec = 0.0;
641 currentGPSWeeks(currentWeek, currentSec);
642 bncTime currentTime(currentWeek, currentSec);
643
644 // Set _lastTime close to currentTime
645 // ----------------------------------
646 if (epoSecGPS != -1) {
647 _lastTime.set(currentWeek, epoSecGPS);
648 }
649 else if (epoSecGlo != -1) {
650 QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
651 epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
652 _lastTime.set(currentWeek, epoSecGlo);
[6468]653 }
[6854]654 else if (epoSecGal != -1) {
655 _lastTime.set(currentWeek, epoSecGal);
656 }
657 else if (epoSecQzss != -1) {
658 _lastTime.set(currentWeek, epoSecQzss);
659 }
660 else if (epoSecSbas != -1) {
661 _lastTime.set(currentWeek, epoSecSbas);
662 }
663 else if (epoSecBds != -1) {
664 epoSecBds += 14.0;
665 _lastTime.set(currentWeek, epoSecBds);
666 }
[6468]667
668 if (_lastTime.valid()) {
[6469]669 double maxDiff = 12 * 3600.0;
670 while (_lastTime < currentTime - maxDiff) {
671 _lastTime = _lastTime + maxDiff;
[6467]672 }
[6469]673 while (_lastTime > currentTime + maxDiff) {
674 _lastTime = _lastTime - maxDiff;
[6467]675 }
676 }
677}
[6472]678
679//
680////////////////////////////////////////////////////////////////////////////
681string RTCM3coDecoder::codeTypeToRnxType(char system, CodeType type) const {
682 if (system == 'G') {
683 switch (type) {
[6473]684 case CODETYPEGPS_L1_CA: return "1C";
685 case CODETYPEGPS_L1_P: return "1P";
686 case CODETYPEGPS_L1_Z: return "1W";
687 case CODETYPEGPS_L2_CA: return "2C";
688 case CODETYPEGPS_SEMI_CODELESS: return "?N"; // which carrier ?
689 case CODETYPEGPS_L2_CM: return "2S";
690 case CODETYPEGPS_L2_CL: return "2L";
691 case CODETYPEGPS_L2_CML: return "2X";
692 case CODETYPEGPS_L2_P: return "2P";
693 case CODETYPEGPS_L2_Z: return "2W";
694 case CODETYPEGPS_L5_I: return "5I";
695 case CODETYPEGPS_L5_Q: return "5Q";
[7641]696 default: return "";
[6472]697 }
698 }
699 else if (system == 'R') {
700 switch (type) {
[6473]701 case CODETYPEGLONASS_L1_CA: return "1C";
702 case CODETYPEGLONASS_L1_P: return "1P";
703 case CODETYPEGLONASS_L2_CA: return "2C";
704 case CODETYPEGLONASS_L2_P: return "2P";
[7641]705 default: return "";
[6472]706 }
707 }
708 else if (system == 'E') {
709 switch (type) {
[6473]710 case CODETYPEGALILEO_E1_A: return "1A";
711 case CODETYPEGALILEO_E1_B: return "1B";
712 case CODETYPEGALILEO_E1_C: return "1C";
713 case CODETYPEGALILEO_E5A_I: return "5I";
714 case CODETYPEGALILEO_E5A_Q: return "5Q";
715 case CODETYPEGALILEO_E5B_I: return "7I";
716 case CODETYPEGALILEO_E5B_Q: return "7Q";
717 case CODETYPEGALILEO_E5_I: return "8I";
718 case CODETYPEGALILEO_E5_Q: return "8Q";
719 case CODETYPEGALILEO_E6_A: return "6A";
720 case CODETYPEGALILEO_E6_B: return "6B";
721 case CODETYPEGALILEO_E6_C: return "6C";
[7641]722 default: return "";
[6472]723 }
724 }
725 else if (system == 'J') {
726 switch (type) {
[6473]727 case CODETYPEQZSS_L1_CA: return "1C";
728 case CODETYPEQZSS_L1C_D: return "1S";
729 case CODETYPEQZSS_L1C_P: return "1L";
730 case CODETYPEQZSS_L1C_DP: return "1X";
731 case CODETYPEQZSS_L2_CM: return "2S";
732 case CODETYPEQZSS_L2_CL: return "2L";
733 case CODETYPEQZSS_L2_CML: return "2X";
734 case CODETYPEQZSS_L5_I: return "5I";
735 case CODETYPEQZSS_L5_Q: return "5Q";
736 case CODETYPEQZSS_L5_IQ: return "5X";
737 case CODETYPEQZSS_LEX_S: return "6S";
738 case CODETYPEQZSS_LEX_L: return "6L";
739 case CODETYPEQZSS_LEX_SL: return "6X";
[7641]740 default: return "";
[6472]741 }
742 }
743 else if (system == 'S') {
744 switch (type) {
[6473]745 case CODETYPE_SBAS_L1_CA: return "1C";
746 case CODETYPE_SBAS_L5_I: return "5I";
747 case CODETYPE_SBAS_L5_Q: return "5Q";
748 case CODETYPE_SBAS_L5_IQ: return "5X";
[7641]749 default: return "";
[6472]750 }
751 }
752 else if (system == 'C') {
753 switch (type) {
[6473]754 case CODETYPE_BDS_B1_I: return "1I";
755 case CODETYPE_BDS_B1_Q: return "1Q";
756 case CODETYPE_BDS_B1_IQ: return "1X";
757 case CODETYPE_BDS_B2_I: return "7I";
758 case CODETYPE_BDS_B2_Q: return "7Q";
759 case CODETYPE_BDS_B2_IQ: return "7X";
760 case CODETYPE_BDS_B3_I: return "6I";
761 case CODETYPE_BDS_B3_Q: return "6Q";
762 case CODETYPE_BDS_B3_IQ: return "6X";
[7641]763 default: return "";
[6472]764 }
765 }
766 return "";
767};
Note: See TracBrowser for help on using the repository browser.