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

Last change on this file since 9880 was 9880, checked in by stuerze, 17 months ago

minor changes

File size: 40.6 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 // Append to internal buffer
267 // -------------------------
268 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
269
270 // Select buffer part that contains last epoch
271 // -------------------------------------------
272
273 // Find the begin of last epoch
274 int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*');
275 if (iEpoBeg == -1) {
276 _rtnetStreamBuffer.clear();
277 emit(newMessage(QString("bncRtnetUploadCaster: no Epoch line found: %1").arg(_casterID).toLatin1(), false));
278 return;
279 }
280
281 // Find the begin of the first epoch
282 int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
283 if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) {
284 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
285 }
286 else {
287 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
288 }
289
290 // Find End of the last epoch
291 int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE");
292 if (iEpoEnd == -1) {
293 _rtnetStreamBuffer.clear();
294 emit(newMessage(QString("bncRtnetUploadCaster: no EOE found: %1").arg(_casterID).toLatin1(), false));
295 return;
296 }
297
298 QStringList lines;
299 // If there is there more than 1 epoch line in the buffer
300 while (_rtnetStreamBuffer.count('*') > 1) {
301 cout << "more than 1 epoch in buffer: " << _rtnetStreamBuffer.count('*') << endl; emit(newMessage(QString("bncRtnetUploadCaster: more than 1 epoch in buffer: %1").arg(_rtnetStreamBuffer.count('*')).toLatin1(), false));
302 QString rtnetStreamBuffer = _rtnetStreamBuffer;
303 int nextEpoch = rtnetStreamBuffer.indexOf('*');
304 int nextEpochEnd = rtnetStreamBuffer.indexOf("EOE");
305 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(1);
306 nextEpoch = rtnetStreamBuffer.indexOf('*');
307 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpoch);
308 if (nextEpoch != -1 && nextEpoch < iEpoEnd) {
309 rtnetStreamBuffer = rtnetStreamBuffer.mid(nextEpoch);
310 lines = _rtnetStreamBuffer.left(nextEpochEnd).split('\n', QString::SkipEmptyParts);
311 if (lines.size() > 2) {
312 decodeRtnetEpoch(lines);
313 }
314 }
315 else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
316 break;
317 }
318 }
319
320 lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
321
322 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd + 3);
323
324 if (lines.size() < 2) {
325 emit(newMessage(QString("bncRtnetUploadCaster: less than 2 lines to decode : %1").arg(_casterID).toLatin1(), false));
326 return;
327 }
328
329 decodeRtnetEpoch(lines);
330
331}
332
333//
334////////////////////////////////////////////////////////////////////////////
335void bncRtnetUploadCaster::decodeRtnetEpoch(QStringList epochLines) {
336
337 // Read first line (with epoch time)
338 // ---------------------------------
339 QTextStream in(epochLines[0].toLatin1()); cout << epochLines[0].toLatin1().toStdString() << " : " << endl;
340 QString hlp;
341 int year, month, day, hour, min;
342 double sec;
343 in >> hlp >> year >> month >> day >> hour >> min >> sec;
344 bncTime epoTime;
345 epoTime.set(year, month, day, hour, min, sec); cout << "decodeEpoch: " << epoTime.timestr().c_str() << endl;
346
347 emit(newMessage(
348 "bncRtnetUploadCaster: decode " + QByteArray(epoTime.datestr().c_str())
349 + " " + QByteArray(epoTime.timestr().c_str()) + " "
350 + _casterID.toLatin1(), false));
351
352 struct SsrCorr::ClockOrbit co;
353 memset(&co, 0, sizeof(co));
354 co.EpochTime[CLOCKORBIT_SATGPS] = static_cast<int>(epoTime.gpssec());
355 if (_ssrFormat == "RTCM-SSR") {
356 double gt = epoTime.gpssec() + 3 * 3600 - gnumleap(year, month, day);
357 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(fmod(gt, 86400.0));
358 }
359 else if (_ssrFormat == "IGS-SSR") {
360 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(epoTime.gpssec());
361 }
362 co.EpochTime[CLOCKORBIT_SATGALILEO] = static_cast<int>(epoTime.gpssec());
363 co.EpochTime[CLOCKORBIT_SATQZSS] = static_cast<int>(epoTime.gpssec());
364 co.EpochTime[CLOCKORBIT_SATSBAS] = static_cast<int>(epoTime.gpssec());
365 if (_ssrFormat == "RTCM-SSR") {
366 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.bdssec());
367 }
368 else if (_ssrFormat == "IGS-SSR") {
369 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.gpssec());
370 }
371 co.Supplied[_ssrCorr->COBOFS_CLOCK] = 1;
372 co.Supplied[_ssrCorr->COBOFS_ORBIT] = 1;
373 co.SatRefDatum = _ssrCorr->DATUM_ITRF; // ToDo: to decode from RTNET format
374 co.SSRIOD = _IOD;
375 co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
376 co.SSRSolutionID = _SID;
377
378 struct SsrCorr::CodeBias bias;
379 memset(&bias, 0, sizeof(bias));
380 bias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
381 bias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
382 bias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
383 bias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
384 bias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
385 bias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
386 bias.SSRIOD = _IOD;
387 bias.SSRProviderID = _PID;
388 bias.SSRSolutionID = _SID;
389
390 struct SsrCorr::PhaseBias phasebias;
391 memset(&phasebias, 0, sizeof(phasebias));
392 unsigned int dispersiveBiasConsistenyIndicator = 0;
393 unsigned int mwConsistencyIndicator = 0;
394 phasebias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
395 phasebias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
396 phasebias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
397 phasebias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
398 phasebias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
399 phasebias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
400 phasebias.SSRIOD = _IOD;
401 phasebias.SSRProviderID = _PID;
402 phasebias.SSRSolutionID = _SID;
403
404 struct SsrCorr::VTEC vtec;
405 memset(&vtec, 0, sizeof(vtec));
406 vtec.EpochTime = static_cast<int>(epoTime.gpssec());
407 vtec.SSRIOD = _IOD;
408 vtec.SSRProviderID = _PID;
409 vtec.SSRSolutionID = _SID;
410
411 // Default Update Interval
412 // -----------------------
413 int clkUpdInd = 2; // 5 sec
414 int ephUpdInd = clkUpdInd; // default
415
416 if (!_samplRtcmEphCorr) {
417 _samplRtcmEphCorr = 5.0;
418 }
419
420 if (_samplRtcmClkCorr > 5.0 && _samplRtcmEphCorr <= 5.0) { // combined orb and clock
421 ephUpdInd = determineUpdateInd(_samplRtcmClkCorr);
422 }
423 if (_samplRtcmClkCorr > 5.0) {
424 clkUpdInd = determineUpdateInd(_samplRtcmClkCorr);
425 }
426 if (_samplRtcmEphCorr > 5.0) {
427 ephUpdInd = determineUpdateInd(_samplRtcmEphCorr);
428 }
429
430 co.UpdateInterval = clkUpdInd;
431 bias.UpdateInterval = ephUpdInd;
432 phasebias.UpdateInterval = ephUpdInd;
433
434 for (int ii = 1; ii < epochLines.size(); ii++) {
435 QString key; // prn or key VTEC, IND (phase bias indicators)
436 double rtnUra = 0.0; // [m]
437 ColumnVector rtnAPC; rtnAPC.ReSize(3); rtnAPC = 0.0; // [m, m, m]
438 ColumnVector rtnVel; rtnVel.ReSize(3); rtnVel = 0.0; // [m/s, m/s, m/s]
439 ColumnVector rtnCoM; rtnCoM.ReSize(3); rtnCoM = 0.0; // [m, m, m]
440 ColumnVector rtnClk; rtnClk.ReSize(3); rtnClk = 0.0; // [m, m/s, m/s²]
441 ColumnVector rtnClkSig; rtnClkSig.ReSize(3); rtnClkSig = 0.0; // [m, m/s, m/s²]
442 t_prn prn;
443
444 QTextStream in(epochLines[ii].toLatin1());
445
446 in >> key;
447
448 // non-satellite specific parameters
449 if (key.contains("IND", Qt::CaseSensitive)) {
450 in >> dispersiveBiasConsistenyIndicator >> mwConsistencyIndicator;
451 continue;
452 }
453 // non-satellite specific parameters
454 if (key.contains("VTEC", Qt::CaseSensitive)) {
455 double ui;
456 in >> ui >> vtec.NumLayers;
457 vtec.UpdateInterval = (unsigned int) determineUpdateInd(ui);
458 for (unsigned ll = 0; ll < vtec.NumLayers; ll++) {
459 int dummy;
460 in >> dummy >> vtec.Layers[ll].Degree >> vtec.Layers[ll].Order
461 >> vtec.Layers[ll].Height;
462 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
463 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
464 in >> vtec.Layers[ll].Cosinus[iDeg][iOrd];
465 }
466 }
467 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
468 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
469 in >> vtec.Layers[ll].Sinus[iDeg][iOrd];
470 }
471 }
472 }
473 continue;
474 }
475 // satellite specific parameters
476 char sys = key.mid(0, 1).at(0).toLatin1();
477 int number = key.mid(1, 2).toInt();
478 int flags = 0;
479 if (sys == 'E') { // I/NAV
480 flags = 1;
481 }
482 if (number == 0) {
483 continue;
484 }
485 prn.set(sys, number, flags);
486 QString prnInternalStr = QString::fromStdString(prn.toInternalString());
487 QString prnStr = QString::fromStdString(prn.toString());
488
489 const t_eph* ephLast = _ephUser->ephLast(prnInternalStr);
490 const t_eph* ephPrev = _ephUser->ephPrev(prnInternalStr);
491 const t_eph* eph = ephLast;
492 if (eph) {
493
494 // Use previous ephemeris if the last one is too recent
495 // ----------------------------------------------------
496 const int MINAGE = 60; // seconds
497 if (ephPrev && eph->receptDateTime().isValid()
498 && eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
499 eph = ephPrev;
500 }
501
502 // Make sure the clock messages refer to same IOD as orbit messages
503 // ----------------------------------------------------------------
504 if (_usedEph) {
505 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
506 (*_usedEph)[prnInternalStr] = eph;
507 }
508 else {
509 eph = 0;
510 if (_usedEph->contains(prnInternalStr)) {
511 const t_eph* usedEph = _usedEph->value(prnInternalStr);
512 if (usedEph == ephLast) {
513 eph = ephLast;
514 }
515 else if (usedEph == ephPrev) {
516 eph = ephPrev;
517 }
518 }
519 }
520 }
521 }
522
523 if (eph &&
524 !outDatedBcep(eph) && // detected from storage because of no update
525 eph->checkState() != t_eph::bad &&
526 eph->checkState() != t_eph::unhealthy &&
527 eph->checkState() != t_eph::outdated) { // detected during reception (bncephuser)
528 QMap<QString, double> codeBiases;
529 QList<phaseBiasSignal> phaseBiasList;
530 phaseBiasesSat pbSat;
531 _phaseBiasInformationDecoded = false;
532
533 while (true) {
534 QString key;
535 int numVal = 0;
536 in >> key;
537 if (in.status() != QTextStream::Ok) {
538 break;
539 }
540 if (key == "APC") {
541 in >> numVal;
542 rtnAPC.ReSize(3); rtnAPC = 0.0;
543 for (int ii = 0; ii < numVal; ii++) {
544 in >> rtnAPC[ii];
545 }
546 }
547 else if (key == "Ura") {
548 in >> numVal;
549 if (numVal == 1)
550 in >> rtnUra;
551 }
552 else if (key == "Clk") {
553 in >> numVal;
554 rtnClk.ReSize(3); rtnClk = 0.0;
555 for (int ii = 0; ii < numVal; ii++) {
556 in >> rtnClk[ii];
557 }
558 }
559 else if (key == "ClkSig") {
560 in >> numVal;
561 rtnClkSig.ReSize(3); rtnClkSig = 0.0;
562 for (int ii = 0; ii < numVal; ii++) {
563 in >> rtnClkSig[ii];
564 }
565 }
566 else if (key == "Vel") {
567 in >> numVal;
568 rtnVel.ReSize(3); rtnVel = 0.0;
569 for (int ii = 0; ii < numVal; ii++) {
570 in >> rtnVel[ii];
571 }
572 }
573 else if (key == "CoM") {
574 in >> numVal;
575 rtnCoM.ReSize(3); rtnCoM = 0.0;
576 for (int ii = 0; ii < numVal; ii++) {
577 in >> rtnCoM[ii];
578 }
579 }
580 else if (key == "CodeBias") {
581 in >> numVal;
582 for (int ii = 0; ii < numVal; ii++) {
583 QString type;
584 double value;
585 in >> type >> value;
586 codeBiases[type] = value;
587 }
588 }
589 else if (key == "YawAngle") {
590 _phaseBiasInformationDecoded = true;
591 in >> numVal >> pbSat.yawAngle;
592 if (pbSat.yawAngle < 0.0) {
593 pbSat.yawAngle += (2*M_PI);
594 }
595 else if (pbSat.yawAngle > 2*M_PI) {
596 pbSat.yawAngle -= (2*M_PI);
597 }
598 }
599 else if (key == "YawRate") {
600 _phaseBiasInformationDecoded = true;
601 in >> numVal >> pbSat.yawRate;
602 }
603 else if (key == "PhaseBias") {
604 _phaseBiasInformationDecoded = true;
605 in >> numVal;
606 for (int ii = 0; ii < numVal; ii++) {
607 phaseBiasSignal pb;
608 in >> pb.type >> pb.bias >> pb.integerIndicator
609 >> pb.wlIndicator >> pb.discontinuityCounter;
610 phaseBiasList.append(pb);
611 }
612 }
613 else {
614 in >> numVal;
615 for (int ii = 0; ii < numVal; ii++) {
616 double dummy;
617 in >> dummy;
618 }
619 emit(newMessage(" RTNET format error: "
620 + epochLines[ii].toLatin1(), false));
621 break;
622 }
623 }
624
625 struct SsrCorr::ClockOrbit::SatData* sd = 0;
626 if (prn.system() == 'G') {
627 sd = co.Sat + co.NumberOfSat[CLOCKORBIT_SATGPS];
628 ++co.NumberOfSat[CLOCKORBIT_SATGPS];
629 }
630 else if (prn.system() == 'R') {
631 sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfSat[CLOCKORBIT_SATGLONASS];
632 ++co.NumberOfSat[CLOCKORBIT_SATGLONASS];
633 }
634 else if (prn.system() == 'E') {
635 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
636 + co.NumberOfSat[CLOCKORBIT_SATGALILEO];
637 ++co.NumberOfSat[CLOCKORBIT_SATGALILEO];
638 }
639 else if (prn.system() == 'J') {
640 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
641 + CLOCKORBIT_NUMGALILEO
642 + co.NumberOfSat[CLOCKORBIT_SATQZSS];
643 ++co.NumberOfSat[CLOCKORBIT_SATQZSS];
644 }
645 else if (prn.system() == 'S') {
646 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
647 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
648 + co.NumberOfSat[CLOCKORBIT_SATSBAS];
649 ++co.NumberOfSat[CLOCKORBIT_SATSBAS];
650 }
651 else if (prn.system() == 'C') {
652 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
653 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
654 + CLOCKORBIT_NUMSBAS
655 + co.NumberOfSat[CLOCKORBIT_SATBDS];
656 ++co.NumberOfSat[CLOCKORBIT_SATBDS];
657 }
658 if (sd) {
659 QString outLine;
660 t_irc irc = processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prnStr, rtnAPC,
661 rtnUra, rtnClk, rtnVel, rtnCoM, rtnClkSig, sd, outLine);
662 if (irc != success) {
663 continue;
664 }
665 }
666
667 // Code Biases
668 // -----------
669 struct SsrCorr::CodeBias::BiasSat* biasSat = 0;
670 if (!codeBiases.isEmpty()) {
671 if (prn.system() == 'G') {
672 biasSat = bias.Sat + bias.NumberOfSat[CLOCKORBIT_SATGPS];
673 ++bias.NumberOfSat[CLOCKORBIT_SATGPS];
674 }
675 else if (prn.system() == 'R') {
676 biasSat = bias.Sat + CLOCKORBIT_NUMGPS
677 + bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
678 ++bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
679 }
680 else if (prn.system() == 'E') {
681 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
682 + bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
683 ++bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
684 }
685 else if (prn.system() == 'J') {
686 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
687 + CLOCKORBIT_NUMGALILEO
688 + bias.NumberOfSat[CLOCKORBIT_SATQZSS];
689 ++bias.NumberOfSat[CLOCKORBIT_SATQZSS];
690 }
691 else if (prn.system() == 'S') {
692 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
693 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
694 + bias.NumberOfSat[CLOCKORBIT_SATSBAS];
695 ++bias.NumberOfSat[CLOCKORBIT_SATSBAS];
696 }
697 else if (prn.system() == 'C') {
698 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
699 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
700 + CLOCKORBIT_NUMSBAS
701 + bias.NumberOfSat[CLOCKORBIT_SATBDS];
702 ++bias.NumberOfSat[CLOCKORBIT_SATBDS];
703 }
704 }
705
706 if (biasSat) {
707 biasSat->ID = prn.number();
708 biasSat->NumberOfCodeBiases = 0;
709 QMapIterator<QString, double> it(codeBiases);
710 while (it.hasNext()) {
711 it.next();
712 int ii = biasSat->NumberOfCodeBiases;
713 if (ii >= CLOCKORBIT_NUMBIAS)
714 break;
715 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), it.key().toStdString());
716 if (type != _ssrCorr->RESERVED) {
717 biasSat->NumberOfCodeBiases += 1;
718 biasSat->Biases[ii].Type = type;
719 biasSat->Biases[ii].Bias = it.value();
720 if (_bsx) {
721 QString obsCode = 'C' + it.key();
722 _bsx->write(epoTime.gpsw(), epoTime.gpssec(), prnStr, obsCode, it.value());
723 }
724 }
725 }
726 }
727
728 // Phase Biases
729 // ------------
730 struct SsrCorr::PhaseBias::PhaseBiasSat* phasebiasSat = 0;
731 if (prn.system() == 'G') {
732 phasebiasSat = phasebias.Sat
733 + phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
734 ++phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
735 }
736 else if (prn.system() == 'R') {
737 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS
738 + phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
739 ++phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
740 }
741 else if (prn.system() == 'E') {
742 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
743 + phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
744 ++phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
745 }
746 else if (prn.system() == 'J') {
747 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
748 + CLOCKORBIT_NUMGALILEO
749 + phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
750 ++phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
751 }
752 else if (prn.system() == 'S') {
753 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
754 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
755 + phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
756 ++phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
757 }
758 else if (prn.system() == 'C') {
759 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
760 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
761 + CLOCKORBIT_NUMSBAS
762 + phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
763 ++phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
764 }
765
766 if (phasebiasSat && _phaseBiasInformationDecoded) {
767 phasebias.DispersiveBiasConsistencyIndicator = dispersiveBiasConsistenyIndicator;
768 phasebias.MWConsistencyIndicator = mwConsistencyIndicator;
769 phasebiasSat->ID = prn.number();
770 phasebiasSat->NumberOfPhaseBiases = 0;
771 phasebiasSat->YawAngle = pbSat.yawAngle;
772 phasebiasSat->YawRate = pbSat.yawRate;
773 QListIterator<phaseBiasSignal> it(phaseBiasList);
774 while (it.hasNext()) {
775 const phaseBiasSignal &pbSig = it.next();
776 int ii = phasebiasSat->NumberOfPhaseBiases;
777 if (ii >= CLOCKORBIT_NUMBIAS)
778 break;
779 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), pbSig.type.toStdString());
780 if (type != _ssrCorr->RESERVED) {
781 phasebiasSat->NumberOfPhaseBiases += 1;
782 phasebiasSat->Biases[ii].Type = type;
783 phasebiasSat->Biases[ii].Bias = pbSig.bias;
784 phasebiasSat->Biases[ii].SignalIntegerIndicator = pbSig.integerIndicator;
785 phasebiasSat->Biases[ii].SignalsWideLaneIntegerIndicator = pbSig.wlIndicator;
786 phasebiasSat->Biases[ii].SignalDiscontinuityCounter = pbSig.discontinuityCounter;
787 if (_bsx) {
788 QString obsCode = 'L' + pbSig.type;
789 _bsx->write(epoTime.gpsw(), epoTime.gpssec(), prnStr, obsCode, pbSig.bias);
790 }
791 }
792 }
793 }
794 }
795 }
796
797 QByteArray hlpBufferCo;
798
799 // Orbit and Clock Corrections together
800 // ------------------------------------
801 if (_samplRtcmEphCorr == _samplRtcmClkCorr) {
802 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0
803 || co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
804 || co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
805 || co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
806 || co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
807 || co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
808 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
809 int len = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
810 if (len > 0) {
811 hlpBufferCo = QByteArray(obuffer, len);
812 }
813 }
814 }
815
816 // Orbit and Clock Corrections separately
817 // --------------------------------------
818 else {
819 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
820 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
821 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
822 co.UpdateInterval = ephUpdInd;
823 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer,
824 sizeof(obuffer));
825 co.UpdateInterval = clkUpdInd;
826 if (len1 > 0) {
827 hlpBufferCo += QByteArray(obuffer, len1);
828 }
829 }
830 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0 ||
831 co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
832 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
833 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
834 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
835 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer,
836 sizeof(obuffer));
837 if (len2 > 0) {
838 hlpBufferCo += QByteArray(obuffer, len2);
839 }
840 }
841 if (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
842 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
843 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
844 co.UpdateInterval = ephUpdInd;
845 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer,
846 sizeof(obuffer));
847 co.UpdateInterval = clkUpdInd;
848 if (len1 > 0) {
849 hlpBufferCo += QByteArray(obuffer, len1);
850 }
851 }
852 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
853 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
854 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
855 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
856 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer,
857 sizeof(obuffer));
858 if (len2 > 0) {
859 hlpBufferCo += QByteArray(obuffer, len2);
860 }
861 }
862 if (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
863 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
864 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
865 co.UpdateInterval = ephUpdInd;
866 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer,
867 sizeof(obuffer));
868 co.UpdateInterval = clkUpdInd;
869 if (len1 > 0) {
870 hlpBufferCo += QByteArray(obuffer, len1);
871 }
872 }
873 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
874 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
875 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
876 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer,
877 sizeof(obuffer));
878 if (len2 > 0) {
879 hlpBufferCo += QByteArray(obuffer, len2);
880 }
881 }
882 if (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
883 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
884 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
885 co.UpdateInterval = ephUpdInd;
886 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer,
887 sizeof(obuffer));
888 co.UpdateInterval = clkUpdInd;
889 if (len1 > 0) {
890 hlpBufferCo += QByteArray(obuffer, len1);
891 }
892 }
893 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
894 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
895 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer,
896 sizeof(obuffer));
897 if (len2 > 0) {
898 hlpBufferCo += QByteArray(obuffer, len2);
899 }
900 }
901 if (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
902 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
903 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
904 co.UpdateInterval = ephUpdInd;
905 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer,
906 sizeof(obuffer));
907 co.UpdateInterval = clkUpdInd;
908 if (len1 > 0) {
909 hlpBufferCo += QByteArray(obuffer, len1);
910 }
911 }
912 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) ? 1 : 0;
913 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASCLOCK, mmsg, obuffer,
914 sizeof(obuffer));
915 if (len2 > 0) {
916 hlpBufferCo += QByteArray(obuffer, len2);
917 }
918 }
919 if (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
920 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
921 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
922 co.UpdateInterval = ephUpdInd;
923 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer,
924 sizeof(obuffer));
925 co.UpdateInterval = clkUpdInd;
926 if (len1 > 0) {
927 hlpBufferCo += QByteArray(obuffer, len1);
928 }
929 }
930 int mmsg = 0;
931 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer,
932 sizeof(obuffer));
933 if (len2 > 0) {
934 hlpBufferCo += QByteArray(obuffer, len2);
935 }
936 }
937 }
938
939 // Code Biases
940 // -----------
941 QByteArray hlpBufferBias;
942 if (bias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
943 || bias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
944 || bias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
945 || bias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
946 || bias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
947 || bias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
948 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
949 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
950 int len = _ssrCorr->MakeCodeBias(&bias, _ssrCorr->CBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
951 if (len > 0) {
952 hlpBufferBias = QByteArray(obuffer, len);
953 }
954 }
955 }
956
957 // Phase Biases
958 // ------------
959 QByteArray hlpBufferPhaseBias;
960 if ((phasebias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
961 || phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
962 || phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
963 || phasebias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
964 || phasebias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
965 || phasebias.NumberOfSat[CLOCKORBIT_SATBDS] > 0)
966 && (_phaseBiasInformationDecoded)) {
967 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
968 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
969 int len = _ssrCorr->MakePhaseBias(&phasebias, _ssrCorr->PBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
970 if (len > 0) {
971 hlpBufferPhaseBias = QByteArray(obuffer, len);
972 }
973 }
974 }
975
976 // VTEC
977 // ----
978 QByteArray hlpBufferVtec;
979 if (vtec.NumLayers > 0) {
980 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
981 int len = _ssrCorr->MakeVTEC(&vtec, 0, obuffer, sizeof(obuffer));
982 if (len > 0) {
983 hlpBufferVtec = QByteArray(obuffer, len);
984 }
985 }
986
987 _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias + hlpBufferVtec + '\0';
988}
989//
990////////////////////////////////////////////////////////////////////////////
991t_irc bncRtnetUploadCaster::processSatellite(const t_eph* eph, int GPSweek,
992 double GPSweeks, const QString& prn, const ColumnVector& rtnAPC,
993 double rtnUra, const ColumnVector& rtnClk, const ColumnVector& rtnVel,
994 const ColumnVector& rtnCoM, const ColumnVector& rtnClkSig,
995 struct SsrCorr::ClockOrbit::SatData* sd, QString& outLine) {
996
997 // Broadcast Position and Velocity
998 // -------------------------------
999 ColumnVector xB(6);
1000 ColumnVector vB(3);
1001 t_irc irc = eph->getCrd(bncTime(GPSweek, GPSweeks), xB, vB, false);
1002
1003 if (irc != success) {
1004 return irc;
1005 }
1006
1007 // Precise Position
1008 // ----------------
1009 ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
1010
1011 if (xP.size() == 0) {
1012 return failure;
1013 }
1014
1015 double dc = 0.0;
1016 if (_crdTrafo != "IGS14") {
1017 crdTrafo(GPSweek, xP, dc);
1018 }
1019
1020 // Difference in xyz
1021 // -----------------
1022 ColumnVector dx = xB.Rows(1, 3) - xP;
1023 ColumnVector dv = vB - rtnVel;
1024
1025 // Difference in RSW
1026 // -----------------
1027 ColumnVector rsw(3);
1028 XYZ_to_RSW(xB.Rows(1, 3), vB, dx, rsw);
1029
1030 ColumnVector dotRsw(3);
1031 XYZ_to_RSW(xB.Rows(1, 3), vB, dv, dotRsw);
1032
1033 // Clock Correction
1034 // ----------------
1035 double dClkA0 = rtnClk(1) - (xB(4) - dc) * t_CST::c;
1036 double dClkA1 = 0.0;
1037 if (rtnClk(2)) {
1038 dClkA1 = rtnClk(2) - xB(5) * t_CST::c;
1039 }
1040 double dClkA2 = 0.0;
1041 if (rtnClk(3)) {
1042 dClkA2 = rtnClk(3) - xB(6) * t_CST::c;
1043 }
1044
1045 if (sd) {
1046 sd->ID = prn.mid(1).toInt();
1047 sd->IOD = eph->IOD();
1048 sd->Clock.DeltaA0 = dClkA0;
1049 sd->Clock.DeltaA1 = dClkA1;
1050 sd->Clock.DeltaA2 = dClkA2;
1051 sd->UserRangeAccuracy = rtnUra;
1052 sd->Orbit.DeltaRadial = rsw(1);
1053 sd->Orbit.DeltaAlongTrack = rsw(2);
1054 sd->Orbit.DeltaCrossTrack = rsw(3);
1055 sd->Orbit.DotDeltaRadial = dotRsw(1);
1056 sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
1057 sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
1058
1059 if (corrIsOutOfRange(sd)) {
1060 return failure;
1061 }
1062 }
1063
1064 outLine = QString().asprintf("%d %.1f %s %u %10.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", GPSweek,
1065 GPSweeks, eph->prn().toString().c_str(), eph->IOD(), dClkA0, dClkA1, dClkA2,
1066 rsw(1), rsw(2), rsw(3)); //fprintf(stderr, "%s\n", outLine.toStdString().c_str());
1067
1068 // RTNET full clock for RINEX and SP3 file
1069 // ---------------------------------------
1070 double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
1071 double clkRnx = (rtnClk[0] - relativity) / t_CST::c; // [s]
1072 double clkRnxRate = rtnClk[1] / t_CST::c; // [s/s = -]
1073 double clkRnxAcc = rtnClk[2] / t_CST::c; // [s/s² ) -/s]
1074
1075 if (_rnx) {
1076 double clkRnxSig, clkRnxRateSig, clkRnxAccSig;
1077 int s = rtnClkSig.size();
1078 switch (s) {
1079 case 1:
1080 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1081 clkRnxRateSig = 0.0; // [s/s = -]
1082 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1083 break;
1084 case 2:
1085 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1086 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1087 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1088 break;
1089 case 3:
1090 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1091 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1092 clkRnxAccSig = rtnClkSig[2] / t_CST::c; // [s/s² ) -/s]
1093 break;
1094 }
1095 _rnx->write(GPSweek, GPSweeks, prn, clkRnx, clkRnxRate, clkRnxAcc,
1096 clkRnxSig, clkRnxRateSig, clkRnxAccSig);
1097 }
1098 if (_sp3) {
1099 _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, clkRnx, rtnVel, clkRnxRate);
1100 }
1101 return success;
1102}
1103
1104// Transform Coordinates
1105////////////////////////////////////////////////////////////////////////////
1106void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
1107 double& dc) {
1108
1109 // Current epoch minus 2000.0 in years
1110 // ------------------------------------
1111 double dt = (GPSWeek - (1042.0 + 6.0 / 7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
1112
1113 ColumnVector dx(3);
1114
1115 dx(1) = _dx + dt * _dxr;
1116 dx(2) = _dy + dt * _dyr;
1117 dx(3) = _dz + dt * _dzr;
1118
1119 static const double arcSec = 180.0 * 3600.0 / M_PI;
1120
1121 double ox = (_ox + dt * _oxr) / arcSec;
1122 double oy = (_oy + dt * _oyr) / arcSec;
1123 double oz = (_oz + dt * _ozr) / arcSec;
1124
1125 double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
1126
1127 // Specify approximate center of area
1128 // ----------------------------------
1129 ColumnVector meanSta(3);
1130
1131 if (_crdTrafo == "ETRF2000") {
1132 meanSta(1) = 3661090.0;
1133 meanSta(2) = 845230.0;
1134 meanSta(3) = 5136850.0;
1135 }
1136 else if (_crdTrafo == "GDA2020") {
1137 meanSta(1) = -4052050.0;
1138 meanSta(2) = 4212840.0;
1139 meanSta(3) = -2545110.0;
1140 }
1141 else if (_crdTrafo == "SIRGAS2000") {
1142 meanSta(1) = 3740860.0;
1143 meanSta(2) = -4964290.0;
1144 meanSta(3) = -1425420.0;
1145 }
1146 else if (_crdTrafo == "DREF91") {
1147 meanSta(1) = 3959579.0;
1148 meanSta(2) = 721719.0;
1149 meanSta(3) = 4931539.0;
1150 }
1151 else if (_crdTrafo == "Custom") {
1152 meanSta(1) = 0.0; // TODO
1153 meanSta(2) = 0.0; // TODO
1154 meanSta(3) = 0.0; // TODO
1155 }
1156
1157 // Clock correction proportional to topocentric distance to satellites
1158 // -------------------------------------------------------------------
1159 double rho = (xyz - meanSta).NormFrobenius();
1160 dc = rho * (sc - 1.0) / sc / t_CST::c;
1161
1162 Matrix rMat(3, 3);
1163 rMat(1, 1) = 1.0;
1164 rMat(1, 2) = -oz;
1165 rMat(1, 3) = oy;
1166 rMat(2, 1) = oz;
1167 rMat(2, 2) = 1.0;
1168 rMat(2, 3) = -ox;
1169 rMat(3, 1) = -oy;
1170 rMat(3, 2) = ox;
1171 rMat(3, 3) = 1.0;
1172
1173 xyz = sc * rMat * xyz + dx;
1174}
1175
1176int bncRtnetUploadCaster::determineUpdateInd(double samplingRate) {
1177
1178 if (samplingRate == 10.0) {
1179 return 3;
1180 }
1181 else if (samplingRate == 15.0) {
1182 return 4;
1183 }
1184 else if (samplingRate == 30.0) {
1185 return 5;
1186 }
1187 else if (samplingRate == 60.0) {
1188 return 6;
1189 }
1190 else if (samplingRate == 120.0) {
1191 return 7;
1192 }
1193 else if (samplingRate == 240.0) {
1194 return 8;
1195 }
1196 else if (samplingRate == 300.0) {
1197 return 9;
1198 }
1199 else if (samplingRate == 600.0) {
1200 return 10;
1201 }
1202 else if (samplingRate == 900.0) {
1203 return 11;
1204 }
1205 else if (samplingRate == 1800.0) {
1206 return 12;
1207 }
1208 else if (samplingRate == 3600.0) {
1209 return 13;
1210 }
1211 else if (samplingRate == 7200.0) {
1212 return 14;
1213 }
1214 else if (samplingRate == 10800.0) {
1215 return 15;
1216 }
1217 return 2; // default
1218}
1219
1220bool bncRtnetUploadCaster::corrIsOutOfRange(struct SsrCorr::ClockOrbit::SatData* sd) {
1221
1222 if (fabs(sd->Clock.DeltaA0) > 209.7151) {return true;}
1223 if (fabs(sd->Clock.DeltaA1) > 1.048575) {return true;}
1224 if (fabs(sd->Clock.DeltaA2) > 1.34217726) {return true;}
1225
1226 if (fabs(sd->Orbit.DeltaRadial) > 209.7151) {return true;}
1227 if (fabs(sd->Orbit.DeltaAlongTrack) > 209.7148) {return true;}
1228 if (fabs(sd->Orbit.DeltaCrossTrack) > 209.7148) {return true;}
1229
1230 if (fabs(sd->Orbit.DotDeltaRadial) > 1.048575) {return true;}
1231 if (fabs(sd->Orbit.DotDeltaAlongTrack) > 1.048572) {return true;}
1232 if (fabs(sd->Orbit.DotDeltaCrossTrack) > 1.048572) {return true;}
1233 return false;
1234}
Note: See TracBrowser for help on using the repository browser.