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

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

extension of the rtcm3coDecoder interface regarding RTCM SSR I+II messages for Galileo, QZSS, SBAS and BDS

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