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

Last change on this file since 9861 was 9861, checked in by stuerze, 18 months ago

minor changes

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