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

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

minor changes

File size: 38.8 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 "bncsp3.h"
23#include "gnss.h"
24#include "bncutils.h"
25
26using namespace std;
27
28// Constructor
29////////////////////////////////////////////////////////////////////////////
30bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint,
31 const QString& outHost, int outPort,
32 const QString& ntripVersion,
33 const QString& userName, const QString& password,
34 const QString& crdTrafo, const QString& ssrFormat, bool CoM, const QString& sp3FileName,
35 const QString& rnxFileName, int PID, int SID, int IOD, int iRow) :
36 bncUploadCaster(mountpoint, outHost, outPort, ntripVersion, userName, password, iRow, 0) {
37
38 if (!mountpoint.isEmpty()) {
39 _casterID += mountpoint;
40 }
41 if (!outHost.isEmpty()) {
42 _casterID += " " + outHost;
43 if (outPort) {
44 _casterID += ":" + QString("%1").arg(outPort, 10);
45 }
46 }
47 if (!crdTrafo.isEmpty()) {
48 _casterID += " " + crdTrafo;
49 }
50 if (!sp3FileName.isEmpty()) {
51 _casterID += " " + sp3FileName;
52 }
53 if (!rnxFileName.isEmpty()) {
54 _casterID += " " + rnxFileName;
55 }
56
57 _crdTrafo = crdTrafo;
58
59 _ssrFormat = ssrFormat;
60
61 _ssrCorr = 0;
62 if (_ssrFormat == "IGS-SSR") {
63 _ssrCorr = new SsrCorrIgs();
64 }
65 else if (_ssrFormat == "RTCM-SSR") {
66 _ssrCorr = new SsrCorrRtcm();
67 }
68
69 _CoM = CoM;
70 _PID = PID;
71 _SID = SID;
72 _IOD = IOD;
73
74 // Member that receives the ephemeris
75 // ----------------------------------
76 _ephUser = new bncEphUser(true);
77
78 bncSettings settings;
79 QString intr = settings.value("uploadIntr").toString();
80 QStringList hlp = settings.value("cmbStreams").toStringList();
81 _samplRtcmEphCorr = settings.value("uploadSamplRtcmEphCorr").toDouble();
82 if (hlp.size() > 1) { // combination stream upload
83 _samplRtcmClkCorr = settings.value("cmbSampl").toInt();
84 }
85 else { // single stream upload or sp3 file generation
86 _samplRtcmClkCorr = 5; // default
87 }
88 int samplClkRnx = settings.value("uploadSamplClkRnx").toInt();
89 int samplSp3 = settings.value("uploadSamplSp3").toInt() * 60;
90
91 if (_samplRtcmEphCorr == 0.0) {
92 _usedEph = 0;
93 }
94 else {
95 _usedEph = new QMap<QString, const t_eph*>;
96 }
97
98 // RINEX writer
99 // ------------
100 if (!rnxFileName.isEmpty()) {
101 _rnx = new bncClockRinex(rnxFileName, intr, samplClkRnx);
102 }
103 else {
104 _rnx = 0;
105 }
106
107 // SP3 writer
108 // ----------
109 if (!sp3FileName.isEmpty()) {
110 _sp3 = new bncSP3(sp3FileName, intr, samplSp3);
111 }
112 else {
113 _sp3 = 0;
114 }
115
116 // Set Transformation Parameters
117 // -----------------------------
118 // Transformation Parameters from ITRF2014 to ETRF2000
119 // EUREF Technical Note 1 Relationship and Transformation between the ITRF and ETRF
120 // Zuheir Altamimi, June 28, 2018
121 if (_crdTrafo == "ETRF2000") {
122 _dx = 0.0547;
123 _dy = 0.0522;
124 _dz = -0.0741;
125
126 _dxr = 0.0001;
127 _dyr = 0.0001;
128 _dzr = -0.0019;
129
130 _ox = 0.001701;
131 _oy = 0.010290;
132 _oz = -0.016632;
133
134 _oxr = 0.000081;
135 _oyr = 0.000490;
136 _ozr = -0.000729;
137
138 _sc = 2.12;
139 _scr = 0.11;
140
141 _t0 = 2010.0;
142 }
143 // Transformation Parameters from ITRF2014 to GDA2020 (Ryan Ruddick, GA)
144 else if (_crdTrafo == "GDA2020") {
145 _dx = 0.0;
146 _dy = 0.0;
147 _dz = 0.0;
148
149 _dxr = 0.0;
150 _dyr = 0.0;
151 _dzr = 0.0;
152
153 _ox = 0.0;
154 _oy = 0.0;
155 _oz = 0.0;
156
157 _oxr = 0.00150379;
158 _oyr = 0.00118346;
159 _ozr = 0.00120716;
160
161 _sc = 0.0;
162 _scr = 0.0;
163
164 _t0 = 2020.0;
165 }
166 // Transformation Parameters from IGb14 to SIRGAS2000 (Thanks to Sonia Costa, BRA)
167 // June 29 2020: TX:-0.0027 m TY:-0.0025 m TZ:-0.0042 m SCL:1.20 (ppb) no rotations and no rates.*/
168 else if (_crdTrafo == "SIRGAS2000") {
169 _dx = -0.0027;
170 _dy = -0.0025;
171 _dz = -0.0042;
172
173 _dxr = 0.0000;
174 _dyr = 0.0000;
175 _dzr = 0.0000;
176
177 _ox = 0.000000;
178 _oy = 0.000000;
179 _oz = 0.000000;
180
181 _oxr = 0.000000;
182 _oyr = 0.000000;
183 _ozr = 0.000000;
184
185 _sc = 1.20000;
186 _scr = 0.00000;
187 _t0 = 2000.0;
188 }
189 // Transformation Parameters from ITRF2014 to DREF91
190 else if (_crdTrafo == "DREF91") {
191 _dx = 0.0547;
192 _dy = 0.0522;
193 _dz = -0.0741;
194
195 _dxr = 0.0001;
196 _dyr = 0.0001;
197 _dzr = -0.0019;
198 // ERTF200 + rotation parameters (ETRF200 => DREF91)
199 _ox = 0.001701 + 0.000658;
200 _oy = 0.010290 - 0.000208;
201 _oz = -0.016632 + 0.000755;
202
203 _oxr = 0.000081;
204 _oyr = 0.000490;
205 _ozr = -0.000729;
206
207 _sc = 2.12;
208 _scr = 0.11;
209
210 _t0 = 2010.0;
211 }
212 else if (_crdTrafo == "Custom") {
213 _dx = settings.value("trafo_dx").toDouble();
214 _dy = settings.value("trafo_dy").toDouble();
215 _dz = settings.value("trafo_dz").toDouble();
216 _dxr = settings.value("trafo_dxr").toDouble();
217 _dyr = settings.value("trafo_dyr").toDouble();
218 _dzr = settings.value("trafo_dzr").toDouble();
219 _ox = settings.value("trafo_ox").toDouble();
220 _oy = settings.value("trafo_oy").toDouble();
221 _oz = settings.value("trafo_oz").toDouble();
222 _oxr = settings.value("trafo_oxr").toDouble();
223 _oyr = settings.value("trafo_oyr").toDouble();
224 _ozr = settings.value("trafo_ozr").toDouble();
225 _sc = settings.value("trafo_sc").toDouble();
226 _scr = settings.value("trafo_scr").toDouble();
227 _t0 = settings.value("trafo_t0").toDouble();
228 }
229}
230
231// Destructor
232////////////////////////////////////////////////////////////////////////////
233bncRtnetUploadCaster::~bncRtnetUploadCaster() {
234 if (isRunning()) {
235 wait();
236 }
237 delete _rnx;
238 delete _sp3;
239 delete _ephUser;
240 delete _usedEph;
241 delete _ssrCorr;
242}
243
244//
245////////////////////////////////////////////////////////////////////////////
246void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
247
248 QMutexLocker locker(&_mutex);
249
250 // Append to internal buffer
251 // -------------------------
252 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
253
254 // Select buffer part that contains last epoch
255 // -------------------------------------------
256 QStringList lines;
257 int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
258 if (iEpoBeg == -1) {
259 _rtnetStreamBuffer.clear();
260 return;
261 }
262 int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
263 if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) { // are there two epoch lines in buffer?
264 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
265 }
266 else {
267 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
268 }
269 int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
270 if (iEpoEnd == -1) {
271 return;
272 }
273
274 while (_rtnetStreamBuffer.count('*') > 1) { // is there more than 1 epoch line in buffer?
275 QString rtnetStreamBuffer = _rtnetStreamBuffer.mid(1);
276 int nextEpoch = rtnetStreamBuffer.indexOf('*');
277 if (nextEpoch != -1 && nextEpoch < iEpoEnd) {
278 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpoch);
279 }
280 else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
281 break;
282 }
283 }
284
285 lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n',
286 QString::SkipEmptyParts);
287 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd + 3);
288
289 if (lines.size() < 2) {
290 return;
291 }
292
293 // Read first line (with epoch time)
294 // ---------------------------------
295 QTextStream in(lines[0].toLatin1());
296 QString hlp;
297 int year, month, day, hour, min;
298 double sec;
299 in >> hlp >> year >> month >> day >> hour >> min >> sec;
300 bncTime epoTime;
301 epoTime.set(year, month, day, hour, min, sec);
302
303 emit(newMessage(
304 "bncRtnetUploadCaster: decode " + QByteArray(epoTime.datestr().c_str())
305 + " " + QByteArray(epoTime.timestr().c_str()) + " "
306 + _casterID.toLatin1(), false));
307
308 struct SsrCorr::ClockOrbit co;
309 memset(&co, 0, sizeof(co));
310 co.EpochTime[CLOCKORBIT_SATGPS] = static_cast<int>(epoTime.gpssec());
311 if (_ssrFormat == "RTCM-SSR") {
312 double gt = epoTime.gpssec() + 3 * 3600 - gnumleap(year, month, day);
313 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(fmod(gt, 86400.0));
314 }
315 else if (_ssrFormat == "IGS-SSR") {
316 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(epoTime.gpssec());
317 }
318 co.EpochTime[CLOCKORBIT_SATGALILEO] = static_cast<int>(epoTime.gpssec());
319 co.EpochTime[CLOCKORBIT_SATQZSS] = static_cast<int>(epoTime.gpssec());
320 co.EpochTime[CLOCKORBIT_SATSBAS] = static_cast<int>(epoTime.gpssec());
321 if (_ssrFormat == "RTCM-SSR") {
322 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.bdssec());
323 }
324 else if (_ssrFormat == "IGS-SSR") {
325 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.gpssec());
326 }
327 co.Supplied[_ssrCorr->COBOFS_CLOCK] = 1;
328 co.Supplied[_ssrCorr->COBOFS_ORBIT] = 1;
329 co.SatRefDatum = _ssrCorr->DATUM_ITRF; // ToDo: to decode from RTNET format
330 co.SSRIOD = _IOD;
331 co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
332 co.SSRSolutionID = _SID;
333
334 struct SsrCorr::CodeBias bias;
335 memset(&bias, 0, sizeof(bias));
336 bias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
337 bias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
338 bias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
339 bias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
340 bias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
341 bias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
342 bias.SSRIOD = _IOD;
343 bias.SSRProviderID = _PID;
344 bias.SSRSolutionID = _SID;
345
346 struct SsrCorr::PhaseBias phasebias;
347 memset(&phasebias, 0, sizeof(phasebias));
348 unsigned int dispersiveBiasConsistenyIndicator = 0;
349 unsigned int mwConsistencyIndicator = 0;
350 phasebias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
351 phasebias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
352 phasebias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
353 phasebias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
354 phasebias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
355 phasebias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
356 phasebias.SSRIOD = _IOD;
357 phasebias.SSRProviderID = _PID;
358 phasebias.SSRSolutionID = _SID;
359
360 struct SsrCorr::VTEC vtec;
361 memset(&vtec, 0, sizeof(vtec));
362 vtec.EpochTime = static_cast<int>(epoTime.gpssec());
363 vtec.SSRIOD = _IOD;
364 vtec.SSRProviderID = _PID;
365 vtec.SSRSolutionID = _SID;
366
367 // Default Update Interval
368 // -----------------------
369 int clkUpdInd = 2; // 5 sec
370 int ephUpdInd = clkUpdInd; // default
371
372 if (!_samplRtcmEphCorr) {
373 _samplRtcmEphCorr = 5.0;
374 }
375
376 if (_samplRtcmClkCorr > 5.0 && _samplRtcmEphCorr <= 5.0) { // combined orb and clock
377 ephUpdInd = determineUpdateInd(_samplRtcmClkCorr);
378 }
379 if (_samplRtcmClkCorr > 5.0) {
380 clkUpdInd = determineUpdateInd(_samplRtcmClkCorr);
381 }
382 if (_samplRtcmEphCorr > 5.0) {
383 ephUpdInd = determineUpdateInd(_samplRtcmEphCorr);
384 }
385
386 co.UpdateInterval = clkUpdInd;
387 bias.UpdateInterval = ephUpdInd;
388 phasebias.UpdateInterval = ephUpdInd;
389
390 for (int ii = 1; ii < lines.size(); ii++) {
391 QString key; // prn or key VTEC, IND (phase bias indicators)
392 double rtnUra = 0.0; // [m]
393 ColumnVector rtnAPC; rtnAPC.ReSize(3); rtnAPC = 0.0; // [m, m, m]
394 ColumnVector rtnVel; rtnVel.ReSize(3); rtnVel = 0.0; // [m/s, m/s, m/s]
395 ColumnVector rtnCoM; rtnCoM.ReSize(3); rtnCoM = 0.0; // [m, m, m]
396 ColumnVector rtnClk; rtnClk.ReSize(3); rtnClk = 0.0; // [m, m/s, m/s²]
397 ColumnVector rtnClkSig; rtnClkSig.ReSize(3); rtnClkSig = 0.0; // [m, m/s, m/s²]
398 t_prn prn;
399
400 QTextStream in(lines[ii].toLatin1());
401
402 in >> key;
403
404 // non-satellite specific parameters
405 if (key.contains("IND", Qt::CaseSensitive)) {
406 in >> dispersiveBiasConsistenyIndicator >> mwConsistencyIndicator;
407 continue;
408 }
409 // non-satellite specific parameters
410 if (key.contains("VTEC", Qt::CaseSensitive)) {
411 double ui;
412 in >> ui >> vtec.NumLayers;
413 vtec.UpdateInterval = (unsigned int) determineUpdateInd(ui);
414 for (unsigned ll = 0; ll < vtec.NumLayers; ll++) {
415 int dummy;
416 in >> dummy >> vtec.Layers[ll].Degree >> vtec.Layers[ll].Order
417 >> vtec.Layers[ll].Height;
418 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
419 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
420 in >> vtec.Layers[ll].Cosinus[iDeg][iOrd];
421 }
422 }
423 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
424 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
425 in >> vtec.Layers[ll].Sinus[iDeg][iOrd];
426 }
427 }
428 }
429 continue;
430 }
431 // satellite specific parameters
432 char sys = key.mid(0, 1).at(0).toLatin1();
433 int number = key.mid(1, 2).toInt();
434 int flags = 0;
435 if (sys == 'E') { // I/NAV
436 flags = 1;
437 }
438 prn.set(sys, number, flags);
439 QString prnInternalStr = QString::fromStdString(prn.toInternalString());
440 QString prnStr = QString::fromStdString(prn.toString());
441
442 const t_eph* ephLast = _ephUser->ephLast(prnInternalStr);
443 const t_eph* ephPrev = _ephUser->ephPrev(prnInternalStr);
444 const t_eph* eph = ephLast;
445 if (eph) {
446
447 // Use previous ephemeris if the last one is too recent
448 // ----------------------------------------------------
449 const int MINAGE = 60; // seconds
450 if (ephPrev && eph->receptDateTime().isValid()
451 && eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
452 eph = ephPrev;
453 }
454
455 // Make sure the clock messages refer to same IOD as orbit messages
456 // ----------------------------------------------------------------
457 if (_usedEph) {
458 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
459 (*_usedEph)[prnInternalStr] = eph;
460 }
461 else {
462 eph = 0;
463 if (_usedEph->contains(prnInternalStr)) {
464 const t_eph* usedEph = _usedEph->value(prnInternalStr);
465 if (usedEph == ephLast) {
466 eph = ephLast;
467 }
468 else if (usedEph == ephPrev) {
469 eph = ephPrev;
470 }
471 }
472 }
473 }
474 }
475
476 if (eph &&
477 !outDatedBcep(eph) && // detected from storage because of no update
478 eph->checkState() != t_eph::bad &&
479 eph->checkState() != t_eph::unhealthy &&
480 eph->checkState() != t_eph::outdated) { // detected during reception (bncephuser)
481 QMap<QString, double> codeBiases;
482 QList<phaseBiasSignal> phaseBiasList;
483 phaseBiasesSat pbSat;
484 _phaseBiasInformationDecoded = false;
485
486 while (true) {
487 QString key;
488 int numVal = 0;
489 in >> key;
490 if (in.status() != QTextStream::Ok) {
491 break;
492 }
493 if (key == "APC") {
494 in >> numVal;
495 rtnAPC.ReSize(3); rtnAPC = 0.0;
496 for (int ii = 0; ii < numVal; ii++) {
497 in >> rtnAPC[ii];
498 }
499 }
500 else if (key == "Ura") {
501 in >> numVal;
502 if (numVal == 1)
503 in >> rtnUra;
504 }
505 else if (key == "Clk") {
506 in >> numVal;
507 rtnClk.ReSize(3); rtnClk = 0.0;
508 for (int ii = 0; ii < numVal; ii++) {
509 in >> rtnClk[ii];
510 }
511 }
512 else if (key == "ClkSig") {
513 in >> numVal;
514 rtnClkSig.ReSize(3); rtnClkSig = 0.0;
515 for (int ii = 0; ii < numVal; ii++) {
516 in >> rtnClkSig[ii];
517 }
518 }
519 else if (key == "Vel") {
520 in >> numVal;
521 rtnVel.ReSize(3); rtnVel = 0.0;
522 for (int ii = 0; ii < numVal; ii++) {
523 in >> rtnVel[ii];
524 }
525 }
526 else if (key == "CoM") {
527 in >> numVal;
528 rtnCoM.ReSize(3); rtnCoM = 0.0;
529 for (int ii = 0; ii < numVal; ii++) {
530 in >> rtnCoM[ii];
531 }
532 }
533 else if (key == "CodeBias") {
534 in >> numVal;
535 for (int ii = 0; ii < numVal; ii++) {
536 QString type;
537 double value;
538 in >> type >> value;
539 codeBiases[type] = value;
540 }
541 }
542 else if (key == "YawAngle") {
543 _phaseBiasInformationDecoded = true;
544 in >> numVal >> pbSat.yawAngle;
545 if (pbSat.yawAngle < 0.0) {
546 pbSat.yawAngle += (2*M_PI);
547 }
548 else if (pbSat.yawAngle > 2*M_PI) {
549 pbSat.yawAngle -= (2*M_PI);
550 }
551 }
552 else if (key == "YawRate") {
553 _phaseBiasInformationDecoded = true;
554 in >> numVal >> pbSat.yawRate;
555 }
556 else if (key == "PhaseBias") {
557 _phaseBiasInformationDecoded = true;
558 in >> numVal;
559 for (int ii = 0; ii < numVal; ii++) {
560 phaseBiasSignal pb;
561 in >> pb.type >> pb.bias >> pb.integerIndicator
562 >> pb.wlIndicator >> pb.discontinuityCounter;
563 phaseBiasList.append(pb);
564 }
565 }
566 else {
567 in >> numVal;
568 for (int ii = 0; ii < numVal; ii++) {
569 double dummy;
570 in >> dummy;
571 }
572 emit(newMessage(" RTNET format error: "
573 + lines[ii].toLatin1(), false));
574 }
575 }
576
577 struct SsrCorr::ClockOrbit::SatData* sd = 0;
578 if (prn.system() == 'G') {
579 sd = co.Sat + co.NumberOfSat[CLOCKORBIT_SATGPS];
580 ++co.NumberOfSat[CLOCKORBIT_SATGPS];
581 }
582 else if (prn.system() == 'R') {
583 sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfSat[CLOCKORBIT_SATGLONASS];
584 ++co.NumberOfSat[CLOCKORBIT_SATGLONASS];
585 }
586 else if (prn.system() == 'E') {
587 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
588 + co.NumberOfSat[CLOCKORBIT_SATGALILEO];
589 ++co.NumberOfSat[CLOCKORBIT_SATGALILEO];
590 }
591 else if (prn.system() == 'J') {
592 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
593 + CLOCKORBIT_NUMGALILEO
594 + co.NumberOfSat[CLOCKORBIT_SATQZSS];
595 ++co.NumberOfSat[CLOCKORBIT_SATQZSS];
596 }
597 else if (prn.system() == 'S') {
598 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
599 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
600 + co.NumberOfSat[CLOCKORBIT_SATSBAS];
601 ++co.NumberOfSat[CLOCKORBIT_SATSBAS];
602 }
603 else if (prn.system() == 'C') {
604 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
605 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
606 + CLOCKORBIT_NUMSBAS
607 + co.NumberOfSat[CLOCKORBIT_SATBDS];
608 ++co.NumberOfSat[CLOCKORBIT_SATBDS];
609 }
610 if (sd) {
611 QString outLine;
612 t_irc irc = processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prnStr, rtnAPC,
613 rtnUra, rtnClk, rtnVel, rtnCoM, rtnClkSig, sd, outLine);
614 if (irc != success) {/*
615 // very few cases: check states bad and unhealthy are excluded earlier
616 sd->ID = prnStr.mid(1).toInt(); // to prevent G00, R00 entries
617 sd->IOD = eph->IOD();
618 */
619 continue;
620 }
621 }
622
623 // Code Biases
624 // -----------
625 struct SsrCorr::CodeBias::BiasSat* biasSat = 0;
626 if (!codeBiases.isEmpty()) {
627 if (prn.system() == 'G') {
628 biasSat = bias.Sat + bias.NumberOfSat[CLOCKORBIT_SATGPS];
629 ++bias.NumberOfSat[CLOCKORBIT_SATGPS];
630 }
631 else if (prn.system() == 'R') {
632 biasSat = bias.Sat + CLOCKORBIT_NUMGPS
633 + bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
634 ++bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
635 }
636 else if (prn.system() == 'E') {
637 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
638 + bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
639 ++bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
640 }
641 else if (prn.system() == 'J') {
642 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
643 + CLOCKORBIT_NUMGALILEO
644 + bias.NumberOfSat[CLOCKORBIT_SATQZSS];
645 ++bias.NumberOfSat[CLOCKORBIT_SATQZSS];
646 }
647 else if (prn.system() == 'S') {
648 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
649 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
650 + bias.NumberOfSat[CLOCKORBIT_SATSBAS];
651 ++bias.NumberOfSat[CLOCKORBIT_SATSBAS];
652 }
653 else if (prn.system() == 'C') {
654 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
655 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
656 + CLOCKORBIT_NUMSBAS
657 + bias.NumberOfSat[CLOCKORBIT_SATBDS];
658 ++bias.NumberOfSat[CLOCKORBIT_SATBDS];
659 }
660 }
661
662 if (biasSat) {
663 biasSat->ID = prn.number();
664 biasSat->NumberOfCodeBiases = 0;
665 QMapIterator<QString, double> it(codeBiases);
666 while (it.hasNext()) {
667 it.next();
668 int ii = biasSat->NumberOfCodeBiases;
669 if (ii >= CLOCKORBIT_NUMBIAS)
670 break;
671 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), it.key().toStdString());
672 if (type != _ssrCorr->RESERVED) {
673 biasSat->NumberOfCodeBiases += 1;
674 biasSat->Biases[ii].Type = type;
675 biasSat->Biases[ii].Bias = it.value();
676 }
677 }
678 }
679
680 // Phase Biases
681 // ------------
682 struct SsrCorr::PhaseBias::PhaseBiasSat* phasebiasSat = 0;
683 if (prn.system() == 'G') {
684 phasebiasSat = phasebias.Sat
685 + phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
686 ++phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
687 }
688 else if (prn.system() == 'R') {
689 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS
690 + phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
691 ++phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
692 }
693 else if (prn.system() == 'E') {
694 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
695 + phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
696 ++phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
697 }
698 else if (prn.system() == 'J') {
699 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
700 + CLOCKORBIT_NUMGALILEO
701 + phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
702 ++phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
703 }
704 else if (prn.system() == 'S') {
705 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
706 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
707 + phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
708 ++phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
709 }
710 else if (prn.system() == 'C') {
711 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
712 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
713 + CLOCKORBIT_NUMSBAS
714 + phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
715 ++phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
716 }
717
718 if (phasebiasSat && _phaseBiasInformationDecoded) {
719 phasebias.DispersiveBiasConsistencyIndicator = dispersiveBiasConsistenyIndicator;
720 phasebias.MWConsistencyIndicator = mwConsistencyIndicator;
721 phasebiasSat->ID = prn.number();
722 phasebiasSat->NumberOfPhaseBiases = 0;
723 phasebiasSat->YawAngle = pbSat.yawAngle;
724 phasebiasSat->YawRate = pbSat.yawRate;
725 QListIterator<phaseBiasSignal> it(phaseBiasList);
726 while (it.hasNext()) {
727 const phaseBiasSignal &pbSig = it.next();
728 int ii = phasebiasSat->NumberOfPhaseBiases;
729 if (ii >= CLOCKORBIT_NUMBIAS)
730 break;
731 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), pbSig.type.toStdString());
732 if (type != _ssrCorr->RESERVED) {
733 phasebiasSat->NumberOfPhaseBiases += 1;
734 phasebiasSat->Biases[ii].Type = type;
735 phasebiasSat->Biases[ii].Bias = pbSig.bias;
736 phasebiasSat->Biases[ii].SignalIntegerIndicator = pbSig.integerIndicator;
737 phasebiasSat->Biases[ii].SignalsWideLaneIntegerIndicator = pbSig.wlIndicator;
738 phasebiasSat->Biases[ii].SignalDiscontinuityCounter = pbSig.discontinuityCounter;
739 }
740 }
741 }
742 }
743 }
744
745 QByteArray hlpBufferCo;
746
747 // Orbit and Clock Corrections together
748 // ------------------------------------
749 if (_samplRtcmEphCorr == _samplRtcmClkCorr) {
750 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0
751 || co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
752 || co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
753 || co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
754 || co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
755 || co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
756 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
757 int len = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
758 if (len > 0) {
759 hlpBufferCo = QByteArray(obuffer, len);
760 }
761 }
762 }
763
764 // Orbit and Clock Corrections separately
765 // --------------------------------------
766 else {
767 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
768 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
769 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
770 co.UpdateInterval = ephUpdInd;
771 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer,
772 sizeof(obuffer));
773 co.UpdateInterval = clkUpdInd;
774 if (len1 > 0) {
775 hlpBufferCo += QByteArray(obuffer, len1);
776 }
777 }
778 int mmsg = (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 ) ? 1 : 0;
783 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer,
784 sizeof(obuffer));
785 if (len2 > 0) {
786 hlpBufferCo += QByteArray(obuffer, len2);
787 }
788 }
789 if (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
790 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
791 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
792 co.UpdateInterval = ephUpdInd;
793 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer,
794 sizeof(obuffer));
795 co.UpdateInterval = clkUpdInd;
796 if (len1 > 0) {
797 hlpBufferCo += QByteArray(obuffer, len1);
798 }
799 }
800 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
801 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
802 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
803 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
804 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer,
805 sizeof(obuffer));
806 if (len2 > 0) {
807 hlpBufferCo += QByteArray(obuffer, len2);
808 }
809 }
810 if (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
811 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
812 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
813 co.UpdateInterval = ephUpdInd;
814 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer,
815 sizeof(obuffer));
816 co.UpdateInterval = clkUpdInd;
817 if (len1 > 0) {
818 hlpBufferCo += QByteArray(obuffer, len1);
819 }
820 }
821 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
822 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
823 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
824 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer,
825 sizeof(obuffer));
826 if (len2 > 0) {
827 hlpBufferCo += QByteArray(obuffer, len2);
828 }
829 }
830 if (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
831 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
832 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
833 co.UpdateInterval = ephUpdInd;
834 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer,
835 sizeof(obuffer));
836 co.UpdateInterval = clkUpdInd;
837 if (len1 > 0) {
838 hlpBufferCo += QByteArray(obuffer, len1);
839 }
840 }
841 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
842 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
843 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer,
844 sizeof(obuffer));
845 if (len2 > 0) {
846 hlpBufferCo += QByteArray(obuffer, len2);
847 }
848 }
849 if (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
850 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
851 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
852 co.UpdateInterval = ephUpdInd;
853 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer,
854 sizeof(obuffer));
855 co.UpdateInterval = clkUpdInd;
856 if (len1 > 0) {
857 hlpBufferCo += QByteArray(obuffer, len1);
858 }
859 }
860 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) ? 1 : 0;
861 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASCLOCK, mmsg, obuffer,
862 sizeof(obuffer));
863 if (len2 > 0) {
864 hlpBufferCo += QByteArray(obuffer, len2);
865 }
866 }
867 if (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
868 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
869 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
870 co.UpdateInterval = ephUpdInd;
871 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer,
872 sizeof(obuffer));
873 co.UpdateInterval = clkUpdInd;
874 if (len1 > 0) {
875 hlpBufferCo += QByteArray(obuffer, len1);
876 }
877 }
878 int mmsg = 0;
879 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer,
880 sizeof(obuffer));
881 if (len2 > 0) {
882 hlpBufferCo += QByteArray(obuffer, len2);
883 }
884 }
885 }
886
887 // Code Biases
888 // -----------
889 QByteArray hlpBufferBias;
890 if (bias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
891 || bias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
892 || bias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
893 || bias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
894 || bias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
895 || bias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
896 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
897 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
898 int len = _ssrCorr->MakeCodeBias(&bias, _ssrCorr->CBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
899 if (len > 0) {
900 hlpBufferBias = QByteArray(obuffer, len);
901 }
902 }
903 }
904
905 // Phase Biases
906 // ------------
907 QByteArray hlpBufferPhaseBias;
908 if ((phasebias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
909 || phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
910 || phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
911 || phasebias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
912 || phasebias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
913 || phasebias.NumberOfSat[CLOCKORBIT_SATBDS] > 0)
914 && (_phaseBiasInformationDecoded)) {
915 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
916 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
917 int len = _ssrCorr->MakePhaseBias(&phasebias, _ssrCorr->PBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
918 if (len > 0) {
919 hlpBufferPhaseBias = QByteArray(obuffer, len);
920 }
921 }
922 }
923
924 // VTEC
925 // ----
926 QByteArray hlpBufferVtec;
927 if (vtec.NumLayers > 0) {
928 char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
929 int len = _ssrCorr->MakeVTEC(&vtec, 0, obuffer, sizeof(obuffer));
930 if (len > 0) {
931 hlpBufferVtec = QByteArray(obuffer, len);
932 }
933 }
934
935 _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias
936 + hlpBufferVtec + '\0';
937}
938
939//
940////////////////////////////////////////////////////////////////////////////
941t_irc bncRtnetUploadCaster::processSatellite(const t_eph* eph, int GPSweek,
942 double GPSweeks, const QString& prn, const ColumnVector& rtnAPC,
943 double rtnUra, const ColumnVector& rtnClk, const ColumnVector& rtnVel,
944 const ColumnVector& rtnCoM, const ColumnVector& rtnClkSig,
945 struct SsrCorr::ClockOrbit::SatData* sd, QString& outLine) {
946
947 if (eph->prn().number() == 0) {
948 return failure;
949 }
950 // Broadcast Position and Velocity
951 // -------------------------------
952 ColumnVector xB(6);
953 ColumnVector vB(3);
954 t_irc irc = eph->getCrd(bncTime(GPSweek, GPSweeks), xB, vB, false);
955
956 if (irc != success) {
957 return irc;
958 }
959
960 // Precise Position
961 // ----------------
962 ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
963
964 if (xP.size() == 0) {
965 return failure;
966 }
967
968 double dc = 0.0;
969 if (_crdTrafo != "IGS14") {
970 crdTrafo(GPSweek, xP, dc);
971 }
972
973 // Difference in xyz
974 // -----------------
975 ColumnVector dx = xB.Rows(1, 3) - xP;
976 ColumnVector dv = vB - rtnVel;
977
978 // Difference in RSW
979 // -----------------
980 ColumnVector rsw(3);
981 XYZ_to_RSW(xB.Rows(1, 3), vB, dx, rsw);
982
983 ColumnVector dotRsw(3);
984 XYZ_to_RSW(xB.Rows(1, 3), vB, dv, dotRsw);
985
986 // Clock Correction
987 // ----------------
988 double dClkA0 = rtnClk(1) - (xB(4) - dc) * t_CST::c;
989 double dClkA1 = 0.0;
990 if (rtnClk(2)) {
991 dClkA1 = rtnClk(2) - xB(5) * t_CST::c;
992 }
993 double dClkA2 = 0.0;
994 if (rtnClk(3)) {
995 dClkA2 = rtnClk(3) - xB(6) * t_CST::c;
996 }
997
998 if (sd) {
999 sd->ID = prn.mid(1).toInt();
1000 sd->IOD = eph->IOD();
1001 sd->Clock.DeltaA0 = dClkA0;
1002 sd->Clock.DeltaA1 = dClkA1;
1003 sd->Clock.DeltaA2 = dClkA2;
1004 sd->UserRangeAccuracy = rtnUra;
1005 sd->Orbit.DeltaRadial = rsw(1);
1006 sd->Orbit.DeltaAlongTrack = rsw(2);
1007 sd->Orbit.DeltaCrossTrack = rsw(3);
1008 sd->Orbit.DotDeltaRadial = dotRsw(1);
1009 sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
1010 sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
1011
1012 if (corrIsOutOfRange(sd)) {
1013 return failure;
1014 }
1015 }
1016
1017 outLine.sprintf("%d %.1f %s %u %10.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", GPSweek,
1018 GPSweeks, eph->prn().toString().c_str(), eph->IOD(), dClkA0, dClkA1, dClkA2,
1019 rsw(1), rsw(2), rsw(3)); //fprintf(stderr, "%s\n", outLine.toStdString().c_str());
1020
1021 // RTNET full clock for RINEX and SP3 file
1022 // ---------------------------------------
1023 double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
1024 double clkRnx = (rtnClk[0] - relativity) / t_CST::c; // [s]
1025 double clkRnxRate = rtnClk[1] / t_CST::c; // [s/s = -]
1026 double clkRnxAcc = rtnClk[2] / t_CST::c; // [s/s² ) -/s]
1027
1028 if (_rnx) {
1029 double clkRnxSig, clkRnxRateSig, clkRnxAccSig;
1030 int s = rtnClkSig.size();
1031 switch (s) {
1032 case 1:
1033 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1034 clkRnxRateSig = 0.0; // [s/s = -]
1035 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1036 break;
1037 case 2:
1038 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1039 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1040 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1041 break;
1042 case 3:
1043 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1044 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1045 clkRnxAccSig = rtnClkSig[2] / t_CST::c; // [s/s² ) -/s]
1046 break;
1047 }
1048 _rnx->write(GPSweek, GPSweeks, prn, clkRnx, clkRnxRate, clkRnxAcc,
1049 clkRnxSig, clkRnxRateSig, clkRnxAccSig);
1050 }
1051 if (_sp3) {
1052 _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, clkRnx, rtnVel, clkRnxRate);
1053 }
1054 return success;
1055}
1056
1057// Transform Coordinates
1058////////////////////////////////////////////////////////////////////////////
1059void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
1060 double& dc) {
1061
1062 // Current epoch minus 2000.0 in years
1063 // ------------------------------------
1064 double dt = (GPSWeek - (1042.0 + 6.0 / 7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
1065
1066 ColumnVector dx(3);
1067
1068 dx(1) = _dx + dt * _dxr;
1069 dx(2) = _dy + dt * _dyr;
1070 dx(3) = _dz + dt * _dzr;
1071
1072 static const double arcSec = 180.0 * 3600.0 / M_PI;
1073
1074 double ox = (_ox + dt * _oxr) / arcSec;
1075 double oy = (_oy + dt * _oyr) / arcSec;
1076 double oz = (_oz + dt * _ozr) / arcSec;
1077
1078 double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
1079
1080 // Specify approximate center of area
1081 // ----------------------------------
1082 ColumnVector meanSta(3);
1083
1084 if (_crdTrafo == "ETRF2000") {
1085 meanSta(1) = 3661090.0;
1086 meanSta(2) = 845230.0;
1087 meanSta(3) = 5136850.0;
1088 }
1089 else if (_crdTrafo == "GDA2020") {
1090 meanSta(1) = -4052050.0;
1091 meanSta(2) = 4212840.0;
1092 meanSta(3) = -2545110.0;
1093 }
1094 else if (_crdTrafo == "SIRGAS2000") {
1095 meanSta(1) = 3740860.0;
1096 meanSta(2) = -4964290.0;
1097 meanSta(3) = -1425420.0;
1098 }
1099 else if (_crdTrafo == "DREF91") {
1100 meanSta(1) = 3959579.0;
1101 meanSta(2) = 721719.0;
1102 meanSta(3) = 4931539.0;
1103 }
1104 else if (_crdTrafo == "Custom") {
1105 meanSta(1) = 0.0; // TODO
1106 meanSta(2) = 0.0; // TODO
1107 meanSta(3) = 0.0; // TODO
1108 }
1109
1110 // Clock correction proportional to topocentric distance to satellites
1111 // -------------------------------------------------------------------
1112 double rho = (xyz - meanSta).NormFrobenius();
1113 dc = rho * (sc - 1.0) / sc / t_CST::c;
1114
1115 Matrix rMat(3, 3);
1116 rMat(1, 1) = 1.0;
1117 rMat(1, 2) = -oz;
1118 rMat(1, 3) = oy;
1119 rMat(2, 1) = oz;
1120 rMat(2, 2) = 1.0;
1121 rMat(2, 3) = -ox;
1122 rMat(3, 1) = -oy;
1123 rMat(3, 2) = ox;
1124 rMat(3, 3) = 1.0;
1125
1126 xyz = sc * rMat * xyz + dx;
1127}
1128
1129int bncRtnetUploadCaster::determineUpdateInd(double samplingRate) {
1130
1131 if (samplingRate == 10.0) {
1132 return 3;
1133 }
1134 else if (samplingRate == 15.0) {
1135 return 4;
1136 }
1137 else if (samplingRate == 30.0) {
1138 return 5;
1139 }
1140 else if (samplingRate == 60.0) {
1141 return 6;
1142 }
1143 else if (samplingRate == 120.0) {
1144 return 7;
1145 }
1146 else if (samplingRate == 240.0) {
1147 return 8;
1148 }
1149 else if (samplingRate == 300.0) {
1150 return 9;
1151 }
1152 else if (samplingRate == 600.0) {
1153 return 10;
1154 }
1155 else if (samplingRate == 900.0) {
1156 return 11;
1157 }
1158 else if (samplingRate == 1800.0) {
1159 return 12;
1160 }
1161 else if (samplingRate == 3600.0) {
1162 return 13;
1163 }
1164 else if (samplingRate == 7200.0) {
1165 return 14;
1166 }
1167 else if (samplingRate == 10800.0) {
1168 return 15;
1169 }
1170 return 2; // default
1171}
1172
1173bool bncRtnetUploadCaster::corrIsOutOfRange(struct SsrCorr::ClockOrbit::SatData* sd) {
1174
1175 if (fabs(sd->Clock.DeltaA0) > 209.7151) {return true;}
1176 if (fabs(sd->Clock.DeltaA1) > 1.048575) {return true;}
1177 if (fabs(sd->Clock.DeltaA2) > 1.34217726) {return true;}
1178
1179 if (fabs(sd->Orbit.DeltaRadial) > 209.7151) {return true;}
1180 if (fabs(sd->Orbit.DeltaAlongTrack) > 209.7148) {return true;}
1181 if (fabs(sd->Orbit.DeltaCrossTrack) > 209.7148) {return true;}
1182
1183 if (fabs(sd->Orbit.DotDeltaRadial) > 1.048575) {return true;}
1184 if (fabs(sd->Orbit.DotDeltaAlongTrack) > 1.048572) {return true;}
1185 if (fabs(sd->Orbit.DotDeltaCrossTrack) > 1.048572) {return true;}
1186
1187 return false;
1188}
Note: See TracBrowser for help on using the repository browser.