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

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