source: ntrip/branches/BNC_2.12/src/upload/bncrtnetuploadcaster.cpp@ 10076

Last change on this file since 10076 was 9393, checked in by stuerze, 4 years ago

minor changes

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