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