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

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

minor changes

File size: 37.3 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) {
[3224]36
[8361]37 if (!mountpoint.isEmpty()) {
38 _casterID += mountpoint;
39 }
[5130]40 if (!outHost.isEmpty()) {
[8361]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;
[9025]57
[9034]58 _ssrFormat = ssrFormat;
59
[9025]60 _ssrCorr = 0;
[9033]61 if (_ssrFormat == "IGS-SSR") {
[9025]62 _ssrCorr = new SsrCorrIgs();
63 }
[9033]64 else if (_ssrFormat == "RTCM-SSR") {
[9025]65 _ssrCorr = new SsrCorrRtcm();
66 }
[9033]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 // -----------------------------
[8405]117 // Transformation Parameters from ITRF2014 to ETRF2000
[8720]118 // EUREF Technical Note 1 Relationship and Transformation between the ITRF and ETRF
119 // Zuheir Altamimi, June 28, 2018
[6877]120 if (_crdTrafo == "ETRF2000") {
[8720]121 _dx = 0.0547;
122 _dy = 0.0522;
123 _dz = -0.0741;
124
[8094]125 _dxr = 0.0001;
126 _dyr = 0.0001;
[8405]127 _dzr = -0.0019;
[8720]128
129 _ox = 0.001701;
130 _oy = 0.010290;
131 _oz = -0.016632;
132
133 _oxr = 0.000081;
134 _oyr = 0.000490;
135 _ozr = -0.000729;
136
137 _sc = 2.12;
[8405]138 _scr = 0.11;
[8720]139
140 _t0 = 2010.0;
[3222]141 }
[8094]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;
[8720]147
[8094]148 _dxr = 0.0;
149 _dyr = 0.0;
150 _dzr = 0.0;
[8720]151
[8094]152 _ox = 0.0;
153 _oy = 0.0;
154 _oz = 0.0;
[8720]155
[8094]156 _oxr = 0.00150379;
157 _oyr = 0.00118346;
158 _ozr = 0.00120716;
[8720]159
[8094]160 _sc = 0.0;
161 _scr = 0.0;
[8720]162
[8094]163 _t0 = 2020.0;
[3222]164 }
[8962]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.*/
[8094]167 else if (_crdTrafo == "SIRGAS2000") {
[8962]168 _dx = -0.0027;
169 _dy = -0.0025;
170 _dz = -0.0042;
[8720]171
[8094]172 _dxr = 0.0000;
173 _dyr = 0.0000;
174 _dzr = 0.0000;
[8720]175
176 _ox = 0.000000;
177 _oy = 0.000000;
178 _oz = 0.000000;
179
[8094]180 _oxr = 0.000000;
181 _oyr = 0.000000;
182 _ozr = 0.000000;
[8720]183
[8962]184 _sc = 1.20000;
[8720]185 _scr = 0.00000;
186 _t0 = 2000.0;
[3222]187 }
[8405]188 // Transformation Parameters from ITRF2014 to DREF91
[5347]189 else if (_crdTrafo == "DREF91") {
[8720]190 _dx = 0.0547;
191 _dy = 0.0522;
192 _dz = -0.0741;
193
[8094]194 _dxr = 0.0001;
195 _dyr = 0.0001;
[8405]196 _dzr = -0.0019;
[8720]197 // ERTF200 + rotation parameters (ETRF200 => DREF91)
198 _ox = 0.001701 + 0.000658;
199 _oy = 0.010290 - 0.000208;
200 _oz = -0.016632 + 0.000755;
201
202 _oxr = 0.000081;
203 _oyr = 0.000490;
204 _ozr = -0.000729;
205
206 _sc = 2.12;
[8405]207 _scr = 0.11;
[8720]208
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;
[9025]240 delete _ssrCorr;
[3222]241}
242
[5662]243//
[3222]244////////////////////////////////////////////////////////////////////////////
[9032]245void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
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 }
[8755]261 int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
262 if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) { // are there two epoch lines in buffer?
263 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
264 }
[6896]265 else {
266 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
267 }
[8755]268 int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
[3230]269 if (iEpoEnd == -1) {
270 return;
271 }
[8755]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('*');
[8982]276 if (nextEpoch != -1 && nextEpoch < iEpoEnd) {
[8755]277 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpoch);
278 }
[8761]279 else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
280 break;
281 }
[3226]282 }
[3222]283
[8904]284 lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n',
[8755]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 // ---------------------------------
[8204]294 QTextStream in(lines[0].toLatin1());
[3226]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()) + " "
[8204]305 + _casterID.toLatin1(), false));
[4808]306
[9025]307 struct SsrCorr::ClockOrbit co;
[3222]308 memset(&co, 0, sizeof(co));
[8991]309 co.EpochTime[CLOCKORBIT_SATGPS] = static_cast<int>(epoTime.gpssec());
[9025]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());
[9025]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; // ToDo: to decode from RTNET format
329 co.SSRIOD = _IOD;
[6850]330 co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
331 co.SSRSolutionID = _SID;
[5662]332
[9025]333 struct SsrCorr::CodeBias bias;
[3222]334 memset(&bias, 0, sizeof(bias));
[9025]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];
[9025]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
[9025]345 struct SsrCorr::PhaseBias phasebias;
[6850]346 memset(&phasebias, 0, sizeof(phasebias));
[8017]347 unsigned int dispersiveBiasConsistenyIndicator = 0;
348 unsigned int mwConsistencyIndicator = 0;
[9025]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];
[9025]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
[9025]359 struct SsrCorr::VTEC vtec;
[6860]360 memset(&vtec, 0, sizeof(vtec));
361 vtec.EpochTime = static_cast<int>(epoTime.gpssec());
[9025]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
[6559]371 if (_samplRtcmClkCorr > 5.0 && _samplRtcmEphCorr <= 5.0) { // combined orb and clock
372 ephUpdInd = determineUpdateInd(_samplRtcmClkCorr);
[4754]373 }
[6559]374 if (_samplRtcmClkCorr > 5.0) {
[6557]375 clkUpdInd = determineUpdateInd(_samplRtcmClkCorr);
[4754]376 }
[6559]377 if (_samplRtcmEphCorr > 5.0) {
378 ephUpdInd = determineUpdateInd(_samplRtcmEphCorr);
379 }
[4753]380
[6877]381 co.UpdateInterval = clkUpdInd;
[4754]382 bias.UpdateInterval = clkUpdInd;
[6850]383 phasebias.UpdateInterval = clkUpdInd;
[4753]384
[3226]385 for (int ii = 1; ii < lines.size(); ii++) {
[6877]386 QString key; // prn or key VTEC, IND (phase bias indicators)
[8679]387 double rtnUra = 0.0; // [m]
388 ColumnVector rtnAPC; rtnAPC.ReSize(3); rtnAPC = 0.0; // [m, m, m]
389 ColumnVector rtnVel; rtnVel.ReSize(3); rtnVel = 0.0; // [m/s, m/s, m/s]
390 ColumnVector rtnCoM; rtnCoM.ReSize(3); rtnCoM = 0.0; // [m, m, m]
391 ColumnVector rtnClk; rtnClk.ReSize(3); rtnClk = 0.0; // [m, m/s, m/s²]
392 ColumnVector rtnClkSig; rtnClkSig.ReSize(3); rtnClkSig = 0.0; // [m, m/s, m/s²]
[6877]393 t_prn prn;
[5662]394
[8204]395 QTextStream in(lines[ii].toLatin1());
[3222]396
[6876]397 in >> key;
[3222]398
[6860]399 // non-satellite specific parameters
[6877]400 if (key.contains("IND", Qt::CaseSensitive)) {
[8017]401 in >> dispersiveBiasConsistenyIndicator >> mwConsistencyIndicator;
[6860]402 continue;
403 }
[6893]404 // non-satellite specific parameters
[6876]405 if (key.contains("VTEC", Qt::CaseSensitive)) {
[6897]406 double ui;
407 in >> ui >> vtec.NumLayers;
408 vtec.UpdateInterval = (unsigned int) determineUpdateInd(ui);
[6860]409 for (unsigned ll = 0; ll < vtec.NumLayers; ll++) {
410 int dummy;
411 in >> dummy >> vtec.Layers[ll].Degree >> vtec.Layers[ll].Order
[6877]412 >> vtec.Layers[ll].Height;
[6879]413 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
414 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
[6860]415 in >> vtec.Layers[ll].Cosinus[iDeg][iOrd];
416 }
417 }
[6879]418 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
419 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
[6860]420 in >> vtec.Layers[ll].Sinus[iDeg][iOrd];
421 }
422 }
423 }
424 continue;
425 }
[6877]426 // satellite specific parameters
[8204]427 char sys = key.mid(0, 1).at(0).toLatin1();
[6877]428 int number = key.mid(1, 2).toInt();
429 int flags = 0;
430 if (sys == 'E') { // I/NAV
431 flags = 1;
432 }
[6876]433 prn.set(sys, number, flags);
434 QString prnInternalStr = QString::fromStdString(prn.toInternalString());
[6877]435 QString prnStr = QString::fromStdString(prn.toString());
436
[6876]437 const t_eph* ephLast = _ephUser->ephLast(prnInternalStr);
438 const t_eph* ephPrev = _ephUser->ephPrev(prnInternalStr);
[6877]439 const t_eph* eph = ephLast;
[6442]440 if (eph) {
[3754]441
[4098]442 // Use previous ephemeris if the last one is too recent
443 // ----------------------------------------------------
444 const int MINAGE = 60; // seconds
[6877]445 if (ephPrev && eph->receptDateTime().isValid()
446 && eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
[6442]447 eph = ephPrev;
[4098]448 }
[3754]449
[3753]450 // Make sure the clock messages refer to same IOD as orbit messages
451 // ----------------------------------------------------------------
452 if (_usedEph) {
[4174]453 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
[6876]454 (*_usedEph)[prnInternalStr] = eph;
[3753]455 }
456 else {
457 eph = 0;
[6876]458 if (_usedEph->contains(prnInternalStr)) {
459 const t_eph* usedEph = _usedEph->value(prnInternalStr);
[6877]460 if (usedEph == ephLast) {
[6442]461 eph = ephLast;
[3753]462 }
[6442]463 else if (usedEph == ephPrev) {
464 eph = ephPrev;
[3753]465 }
466 }
467 }
468 }
469 }
470
[8679]471 if (eph &&
472 eph->checkState() != t_eph::bad &&
473 eph->checkState() != t_eph::unhealthy &&
474 eph->checkState() != t_eph::outdated) {
[5503]475 QMap<QString, double> codeBiases;
[6851]476 QList<phaseBiasSignal> phaseBiasList;
477 phaseBiasesSat pbSat;
[5503]478
[4991]479 while (true) {
480 QString key;
[6877]481 int numVal = 0;
[9032]482 in >> key;
[4991]483 if (in.status() != QTextStream::Ok) {
484 break;
485 }
[6877]486 if (key == "APC") {
[6850]487 in >> numVal;
[8679]488 rtnAPC.ReSize(3); rtnAPC = 0.0;
[6850]489 for (int ii = 0; ii < numVal; ii++) {
490 in >> rtnAPC[ii];
491 }
[4991]492 }
[8483]493 else if (key == "Ura") {
[6850]494 in >> numVal;
[6877]495 if (numVal == 1)
[8483]496 in >> rtnUra;
[4991]497 }
[8483]498 else if (key == "Clk") {
499 in >> numVal;
[8679]500 rtnClk.ReSize(3); rtnClk = 0.0;
[8483]501 for (int ii = 0; ii < numVal; ii++) {
502 in >> rtnClk[ii];
503 }
504 }
505 else if (key == "ClkSig") {
506 in >> numVal;
[8679]507 rtnClkSig.ReSize(3); rtnClkSig = 0.0;
[8483]508 for (int ii = 0; ii < numVal; ii++) {
509 in >> rtnClkSig[ii];
510 }
511 }
[4991]512 else if (key == "Vel") {
[6850]513 in >> numVal;
[8679]514 rtnVel.ReSize(3); rtnVel = 0.0;
[6850]515 for (int ii = 0; ii < numVal; ii++) {
516 in >> rtnVel[ii];
517 }
[4991]518 }
519 else if (key == "CoM") {
[6850]520 in >> numVal;
[8679]521 rtnCoM.ReSize(3); rtnCoM = 0.0;
[6850]522 for (int ii = 0; ii < numVal; ii++) {
523 in >> rtnCoM[ii];
524 }
[4991]525 }
[5503]526 else if (key == "CodeBias") {
[6850]527 in >> numVal;
[5503]528 for (int ii = 0; ii < numVal; ii++) {
529 QString type;
[6877]530 double value;
[5503]531 in >> type >> value;
532 codeBiases[type] = value;
533 }
534 }
[6857]535 else if (key == "YawAngle") {
[8017]536 in >> numVal >> pbSat.yawAngle;
537 if (pbSat.yawAngle < 0.0) {
538 pbSat.yawAngle += (2*M_PI);
[6975]539 }
[8017]540 else if (pbSat.yawAngle > 2*M_PI) {
541 pbSat.yawAngle -= (2*M_PI);
[6975]542 }
[6851]543 }
[6857]544 else if (key == "YawRate") {
[8017]545 in >> numVal >> pbSat.yawRate;
[6851]546 }
[6850]547 else if (key == "PhaseBias") {
548 in >> numVal;
549 for (int ii = 0; ii < numVal; ii++) {
[6851]550 phaseBiasSignal pb;
[8017]551 in >> pb.type >> pb.bias >> pb.integerIndicator
552 >> pb.wlIndicator >> pb.discontinuityCounter;
[6851]553 phaseBiasList.append(pb);
[6850]554 }
555 }
[4991]556 else {
[8689]557 in >> numVal;
558 for (int ii = 0; ii < numVal; ii++) {
559 double dummy;
560 in >> dummy;
561 }
[8542]562 emit(newMessage(" RTNET format error: "
563 + lines[ii].toLatin1(), false));
[4991]564 }
[5662]565 }
[6850]566
[9025]567 struct SsrCorr::ClockOrbit::SatData* sd = 0;
[6877]568 if (prn.system() == 'G') {
[5666]569 sd = co.Sat + co.NumberOfSat[CLOCKORBIT_SATGPS];
570 ++co.NumberOfSat[CLOCKORBIT_SATGPS];
[3222]571 }
[6876]572 else if (prn.system() == 'R') {
[6877]573 sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfSat[CLOCKORBIT_SATGLONASS];
[5666]574 ++co.NumberOfSat[CLOCKORBIT_SATGLONASS];
[3222]575 }
[6876]576 else if (prn.system() == 'E') {
[6844]577 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
[8967]578 + co.NumberOfSat[CLOCKORBIT_SATGALILEO];
[6844]579 ++co.NumberOfSat[CLOCKORBIT_SATGALILEO];
580 }
[6876]581 else if (prn.system() == 'J') {
[6877]582 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
[8967]583 + CLOCKORBIT_NUMGALILEO
[8982]584 + co.NumberOfSat[CLOCKORBIT_SATQZSS];
[6844]585 ++co.NumberOfSat[CLOCKORBIT_SATQZSS];
586 }
[8980]587 else if (prn.system() == 'S') {
588 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
589 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
590 + co.NumberOfSat[CLOCKORBIT_SATSBAS];
591 ++co.NumberOfSat[CLOCKORBIT_SATSBAS];
592 }
[8967]593 else if (prn.system() == 'C') {
594 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
[8980]595 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
596 + CLOCKORBIT_NUMSBAS
597 + co.NumberOfSat[CLOCKORBIT_SATBDS];
[8967]598 ++co.NumberOfSat[CLOCKORBIT_SATBDS];
599 }
[3222]600 if (sd) {
601 QString outLine;
[8542]602 t_irc irc = processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prnStr, rtnAPC,
603 rtnUra, rtnClk, rtnVel, rtnCoM, rtnClkSig, sd, outLine);
604 if (irc != success) {
[8679]605 // very few cases: check states bad and unhealthy are excluded earlier
606 sd->ID = prnStr.mid(1).toInt(); // to prevent G00, R00 entries
607 sd->IOD = eph->IOD();
[8542]608 }
[3222]609 }
[5662]610
[6850]611 // Code Biases
612 // -----------
[9025]613 struct SsrCorr::CodeBias::BiasSat* biasSat = 0;
[6877]614 if (!codeBiases.isEmpty()) {
615 if (prn.system() == 'G') {
616 biasSat = bias.Sat + bias.NumberOfSat[CLOCKORBIT_SATGPS];
617 ++bias.NumberOfSat[CLOCKORBIT_SATGPS];
618 }
619 else if (prn.system() == 'R') {
620 biasSat = bias.Sat + CLOCKORBIT_NUMGPS
[8967]621 + bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
[6877]622 ++bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
623 }
624 else if (prn.system() == 'E') {
625 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
[8982]626 + bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
[6877]627 ++bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
628 }
629 else if (prn.system() == 'J') {
630 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
[8967]631 + CLOCKORBIT_NUMGALILEO
[8982]632 + bias.NumberOfSat[CLOCKORBIT_SATQZSS];
[6877]633 ++bias.NumberOfSat[CLOCKORBIT_SATQZSS];
634 }
635 else if (prn.system() == 'S') {
636 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
[8982]637 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
[8967]638 + bias.NumberOfSat[CLOCKORBIT_SATSBAS];
[6877]639 ++bias.NumberOfSat[CLOCKORBIT_SATSBAS];
640 }
[8982]641 else if (prn.system() == 'C') {
642 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
[8983]643 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
[8982]644 + CLOCKORBIT_NUMSBAS
645 + bias.NumberOfSat[CLOCKORBIT_SATBDS];
646 ++bias.NumberOfSat[CLOCKORBIT_SATBDS];
647 }
[3222]648 }
[5662]649
[3222]650 if (biasSat) {
[6876]651 biasSat->ID = prn.number();
[5503]652 biasSat->NumberOfCodeBiases = 0;
[9025]653 QMapIterator<QString, double> it(codeBiases);
654 while (it.hasNext()) {
655 it.next();
656 int ii = biasSat->NumberOfCodeBiases;
657 if (ii >= CLOCKORBIT_NUMBIAS)
658 break;
659 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), it.key().toStdString());
660 if (type != _ssrCorr->RESERVED) {
661 biasSat->NumberOfCodeBiases += 1;
662 biasSat->Biases[ii].Type = type;
663 biasSat->Biases[ii].Bias = it.value();
[5503]664 }
[3222]665 }
666 }
[8944]667
[6850]668 // Phase Biases
669 // ------------
[9025]670 struct SsrCorr::PhaseBias::PhaseBiasSat* phasebiasSat = 0;
[8986]671 if (prn.system() == 'G') {
672 phasebiasSat = phasebias.Sat
673 + phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
674 ++phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
675 }
676 else if (prn.system() == 'R') {
677 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS
678 + phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
679 ++phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
680 }
681 else if (prn.system() == 'E') {
682 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
683 + phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
684 ++phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
685 }
686 else if (prn.system() == 'J') {
687 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
688 + CLOCKORBIT_NUMGALILEO
689 + phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
690 ++phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
691 }
692 else if (prn.system() == 'S') {
693 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
694 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
695 + phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
696 ++phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
697 }
698 else if (prn.system() == 'C') {
699 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
700 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
701 + CLOCKORBIT_NUMSBAS
702 + phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
703 ++phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
704 }
[6850]705
706 if (phasebiasSat) {
[8017]707 phasebias.DispersiveBiasConsistencyIndicator = dispersiveBiasConsistenyIndicator;
708 phasebias.MWConsistencyIndicator = mwConsistencyIndicator;
[6876]709 phasebiasSat->ID = prn.number();
[6850]710 phasebiasSat->NumberOfPhaseBiases = 0;
[8017]711 phasebiasSat->YawAngle = pbSat.yawAngle;
712 phasebiasSat->YawRate = pbSat.yawRate;
[9025]713 QListIterator<phaseBiasSignal> it(phaseBiasList);
714 while (it.hasNext()) {
715 const phaseBiasSignal &pbSig = it.next();
716 int ii = phasebiasSat->NumberOfPhaseBiases;
717 if (ii >= CLOCKORBIT_NUMBIAS)
718 break;
719 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), pbSig.type.toStdString());
720 if (type != _ssrCorr->RESERVED) {
721 phasebiasSat->NumberOfPhaseBiases += 1;
722 phasebiasSat->Biases[ii].Type = type;
723 phasebiasSat->Biases[ii].Bias = pbSig.bias;
724 phasebiasSat->Biases[ii].SignalIntegerIndicator = pbSig.integerIndicator;
725 phasebiasSat->Biases[ii].SignalsWideLaneIntegerIndicator = pbSig.wlIndicator;
726 phasebiasSat->Biases[ii].SignalDiscontinuityCounter = pbSig.discontinuityCounter;
[6850]727 }
728 }
729 }
[3222]730 }
731 }
[3227]732
[5662]733 QByteArray hlpBufferCo;
[3493]734
735 // Orbit and Clock Corrections together
736 // ------------------------------------
[4174]737 if (_samplRtcmEphCorr == 0.0) {
[6877]738 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0
739 || co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
740 || co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
741 || co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
742 || co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
743 || co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
[3493]744 char obuffer[CLOCKORBIT_BUFFERSIZE];
[9025]745 int len = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
[3493]746 if (len > 0) {
747 hlpBufferCo = QByteArray(obuffer, len);
748 }
[3222]749 }
750 }
[3493]751
752 // Orbit and Clock Corrections separately
753 // --------------------------------------
754 else {
[5666]755 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
[3493]756 char obuffer[CLOCKORBIT_BUFFERSIZE];
[4174]757 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
[4754]758 co.UpdateInterval = ephUpdInd;
[9025]759 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer,
[6877]760 sizeof(obuffer));
[4754]761 co.UpdateInterval = clkUpdInd;
[3493]762 if (len1 > 0) {
763 hlpBufferCo += QByteArray(obuffer, len1);
764 }
765 }
[8808]766 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0 ||
767 co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
768 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
769 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
770 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
[9025]771 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer,
[6877]772 sizeof(obuffer));
[3493]773 if (len2 > 0) {
774 hlpBufferCo += QByteArray(obuffer, len2);
775 }
776 }
[5666]777 if (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
[3493]778 char obuffer[CLOCKORBIT_BUFFERSIZE];
[4174]779 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
[4754]780 co.UpdateInterval = ephUpdInd;
[9025]781 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer,
[6877]782 sizeof(obuffer));
[4754]783 co.UpdateInterval = clkUpdInd;
[3493]784 if (len1 > 0) {
785 hlpBufferCo += QByteArray(obuffer, len1);
786 }
787 }
[8808]788 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
789 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
790 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
791 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
[9025]792 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer,
[6877]793 sizeof(obuffer));
[3493]794 if (len2 > 0) {
795 hlpBufferCo += QByteArray(obuffer, len2);
796 }
797 }
[6844]798 if (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
799 char obuffer[CLOCKORBIT_BUFFERSIZE];
800 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
801 co.UpdateInterval = ephUpdInd;
[9025]802 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer,
[6877]803 sizeof(obuffer));
[6844]804 co.UpdateInterval = clkUpdInd;
805 if (len1 > 0) {
806 hlpBufferCo += QByteArray(obuffer, len1);
807 }
808 }
[8808]809 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
810 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
811 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
[9025]812 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer,
[6877]813 sizeof(obuffer));
[6844]814 if (len2 > 0) {
815 hlpBufferCo += QByteArray(obuffer, len2);
816 }
817 }
818 if (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
819 char obuffer[CLOCKORBIT_BUFFERSIZE];
820 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
821 co.UpdateInterval = ephUpdInd;
[9025]822 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer,
[6877]823 sizeof(obuffer));
[6844]824 co.UpdateInterval = clkUpdInd;
825 if (len1 > 0) {
826 hlpBufferCo += QByteArray(obuffer, len1);
827 }
828 }
[8808]829 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
830 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
[9025]831 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer,
[6877]832 sizeof(obuffer));
[6844]833 if (len2 > 0) {
834 hlpBufferCo += QByteArray(obuffer, len2);
835 }
836 }
837 if (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
838 char obuffer[CLOCKORBIT_BUFFERSIZE];
839 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
840 co.UpdateInterval = ephUpdInd;
[9025]841 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer,
[6877]842 sizeof(obuffer));
[6844]843 co.UpdateInterval = clkUpdInd;
844 if (len1 > 0) {
845 hlpBufferCo += QByteArray(obuffer, len1);
846 }
847 }
848 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) ? 1 : 0;
[9025]849 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASCLOCK, mmsg, obuffer,
[6877]850 sizeof(obuffer));
[6844]851 if (len2 > 0) {
852 hlpBufferCo += QByteArray(obuffer, len2);
853 }
854 }
855 if (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
856 char obuffer[CLOCKORBIT_BUFFERSIZE];
857 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
858 co.UpdateInterval = ephUpdInd;
[9025]859 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer,
[6877]860 sizeof(obuffer));
[6844]861 co.UpdateInterval = clkUpdInd;
862 if (len1 > 0) {
863 hlpBufferCo += QByteArray(obuffer, len1);
864 }
865 }
[8808]866 int mmsg = 0;
[9025]867 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer,
[6877]868 sizeof(obuffer));
[6844]869 if (len2 > 0) {
870 hlpBufferCo += QByteArray(obuffer, len2);
871 }
872 }
[3493]873 }
[5662]874
[6850]875 // Code Biases
876 // -----------
[5662]877 QByteArray hlpBufferBias;
[6877]878 if (bias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
879 || bias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
880 || bias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
881 || bias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
882 || bias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
883 || bias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
[3222]884 char obuffer[CLOCKORBIT_BUFFERSIZE];
[9025]885 int len = _ssrCorr->MakeCodeBias(&bias, _ssrCorr->CBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
[3222]886 if (len > 0) {
[3227]887 hlpBufferBias = QByteArray(obuffer, len);
[3222]888 }
889 }
[3227]890
[6850]891 // Phase Biases
892 // ------------
893 QByteArray hlpBufferPhaseBias;
[6877]894 if (phasebias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
895 || phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
896 || phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
897 || phasebias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
898 || phasebias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
899 || phasebias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
[6850]900 char obuffer[CLOCKORBIT_BUFFERSIZE];
[9025]901 int len = _ssrCorr->MakePhaseBias(&phasebias, _ssrCorr->PBTYPE_AUTO, 0, obuffer,
[6877]902 sizeof(obuffer));
[6850]903 if (len > 0) {
904 hlpBufferPhaseBias = QByteArray(obuffer, len);
905 }
906 }
907
908 // VTEC
909 // ----
910 QByteArray hlpBufferVtec;
[6860]911 if (vtec.NumLayers > 0) {
912 char obuffer[CLOCKORBIT_BUFFERSIZE];
[9025]913 int len = _ssrCorr->MakeVTEC(&vtec, 0, obuffer, sizeof(obuffer));
[6860]914 if (len > 0) {
915 hlpBufferVtec = QByteArray(obuffer, len);
916 }
917 }
[6850]918
[6877]919 _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias
920 + hlpBufferVtec;
[3222]921}
922
[5662]923//
[3222]924////////////////////////////////////////////////////////////////////////////
[8542]925t_irc bncRtnetUploadCaster::processSatellite(const t_eph* eph, int GPSweek,
[6877]926 double GPSweeks, const QString& prn, const ColumnVector& rtnAPC,
[8483]927 double rtnUra, const ColumnVector& rtnClk, const ColumnVector& rtnVel,
928 const ColumnVector& rtnCoM, const ColumnVector& rtnClkSig,
[9025]929 struct SsrCorr::ClockOrbit::SatData* sd, QString& outLine) {
[3222]930
[4930]931 // Broadcast Position and Velocity
932 // -------------------------------
[8542]933 ColumnVector xB(6);
[4930]934 ColumnVector vB(3);
[8542]935 t_irc irc = eph->getCrd(bncTime(GPSweek, GPSweeks), xB, vB, false);
[5662]936
[8542]937 if (irc != success) {
938 return irc;
939 }
940
[4991]941 // Precise Position
942 // ----------------
943 ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
[3222]944
[8542]945 if (xP.size() == 0) {
946 return failure;
947 }
948
[5662]949 double dc = 0.0;
[8405]950 if (_crdTrafo != "IGS14") {
[8145]951 crdTrafo(GPSweek, xP, dc);
[8094]952 }
[5662]953
[4930]954 // Difference in xyz
955 // -----------------
[6877]956 ColumnVector dx = xB.Rows(1, 3) - xP;
957 ColumnVector dv = vB - rtnVel;
[5662]958
[4930]959 // Difference in RSW
960 // -----------------
[3222]961 ColumnVector rsw(3);
[6877]962 XYZ_to_RSW(xB.Rows(1, 3), vB, dx, rsw);
[3222]963
[4930]964 ColumnVector dotRsw(3);
[6877]965 XYZ_to_RSW(xB.Rows(1, 3), vB, dv, dotRsw);
[3222]966
[4930]967 // Clock Correction
968 // ----------------
[8499]969 double dClkA0 = rtnClk(1) - (xB(4) - dc) * t_CST::c;
[8679]970 double dClkA1 = 0.0;
971 if (rtnClk(2)) {
[9025]972 dClkA1 = rtnClk(2) - xB(5) * t_CST::c;
[8679]973 }
974 double dClkA2 = 0.0;
975 if (rtnClk(3)) {
[9025]976 dClkA2 = rtnClk(3) - xB(6) * t_CST::c;
[8679]977 }
[3222]978
979 if (sd) {
[6877]980 sd->ID = prn.mid(1).toInt();
981 sd->IOD = eph->IOD();
[8483]982 sd->Clock.DeltaA0 = dClkA0;
983 sd->Clock.DeltaA1 = dClkA1;
984 sd->Clock.DeltaA2 = dClkA2;
985 sd->UserRangeAccuracy = rtnUra;
986 sd->Orbit.DeltaRadial = rsw(1);
[6877]987 sd->Orbit.DeltaAlongTrack = rsw(2);
988 sd->Orbit.DeltaCrossTrack = rsw(3);
[8483]989 sd->Orbit.DotDeltaRadial = dotRsw(1);
[4930]990 sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
991 sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
[3222]992 }
993
[8483]994 outLine.sprintf("%d %.1f %s %u %10.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", GPSweek,
995 GPSweeks, eph->prn().toString().c_str(), eph->IOD(), dClkA0, dClkA1, dClkA2,
996 rsw(1), rsw(2), rsw(3));
[3222]997
[8499]998 // RTNET full clock for RINEX and SP3 file
999 // ---------------------------------------
[4991]1000 double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
[8499]1001 double clkRnx = (rtnClk[0] - relativity) / t_CST::c; // [s]
[8483]1002 double clkRnxRate = rtnClk[1] / t_CST::c; // [s/s = -]
1003 double clkRnxAcc = rtnClk[2] / t_CST::c; // [s/s² ) -/s]
[4991]1004
[3222]1005 if (_rnx) {
[8510]1006 double clkRnxSig, clkRnxRateSig, clkRnxAccSig;
1007 int s = rtnClkSig.size();
1008 switch (s) {
1009 case 1:
1010 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1011 clkRnxRateSig = 0.0; // [s/s = -]
1012 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1013 break;
1014 case 2:
1015 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1016 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1017 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1018 break;
1019 case 3:
1020 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1021 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1022 clkRnxAccSig = rtnClkSig[2] / t_CST::c; // [s/s² ) -/s]
1023 break;
1024 }
[8483]1025 _rnx->write(GPSweek, GPSweeks, prn, clkRnx, clkRnxRate, clkRnxAcc,
1026 clkRnxSig, clkRnxRateSig, clkRnxAccSig);
[3222]1027 }
1028 if (_sp3) {
[8483]1029 _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, clkRnx, rtnVel, clkRnxRate);
[3222]1030 }
[8542]1031 return success;
[3222]1032}
1033
1034// Transform Coordinates
1035////////////////////////////////////////////////////////////////////////////
[5662]1036void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
[6877]1037 double& dc) {
[3222]1038
1039 // Current epoch minus 2000.0 in years
1040 // ------------------------------------
[6877]1041 double dt = (GPSWeek - (1042.0 + 6.0 / 7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
[3222]1042
1043 ColumnVector dx(3);
1044
1045 dx(1) = _dx + dt * _dxr;
1046 dx(2) = _dy + dt * _dyr;
1047 dx(3) = _dz + dt * _dzr;
1048
1049 static const double arcSec = 180.0 * 3600.0 / M_PI;
1050
1051 double ox = (_ox + dt * _oxr) / arcSec;
1052 double oy = (_oy + dt * _oyr) / arcSec;
1053 double oz = (_oz + dt * _ozr) / arcSec;
1054
1055 double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
1056
[4912]1057 // Specify approximate center of area
1058 // ----------------------------------
1059 ColumnVector meanSta(3);
1060
[6877]1061 if (_crdTrafo == "ETRF2000") {
1062 meanSta(1) = 3661090.0;
1063 meanSta(2) = 845230.0;
1064 meanSta(3) = 5136850.0;
[4908]1065 }
[8094]1066 else if (_crdTrafo == "GDA2020") {
[4973]1067 meanSta(1) = -4052050.0;
[6877]1068 meanSta(2) = 4212840.0;
[4973]1069 meanSta(3) = -2545110.0;
[4912]1070 }
1071 else if (_crdTrafo == "SIRGAS2000") {
[6877]1072 meanSta(1) = 3740860.0;
[4973]1073 meanSta(2) = -4964290.0;
1074 meanSta(3) = -1425420.0;
[4912]1075 }
[5343]1076 else if (_crdTrafo == "DREF91") {
[6877]1077 meanSta(1) = 3959579.0;
1078 meanSta(2) = 721719.0;
1079 meanSta(3) = 4931539.0;
[5343]1080 }
[4912]1081 else if (_crdTrafo == "Custom") {
[6877]1082 meanSta(1) = 0.0; // TODO
1083 meanSta(2) = 0.0; // TODO
1084 meanSta(3) = 0.0; // TODO
[4912]1085 }
[4908]1086
[4912]1087 // Clock correction proportional to topocentric distance to satellites
1088 // -------------------------------------------------------------------
[8904]1089 double rho = (xyz - meanSta).NormFrobenius();
[4913]1090 dc = rho * (sc - 1.0) / sc / t_CST::c;
[4908]1091
[6877]1092 Matrix rMat(3, 3);
1093 rMat(1, 1) = 1.0;
1094 rMat(1, 2) = -oz;
1095 rMat(1, 3) = oy;
1096 rMat(2, 1) = oz;
1097 rMat(2, 2) = 1.0;
1098 rMat(2, 3) = -ox;
1099 rMat(3, 1) = -oy;
1100 rMat(3, 2) = ox;
1101 rMat(3, 3) = 1.0;
[3222]1102
1103 xyz = sc * rMat * xyz + dx;
1104}
1105
[6557]1106int bncRtnetUploadCaster::determineUpdateInd(double samplingRate) {
1107
1108 if (samplingRate == 10.0) {
1109 return 3;
1110 }
1111 else if (samplingRate == 15.0) {
1112 return 4;
1113 }
1114 else if (samplingRate == 30.0) {
1115 return 5;
1116 }
1117 else if (samplingRate == 60.0) {
1118 return 6;
1119 }
1120 else if (samplingRate == 120.0) {
1121 return 7;
1122 }
1123 else if (samplingRate == 240.0) {
1124 return 8;
1125 }
1126 else if (samplingRate == 300.0) {
1127 return 9;
1128 }
1129 else if (samplingRate == 600.0) {
1130 return 10;
1131 }
1132 else if (samplingRate == 900.0) {
1133 return 11;
1134 }
1135 else if (samplingRate == 1800.0) {
1136 return 12;
1137 }
1138 else if (samplingRate == 3600.0) {
1139 return 13;
1140 }
1141 else if (samplingRate == 7200.0) {
1142 return 14;
1143 }
1144 else if (samplingRate == 10800.0) {
1145 return 15;
1146 }
[6877]1147 return 2; // default
[6557]1148}
Note: See TracBrowser for help on using the repository browser.