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

Last change on this file since 9051 was 9051, checked in by stuerze, 4 years ago

minor changes

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