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

Last change on this file since 9842 was 9842, checked in by stuerze, 19 months ago

restore RTNET buffer reading code

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