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

Last change on this file since 9424 was 9424, checked in by stuerze, 3 years ago

Example Configs updated

File size: 23.3 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////////////////////////////////////////////////////////////////////////////
[9048]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;
[9025]98
99 _ssrCorr = 0;
[866]100}
101
102// Destructor
103////////////////////////////////////////////////////////////////////////////
104RTCM3coDecoder::~RTCM3coDecoder() {
[935]105 delete _out;
[9025]106 delete _ssrCorr;
[7641]107 _IODs.clear();
108 _orbCorrections.clear();
109 _clkCorrections.clear();
110 _lastClkCorrections.clear();
111 _codeBiases.clear();
112 _phaseBiases.clear();
113 _vTecMap.clear();
[866]114}
115
[7641]116//
[6467]117////////////////////////////////////////////////////////////////////////////
118void RTCM3coDecoder::reset() {
119 memset(&_clkOrb, 0, sizeof(_clkOrb));
120 memset(&_codeBias, 0, sizeof(_codeBias));
121 memset(&_phaseBias, 0, sizeof(_phaseBias));
122 memset(&_vTEC, 0, sizeof(_vTEC));
123}
124
[934]125// Reopen Output File
[6215]126////////////////////////////////////////////////////////////////////////
[6141]127void RTCM3coDecoder::reopen() {
[934]128
[6141]129 if (!_fileNameSkl.isEmpty()) {
[934]130
[1535]131 bncSettings settings;
[934]132
[1154]133 QDateTime datTim = currentDateAndTimeGPS();
[934]134
135 QString hlpStr = bncRinex::nextEpochStr(datTim,
[7179]136 settings.value("corrIntr").toString(), false);
[934]137
[6215]138 QString fileNameHlp = _fileNameSkl
[9424]139 + QString("_%1").arg(datTim.date().year())
[934]140 + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'))
[938]141 + hlpStr + datTim.toString(".yyC");
[934]142
[6141]143 if (_fileName == fileNameHlp) {
[934]144 return;
145 }
146 else {
[6141]147 _fileName = fileNameHlp;
[934]148 }
149
[6141]150 delete _out;
[1727]151 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
[8204]152 _out = new ofstream( _fileName.toLatin1().data(), ios_base::out | ios_base::app );
[1727]153 }
154 else {
[8204]155 _out = new ofstream( _fileName.toLatin1().data() );
[1727]156 }
[934]157 }
158}
159
[6215]160//
[866]161////////////////////////////////////////////////////////////////////////////
[1227]162t_irc RTCM3coDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
[868]163
[1218]164 errmsg.clear();
165
[1227]166 _buffer.append(QByteArray(buffer,bufLen));
[868]167
[1023]168 t_irc retCode = failure;
169
[1832]170 while(_buffer.size()) {
171
[9025]172 struct SsrCorr::ClockOrbit clkOrbSav;
173 struct SsrCorr::CodeBias codeBiasSav;
174 struct SsrCorr::PhaseBias phaseBiasSav;
175 struct SsrCorr::VTEC vTECSav;
[6454]176 memcpy(&clkOrbSav, &_clkOrb, sizeof(clkOrbSav)); // save state
177 memcpy(&codeBiasSav, &_codeBias, sizeof(codeBiasSav));
178 memcpy(&phaseBiasSav, &_phaseBias, sizeof(phaseBiasSav));
179 memcpy(&vTECSav, &_vTEC, sizeof(vTECSav));
180
[879]181 int bytesused = 0;
[9306]182
[9025]183 GCOB_RETURN irc = _ssrCorr->GetSSR(&_clkOrb, &_codeBias, &_vTEC, &_phaseBias,
[9306]184 _buffer.data(), _buffer.size(), &bytesused);
[1829]185
[1833]186 if (irc <= -30) { // not enough data - restore state and exit loop
[6454]187 memcpy(&_clkOrb, &clkOrbSav, sizeof(clkOrbSav));
188 memcpy(&_codeBias, &codeBiasSav, sizeof(codeBiasSav));
189 memcpy(&_phaseBias, &phaseBiasSav, sizeof(phaseBiasSav));
190 memcpy(&_vTEC, &vTECSav, sizeof(vTECSav));
[1833]191 break;
[869]192 }
[1832]193
[1833]194 else if (irc < 0) { // error - skip 1 byte and retry
[6467]195 reset();
[1842]196 _buffer = _buffer.mid(bytesused ? bytesused : 1);
[1833]197 }
198
199 else { // OK or MESSAGEFOLLOWS
[1828]200 _buffer = _buffer.mid(bytesused);
201
[6467]202 if (irc == GCOBR_OK || irc == GCOBR_MESSAGEFOLLOWS ) {
[2435]203
[6556]204 setEpochTime(); // sets _lastTime
[7641]205
206 if (_lastTime.valid()) {
[6467]207 reopen();
208 checkProviderID();
209 sendResults();
210 retCode = success;
[919]211 }
[6467]212 else {
213 retCode = failure;
[1829]214 }
[918]215
[6467]216 reset();
[869]217 }
[1829]218 }
[1833]219 }
[1832]220
[1829]221 return retCode;
[866]222}
[934]223
[6215]224//
[934]225////////////////////////////////////////////////////////////////////////////
[6141]226void RTCM3coDecoder::sendResults() {
[934]227
[6455]228 // Orbit and clock corrections of all satellites
229 // ---------------------------------------------
[6854]230 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
231 + CLOCKORBIT_NUMGLONASS
232 + CLOCKORBIT_NUMGALILEO
233 + CLOCKORBIT_NUMQZSS
234 + CLOCKORBIT_NUMSBAS
235 + _clkOrb.NumberOfSat[CLOCKORBIT_SATBDS];
236 ii++) {
[3022]237 char sysCh = ' ';
[7005]238 int flag = 0;
[6454]239 if (ii < _clkOrb.NumberOfSat[CLOCKORBIT_SATGPS]) {
[3022]240 sysCh = 'G';
241 }
[6854]242 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]243 ii < CLOCKORBIT_OFFSETGLONASS + _clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[3022]244 sysCh = 'R';
245 }
[6854]246 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]247 ii < CLOCKORBIT_OFFSETGALILEO + _clkOrb.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]248 sysCh = 'E';
[7005]249 flag = 1; // I/NAV clock has been chosen as reference clock for Galileo SSR corrections
[6854]250 }
251 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]252 ii < CLOCKORBIT_OFFSETQZSS + _clkOrb.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]253 sysCh = 'J';
254 }
255 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]256 ii < CLOCKORBIT_OFFSETSBAS + _clkOrb.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]257 sysCh = 'S';
258 }
259 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]260 ii < CLOCKORBIT_OFFSETBDS + _clkOrb.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]261 sysCh = 'C';
262 }
[6141]263 else {
264 continue;
265 }
[9025]266
[6141]267 // Orbit correction
268 // ----------------
[9025]269 if ( _clkOrb.messageType == _ssrCorr->COTYPE_GPSCOMBINED ||
270 _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSCOMBINED ||
271 _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOCOMBINED ||
272 _clkOrb.messageType == _ssrCorr->COTYPE_QZSSCOMBINED ||
273 _clkOrb.messageType == _ssrCorr->COTYPE_SBASCOMBINED ||
274 _clkOrb.messageType == _ssrCorr->COTYPE_BDSCOMBINED ||
275 _clkOrb.messageType == _ssrCorr->COTYPE_GPSORBIT ||
276 _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSORBIT ||
277 _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOORBIT ||
278 _clkOrb.messageType == _ssrCorr->COTYPE_QZSSORBIT ||
279 _clkOrb.messageType == _ssrCorr->COTYPE_SBASORBIT ||
280 _clkOrb.messageType == _ssrCorr->COTYPE_BDSORBIT ) {
[3022]281
[6141]282 t_orbCorr orbCorr;
[8313]283 orbCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID, flag);
[6564]284 orbCorr._staID = _staID.toStdString();
[6556]285 orbCorr._iod = _clkOrb.Sat[ii].IOD;
286 orbCorr._time = _lastTime;
287 orbCorr._updateInt = _clkOrb.UpdateInterval;
[6854]288 orbCorr._system = sysCh;
[6556]289 orbCorr._xr[0] = _clkOrb.Sat[ii].Orbit.DeltaRadial;
290 orbCorr._xr[1] = _clkOrb.Sat[ii].Orbit.DeltaAlongTrack;
291 orbCorr._xr[2] = _clkOrb.Sat[ii].Orbit.DeltaCrossTrack;
292 orbCorr._dotXr[0] = _clkOrb.Sat[ii].Orbit.DotDeltaRadial;
293 orbCorr._dotXr[1] = _clkOrb.Sat[ii].Orbit.DotDeltaAlongTrack;
294 orbCorr._dotXr[2] = _clkOrb.Sat[ii].Orbit.DotDeltaCrossTrack;
[3022]295
[7652]296 _orbCorrections[_lastTime].append(orbCorr);
[3022]297
[6471]298 _IODs[orbCorr._prn] = _clkOrb.Sat[ii].IOD;
[6141]299 }
[3022]300
[6455]301 // Clock Corrections
302 // -----------------
[9025]303 if ( _clkOrb.messageType == _ssrCorr->COTYPE_GPSCOMBINED ||
304 _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSCOMBINED ||
305 _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOCOMBINED ||
306 _clkOrb.messageType == _ssrCorr->COTYPE_QZSSCOMBINED ||
307 _clkOrb.messageType == _ssrCorr->COTYPE_SBASCOMBINED ||
308 _clkOrb.messageType == _ssrCorr->COTYPE_BDSCOMBINED ||
309 _clkOrb.messageType == _ssrCorr->COTYPE_GPSCLOCK ||
310 _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSCLOCK ||
311 _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOCLOCK ||
312 _clkOrb.messageType == _ssrCorr->COTYPE_QZSSCLOCK ||
313 _clkOrb.messageType == _ssrCorr->COTYPE_SBASCLOCK ||
314 _clkOrb.messageType == _ssrCorr->COTYPE_BDSCLOCK) {
[3022]315
[6141]316 t_clkCorr clkCorr;
[8313]317 clkCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID, flag);
[6564]318 clkCorr._staID = _staID.toStdString();
[6141]319 clkCorr._time = _lastTime;
[6556]320 clkCorr._updateInt = _clkOrb.UpdateInterval;
[7014]321 clkCorr._dClk = _clkOrb.Sat[ii].Clock.DeltaA0 / t_CST::c;
322 clkCorr._dotDClk = _clkOrb.Sat[ii].Clock.DeltaA1 / t_CST::c;
323 clkCorr._dotDotDClk = _clkOrb.Sat[ii].Clock.DeltaA2 / t_CST::c;
[3022]324
[6471]325 _lastClkCorrections[clkCorr._prn] = clkCorr;
326
327 if (_IODs.contains(clkCorr._prn)) {
328 clkCorr._iod = _IODs[clkCorr._prn];
[7652]329 _clkCorrections[_lastTime].append(clkCorr);
[3022]330 }
331 }
[6141]332
333 // High-Resolution Clocks
334 // ----------------------
[9025]335 if ( _clkOrb.messageType == _ssrCorr->COTYPE_GPSHR ||
336 _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSHR ||
337 _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOHR ||
338 _clkOrb.messageType == _ssrCorr->COTYPE_QZSSHR ||
339 _clkOrb.messageType == _ssrCorr->COTYPE_SBASHR ||
340 _clkOrb.messageType == _ssrCorr->COTYPE_BDSHR) {
[7005]341 t_prn prn(sysCh, _clkOrb.Sat[ii].ID, flag);
[6471]342 if (_lastClkCorrections.contains(prn)) {
343 t_clkCorr clkCorr;
[6556]344 clkCorr = _lastClkCorrections[prn];
345 clkCorr._time = _lastTime;
346 clkCorr._updateInt = _clkOrb.UpdateInterval;
347 clkCorr._dClk += _clkOrb.Sat[ii].hrclock / t_CST::c;
[6471]348 if (_IODs.contains(clkCorr._prn)) {
349 clkCorr._iod = _IODs[clkCorr._prn];
[6497]350 _clkCorrections[_lastTime].push_back(clkCorr);
[6471]351 }
352 }
[6141]353 }
[3022]354 }
355
[6455]356 // Code Biases
357 // -----------
[6854]358 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
359 + CLOCKORBIT_NUMGLONASS
360 + CLOCKORBIT_NUMGALILEO
361 + CLOCKORBIT_NUMQZSS
362 + CLOCKORBIT_NUMSBAS
363 + _codeBias.NumberOfSat[CLOCKORBIT_SATBDS];
364 ii++) {
[6141]365 char sysCh = ' ';
[6454]366 if (ii < _codeBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
[6141]367 sysCh = 'G';
[3022]368 }
[6854]369 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]370 ii < CLOCKORBIT_OFFSETGLONASS + _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[6141]371 sysCh = 'R';
[3022]372 }
[6854]373 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]374 ii < CLOCKORBIT_OFFSETGALILEO + _codeBias.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]375 sysCh = 'E';
376 }
377 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]378 ii < CLOCKORBIT_OFFSETQZSS + _codeBias.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]379 sysCh = 'J';
380 }
381 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]382 ii < CLOCKORBIT_OFFSETSBAS + _codeBias.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]383 sysCh = 'S';
384 }
385 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]386 ii < CLOCKORBIT_OFFSETBDS + _codeBias.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]387 sysCh = 'C';
388 }
[6141]389 else {
390 continue;
391 }
[6463]392 t_satCodeBias satCodeBias;
[8313]393 satCodeBias._prn.set(sysCh, _codeBias.Sat[ii].ID);
[6564]394 satCodeBias._staID = _staID.toStdString();
[6556]395 satCodeBias._time = _lastTime;
396 satCodeBias._updateInt = _codeBias.UpdateInterval;
[6454]397 for (unsigned jj = 0; jj < _codeBias.Sat[ii].NumberOfCodeBiases; jj++) {
[9025]398 const SsrCorr::CodeBias::BiasSat::CodeBiasEntry& biasEntry = _codeBias.Sat[ii].Biases[jj];
[6472]399 t_frqCodeBias frqCodeBias;
[9025]400 frqCodeBias._rnxType2ch.assign(_ssrCorr->codeTypeToRnxType(sysCh, biasEntry.Type));
[6472]401 frqCodeBias._value = biasEntry.Bias;
[6474]402 if (!frqCodeBias._rnxType2ch.empty()) {
403 satCodeBias._bias.push_back(frqCodeBias);
404 }
[6141]405 }
[7652]406 _codeBiases[_lastTime].append(satCodeBias);
[3022]407 }
408
[6487]409 // Phase Biases
410 // -----------
[6854]411 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS
412 + CLOCKORBIT_NUMGLONASS
413 + CLOCKORBIT_NUMGALILEO
414 + CLOCKORBIT_NUMQZSS
415 + CLOCKORBIT_NUMSBAS
416 + _phaseBias.NumberOfSat[CLOCKORBIT_SATBDS];
417 ii++) {
[6487]418 char sysCh = ' ';
419 if (ii < _phaseBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
420 sysCh = 'G';
421 }
[6854]422 else if (ii >= CLOCKORBIT_OFFSETGLONASS &&
[6855]423 ii < CLOCKORBIT_OFFSETGLONASS + _phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS]) {
[6487]424 sysCh = 'R';
425 }
[6854]426 else if (ii >= CLOCKORBIT_OFFSETGALILEO &&
[6855]427 ii < CLOCKORBIT_OFFSETGALILEO + _phaseBias.NumberOfSat[CLOCKORBIT_SATGALILEO]) {
[6854]428 sysCh = 'E';
429 }
430 else if (ii >= CLOCKORBIT_OFFSETQZSS &&
[6855]431 ii < CLOCKORBIT_OFFSETQZSS + _phaseBias.NumberOfSat[CLOCKORBIT_SATQZSS]) {
[6854]432 sysCh = 'J';
433 }
434 else if (ii >= CLOCKORBIT_OFFSETSBAS &&
[6855]435 ii < CLOCKORBIT_OFFSETSBAS + _phaseBias.NumberOfSat[CLOCKORBIT_SATSBAS]) {
[6854]436 sysCh = 'S';
437 }
438 else if (ii >= CLOCKORBIT_OFFSETBDS &&
[6855]439 ii < CLOCKORBIT_OFFSETBDS + _phaseBias.NumberOfSat[CLOCKORBIT_SATBDS]) {
[6854]440 sysCh = 'C';
441 }
[6487]442 else {
443 continue;
444 }
445 t_satPhaseBias satPhaseBias;
[8313]446 satPhaseBias._prn.set(sysCh, _phaseBias.Sat[ii].ID);
[6564]447 satPhaseBias._staID = _staID.toStdString();
[6488]448 satPhaseBias._time = _lastTime;
[6556]449 satPhaseBias._updateInt = _phaseBias.UpdateInterval;
[6857]450 satPhaseBias._dispBiasConstistInd = _phaseBias.DispersiveBiasConsistencyIndicator;
451 satPhaseBias._MWConsistInd = _phaseBias.MWConsistencyIndicator;
[8617]452 satPhaseBias._yaw = _phaseBias.Sat[ii].YawAngle;
453 satPhaseBias._yawRate = _phaseBias.Sat[ii].YawRate;
[6487]454 for (unsigned jj = 0; jj < _phaseBias.Sat[ii].NumberOfPhaseBiases; jj++) {
[9025]455 const SsrCorr::PhaseBias::PhaseBiasSat::PhaseBiasEntry& biasEntry = _phaseBias.Sat[ii].Biases[jj];
[6487]456 t_frqPhaseBias frqPhaseBias;
[9025]457 frqPhaseBias._rnxType2ch.assign(_ssrCorr->codeTypeToRnxType(sysCh, biasEntry.Type));
[6488]458 frqPhaseBias._value = biasEntry.Bias;
459 frqPhaseBias._fixIndicator = biasEntry.SignalIntegerIndicator;
460 frqPhaseBias._fixWideLaneIndicator = biasEntry.SignalsWideLaneIntegerIndicator;
461 frqPhaseBias._jumpCounter = biasEntry.SignalDiscontinuityCounter;
[6487]462 if (!frqPhaseBias._rnxType2ch.empty()) {
463 satPhaseBias._bias.push_back(frqPhaseBias);
464 }
465 }
[7652]466 _phaseBiases[_lastTime].append(satPhaseBias);
[6487]467 }
468
[6490]469 // Ionospheric Model
470 // -----------------
471 if (_vTEC.NumLayers > 0) {
[6497]472 _vTecMap[_lastTime]._time = _lastTime;
[6556]473 _vTecMap[_lastTime]._updateInt = _vTEC.UpdateInterval;
[6564]474 _vTecMap[_lastTime]._staID = _staID.toStdString();
[6491]475 for (unsigned ii = 0; ii < _vTEC.NumLayers; ii++) {
[9025]476 const SsrCorr::VTEC::IonoLayers& ionoLayer = _vTEC.Layers[ii];
[6491]477 t_vTecLayer layer;
478 layer._height = ionoLayer.Height;
[6878]479 layer._C.ReSize(ionoLayer.Degree+1, ionoLayer.Order+1);
480 layer._S.ReSize(ionoLayer.Degree+1, ionoLayer.Order+1);
481 for (unsigned iDeg = 0; iDeg <= ionoLayer.Degree; iDeg++) {
482 for (unsigned iOrd = 0; iOrd <= ionoLayer.Order; iOrd++) {
[6491]483 layer._C[iDeg][iOrd] = ionoLayer.Cosinus[iDeg][iOrd];
484 layer._S[iDeg][iOrd] = ionoLayer.Sinus[iDeg][iOrd];
485 }
486 }
[6497]487 _vTecMap[_lastTime]._layers.push_back(layer);
[6491]488 }
[6490]489 }
490
[6455]491 // Dump all older epochs
492 // ---------------------
493 QMutableMapIterator<bncTime, QList<t_orbCorr> > itOrb(_orbCorrections);
494 while (itOrb.hasNext()) {
495 itOrb.next();
496 if (itOrb.key() < _lastTime) {
497 emit newOrbCorrections(itOrb.value());
[6456]498 t_orbCorr::writeEpoch(_out, itOrb.value());
[6455]499 itOrb.remove();
[7641]500 }
[6141]501 }
[6455]502 QMutableMapIterator<bncTime, QList<t_clkCorr> > itClk(_clkCorrections);
503 while (itClk.hasNext()) {
504 itClk.next();
505 if (itClk.key() < _lastTime) {
506 emit newClkCorrections(itClk.value());
[6456]507 t_clkCorr::writeEpoch(_out, itClk.value());
[6455]508 itClk.remove();
[7641]509 }
[6141]510 }
[6474]511 QMutableMapIterator<bncTime, QList<t_satCodeBias> > itCB(_codeBiases);
512 while (itCB.hasNext()) {
513 itCB.next();
514 if (itCB.key() < _lastTime) {
515 emit newCodeBiases(itCB.value());
[6475]516 t_satCodeBias::writeEpoch(_out, itCB.value());
[6474]517 itCB.remove();
[7641]518 }
[6474]519 }
[6487]520 QMutableMapIterator<bncTime, QList<t_satPhaseBias> > itPB(_phaseBiases);
521 while (itPB.hasNext()) {
522 itPB.next();
523 if (itPB.key() < _lastTime) {
524 emit newPhaseBiases(itPB.value());
525 t_satPhaseBias::writeEpoch(_out, itPB.value());
526 itPB.remove();
[7641]527 }
[6487]528 }
[6490]529 QMutableMapIterator<bncTime, t_vTec> itTec(_vTecMap);
530 while (itTec.hasNext()) {
531 itTec.next();
532 if (itTec.key() < _lastTime) {
533 emit newTec(itTec.value());
534 t_vTec::write(_out, itTec.value());
535 itTec.remove();
[7641]536 }
[6490]537 }
[3022]538}
[5576]539
[6215]540//
[5576]541////////////////////////////////////////////////////////////////////////////
542void RTCM3coDecoder::checkProviderID() {
543
[6454]544 if (_clkOrb.SSRProviderID == 0 && _clkOrb.SSRSolutionID == 0 && _clkOrb.SSRIOD == 0) {
[5576]545 return;
546 }
547
548 int newProviderID[3];
[6454]549 newProviderID[0] = _clkOrb.SSRProviderID;
550 newProviderID[1] = _clkOrb.SSRSolutionID;
551 newProviderID[2] = _clkOrb.SSRIOD;
[5576]552
553 bool alreadySet = false;
554 bool different = false;
555
556 for (unsigned ii = 0; ii < 3; ii++) {
557 if (_providerID[ii] != -1) {
558 alreadySet = true;
559 }
560 if (_providerID[ii] != newProviderID[ii]) {
561 different = true;
562 }
563 _providerID[ii] = newProviderID[ii];
564 }
[6215]565
[5576]566 if (alreadySet && different) {
[8204]567 emit newMessage("RTCM3coDecoder: Provider Changed: " + _staID.toLatin1(), true);
[5577]568 emit providerIDChanged(_staID);
[5576]569 }
570}
[6467]571
572//
573////////////////////////////////////////////////////////////////////////////
[6556]574void RTCM3coDecoder::setEpochTime() {
[6467]575
576 _lastTime.reset();
577
[6854]578 double epoSecGPS = -1.0;
579 double epoSecGlo = -1.0;
580 double epoSecGal = -1.0;
581 double epoSecQzss = -1.0;
582 double epoSecSbas = -1.0;
583 double epoSecBds = -1.0;
[6467]584 if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[6553]585 epoSecGPS = _clkOrb.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6467]586 }
587 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[7641]588 epoSecGPS = _codeBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6467]589 }
[6470]590 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[7641]591 epoSecGPS = _phaseBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
[6470]592 }
593 else if (_vTEC.NumLayers > 0) {
[7641]594 epoSecGPS = _vTEC.EpochTime; // 0 .. 604799 s
[6470]595 }
[6467]596 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
[6470]597 epoSecGlo = _clkOrb.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
[6467]598 }
599 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
[6470]600 epoSecGlo = _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
[6467]601 }
[6470]602 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
603 epoSecGlo = _phaseBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
604 }
[6854]605 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
606 epoSecGal = _clkOrb.EpochTime[CLOCKORBIT_SATGALILEO];
607 }
608 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
609 epoSecGal = _codeBias.EpochTime[CLOCKORBIT_SATGALILEO];
610 }
611 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
612 epoSecGal = _phaseBias.EpochTime[CLOCKORBIT_SATGALILEO];
613 }
614 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
615 epoSecQzss = _clkOrb.EpochTime[CLOCKORBIT_SATQZSS];
616 }
617 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
618 epoSecQzss = _codeBias.EpochTime[CLOCKORBIT_SATQZSS];
619 }
620 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
621 epoSecQzss = _phaseBias.EpochTime[CLOCKORBIT_SATQZSS];
622 }
623 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
624 epoSecSbas = _clkOrb.EpochTime[CLOCKORBIT_SATSBAS];
625 }
626 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
627 epoSecSbas = _codeBias.EpochTime[CLOCKORBIT_SATSBAS];
628 }
629 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
630 epoSecSbas = _phaseBias.EpochTime[CLOCKORBIT_SATSBAS];
631 }
632 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
633 epoSecBds = _clkOrb.EpochTime[CLOCKORBIT_SATBDS];
634 }
635 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
636 epoSecBds = _codeBias.EpochTime[CLOCKORBIT_SATBDS];
637 }
638 else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
639 epoSecBds = _phaseBias.EpochTime[CLOCKORBIT_SATBDS];
640 }
[6467]641
642 // Retrieve current time
643 // ---------------------
644 int currentWeek = 0;
645 double currentSec = 0.0;
646 currentGPSWeeks(currentWeek, currentSec);
647 bncTime currentTime(currentWeek, currentSec);
648
649 // Set _lastTime close to currentTime
650 // ----------------------------------
651 if (epoSecGPS != -1) {
652 _lastTime.set(currentWeek, epoSecGPS);
653 }
654 else if (epoSecGlo != -1) {
[9050]655 if (_type == RTCMssr) {
[9025]656 QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
657 epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
658 }
[6467]659 _lastTime.set(currentWeek, epoSecGlo);
[6468]660 }
[6854]661 else if (epoSecGal != -1) {
662 _lastTime.set(currentWeek, epoSecGal);
663 }
664 else if (epoSecQzss != -1) {
665 _lastTime.set(currentWeek, epoSecQzss);
666 }
667 else if (epoSecSbas != -1) {
668 _lastTime.set(currentWeek, epoSecSbas);
669 }
670 else if (epoSecBds != -1) {
[9050]671 if (_type == RTCMssr) {
[9025]672 epoSecBds += 14.0;
673 if (epoSecBds > 604800.0) {
674 epoSecBds -= 7.0*24.0*60.0*60.0;
675 }
[7711]676 }
[6854]677 _lastTime.set(currentWeek, epoSecBds);
678 }
[6468]679
680 if (_lastTime.valid()) {
[6469]681 double maxDiff = 12 * 3600.0;
682 while (_lastTime < currentTime - maxDiff) {
683 _lastTime = _lastTime + maxDiff;
[6467]684 }
[6469]685 while (_lastTime > currentTime + maxDiff) {
686 _lastTime = _lastTime - maxDiff;
[6467]687 }
688 }
689}
Note: See TracBrowser for help on using the repository browser.