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

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