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

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

small bug fixed

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