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

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