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

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

restore RTNET buffer reading code

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