source: ntrip/trunk/BNC/src/upload/bncrtnetuploadcaster.cpp@ 9823

Last change on this file since 9823 was 9823, checked in by stuerze, 20 months ago

try the old RTNET buffer reading code again

File size: 40.5 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Server
3 * -------------------------------------------------------------------------
4 *
5 * Class: bncRtnetUploadCaster
6 *
7 * Purpose: Connection to NTRIP Caster
8 *
9 * Author: L. Mervart
10 *
11 * Created: 29-Mar-2011
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <math.h>
18#include "bncrtnetuploadcaster.h"
19#include "bncsettings.h"
20#include "bncephuser.h"
21#include "bncclockrinex.h"
22#include "bncbiassinex.h"
23#include "bncsp3.h"
24#include "gnss.h"
25#include "bncutils.h"
26
27using namespace std;
28
29// Constructor
30////////////////////////////////////////////////////////////////////////////
31bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint,
32 const QString& outHost, int outPort,
33 const QString& ntripVersion,
34 const QString& userName, const QString& password,
35 const QString& crdTrafo, const QString& ssrFormat, bool CoM, const QString& sp3FileName,
36 const QString& rnxFileName, const QString& bsxFileName, int PID, int SID, int IOD, int iRow) :
37 bncUploadCaster(mountpoint, outHost, outPort, ntripVersion, userName, password, iRow, 0) {
38
39 if (!mountpoint.isEmpty()) {
40 _casterID += mountpoint;
41 }
42 if (!outHost.isEmpty()) {
43 _casterID += " " + outHost;
44 if (outPort) {
45 _casterID += ":" + QString("%1").arg(outPort, 10);
46 }
47 }
48 if (!crdTrafo.isEmpty()) {
49 _casterID += " " + crdTrafo;
50 }
51 if (!sp3FileName.isEmpty()) {
52 _casterID += " " + sp3FileName;
53 }
54 if (!rnxFileName.isEmpty()) {
55 _casterID += " " + rnxFileName;
56 }
57
58 if (!bsxFileName.isEmpty()) {
59 _casterID += " " + bsxFileName;
60 }
61
62 _crdTrafo = crdTrafo;
63
64 _ssrFormat = ssrFormat;
65
66 _ssrCorr = 0;
67 if (_ssrFormat == "IGS-SSR") {
68 _ssrCorr = new SsrCorrIgs();
69 }
70 else if (_ssrFormat == "RTCM-SSR") {
71 _ssrCorr = new SsrCorrRtcm();
72 }
73
74 _CoM = CoM;
75 _PID = PID;
76 _SID = SID;
77 _IOD = IOD;
78
79 // Member that receives the ephemeris
80 // ----------------------------------
81 _ephUser = new bncEphUser(true);
82
83 bncSettings settings;
84 QString intr = settings.value("uploadIntr").toString();
85 QStringList hlp = settings.value("cmbStreams").toStringList();
86 _samplRtcmEphCorr = settings.value("uploadSamplRtcmEphCorr").toDouble();
87 if (hlp.size() > 1) { // combination stream upload
88 _samplRtcmClkCorr = settings.value("cmbSampl").toInt();
89 }
90 else { // single stream upload or sp3 file generation
91 _samplRtcmClkCorr = 5; // default
92 }
93 int samplClkRnx = settings.value("uploadSamplClkRnx").toInt();
94 int samplSp3 = settings.value("uploadSamplSp3").toInt() * 60;
95 int samplBiaSnx = settings.value("uploadSamplBiaSnx").toInt();
96
97 if (_samplRtcmEphCorr == 0.0) {
98 _usedEph = 0;
99 }
100 else {
101 _usedEph = new QMap<QString, const t_eph*>;
102 }
103
104 // RINEX writer
105 // ------------
106 if (!rnxFileName.isEmpty()) {
107 _rnx = new bncClockRinex(rnxFileName, intr, samplClkRnx);
108 }
109 else {
110 _rnx = 0;
111 }
112
113 // SP3 writer
114 // ----------
115 if (!sp3FileName.isEmpty()) {
116 _sp3 = new bncSP3(sp3FileName, intr, samplSp3);
117 }
118 else {
119 _sp3 = 0;
120 }
121
122 // SINEX writer
123 // ------------
124 if (!bsxFileName.isEmpty()) {
125 _bsx = new bncBiasSinex(bsxFileName, intr, samplBiaSnx);
126 }
127 else {
128 _bsx = 0;
129 }
130
131
132 // Set Transformation Parameters
133 // -----------------------------
134 // Transformation Parameters from ITRF2014 to ETRF2000
135 // EUREF Technical Note 1 Relationship and Transformation between the ITRF and ETRF
136 // Zuheir Altamimi, June 28, 2018
137 if (_crdTrafo == "ETRF2000") {
138 _dx = 0.0547;
139 _dy = 0.0522;
140 _dz = -0.0741;
141
142 _dxr = 0.0001;
143 _dyr = 0.0001;
144 _dzr = -0.0019;
145
146 _ox = 0.001701;
147 _oy = 0.010290;
148 _oz = -0.016632;
149
150 _oxr = 0.000081;
151 _oyr = 0.000490;
152 _ozr = -0.000729;
153
154 _sc = 2.12;
155 _scr = 0.11;
156
157 _t0 = 2010.0;
158 }
159 // Transformation Parameters from ITRF2014 to GDA2020 (Ryan Ruddick, GA)
160 else if (_crdTrafo == "GDA2020") {
161 _dx = 0.0;
162 _dy = 0.0;
163 _dz = 0.0;
164
165 _dxr = 0.0;
166 _dyr = 0.0;
167 _dzr = 0.0;
168
169 _ox = 0.0;
170 _oy = 0.0;
171 _oz = 0.0;
172
173 _oxr = 0.00150379;
174 _oyr = 0.00118346;
175 _ozr = 0.00120716;
176
177 _sc = 0.0;
178 _scr = 0.0;
179
180 _t0 = 2020.0;
181 }
182 // Transformation Parameters from IGb14 to SIRGAS2000 (Thanks to Sonia Costa, BRA)
183 // June 29 2020: TX:-0.0027 m TY:-0.0025 m TZ:-0.0042 m SCL:1.20 (ppb) no rotations and no rates.*/
184 else if (_crdTrafo == "SIRGAS2000") {
185 _dx = -0.0027;
186 _dy = -0.0025;
187 _dz = -0.0042;
188
189 _dxr = 0.0000;
190 _dyr = 0.0000;
191 _dzr = 0.0000;
192
193 _ox = 0.000000;
194 _oy = 0.000000;
195 _oz = 0.000000;
196
197 _oxr = 0.000000;
198 _oyr = 0.000000;
199 _ozr = 0.000000;
200
201 _sc = 1.20000;
202 _scr = 0.00000;
203 _t0 = 2000.0;
204 }
205 // Transformation Parameters from ITRF2014 to DREF91
206 else if (_crdTrafo == "DREF91") {
207 _dx = 0.0547;
208 _dy = 0.0522;
209 _dz = -0.0741;
210
211 _dxr = 0.0001;
212 _dyr = 0.0001;
213 _dzr = -0.0019;
214 // ERTF200 + rotation parameters (ETRF200 => DREF91)
215 _ox = 0.001701 + 0.000658;
216 _oy = 0.010290 - 0.000208;
217 _oz = -0.016632 + 0.000755;
218
219 _oxr = 0.000081;
220 _oyr = 0.000490;
221 _ozr = -0.000729;
222
223 _sc = 2.12;
224 _scr = 0.11;
225
226 _t0 = 2010.0;
227 }
228 else if (_crdTrafo == "Custom") {
229 _dx = settings.value("trafo_dx").toDouble();
230 _dy = settings.value("trafo_dy").toDouble();
231 _dz = settings.value("trafo_dz").toDouble();
232 _dxr = settings.value("trafo_dxr").toDouble();
233 _dyr = settings.value("trafo_dyr").toDouble();
234 _dzr = settings.value("trafo_dzr").toDouble();
235 _ox = settings.value("trafo_ox").toDouble();
236 _oy = settings.value("trafo_oy").toDouble();
237 _oz = settings.value("trafo_oz").toDouble();
238 _oxr = settings.value("trafo_oxr").toDouble();
239 _oyr = settings.value("trafo_oyr").toDouble();
240 _ozr = settings.value("trafo_ozr").toDouble();
241 _sc = settings.value("trafo_sc").toDouble();
242 _scr = settings.value("trafo_scr").toDouble();
243 _t0 = settings.value("trafo_t0").toDouble();
244 }
245}
246
247// Destructor
248////////////////////////////////////////////////////////////////////////////
249bncRtnetUploadCaster::~bncRtnetUploadCaster() {
250 if (isRunning()) {
251 wait();
252 }
253 delete _rnx;
254 delete _sp3;
255 delete _ephUser;
256 delete _usedEph;
257 delete _ssrCorr;
258}
259
260//
261////////////////////////////////////////////////////////////////////////////
262void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
263
264 QMutexLocker locker(&_mutex);
265
266
267
268
269 /* Append to internal buffer
270 // -------------------------
271 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
272
273 // Select buffer part that contains last epoch
274 // -------------------------------------------
275 QStringList lines;
276 int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
277 if (iEpoBeg == -1) {
278 _rtnetStreamBuffer.clear();
279 return;
280 }
281 int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
282 if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) { // are there two epoch lines in buffer?
283 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
284 }
285 else {
286 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
287 }
288 int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
289 if (iEpoEnd == -1) {
290 return;
291 }
292
293 while (_rtnetStreamBuffer.count('*') > 1) { // is there more than 1 epoch line in buffer?
294 QString rtnetStreamBuffer = _rtnetStreamBuffer.mid(1);
295 int nextEpoch = rtnetStreamBuffer.indexOf('*');
296 if (nextEpoch != -1 && nextEpoch < iEpoEnd) {
297 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpoch);
298 }
299 else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
300 break;
301 }
302 }
303
304 lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
305
306 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd + 3);
307
308 if (lines.size() < 2) {
309 emit(newMessage(
310 "bncRtnetUploadCaster: less than 2 lines to decode " + _casterID.toLatin1(), false));
311 return;
312 }
313*/
314
315
316 // Append to internal buffer
317 // -------------------------
318 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
319
320 // Select buffer part that contains last epoch
321 // -------------------------------------------
322 QStringList lines;
323 int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
324 if (iEpoBeg == -1) {
325 _rtnetStreamBuffer.clear();
326 return;
327 }
328 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
329
330 int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
331 if (iEpoEnd == -1) {
332 return;
333 }
334 else {
335 lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
336 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd+3);
337 }
338
339 if (lines.size() < 2) {
340 emit(newMessage(
341 "bncRtnetUploadCaster: less than 2 lines to decode " + _casterID.toLatin1(), false));
342 return;
343 }
344
345 // Keep the last unfinished line in buffer
346 // ---------------------------------------
347 int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n');
348 if (iLastEOL != -1) {
349 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1);
350 }
351 // Read first line (with epoch time)
352 // ---------------------------------
353 QTextStream in(lines[0].toLatin1());
354 QString hlp;
355 int year, month, day, hour, min;
356 double sec;
357 in >> hlp >> year >> month >> day >> hour >> min >> sec;
358 bncTime epoTime;
359 epoTime.set(year, month, day, hour, min, sec);
360
361 emit(newMessage(
362 "bncRtnetUploadCaster: decode " + QByteArray(epoTime.datestr().c_str())
363 + " " + QByteArray(epoTime.timestr().c_str()) + " "
364 + _casterID.toLatin1(), false));
365
366 struct SsrCorr::ClockOrbit co;
367 memset(&co, 0, sizeof(co));
368 co.EpochTime[CLOCKORBIT_SATGPS] = static_cast<int>(epoTime.gpssec());
369 if (_ssrFormat == "RTCM-SSR") {
370 double gt = epoTime.gpssec() + 3 * 3600 - gnumleap(year, month, day);
371 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(fmod(gt, 86400.0));
372 }
373 else if (_ssrFormat == "IGS-SSR") {
374 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(epoTime.gpssec());
375 }
376 co.EpochTime[CLOCKORBIT_SATGALILEO] = static_cast<int>(epoTime.gpssec());
377 co.EpochTime[CLOCKORBIT_SATQZSS] = static_cast<int>(epoTime.gpssec());
378 co.EpochTime[CLOCKORBIT_SATSBAS] = static_cast<int>(epoTime.gpssec());
379 if (_ssrFormat == "RTCM-SSR") {
380 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.bdssec());
381 }
382 else if (_ssrFormat == "IGS-SSR") {
383 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.gpssec());
384 }
385 co.Supplied[_ssrCorr->COBOFS_CLOCK] = 1;
386 co.Supplied[_ssrCorr->COBOFS_ORBIT] = 1;
387 co.SatRefDatum = _ssrCorr->DATUM_ITRF; // ToDo: to decode from RTNET format
388 co.SSRIOD = _IOD;
389 co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
390 co.SSRSolutionID = _SID;
391
392 struct SsrCorr::CodeBias bias;
393 memset(&bias, 0, sizeof(bias));
394 bias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
395 bias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
396 bias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
397 bias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
398 bias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
399 bias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
400 bias.SSRIOD = _IOD;
401 bias.SSRProviderID = _PID;
402 bias.SSRSolutionID = _SID;
403
404 struct SsrCorr::PhaseBias phasebias;
405 memset(&phasebias, 0, sizeof(phasebias));
406 unsigned int dispersiveBiasConsistenyIndicator = 0;
407 unsigned int mwConsistencyIndicator = 0;
408 phasebias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
409 phasebias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
410 phasebias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
411 phasebias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
412 phasebias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
413 phasebias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
414 phasebias.SSRIOD = _IOD;
415 phasebias.SSRProviderID = _PID;
416 phasebias.SSRSolutionID = _SID;
417
418 struct SsrCorr::VTEC vtec;
419 memset(&vtec, 0, sizeof(vtec));
420 vtec.EpochTime = static_cast<int>(epoTime.gpssec());
421 vtec.SSRIOD = _IOD;
422 vtec.SSRProviderID = _PID;
423 vtec.SSRSolutionID = _SID;
424
425 // Default Update Interval
426 // -----------------------
427 int clkUpdInd = 2; // 5 sec
428 int ephUpdInd = clkUpdInd; // default
429
430 if (!_samplRtcmEphCorr) {
431 _samplRtcmEphCorr = 5.0;
432 }
433
434 if (_samplRtcmClkCorr > 5.0 && _samplRtcmEphCorr <= 5.0) { // combined orb and clock
435 ephUpdInd = determineUpdateInd(_samplRtcmClkCorr);
436 }
437 if (_samplRtcmClkCorr > 5.0) {
438 clkUpdInd = determineUpdateInd(_samplRtcmClkCorr);
439 }
440 if (_samplRtcmEphCorr > 5.0) {
441 ephUpdInd = determineUpdateInd(_samplRtcmEphCorr);
442 }
443
444 co.UpdateInterval = clkUpdInd;
445 bias.UpdateInterval = ephUpdInd;
446 phasebias.UpdateInterval = ephUpdInd;
447
448 for (int ii = 1; ii < lines.size(); ii++) {
449 QString key; // prn or key VTEC, IND (phase bias indicators)
450 double rtnUra = 0.0; // [m]
451 ColumnVector rtnAPC; rtnAPC.ReSize(3); rtnAPC = 0.0; // [m, m, m]
452 ColumnVector rtnVel; rtnVel.ReSize(3); rtnVel = 0.0; // [m/s, m/s, m/s]
453 ColumnVector rtnCoM; rtnCoM.ReSize(3); rtnCoM = 0.0; // [m, m, m]
454 ColumnVector rtnClk; rtnClk.ReSize(3); rtnClk = 0.0; // [m, m/s, m/s²]
455 ColumnVector rtnClkSig; rtnClkSig.ReSize(3); rtnClkSig = 0.0; // [m, m/s, m/s²]
456 t_prn prn;
457
458 QTextStream in(lines[ii].toLatin1());
459
460 in >> key;
461
462 // non-satellite specific parameters
463 if (key.contains("IND", Qt::CaseSensitive)) {
464 in >> dispersiveBiasConsistenyIndicator >> mwConsistencyIndicator;
465 continue;
466 }
467 // non-satellite specific parameters
468 if (key.contains("VTEC", Qt::CaseSensitive)) {
469 double ui;
470 in >> ui >> vtec.NumLayers;
471 vtec.UpdateInterval = (unsigned int) determineUpdateInd(ui);
472 for (unsigned ll = 0; ll < vtec.NumLayers; ll++) {
473 int dummy;
474 in >> dummy >> vtec.Layers[ll].Degree >> vtec.Layers[ll].Order
475 >> vtec.Layers[ll].Height;
476 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
477 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
478 in >> vtec.Layers[ll].Cosinus[iDeg][iOrd];
479 }
480 }
481 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
482 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
483 in >> vtec.Layers[ll].Sinus[iDeg][iOrd];
484 }
485 }
486 }
487 continue;
488 }
489 // satellite specific parameters
490 char sys = key.mid(0, 1).at(0).toLatin1();
491 int number = key.mid(1, 2).toInt();
492 int flags = 0;
493 if (sys == 'E') { // I/NAV
494 flags = 1;
495 }
496 if (number == 0) {
497 continue;
498 }
499 prn.set(sys, number, flags);
500 QString prnInternalStr = QString::fromStdString(prn.toInternalString());
501 QString prnStr = QString::fromStdString(prn.toString());
502
503 const t_eph* ephLast = _ephUser->ephLast(prnInternalStr);
504 const t_eph* ephPrev = _ephUser->ephPrev(prnInternalStr);
505 const t_eph* eph = ephLast;
506 if (eph) {
507
508 // Use previous ephemeris if the last one is too recent
509 // ----------------------------------------------------
510 const int MINAGE = 60; // seconds
511 if (ephPrev && eph->receptDateTime().isValid()
512 && eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
513 eph = ephPrev;
514 }
515
516 // Make sure the clock messages refer to same IOD as orbit messages
517 // ----------------------------------------------------------------
518 if (_usedEph) {
519 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
520 (*_usedEph)[prnInternalStr] = eph;
521 }
522 else {
523 eph = 0;
524 if (_usedEph->contains(prnInternalStr)) {
525 const t_eph* usedEph = _usedEph->value(prnInternalStr);
526 if (usedEph == ephLast) {
527 eph = ephLast;
528 }
529 else if (usedEph == ephPrev) {
530 eph = ephPrev;
531 }
532 }
533 }
534 }
535 }
536
537 if (eph &&
538 !outDatedBcep(eph) && // detected from storage because of no update
539 eph->checkState() != t_eph::bad &&
540 eph->checkState() != t_eph::unhealthy &&
541 eph->checkState() != t_eph::outdated) { // detected during reception (bncephuser)
542 QMap<QString, double> codeBiases;
543 QList<phaseBiasSignal> phaseBiasList;
544 phaseBiasesSat pbSat;
545 _phaseBiasInformationDecoded = false;
546
547 while (true) {
548 QString key;
549 int numVal = 0;
550 in >> key;
551 if (in.status() != QTextStream::Ok) {
552 break;
553 }
554 if (key == "APC") {
555 in >> numVal;
556 rtnAPC.ReSize(3); rtnAPC = 0.0;
557 for (int ii = 0; ii < numVal; ii++) {
558 in >> rtnAPC[ii];
559 }
560 }
561 else if (key == "Ura") {
562 in >> numVal;
563 if (numVal == 1)
564 in >> rtnUra;
565 }
566 else if (key == "Clk") {
567 in >> numVal;
568 rtnClk.ReSize(3); rtnClk = 0.0;
569 for (int ii = 0; ii < numVal; ii++) {
570 in >> rtnClk[ii];
571 }
572 }
573 else if (key == "ClkSig") {
574 in >> numVal;
575 rtnClkSig.ReSize(3); rtnClkSig = 0.0;
576 for (int ii = 0; ii < numVal; ii++) {
577 in >> rtnClkSig[ii];
578 }
579 }
580 else if (key == "Vel") {
581 in >> numVal;
582 rtnVel.ReSize(3); rtnVel = 0.0;
583 for (int ii = 0; ii < numVal; ii++) {
584 in >> rtnVel[ii];
585 }
586 }
587 else if (key == "CoM") {
588 in >> numVal;
589 rtnCoM.ReSize(3); rtnCoM = 0.0;
590 for (int ii = 0; ii < numVal; ii++) {
591 in >> rtnCoM[ii];
592 }
593 }
594 else if (key == "CodeBias") {
595 in >> numVal;
596 for (int ii = 0; ii < numVal; ii++) {
597 QString type;
598 double value;
599 in >> type >> value;
600 codeBiases[type] = value;
601 }
602 }
603 else if (key == "YawAngle") {
604 _phaseBiasInformationDecoded = true;
605 in >> numVal >> pbSat.yawAngle;
606 if (pbSat.yawAngle < 0.0) {
607 pbSat.yawAngle += (2*M_PI);
608 }
609 else if (pbSat.yawAngle > 2*M_PI) {
610 pbSat.yawAngle -= (2*M_PI);
611 }
612 }
613 else if (key == "YawRate") {
614 _phaseBiasInformationDecoded = true;
615 in >> numVal >> pbSat.yawRate;
616 }
617 else if (key == "PhaseBias") {
618 _phaseBiasInformationDecoded = true;
619 in >> numVal;
620 for (int ii = 0; ii < numVal; ii++) {
621 phaseBiasSignal pb;
622 in >> pb.type >> pb.bias >> pb.integerIndicator
623 >> pb.wlIndicator >> pb.discontinuityCounter;
624 phaseBiasList.append(pb);
625 }
626 }
627 else {
628 in >> numVal;
629 for (int ii = 0; ii < numVal; ii++) {
630 double dummy;
631 in >> dummy;
632 }
633 emit(newMessage(" RTNET format error: "
634 + lines[ii].toLatin1(), false));
635 break;
636 }
637 }
638
639 struct SsrCorr::ClockOrbit::SatData* sd = 0;
640 if (prn.system() == 'G') {
641 sd = co.Sat + co.NumberOfSat[CLOCKORBIT_SATGPS];
642 ++co.NumberOfSat[CLOCKORBIT_SATGPS];
643 }
644 else if (prn.system() == 'R') {
645 sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfSat[CLOCKORBIT_SATGLONASS];
646 ++co.NumberOfSat[CLOCKORBIT_SATGLONASS];
647 }
648 else if (prn.system() == 'E') {
649 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
650 + co.NumberOfSat[CLOCKORBIT_SATGALILEO];
651 ++co.NumberOfSat[CLOCKORBIT_SATGALILEO];
652 }
653 else if (prn.system() == 'J') {
654 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
655 + CLOCKORBIT_NUMGALILEO
656 + co.NumberOfSat[CLOCKORBIT_SATQZSS];
657 ++co.NumberOfSat[CLOCKORBIT_SATQZSS];
658 }
659 else if (prn.system() == 'S') {
660 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
661 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
662 + co.NumberOfSat[CLOCKORBIT_SATSBAS];
663 ++co.NumberOfSat[CLOCKORBIT_SATSBAS];
664 }
665 else if (prn.system() == 'C') {
666 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
667 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
668 + CLOCKORBIT_NUMSBAS
669 + co.NumberOfSat[CLOCKORBIT_SATBDS];
670 ++co.NumberOfSat[CLOCKORBIT_SATBDS];
671 }
672 if (sd) {
673 QString outLine;
674 t_irc irc = processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prnStr, rtnAPC,
675 rtnUra, rtnClk, rtnVel, rtnCoM, rtnClkSig, sd, outLine);
676 if (irc != success) {
677 continue;
678 }
679 }
680
681 // Code Biases
682 // -----------
683 struct SsrCorr::CodeBias::BiasSat* biasSat = 0;
684 if (!codeBiases.isEmpty()) {
685 if (prn.system() == 'G') {
686 biasSat = bias.Sat + bias.NumberOfSat[CLOCKORBIT_SATGPS];
687 ++bias.NumberOfSat[CLOCKORBIT_SATGPS];
688 }
689 else if (prn.system() == 'R') {
690 biasSat = bias.Sat + CLOCKORBIT_NUMGPS
691 + bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
692 ++bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
693 }
694 else if (prn.system() == 'E') {
695 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
696 + bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
697 ++bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
698 }
699 else if (prn.system() == 'J') {
700 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
701 + CLOCKORBIT_NUMGALILEO
702 + bias.NumberOfSat[CLOCKORBIT_SATQZSS];
703 ++bias.NumberOfSat[CLOCKORBIT_SATQZSS];
704 }
705 else if (prn.system() == 'S') {
706 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
707 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
708 + bias.NumberOfSat[CLOCKORBIT_SATSBAS];
709 ++bias.NumberOfSat[CLOCKORBIT_SATSBAS];
710 }
711 else if (prn.system() == 'C') {
712 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
713 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
714 + CLOCKORBIT_NUMSBAS
715 + bias.NumberOfSat[CLOCKORBIT_SATBDS];
716 ++bias.NumberOfSat[CLOCKORBIT_SATBDS];
717 }
718 }
719
720 if (biasSat) {
721 biasSat->ID = prn.number();
722 biasSat->NumberOfCodeBiases = 0;
723 QMapIterator<QString, double> it(codeBiases);
724 while (it.hasNext()) {
725 it.next();
726 int ii = biasSat->NumberOfCodeBiases;
727 if (ii >= CLOCKORBIT_NUMBIAS)
728 break;
729 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), it.key().toStdString());
730 if (type != _ssrCorr->RESERVED) {
731 biasSat->NumberOfCodeBiases += 1;
732 biasSat->Biases[ii].Type = type;
733 biasSat->Biases[ii].Bias = it.value();
734 if (_bsx) {
735 QString obsCode = 'C' + it.key();
736 _bsx->write(epoTime.gpsw(), epoTime.gpssec(), prnStr, obsCode, it.value());
737 }
738 }
739 }
740 }
741
742 // Phase Biases
743 // ------------
744 struct SsrCorr::PhaseBias::PhaseBiasSat* phasebiasSat = 0;
745 if (prn.system() == 'G') {
746 phasebiasSat = phasebias.Sat
747 + phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
748 ++phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
749 }
750 else if (prn.system() == 'R') {
751 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS
752 + phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
753 ++phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
754 }
755 else if (prn.system() == 'E') {
756 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
757 + phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
758 ++phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
759 }
760 else if (prn.system() == 'J') {
761 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
762 + CLOCKORBIT_NUMGALILEO
763 + phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
764 ++phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
765 }
766 else if (prn.system() == 'S') {
767 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
768 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
769 + phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
770 ++phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
771 }
772 else if (prn.system() == 'C') {
773 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
774 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
775 + CLOCKORBIT_NUMSBAS
776 + phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
777 ++phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
778 }
779
780 if (phasebiasSat && _phaseBiasInformationDecoded) {
781 phasebias.DispersiveBiasConsistencyIndicator = dispersiveBiasConsistenyIndicator;
782 phasebias.MWConsistencyIndicator = mwConsistencyIndicator;
783 phasebiasSat->ID = prn.number();
784 phasebiasSat->NumberOfPhaseBiases = 0;
785 phasebiasSat->YawAngle = pbSat.yawAngle;
786 phasebiasSat->YawRate = pbSat.yawRate;
787 QListIterator<phaseBiasSignal> it(phaseBiasList);
788 while (it.hasNext()) {
789 const phaseBiasSignal &pbSig = it.next();
790 int ii = phasebiasSat->NumberOfPhaseBiases;
791 if (ii >= CLOCKORBIT_NUMBIAS)
792 break;
793 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), pbSig.type.toStdString());
794 if (type != _ssrCorr->RESERVED) {
795 phasebiasSat->NumberOfPhaseBiases += 1;
796 phasebiasSat->Biases[ii].Type = type;
797 phasebiasSat->Biases[ii].Bias = pbSig.bias;
798 phasebiasSat->Biases[ii].SignalIntegerIndicator = pbSig.integerIndicator;
799 phasebiasSat->Biases[ii].SignalsWideLaneIntegerIndicator = pbSig.wlIndicator;
800 phasebiasSat->Biases[ii].SignalDiscontinuityCounter = pbSig.discontinuityCounter;
801 if (_bsx) {
802 QString obsCode = 'L' + pbSig.type;
803 _bsx->write(epoTime.gpsw(), epoTime.gpssec(), prnStr, obsCode, pbSig.bias);
804 }
805 }
806 }
807 }
808 }
809 }
810
811 QByteArray hlpBufferCo;
812
813 // Orbit and Clock Corrections together
814 // ------------------------------------
815 if (_samplRtcmEphCorr == _samplRtcmClkCorr) {
816 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0
817 || co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
818 || co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
819 || co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
820 || co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
821 || co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
822 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
823 int len = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
824 if (len > 0) {
825 hlpBufferCo = QByteArray(obuffer, len);
826 }
827 }
828 }
829
830 // Orbit and Clock Corrections separately
831 // --------------------------------------
832 else {
833 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
834 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
835 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
836 co.UpdateInterval = ephUpdInd;
837 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer,
838 sizeof(obuffer));
839 co.UpdateInterval = clkUpdInd;
840 if (len1 > 0) {
841 hlpBufferCo += QByteArray(obuffer, len1);
842 }
843 }
844 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0 ||
845 co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
846 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
847 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
848 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
849 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer,
850 sizeof(obuffer));
851 if (len2 > 0) {
852 hlpBufferCo += QByteArray(obuffer, len2);
853 }
854 }
855 if (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
856 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
857 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
858 co.UpdateInterval = ephUpdInd;
859 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer,
860 sizeof(obuffer));
861 co.UpdateInterval = clkUpdInd;
862 if (len1 > 0) {
863 hlpBufferCo += QByteArray(obuffer, len1);
864 }
865 }
866 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
867 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
868 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
869 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
870 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer,
871 sizeof(obuffer));
872 if (len2 > 0) {
873 hlpBufferCo += QByteArray(obuffer, len2);
874 }
875 }
876 if (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
877 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
878 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
879 co.UpdateInterval = ephUpdInd;
880 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer,
881 sizeof(obuffer));
882 co.UpdateInterval = clkUpdInd;
883 if (len1 > 0) {
884 hlpBufferCo += QByteArray(obuffer, len1);
885 }
886 }
887 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
888 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
889 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
890 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer,
891 sizeof(obuffer));
892 if (len2 > 0) {
893 hlpBufferCo += QByteArray(obuffer, len2);
894 }
895 }
896 if (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
897 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
898 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
899 co.UpdateInterval = ephUpdInd;
900 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer,
901 sizeof(obuffer));
902 co.UpdateInterval = clkUpdInd;
903 if (len1 > 0) {
904 hlpBufferCo += QByteArray(obuffer, len1);
905 }
906 }
907 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
908 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
909 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer,
910 sizeof(obuffer));
911 if (len2 > 0) {
912 hlpBufferCo += QByteArray(obuffer, len2);
913 }
914 }
915 if (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
916 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
917 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
918 co.UpdateInterval = ephUpdInd;
919 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer,
920 sizeof(obuffer));
921 co.UpdateInterval = clkUpdInd;
922 if (len1 > 0) {
923 hlpBufferCo += QByteArray(obuffer, len1);
924 }
925 }
926 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) ? 1 : 0;
927 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASCLOCK, mmsg, obuffer,
928 sizeof(obuffer));
929 if (len2 > 0) {
930 hlpBufferCo += QByteArray(obuffer, len2);
931 }
932 }
933 if (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
934 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
935 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
936 co.UpdateInterval = ephUpdInd;
937 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer,
938 sizeof(obuffer));
939 co.UpdateInterval = clkUpdInd;
940 if (len1 > 0) {
941 hlpBufferCo += QByteArray(obuffer, len1);
942 }
943 }
944 int mmsg = 0;
945 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer,
946 sizeof(obuffer));
947 if (len2 > 0) {
948 hlpBufferCo += QByteArray(obuffer, len2);
949 }
950 }
951 }
952
953 // Code Biases
954 // -----------
955 QByteArray hlpBufferBias;
956 if (bias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
957 || bias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
958 || bias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
959 || bias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
960 || bias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
961 || bias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
962 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
963 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
964 int len = _ssrCorr->MakeCodeBias(&bias, _ssrCorr->CBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
965 if (len > 0) {
966 hlpBufferBias = QByteArray(obuffer, len);
967 }
968 }
969 }
970
971 // Phase Biases
972 // ------------
973 QByteArray hlpBufferPhaseBias;
974 if ((phasebias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
975 || phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
976 || phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
977 || phasebias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
978 || phasebias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
979 || phasebias.NumberOfSat[CLOCKORBIT_SATBDS] > 0)
980 && (_phaseBiasInformationDecoded)) {
981 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
982 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
983 int len = _ssrCorr->MakePhaseBias(&phasebias, _ssrCorr->PBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
984 if (len > 0) {
985 hlpBufferPhaseBias = QByteArray(obuffer, len);
986 }
987 }
988 }
989
990 // VTEC
991 // ----
992 QByteArray hlpBufferVtec;
993 if (vtec.NumLayers > 0) {
994 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
995 int len = _ssrCorr->MakeVTEC(&vtec, 0, obuffer, sizeof(obuffer));
996 if (len > 0) {
997 hlpBufferVtec = QByteArray(obuffer, len);
998 }
999 }
1000
1001 _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias
1002 + hlpBufferVtec + '\0';
1003}
1004
1005//
1006////////////////////////////////////////////////////////////////////////////
1007t_irc bncRtnetUploadCaster::processSatellite(const t_eph* eph, int GPSweek,
1008 double GPSweeks, const QString& prn, const ColumnVector& rtnAPC,
1009 double rtnUra, const ColumnVector& rtnClk, const ColumnVector& rtnVel,
1010 const ColumnVector& rtnCoM, const ColumnVector& rtnClkSig,
1011 struct SsrCorr::ClockOrbit::SatData* sd, QString& outLine) {
1012
1013 // Broadcast Position and Velocity
1014 // -------------------------------
1015 ColumnVector xB(6);
1016 ColumnVector vB(3);
1017 t_irc irc = eph->getCrd(bncTime(GPSweek, GPSweeks), xB, vB, false);
1018
1019 if (irc != success) {
1020 return irc;
1021 }
1022
1023 // Precise Position
1024 // ----------------
1025 ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
1026
1027 if (xP.size() == 0) {
1028 return failure;
1029 }
1030
1031 double dc = 0.0;
1032 if (_crdTrafo != "IGS14") {
1033 crdTrafo(GPSweek, xP, dc);
1034 }
1035
1036 // Difference in xyz
1037 // -----------------
1038 ColumnVector dx = xB.Rows(1, 3) - xP;
1039 ColumnVector dv = vB - rtnVel;
1040
1041 // Difference in RSW
1042 // -----------------
1043 ColumnVector rsw(3);
1044 XYZ_to_RSW(xB.Rows(1, 3), vB, dx, rsw);
1045
1046 ColumnVector dotRsw(3);
1047 XYZ_to_RSW(xB.Rows(1, 3), vB, dv, dotRsw);
1048
1049 // Clock Correction
1050 // ----------------
1051 double dClkA0 = rtnClk(1) - (xB(4) - dc) * t_CST::c;
1052 double dClkA1 = 0.0;
1053 if (rtnClk(2)) {
1054 dClkA1 = rtnClk(2) - xB(5) * t_CST::c;
1055 }
1056 double dClkA2 = 0.0;
1057 if (rtnClk(3)) {
1058 dClkA2 = rtnClk(3) - xB(6) * t_CST::c;
1059 }
1060
1061 if (sd) {
1062 sd->ID = prn.mid(1).toInt();
1063 sd->IOD = eph->IOD();
1064 sd->Clock.DeltaA0 = dClkA0;
1065 sd->Clock.DeltaA1 = dClkA1;
1066 sd->Clock.DeltaA2 = dClkA2;
1067 sd->UserRangeAccuracy = rtnUra;
1068 sd->Orbit.DeltaRadial = rsw(1);
1069 sd->Orbit.DeltaAlongTrack = rsw(2);
1070 sd->Orbit.DeltaCrossTrack = rsw(3);
1071 sd->Orbit.DotDeltaRadial = dotRsw(1);
1072 sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
1073 sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
1074
1075 if (corrIsOutOfRange(sd)) {
1076 return failure;
1077 }
1078 }
1079
1080 outLine = QString().asprintf("%d %.1f %s %u %10.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", GPSweek,
1081 GPSweeks, eph->prn().toString().c_str(), eph->IOD(), dClkA0, dClkA1, dClkA2,
1082 rsw(1), rsw(2), rsw(3)); //fprintf(stderr, "%s\n", outLine.toStdString().c_str());
1083
1084 // RTNET full clock for RINEX and SP3 file
1085 // ---------------------------------------
1086 double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
1087 double clkRnx = (rtnClk[0] - relativity) / t_CST::c; // [s]
1088 double clkRnxRate = rtnClk[1] / t_CST::c; // [s/s = -]
1089 double clkRnxAcc = rtnClk[2] / t_CST::c; // [s/s² ) -/s]
1090
1091 if (_rnx) {
1092 double clkRnxSig, clkRnxRateSig, clkRnxAccSig;
1093 int s = rtnClkSig.size();
1094 switch (s) {
1095 case 1:
1096 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1097 clkRnxRateSig = 0.0; // [s/s = -]
1098 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1099 break;
1100 case 2:
1101 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1102 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1103 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1104 break;
1105 case 3:
1106 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1107 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1108 clkRnxAccSig = rtnClkSig[2] / t_CST::c; // [s/s² ) -/s]
1109 break;
1110 }
1111 _rnx->write(GPSweek, GPSweeks, prn, clkRnx, clkRnxRate, clkRnxAcc,
1112 clkRnxSig, clkRnxRateSig, clkRnxAccSig);
1113 }
1114 if (_sp3) {
1115 _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, clkRnx, rtnVel, clkRnxRate);
1116 }
1117 return success;
1118}
1119
1120// Transform Coordinates
1121////////////////////////////////////////////////////////////////////////////
1122void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
1123 double& dc) {
1124
1125 // Current epoch minus 2000.0 in years
1126 // ------------------------------------
1127 double dt = (GPSWeek - (1042.0 + 6.0 / 7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
1128
1129 ColumnVector dx(3);
1130
1131 dx(1) = _dx + dt * _dxr;
1132 dx(2) = _dy + dt * _dyr;
1133 dx(3) = _dz + dt * _dzr;
1134
1135 static const double arcSec = 180.0 * 3600.0 / M_PI;
1136
1137 double ox = (_ox + dt * _oxr) / arcSec;
1138 double oy = (_oy + dt * _oyr) / arcSec;
1139 double oz = (_oz + dt * _ozr) / arcSec;
1140
1141 double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
1142
1143 // Specify approximate center of area
1144 // ----------------------------------
1145 ColumnVector meanSta(3);
1146
1147 if (_crdTrafo == "ETRF2000") {
1148 meanSta(1) = 3661090.0;
1149 meanSta(2) = 845230.0;
1150 meanSta(3) = 5136850.0;
1151 }
1152 else if (_crdTrafo == "GDA2020") {
1153 meanSta(1) = -4052050.0;
1154 meanSta(2) = 4212840.0;
1155 meanSta(3) = -2545110.0;
1156 }
1157 else if (_crdTrafo == "SIRGAS2000") {
1158 meanSta(1) = 3740860.0;
1159 meanSta(2) = -4964290.0;
1160 meanSta(3) = -1425420.0;
1161 }
1162 else if (_crdTrafo == "DREF91") {
1163 meanSta(1) = 3959579.0;
1164 meanSta(2) = 721719.0;
1165 meanSta(3) = 4931539.0;
1166 }
1167 else if (_crdTrafo == "Custom") {
1168 meanSta(1) = 0.0; // TODO
1169 meanSta(2) = 0.0; // TODO
1170 meanSta(3) = 0.0; // TODO
1171 }
1172
1173 // Clock correction proportional to topocentric distance to satellites
1174 // -------------------------------------------------------------------
1175 double rho = (xyz - meanSta).NormFrobenius();
1176 dc = rho * (sc - 1.0) / sc / t_CST::c;
1177
1178 Matrix rMat(3, 3);
1179 rMat(1, 1) = 1.0;
1180 rMat(1, 2) = -oz;
1181 rMat(1, 3) = oy;
1182 rMat(2, 1) = oz;
1183 rMat(2, 2) = 1.0;
1184 rMat(2, 3) = -ox;
1185 rMat(3, 1) = -oy;
1186 rMat(3, 2) = ox;
1187 rMat(3, 3) = 1.0;
1188
1189 xyz = sc * rMat * xyz + dx;
1190}
1191
1192int bncRtnetUploadCaster::determineUpdateInd(double samplingRate) {
1193
1194 if (samplingRate == 10.0) {
1195 return 3;
1196 }
1197 else if (samplingRate == 15.0) {
1198 return 4;
1199 }
1200 else if (samplingRate == 30.0) {
1201 return 5;
1202 }
1203 else if (samplingRate == 60.0) {
1204 return 6;
1205 }
1206 else if (samplingRate == 120.0) {
1207 return 7;
1208 }
1209 else if (samplingRate == 240.0) {
1210 return 8;
1211 }
1212 else if (samplingRate == 300.0) {
1213 return 9;
1214 }
1215 else if (samplingRate == 600.0) {
1216 return 10;
1217 }
1218 else if (samplingRate == 900.0) {
1219 return 11;
1220 }
1221 else if (samplingRate == 1800.0) {
1222 return 12;
1223 }
1224 else if (samplingRate == 3600.0) {
1225 return 13;
1226 }
1227 else if (samplingRate == 7200.0) {
1228 return 14;
1229 }
1230 else if (samplingRate == 10800.0) {
1231 return 15;
1232 }
1233 return 2; // default
1234}
1235
1236bool bncRtnetUploadCaster::corrIsOutOfRange(struct SsrCorr::ClockOrbit::SatData* sd) {
1237
1238 if (fabs(sd->Clock.DeltaA0) > 209.7151) {return true;}
1239 if (fabs(sd->Clock.DeltaA1) > 1.048575) {return true;}
1240 if (fabs(sd->Clock.DeltaA2) > 1.34217726) {return true;}
1241
1242 if (fabs(sd->Orbit.DeltaRadial) > 209.7151) {return true;}
1243 if (fabs(sd->Orbit.DeltaAlongTrack) > 209.7148) {return true;}
1244 if (fabs(sd->Orbit.DeltaCrossTrack) > 209.7148) {return true;}
1245
1246 if (fabs(sd->Orbit.DotDeltaRadial) > 1.048575) {return true;}
1247 if (fabs(sd->Orbit.DotDeltaAlongTrack) > 1.048572) {return true;}
1248 if (fabs(sd->Orbit.DotDeltaCrossTrack) > 1.048572) {return true;}
1249 return false;
1250}
Note: See TracBrowser for help on using the repository browser.