[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"
|
---|
[1834] | 49 | #include "rtcm3torinex.h"
|
---|
[4428] | 50 | #include "bnctime.h"
|
---|
[866] | 51 |
|
---|
| 52 | using namespace std;
|
---|
| 53 |
|
---|
| 54 | // Constructor
|
---|
| 55 | ////////////////////////////////////////////////////////////////////////////
|
---|
[970] | 56 | RTCM3coDecoder::RTCM3coDecoder(const QString& staID) {
|
---|
[934] | 57 |
|
---|
[970] | 58 | _staID = staID;
|
---|
| 59 |
|
---|
[934] | 60 | // File Output
|
---|
| 61 | // -----------
|
---|
[1535] | 62 | bncSettings settings;
|
---|
[934] | 63 | QString path = settings.value("corrPath").toString();
|
---|
| 64 | if (!path.isEmpty()) {
|
---|
| 65 | expandEnvVar(path);
|
---|
| 66 | if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
|
---|
| 67 | path += QDir::separator();
|
---|
| 68 | }
|
---|
[970] | 69 | _fileNameSkl = path + staID;
|
---|
[934] | 70 | }
|
---|
[6141] | 71 | _out = 0;
|
---|
[934] | 72 |
|
---|
[6215] | 73 | qRegisterMetaType< QList<t_orbCorr> >("QList<t_orbCorr>");
|
---|
| 74 | qRegisterMetaType< QList<t_clkCorr> >("QList<t_clkCorr>");
|
---|
[6474] | 75 | qRegisterMetaType< QList<t_satCodeBias> >("QList<t_satCodeBias>");
|
---|
[5124] | 76 |
|
---|
[6215] | 77 | connect(this, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
[6141] | 78 | BNC_CORE, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
---|
[1828] | 79 |
|
---|
[6215] | 80 | connect(this, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
[6141] | 81 | BNC_CORE, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
---|
| 82 |
|
---|
[6215] | 83 | connect(this, SIGNAL(providerIDChanged(QString)),
|
---|
[5577] | 84 | BNC_CORE, SIGNAL(providerIDChanged(QString)));
|
---|
| 85 |
|
---|
[6215] | 86 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[5068] | 87 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
[4428] | 88 |
|
---|
[6467] | 89 | reset();
|
---|
[5576] | 90 |
|
---|
| 91 | _providerID[0] = -1;
|
---|
| 92 | _providerID[1] = -1;
|
---|
| 93 | _providerID[2] = -1;
|
---|
[866] | 94 | }
|
---|
| 95 |
|
---|
| 96 | // Destructor
|
---|
| 97 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 98 | RTCM3coDecoder::~RTCM3coDecoder() {
|
---|
[935] | 99 | delete _out;
|
---|
[866] | 100 | }
|
---|
| 101 |
|
---|
[6467] | 102 | //
|
---|
| 103 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 104 | void RTCM3coDecoder::reset() {
|
---|
| 105 | memset(&_clkOrb, 0, sizeof(_clkOrb));
|
---|
| 106 | memset(&_codeBias, 0, sizeof(_codeBias));
|
---|
| 107 | memset(&_phaseBias, 0, sizeof(_phaseBias));
|
---|
| 108 | memset(&_vTEC, 0, sizeof(_vTEC));
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[934] | 111 | // Reopen Output File
|
---|
[6215] | 112 | ////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 113 | void RTCM3coDecoder::reopen() {
|
---|
[934] | 114 |
|
---|
[6141] | 115 | if (!_fileNameSkl.isEmpty()) {
|
---|
[934] | 116 |
|
---|
[1535] | 117 | bncSettings settings;
|
---|
[934] | 118 |
|
---|
[1154] | 119 | QDateTime datTim = currentDateAndTimeGPS();
|
---|
[934] | 120 |
|
---|
| 121 | QString hlpStr = bncRinex::nextEpochStr(datTim,
|
---|
| 122 | settings.value("corrIntr").toString());
|
---|
| 123 |
|
---|
[6215] | 124 | QString fileNameHlp = _fileNameSkl
|
---|
[934] | 125 | + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'))
|
---|
[938] | 126 | + hlpStr + datTim.toString(".yyC");
|
---|
[934] | 127 |
|
---|
[6141] | 128 | if (_fileName == fileNameHlp) {
|
---|
[934] | 129 | return;
|
---|
| 130 | }
|
---|
| 131 | else {
|
---|
[6141] | 132 | _fileName = fileNameHlp;
|
---|
[934] | 133 | }
|
---|
| 134 |
|
---|
[6141] | 135 | delete _out;
|
---|
[1727] | 136 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
[6141] | 137 | _out = new ofstream( _fileName.toAscii().data(), ios_base::out | ios_base::app );
|
---|
[1727] | 138 | }
|
---|
| 139 | else {
|
---|
[6141] | 140 | _out = new ofstream( _fileName.toAscii().data() );
|
---|
[1727] | 141 | }
|
---|
[934] | 142 | }
|
---|
| 143 | }
|
---|
| 144 |
|
---|
[6215] | 145 | //
|
---|
[866] | 146 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1227] | 147 | t_irc RTCM3coDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
|
---|
[868] | 148 |
|
---|
[1218] | 149 | errmsg.clear();
|
---|
| 150 |
|
---|
[1227] | 151 | _buffer.append(QByteArray(buffer,bufLen));
|
---|
[868] | 152 |
|
---|
[1023] | 153 | t_irc retCode = failure;
|
---|
| 154 |
|
---|
[1832] | 155 | while(_buffer.size()) {
|
---|
| 156 |
|
---|
[6454] | 157 | struct ClockOrbit clkOrbSav;
|
---|
| 158 | struct CodeBias codeBiasSav;
|
---|
| 159 | struct PhaseBias phaseBiasSav;
|
---|
| 160 | struct VTEC vTECSav;
|
---|
| 161 | memcpy(&clkOrbSav, &_clkOrb, sizeof(clkOrbSav)); // save state
|
---|
| 162 | memcpy(&codeBiasSav, &_codeBias, sizeof(codeBiasSav));
|
---|
| 163 | memcpy(&phaseBiasSav, &_phaseBias, sizeof(phaseBiasSav));
|
---|
| 164 | memcpy(&vTECSav, &_vTEC, sizeof(vTECSav));
|
---|
| 165 |
|
---|
[879] | 166 | int bytesused = 0;
|
---|
[6454] | 167 | GCOB_RETURN irc = GetSSR(&_clkOrb, &_codeBias, &_vTEC, &_phaseBias,
|
---|
| 168 | _buffer.data(), _buffer.size(), &bytesused);
|
---|
[1829] | 169 |
|
---|
[1833] | 170 | if (irc <= -30) { // not enough data - restore state and exit loop
|
---|
[6454] | 171 | memcpy(&_clkOrb, &clkOrbSav, sizeof(clkOrbSav));
|
---|
| 172 | memcpy(&_codeBias, &codeBiasSav, sizeof(codeBiasSav));
|
---|
| 173 | memcpy(&_phaseBias, &phaseBiasSav, sizeof(phaseBiasSav));
|
---|
| 174 | memcpy(&_vTEC, &vTECSav, sizeof(vTECSav));
|
---|
[1833] | 175 | break;
|
---|
[869] | 176 | }
|
---|
[1832] | 177 |
|
---|
[1833] | 178 | else if (irc < 0) { // error - skip 1 byte and retry
|
---|
[6467] | 179 | reset();
|
---|
[1842] | 180 | _buffer = _buffer.mid(bytesused ? bytesused : 1);
|
---|
[1833] | 181 | }
|
---|
| 182 |
|
---|
| 183 | else { // OK or MESSAGEFOLLOWS
|
---|
[1828] | 184 | _buffer = _buffer.mid(bytesused);
|
---|
| 185 |
|
---|
[6467] | 186 | if (irc == GCOBR_OK || irc == GCOBR_MESSAGEFOLLOWS ) {
|
---|
[2435] | 187 |
|
---|
[6467] | 188 | setEpochTime(); // sets _lastTime
|
---|
| 189 |
|
---|
| 190 | if (_lastTime.valid()) {
|
---|
| 191 | reopen();
|
---|
| 192 | checkProviderID();
|
---|
| 193 | sendResults();
|
---|
| 194 | retCode = success;
|
---|
[919] | 195 | }
|
---|
[6467] | 196 | else {
|
---|
| 197 | retCode = failure;
|
---|
[1829] | 198 | }
|
---|
[918] | 199 |
|
---|
[6467] | 200 | reset();
|
---|
[869] | 201 | }
|
---|
[1829] | 202 | }
|
---|
[1833] | 203 | }
|
---|
[1832] | 204 |
|
---|
[1829] | 205 | return retCode;
|
---|
[866] | 206 | }
|
---|
[934] | 207 |
|
---|
[6215] | 208 | //
|
---|
[934] | 209 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 210 | void RTCM3coDecoder::sendResults() {
|
---|
[934] | 211 |
|
---|
[6472] | 212 | QList<t_orbCorr>& orbCorrections = _orbCorrections[_lastTime];
|
---|
| 213 | QList<t_clkCorr>& clkCorrections = _clkCorrections[_lastTime];
|
---|
| 214 | QList<t_satCodeBias>& codeBiases = _codeBiases[_lastTime];
|
---|
[4428] | 215 |
|
---|
[6455] | 216 | // Orbit and clock corrections of all satellites
|
---|
| 217 | // ---------------------------------------------
|
---|
[6454] | 218 | for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) {
|
---|
[3022] | 219 | char sysCh = ' ';
|
---|
[6454] | 220 | if (ii < _clkOrb.NumberOfSat[CLOCKORBIT_SATGPS]) {
|
---|
[3022] | 221 | sysCh = 'G';
|
---|
| 222 | }
|
---|
| 223 | else if (ii >= CLOCKORBIT_NUMGPS) {
|
---|
| 224 | sysCh = 'R';
|
---|
| 225 | }
|
---|
[6141] | 226 | else {
|
---|
| 227 | continue;
|
---|
| 228 | }
|
---|
[3024] | 229 |
|
---|
[6141] | 230 | // Orbit correction
|
---|
| 231 | // ----------------
|
---|
[6454] | 232 | if ( _clkOrb.messageType == COTYPE_GPSCOMBINED ||
|
---|
| 233 | _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 234 | _clkOrb.messageType == COTYPE_GPSORBIT ||
|
---|
| 235 | _clkOrb.messageType == COTYPE_GLONASSORBIT ) {
|
---|
[3022] | 236 |
|
---|
[6141] | 237 | t_orbCorr orbCorr;
|
---|
[6454] | 238 | orbCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID);
|
---|
[6141] | 239 | orbCorr._staID = _staID.toAscii().data();
|
---|
[6454] | 240 | orbCorr._iod = _clkOrb.Sat[ii].IOD;
|
---|
[6141] | 241 | orbCorr._time = _lastTime;
|
---|
| 242 | orbCorr._system = 'R';
|
---|
[6454] | 243 | orbCorr._xr[0] = _clkOrb.Sat[ii].Orbit.DeltaRadial;
|
---|
| 244 | orbCorr._xr[1] = _clkOrb.Sat[ii].Orbit.DeltaAlongTrack;
|
---|
| 245 | orbCorr._xr[2] = _clkOrb.Sat[ii].Orbit.DeltaCrossTrack;
|
---|
| 246 | orbCorr._dotXr[0] = _clkOrb.Sat[ii].Orbit.DotDeltaRadial;
|
---|
| 247 | orbCorr._dotXr[1] = _clkOrb.Sat[ii].Orbit.DotDeltaAlongTrack;
|
---|
| 248 | orbCorr._dotXr[2] = _clkOrb.Sat[ii].Orbit.DotDeltaCrossTrack;
|
---|
[3022] | 249 |
|
---|
[6141] | 250 | orbCorrections.push_back(orbCorr);
|
---|
[3022] | 251 |
|
---|
[6471] | 252 | _IODs[orbCorr._prn] = _clkOrb.Sat[ii].IOD;
|
---|
[6141] | 253 | }
|
---|
[3022] | 254 |
|
---|
[6455] | 255 | // Clock Corrections
|
---|
| 256 | // -----------------
|
---|
[6454] | 257 | if ( _clkOrb.messageType == COTYPE_GPSCOMBINED ||
|
---|
| 258 | _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 259 | _clkOrb.messageType == COTYPE_GPSCLOCK ||
|
---|
| 260 | _clkOrb.messageType == COTYPE_GLONASSCLOCK ) {
|
---|
[3022] | 261 |
|
---|
[6141] | 262 | t_clkCorr clkCorr;
|
---|
[6454] | 263 | clkCorr._prn.set(sysCh, _clkOrb.Sat[ii].ID);
|
---|
[6141] | 264 | clkCorr._staID = _staID.toAscii().data();
|
---|
| 265 | clkCorr._time = _lastTime;
|
---|
[6454] | 266 | clkCorr._dClk = _clkOrb.Sat[ii].Clock.DeltaA0 / t_CST::c;
|
---|
| 267 | clkCorr._dotDClk = _clkOrb.Sat[ii].Clock.DeltaA1 / t_CST::c;
|
---|
| 268 | clkCorr._dotDotDClk = _clkOrb.Sat[ii].Clock.DeltaA2 / t_CST::c;
|
---|
[3022] | 269 |
|
---|
[6471] | 270 | _lastClkCorrections[clkCorr._prn] = clkCorr;
|
---|
| 271 |
|
---|
| 272 | if (_IODs.contains(clkCorr._prn)) {
|
---|
| 273 | clkCorr._iod = _IODs[clkCorr._prn];
|
---|
[6141] | 274 | clkCorrections.push_back(clkCorr);
|
---|
[3022] | 275 | }
|
---|
| 276 | }
|
---|
[6141] | 277 |
|
---|
| 278 | // High-Resolution Clocks
|
---|
| 279 | // ----------------------
|
---|
[6454] | 280 | if ( _clkOrb.messageType == COTYPE_GPSHR ||
|
---|
| 281 | _clkOrb.messageType == COTYPE_GLONASSHR ) {
|
---|
[6471] | 282 |
|
---|
| 283 | t_prn prn(sysCh, _clkOrb.Sat[ii].ID);
|
---|
| 284 | if (_lastClkCorrections.contains(prn)) {
|
---|
| 285 | t_clkCorr clkCorr;
|
---|
| 286 | clkCorr = _lastClkCorrections[prn];
|
---|
| 287 | clkCorr._time = _lastTime;
|
---|
| 288 | clkCorr._dClk +=_clkOrb.Sat[ii].hrclock / t_CST::c;
|
---|
| 289 | if (_IODs.contains(clkCorr._prn)) {
|
---|
| 290 | clkCorr._iod = _IODs[clkCorr._prn];
|
---|
| 291 | clkCorrections.push_back(clkCorr);
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
[6141] | 294 | }
|
---|
[3022] | 295 | }
|
---|
| 296 |
|
---|
[6455] | 297 | // Code Biases
|
---|
| 298 | // -----------
|
---|
[6454] | 299 | for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) {
|
---|
[6141] | 300 | char sysCh = ' ';
|
---|
[6454] | 301 | if (ii < _codeBias.NumberOfSat[CLOCKORBIT_SATGPS]) {
|
---|
[6141] | 302 | sysCh = 'G';
|
---|
[3022] | 303 | }
|
---|
[6141] | 304 | else if (ii >= CLOCKORBIT_NUMGPS) {
|
---|
| 305 | sysCh = 'R';
|
---|
[3022] | 306 | }
|
---|
[6141] | 307 | else {
|
---|
| 308 | continue;
|
---|
| 309 | }
|
---|
[6463] | 310 | t_satCodeBias satCodeBias;
|
---|
| 311 | satCodeBias._prn.set(sysCh, _codeBias.Sat[ii].ID);
|
---|
[6472] | 312 | satCodeBias._staID = _staID.toAscii().data();
|
---|
| 313 | satCodeBias._time = _lastTime;
|
---|
[6454] | 314 | for (unsigned jj = 0; jj < _codeBias.Sat[ii].NumberOfCodeBiases; jj++) {
|
---|
[6472] | 315 | const CodeBias::BiasSat::CodeBiasEntry& biasEntry = _codeBias.Sat[ii].Biases[jj];
|
---|
| 316 | t_frqCodeBias frqCodeBias;
|
---|
| 317 | frqCodeBias._rnxType2ch = codeTypeToRnxType(sysCh, biasEntry.Type);
|
---|
| 318 | frqCodeBias._value = biasEntry.Bias;
|
---|
[6474] | 319 | if (!frqCodeBias._rnxType2ch.empty()) {
|
---|
| 320 | satCodeBias._bias.push_back(frqCodeBias);
|
---|
| 321 | }
|
---|
[6141] | 322 | }
|
---|
[6472] | 323 | codeBiases.push_back(satCodeBias);
|
---|
[3022] | 324 | }
|
---|
| 325 |
|
---|
[6455] | 326 | // Dump all older epochs
|
---|
| 327 | // ---------------------
|
---|
| 328 | QMutableMapIterator<bncTime, QList<t_orbCorr> > itOrb(_orbCorrections);
|
---|
| 329 | while (itOrb.hasNext()) {
|
---|
| 330 | itOrb.next();
|
---|
| 331 | if (itOrb.key() < _lastTime) {
|
---|
| 332 | emit newOrbCorrections(itOrb.value());
|
---|
[6456] | 333 | t_orbCorr::writeEpoch(_out, itOrb.value());
|
---|
[6455] | 334 | itOrb.remove();
|
---|
| 335 | }
|
---|
[6141] | 336 | }
|
---|
[6455] | 337 | QMutableMapIterator<bncTime, QList<t_clkCorr> > itClk(_clkCorrections);
|
---|
| 338 | while (itClk.hasNext()) {
|
---|
| 339 | itClk.next();
|
---|
| 340 | if (itClk.key() < _lastTime) {
|
---|
| 341 | emit newClkCorrections(itClk.value());
|
---|
[6456] | 342 | t_clkCorr::writeEpoch(_out, itClk.value());
|
---|
[6455] | 343 | itClk.remove();
|
---|
| 344 | }
|
---|
[6141] | 345 | }
|
---|
[6474] | 346 | QMutableMapIterator<bncTime, QList<t_satCodeBias> > itCB(_codeBiases);
|
---|
| 347 | while (itCB.hasNext()) {
|
---|
| 348 | itCB.next();
|
---|
| 349 | if (itCB.key() < _lastTime) {
|
---|
| 350 | emit newCodeBiases(itCB.value());
|
---|
[6475] | 351 | t_satCodeBias::writeEpoch(_out, itCB.value());
|
---|
[6474] | 352 | itCB.remove();
|
---|
| 353 | }
|
---|
| 354 | }
|
---|
[3022] | 355 | }
|
---|
[5576] | 356 |
|
---|
[6215] | 357 | //
|
---|
[5576] | 358 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 359 | void RTCM3coDecoder::checkProviderID() {
|
---|
| 360 |
|
---|
[6454] | 361 | if (_clkOrb.SSRProviderID == 0 && _clkOrb.SSRSolutionID == 0 && _clkOrb.SSRIOD == 0) {
|
---|
[5576] | 362 | return;
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | int newProviderID[3];
|
---|
[6454] | 366 | newProviderID[0] = _clkOrb.SSRProviderID;
|
---|
| 367 | newProviderID[1] = _clkOrb.SSRSolutionID;
|
---|
| 368 | newProviderID[2] = _clkOrb.SSRIOD;
|
---|
[5576] | 369 |
|
---|
| 370 | bool alreadySet = false;
|
---|
| 371 | bool different = false;
|
---|
| 372 |
|
---|
| 373 | for (unsigned ii = 0; ii < 3; ii++) {
|
---|
| 374 | if (_providerID[ii] != -1) {
|
---|
| 375 | alreadySet = true;
|
---|
| 376 | }
|
---|
| 377 | if (_providerID[ii] != newProviderID[ii]) {
|
---|
| 378 | different = true;
|
---|
| 379 | }
|
---|
| 380 | _providerID[ii] = newProviderID[ii];
|
---|
| 381 | }
|
---|
[6215] | 382 |
|
---|
[5576] | 383 | if (alreadySet && different) {
|
---|
[5580] | 384 | emit newMessage("RTCM3coDecoder: Provider Changed " + _staID.toAscii() + "\n", true);
|
---|
[5577] | 385 | emit providerIDChanged(_staID);
|
---|
[5576] | 386 | }
|
---|
| 387 | }
|
---|
[6467] | 388 |
|
---|
| 389 | //
|
---|
| 390 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 391 | void RTCM3coDecoder::setEpochTime() {
|
---|
| 392 |
|
---|
| 393 | _lastTime.reset();
|
---|
| 394 |
|
---|
| 395 | int epoSecGPS = -1;
|
---|
| 396 | int epoSecGlo = -1;
|
---|
| 397 | if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
|
---|
[6470] | 398 | epoSecGPS = _clkOrb.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
|
---|
[6467] | 399 | }
|
---|
| 400 | else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
|
---|
[6470] | 401 | epoSecGPS = _codeBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
|
---|
[6467] | 402 | }
|
---|
[6470] | 403 | else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
|
---|
| 404 | epoSecGPS = _phaseBias.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s
|
---|
| 405 | }
|
---|
| 406 | else if (_vTEC.NumLayers > 0) {
|
---|
| 407 | epoSecGPS = _vTEC.EpochTime; // 0 .. 604799 s
|
---|
| 408 | }
|
---|
[6467] | 409 | else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
|
---|
[6470] | 410 | epoSecGlo = _clkOrb.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
|
---|
[6467] | 411 | }
|
---|
| 412 | else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
|
---|
[6470] | 413 | epoSecGlo = _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
|
---|
[6467] | 414 | }
|
---|
[6470] | 415 | else if (_phaseBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
|
---|
| 416 | epoSecGlo = _phaseBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s
|
---|
| 417 | }
|
---|
[6467] | 418 |
|
---|
| 419 | // Retrieve current time
|
---|
| 420 | // ---------------------
|
---|
| 421 | int currentWeek = 0;
|
---|
| 422 | double currentSec = 0.0;
|
---|
| 423 | currentGPSWeeks(currentWeek, currentSec);
|
---|
| 424 | bncTime currentTime(currentWeek, currentSec);
|
---|
| 425 |
|
---|
| 426 | // Set _lastTime close to currentTime
|
---|
| 427 | // ----------------------------------
|
---|
| 428 | if (epoSecGPS != -1) {
|
---|
| 429 | _lastTime.set(currentWeek, epoSecGPS);
|
---|
| 430 | }
|
---|
| 431 | else if (epoSecGlo != -1) {
|
---|
| 432 | QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
|
---|
| 433 | epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
|
---|
| 434 | _lastTime.set(currentWeek, epoSecGlo);
|
---|
[6468] | 435 | }
|
---|
| 436 |
|
---|
| 437 | if (_lastTime.valid()) {
|
---|
[6469] | 438 | double maxDiff = 12 * 3600.0;
|
---|
| 439 | while (_lastTime < currentTime - maxDiff) {
|
---|
| 440 | _lastTime = _lastTime + maxDiff;
|
---|
[6467] | 441 | }
|
---|
[6469] | 442 | while (_lastTime > currentTime + maxDiff) {
|
---|
| 443 | _lastTime = _lastTime - maxDiff;
|
---|
[6467] | 444 | }
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
[6472] | 447 |
|
---|
| 448 | //
|
---|
| 449 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 450 | string RTCM3coDecoder::codeTypeToRnxType(char system, CodeType type) const {
|
---|
| 451 | if (system == 'G') {
|
---|
| 452 | switch (type) {
|
---|
[6473] | 453 | case CODETYPEGPS_L1_CA: return "1C";
|
---|
| 454 | case CODETYPEGPS_L1_P: return "1P";
|
---|
| 455 | case CODETYPEGPS_L1_Z: return "1W";
|
---|
| 456 | case CODETYPEGPS_L2_CA: return "2C";
|
---|
| 457 | case CODETYPEGPS_SEMI_CODELESS: return "?N"; // which carrier ?
|
---|
| 458 | case CODETYPEGPS_L2_CM: return "2S";
|
---|
| 459 | case CODETYPEGPS_L2_CL: return "2L";
|
---|
| 460 | case CODETYPEGPS_L2_CML: return "2X";
|
---|
| 461 | case CODETYPEGPS_L2_P: return "2P";
|
---|
| 462 | case CODETYPEGPS_L2_Z: return "2W";
|
---|
| 463 | case CODETYPEGPS_L5_I: return "5I";
|
---|
| 464 | case CODETYPEGPS_L5_Q: return "5Q";
|
---|
[6472] | 465 | default: return "";
|
---|
| 466 | }
|
---|
| 467 | }
|
---|
| 468 | else if (system == 'R') {
|
---|
| 469 | switch (type) {
|
---|
[6473] | 470 | case CODETYPEGLONASS_L1_CA: return "1C";
|
---|
| 471 | case CODETYPEGLONASS_L1_P: return "1P";
|
---|
| 472 | case CODETYPEGLONASS_L2_CA: return "2C";
|
---|
| 473 | case CODETYPEGLONASS_L2_P: return "2P";
|
---|
[6472] | 474 | default: return "";
|
---|
| 475 | }
|
---|
| 476 | }
|
---|
| 477 | else if (system == 'E') {
|
---|
| 478 | switch (type) {
|
---|
[6473] | 479 | case CODETYPEGALILEO_E1_A: return "1A";
|
---|
| 480 | case CODETYPEGALILEO_E1_B: return "1B";
|
---|
| 481 | case CODETYPEGALILEO_E1_C: return "1C";
|
---|
| 482 | case CODETYPEGALILEO_E5A_I: return "5I";
|
---|
| 483 | case CODETYPEGALILEO_E5A_Q: return "5Q";
|
---|
| 484 | case CODETYPEGALILEO_E5B_I: return "7I";
|
---|
| 485 | case CODETYPEGALILEO_E5B_Q: return "7Q";
|
---|
| 486 | case CODETYPEGALILEO_E5_I: return "8I";
|
---|
| 487 | case CODETYPEGALILEO_E5_Q: return "8Q";
|
---|
| 488 | case CODETYPEGALILEO_E6_A: return "6A";
|
---|
| 489 | case CODETYPEGALILEO_E6_B: return "6B";
|
---|
| 490 | case CODETYPEGALILEO_E6_C: return "6C";
|
---|
[6472] | 491 | default: return "";
|
---|
| 492 | }
|
---|
| 493 | }
|
---|
| 494 | else if (system == 'J') {
|
---|
| 495 | switch (type) {
|
---|
[6473] | 496 | case CODETYPEQZSS_L1_CA: return "1C";
|
---|
| 497 | case CODETYPEQZSS_L1C_D: return "1S";
|
---|
| 498 | case CODETYPEQZSS_L1C_P: return "1L";
|
---|
| 499 | case CODETYPEQZSS_L1C_DP: return "1X";
|
---|
| 500 | case CODETYPEQZSS_L2_CM: return "2S";
|
---|
| 501 | case CODETYPEQZSS_L2_CL: return "2L";
|
---|
| 502 | case CODETYPEQZSS_L2_CML: return "2X";
|
---|
| 503 | case CODETYPEQZSS_L5_I: return "5I";
|
---|
| 504 | case CODETYPEQZSS_L5_Q: return "5Q";
|
---|
| 505 | case CODETYPEQZSS_L5_IQ: return "5X";
|
---|
| 506 | case CODETYPEQZSS_LEX_S: return "6S";
|
---|
| 507 | case CODETYPEQZSS_LEX_L: return "6L";
|
---|
| 508 | case CODETYPEQZSS_LEX_SL: return "6X";
|
---|
[6472] | 509 | default: return "";
|
---|
| 510 | }
|
---|
| 511 | }
|
---|
| 512 | else if (system == 'S') {
|
---|
| 513 | switch (type) {
|
---|
[6473] | 514 | case CODETYPE_SBAS_L1_CA: return "1C";
|
---|
| 515 | case CODETYPE_SBAS_L5_I: return "5I";
|
---|
| 516 | case CODETYPE_SBAS_L5_Q: return "5Q";
|
---|
| 517 | case CODETYPE_SBAS_L5_IQ: return "5X";
|
---|
[6472] | 518 | default: return "";
|
---|
| 519 | }
|
---|
| 520 | }
|
---|
| 521 | else if (system == 'C') {
|
---|
| 522 | switch (type) {
|
---|
[6473] | 523 | case CODETYPE_BDS_B1_I: return "1I";
|
---|
| 524 | case CODETYPE_BDS_B1_Q: return "1Q";
|
---|
| 525 | case CODETYPE_BDS_B1_IQ: return "1X";
|
---|
| 526 | case CODETYPE_BDS_B2_I: return "7I";
|
---|
| 527 | case CODETYPE_BDS_B2_Q: return "7Q";
|
---|
| 528 | case CODETYPE_BDS_B2_IQ: return "7X";
|
---|
| 529 | case CODETYPE_BDS_B3_I: return "6I";
|
---|
| 530 | case CODETYPE_BDS_B3_Q: return "6Q";
|
---|
| 531 | case CODETYPE_BDS_B3_IQ: return "6X";
|
---|
[6472] | 532 | default: return "";
|
---|
| 533 | }
|
---|
| 534 | }
|
---|
| 535 | return "";
|
---|
| 536 | };
|
---|