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

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