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

Last change on this file since 9729 was 9687, checked in by stuerze, 3 years ago

minor changes

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