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