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

Last change on this file since 9245 was 9245, checked in by stuerze, 3 years ago

another check is added, to prevent the usage of not updated nav data sets during ssr upload

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