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

Last change on this file since 9025 was 9025, checked in by stuerze, 4 years ago

some modification to allow encoding and decoding of SSR corrections in RTCM-SSR and IGS-SSR formats

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