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

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

minor changes

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