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

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

minor changes

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