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

Last change on this file since 9861 was 9861, checked in by stuerze, 3 months ago

minor changes

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