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