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

Last change on this file since 9884 was 9884, checked in by stuerze, 19 months ago

minor changes

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