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

Last change on this file since 9510 was 9510, checked in by stuerze, 7 weeks ago

try to solve an upoad error

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