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 |
|
---|
27 | using namespace std;
|
---|
28 |
|
---|
29 | // Constructor
|
---|
30 | ////////////////////////////////////////////////////////////////////////////
|
---|
31 | bncRtnetUploadCaster::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 | _crdTrafoStr = 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 | _phaseBiasInformationDecoded = false;
|
---|
79 |
|
---|
80 | // Member that receives the ephemeris
|
---|
81 | // ----------------------------------
|
---|
82 | _ephUser = new bncEphUser(true);
|
---|
83 |
|
---|
84 | bncSettings settings;
|
---|
85 | QString intr = settings.value("uploadIntr").toString();
|
---|
86 | QStringList hlp = settings.value("cmbStreams").toStringList();
|
---|
87 | _samplRtcmEphCorr = settings.value("uploadSamplRtcmEphCorr").toDouble();
|
---|
88 | if (hlp.size() > 1) { // combination stream upload
|
---|
89 | _samplRtcmClkCorr = settings.value("cmbSampl").toInt();
|
---|
90 | }
|
---|
91 | else { // single stream upload or sp3 file generation
|
---|
92 | _samplRtcmClkCorr = 5; // default
|
---|
93 | }
|
---|
94 | int samplClkRnx = settings.value("uploadSamplClkRnx").toInt();
|
---|
95 | int samplSp3 = settings.value("uploadSamplSp3").toString().split("sec").first().toInt();
|
---|
96 | int samplBiaSnx = settings.value("uploadSamplBiaSnx").toInt();
|
---|
97 |
|
---|
98 | if (_samplRtcmEphCorr == 0.0) {
|
---|
99 | _usedEph = 0;
|
---|
100 | }
|
---|
101 | else {
|
---|
102 | _usedEph = new QMap<QString, const t_eph*>;
|
---|
103 | }
|
---|
104 |
|
---|
105 | // RINEX writer
|
---|
106 | // ------------
|
---|
107 | if (!rnxFileName.isEmpty()) {
|
---|
108 | _rnx = new bncClockRinex(rnxFileName, intr, samplClkRnx);
|
---|
109 | }
|
---|
110 | else {
|
---|
111 | _rnx = 0;
|
---|
112 | }
|
---|
113 |
|
---|
114 | // SP3 writer
|
---|
115 | // ----------
|
---|
116 | if (!sp3FileName.isEmpty()) {
|
---|
117 | _sp3 = new bncSP3(sp3FileName, intr, samplSp3);
|
---|
118 | }
|
---|
119 | else {
|
---|
120 | _sp3 = 0;
|
---|
121 | }
|
---|
122 |
|
---|
123 | // SINEX writer
|
---|
124 | // ------------
|
---|
125 | if (!bsxFileName.isEmpty()) {
|
---|
126 | _bsx = new bncBiasSinex(bsxFileName, intr, samplBiaSnx);
|
---|
127 | }
|
---|
128 | else {
|
---|
129 | _bsx = 0;
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | // Set Transformation Parameters
|
---|
134 | // -----------------------------
|
---|
135 | // Transformation Parameters from ITRF2014 to ETRF2000
|
---|
136 | // http://etrs89.ign.fr/pub/EUREF-TN-1-Mar-04-2024.pdf
|
---|
137 | if (_crdTrafoStr == "ETRF2000") {
|
---|
138 | _dx = 0.0552;
|
---|
139 | _dy = 0.0527;
|
---|
140 | _dz = -0.0836;
|
---|
141 |
|
---|
142 | _dxr = 0.0001;
|
---|
143 | _dyr = 0.0001;
|
---|
144 | _dzr = -0.0019;
|
---|
145 |
|
---|
146 | _ox = 0.002106;
|
---|
147 | _oy = 0.012740;
|
---|
148 | _oz = -0.020592;
|
---|
149 |
|
---|
150 | _oxr = 0.000081;
|
---|
151 | _oyr = 0.000490;
|
---|
152 | _ozr = -0.000792;
|
---|
153 |
|
---|
154 | _sc = 2.67;
|
---|
155 | _scr = 0.11;
|
---|
156 |
|
---|
157 | _t0 = 2015.0;
|
---|
158 | }
|
---|
159 | // Transformation Parameters from ITRF2014 to GDA2020 (Ryan Ruddick, GA)
|
---|
160 | else if (_crdTrafoStr == "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 (_crdTrafoStr == "SIRGAS2000") {
|
---|
185 | _dx = -0.0027;
|
---|
186 | _dy = -0.0025;
|
---|
187 | _dz = -0.0042;
|
---|
188 |
|
---|
189 | _dxr = 0.0;
|
---|
190 | _dyr = 0.0;
|
---|
191 | _dzr = 0.0;
|
---|
192 |
|
---|
193 | _ox = 0.0;
|
---|
194 | _oy = 0.0;
|
---|
195 | _oz = 0.0;
|
---|
196 |
|
---|
197 | _oxr = 0.0;
|
---|
198 | _oyr = 0.0;
|
---|
199 | _ozr = 0.0;
|
---|
200 |
|
---|
201 | _sc = 1.2;
|
---|
202 | _scr = 0.0;
|
---|
203 | _t0 = 2000.0;
|
---|
204 | }
|
---|
205 | // Transformation Parameters from ITRF2014 to DREF91
|
---|
206 | else if (_crdTrafoStr == "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 (ETRF2000 => 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 (_crdTrafoStr == "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 | // TODO: the following lines can be deleted if all parameters are updated regarding ITRF2020
|
---|
246 | if (_crdTrafoStr == "ETRF2000" ||
|
---|
247 | _crdTrafoStr == "GDA2020" ||
|
---|
248 | _crdTrafoStr == "DREF91" ||
|
---|
249 | _crdTrafoStr == "SIRGAS2000") {
|
---|
250 | // Transformation Parameters from ITRF2020 to ITRF2014
|
---|
251 | // from ITRF web site: https://itrf.ign.fr/en/solutions/transformations
|
---|
252 | _dx14 = -0.0014;
|
---|
253 | _dy14 = -0.0009;
|
---|
254 | _dz14 = 0.0014;
|
---|
255 | _dxr14 = 0.0;
|
---|
256 | _dyr14 = -0.0001;
|
---|
257 | _dzr14 = -0.0002;
|
---|
258 | _ox14 = 0.0;
|
---|
259 | _oy14 = 0.0;
|
---|
260 | _oz14 = 0.0;
|
---|
261 | _oxr14 = 0.0;
|
---|
262 | _oyr14 = 0.0;
|
---|
263 | _ozr14 = 0.0;
|
---|
264 | _sc14 = -0.42;
|
---|
265 | _scr14 = 0.0;
|
---|
266 | _t014 = 2015.0;
|
---|
267 | }
|
---|
268 | }
|
---|
269 |
|
---|
270 | // Destructor
|
---|
271 | ////////////////////////////////////////////////////////////////////////////
|
---|
272 | bncRtnetUploadCaster::~bncRtnetUploadCaster() {
|
---|
273 | if (isRunning()) {
|
---|
274 | wait();
|
---|
275 | }
|
---|
276 | delete _rnx;
|
---|
277 | delete _sp3;
|
---|
278 | delete _ephUser;
|
---|
279 | delete _usedEph;
|
---|
280 | delete _ssrCorr;
|
---|
281 | }
|
---|
282 |
|
---|
283 | //
|
---|
284 | ////////////////////////////////////////////////////////////////////////////
|
---|
285 | void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
|
---|
286 |
|
---|
287 | QMutexLocker locker(&_mutex);
|
---|
288 |
|
---|
289 | // Append to internal buffer
|
---|
290 | // -------------------------
|
---|
291 | _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
|
---|
292 |
|
---|
293 | // Select buffer part that contains last epoch
|
---|
294 | // -------------------------------------------
|
---|
295 |
|
---|
296 | // Find the begin of last epoch
|
---|
297 | int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*');
|
---|
298 | if (iEpoBeg == -1) {
|
---|
299 | _rtnetStreamBuffer.clear();
|
---|
300 | emit(newMessage(QString("bncRtnetUploadCaster: no Epoch line found: %1").arg(_casterID).toLatin1(), false));
|
---|
301 | return;
|
---|
302 | }
|
---|
303 |
|
---|
304 | // Find the begin of the first epoch
|
---|
305 | int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
|
---|
306 | if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) {
|
---|
307 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
|
---|
308 | }
|
---|
309 | else {
|
---|
310 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
|
---|
311 | }
|
---|
312 |
|
---|
313 | // Find End of the last epoch
|
---|
314 | int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE");
|
---|
315 | if (iEpoEnd == -1) {
|
---|
316 | _rtnetStreamBuffer.clear();
|
---|
317 | emit(newMessage(QString("bncRtnetUploadCaster: no EOE found: %1").arg(_casterID).toLatin1(), false));
|
---|
318 | return;
|
---|
319 | }
|
---|
320 |
|
---|
321 | QStringList lines;
|
---|
322 | // If there is there more than 1 epoch line in the buffer
|
---|
323 | while (_rtnetStreamBuffer.count('*') > 1) {
|
---|
324 | emit(newMessage(QString("bncRtnetUploadCaster: more than 1 epoch in buffer: %1").arg(_rtnetStreamBuffer.count('*')).toLatin1(), false));
|
---|
325 | QString rtnetStreamBuffer = _rtnetStreamBuffer;
|
---|
326 | int nextEpoch = rtnetStreamBuffer.indexOf('*');
|
---|
327 | int nextEpochEnd = rtnetStreamBuffer.indexOf("EOE");
|
---|
328 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(1);
|
---|
329 | if (nextEpoch != -1 && nextEpoch < iEpoEnd) {
|
---|
330 | rtnetStreamBuffer = rtnetStreamBuffer.mid(nextEpoch, nextEpochEnd);
|
---|
331 | lines = rtnetStreamBuffer.split('\n', Qt::SkipEmptyParts);
|
---|
332 | if (lines.size() > 2) {
|
---|
333 | decodeRtnetEpoch(lines);
|
---|
334 | }
|
---|
335 | nextEpochEnd = _rtnetStreamBuffer.indexOf("EOE");
|
---|
336 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpochEnd+3);
|
---|
337 | }
|
---|
338 | else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
|
---|
339 | break;
|
---|
340 | }
|
---|
341 | }
|
---|
342 |
|
---|
343 | lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', Qt::SkipEmptyParts);
|
---|
344 |
|
---|
345 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd + 3);
|
---|
346 |
|
---|
347 | if (lines.size() < 2) {
|
---|
348 | emit(newMessage(QString("bncRtnetUploadCaster: less than 2 lines to decode : %1").arg(_casterID).toLatin1(), false));
|
---|
349 | return;
|
---|
350 | }
|
---|
351 | decodeRtnetEpoch(lines);
|
---|
352 | }
|
---|
353 |
|
---|
354 | //
|
---|
355 | ////////////////////////////////////////////////////////////////////////////
|
---|
356 | void bncRtnetUploadCaster::decodeRtnetEpoch(QStringList epochLines) {
|
---|
357 |
|
---|
358 | // Read first line (with epoch time)
|
---|
359 | // ---------------------------------
|
---|
360 | QTextStream in(epochLines[0].toLatin1());
|
---|
361 | QString hlp;
|
---|
362 | int year, month, day, hour, min;
|
---|
363 | double sec;
|
---|
364 | in >> hlp >> year >> month >> day >> hour >> min >> sec;
|
---|
365 | bncTime epoTime;
|
---|
366 | epoTime.set(year, month, day, hour, min, sec);
|
---|
367 |
|
---|
368 | emit(newMessage(
|
---|
369 | "bncRtnetUploadCaster: decode " + QByteArray(epoTime.datestr().c_str())
|
---|
370 | + " " + QByteArray(epoTime.timestr().c_str()) + " "
|
---|
371 | + _casterID.toLatin1(), false));
|
---|
372 |
|
---|
373 | struct SsrCorr::ClockOrbit co;
|
---|
374 | memset(&co, 0, sizeof(co));
|
---|
375 | co.EpochTime[CLOCKORBIT_SATGPS] = static_cast<int>(epoTime.gpssec());
|
---|
376 | double gt = epoTime.gpssec() - gnumleap(year, month, day);
|
---|
377 | if (_ssrFormat == "RTCM-SSR") {
|
---|
378 | gt += 3 * 3600;
|
---|
379 | }
|
---|
380 | co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(fmod(gt, 86400.0));
|
---|
381 | co.EpochTime[CLOCKORBIT_SATGALILEO] = static_cast<int>(epoTime.gpssec());
|
---|
382 | co.EpochTime[CLOCKORBIT_SATQZSS] = static_cast<int>(epoTime.gpssec());
|
---|
383 | co.EpochTime[CLOCKORBIT_SATSBAS] = static_cast<int>(epoTime.gpssec());
|
---|
384 | co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.bdssec());
|
---|
385 | co.Supplied[_ssrCorr->COBOFS_CLOCK] = 1;
|
---|
386 | co.Supplied[_ssrCorr->COBOFS_ORBIT] = 1;
|
---|
387 | (_crdTrafoStr == "IGS20") ?
|
---|
388 | co.SatRefDatum = _ssrCorr->DATUM_ITRF :
|
---|
389 | co.SatRefDatum = _ssrCorr->DATUM_LOCAL;
|
---|
390 | co.SSRIOD = _IOD;
|
---|
391 | co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
|
---|
392 | co.SSRSolutionID = _SID;
|
---|
393 | if (_ssrFormat == "RTCM-SSR") {
|
---|
394 | co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.bdssec());
|
---|
395 | }
|
---|
396 | else if (_ssrFormat == "IGS-SSR") {
|
---|
397 | co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.gpssec());
|
---|
398 | }
|
---|
399 | co.Supplied[_ssrCorr->COBOFS_CLOCK] = 1;
|
---|
400 | co.Supplied[_ssrCorr->COBOFS_ORBIT] = 1;
|
---|
401 |
|
---|
402 |
|
---|
403 | t_serviceCrs serviceCrs;
|
---|
404 | t_rtcmCrs rtcmCrs;
|
---|
405 | if (_crdTrafoStr == "IGS20") {
|
---|
406 | serviceCrs._CE = serviceCrs._coordinateEpoch = 0;
|
---|
407 | int nc = _crdTrafoStr.length();
|
---|
408 | if (nc > 31) {nc = 31;}
|
---|
409 | for (int i = 0; i < nc; i++) {
|
---|
410 | serviceCrs._name[i] =
|
---|
411 | rtcmCrs._name[i] = _crdTrafoStr.toStdString()[i];
|
---|
412 | }
|
---|
413 | serviceCrs._name[nc] = 0;
|
---|
414 | rtcmCrs._name[nc] = 0;
|
---|
415 | rtcmCrs._anchor = 0; // global CRS
|
---|
416 | rtcmCrs._plateNumber = 0; // unknown
|
---|
417 | rtcmCrs._databaseLinks << "ISO.DATUM.979" << "ISO.CRS:980";
|
---|
418 | }
|
---|
419 | else {
|
---|
420 | if (_crdTrafoStr != "Custom") {
|
---|
421 | serviceCrs._coordinateEpoch = _t0;
|
---|
422 | serviceCrs.setCEFromCoordinateEpoch();
|
---|
423 | int nc = _crdTrafoStr.length();
|
---|
424 | if (nc > 31) {nc = 31;}
|
---|
425 | for (int i = 0; i < nc; i++) {
|
---|
426 | serviceCrs._name[i] = _crdTrafoStr.toStdString()[i];
|
---|
427 | }
|
---|
428 | serviceCrs._name[nc] = 0;
|
---|
429 | QString rtcmcrsname = _crdTrafoStr + QString("(%1)").arg(_t0,4,'d',0);
|
---|
430 | nc = rtcmcrsname.length();
|
---|
431 | if (nc > 31) {nc = 31;}
|
---|
432 | for (int i = 0; i < nc; i++) {
|
---|
433 | rtcmCrs._name[i] = rtcmcrsname.toStdString()[i];
|
---|
434 | }
|
---|
435 | rtcmCrs._name[nc] = 0;
|
---|
436 | if (_crdTrafoStr == "ETRF2000") {
|
---|
437 | rtcmCrs._anchor = 1; // plate-fixed CRS
|
---|
438 | rtcmCrs._plateNumber = 7; // Eurasia
|
---|
439 | rtcmCrs._databaseLinks << "ISO.DATUM.187" << "ISO.CRS:260" << "ISO.CRS:457"
|
---|
440 | << "EPSG.DATUM:1186" << "EPSG.CRS:7930" << "EPSG.CRS:7931";
|
---|
441 | }
|
---|
442 | else if (_crdTrafoStr == "DREF91") {
|
---|
443 | rtcmCrs._anchor = 1; // plate-fixed CRS
|
---|
444 | rtcmCrs._plateNumber = 7; // Eurasia
|
---|
445 | }
|
---|
446 | else if (_crdTrafoStr == "GDA2020") {
|
---|
447 | rtcmCrs._anchor = 1; // plate-fixed CRS
|
---|
448 | rtcmCrs._plateNumber = 4; // Australia
|
---|
449 | rtcmCrs._databaseLinks << "ISO.DATUM.186" << "ISO.CRS:404" << "ISO.CRS:329"
|
---|
450 | << "EPSG.DATUM:1168" << "EPSG.CRS:7842" << "EPSG.CRS:7843";
|
---|
451 | }
|
---|
452 | else if (_crdTrafoStr == "SIRGAS2000") {
|
---|
453 | rtcmCrs._anchor = 1; // plate-fixed CRS
|
---|
454 | rtcmCrs._plateNumber = 12; // S.America
|
---|
455 | rtcmCrs._databaseLinks << "ISO.DATUM:169" << "ISO.CRS:384" << "ISO.CRS:313"
|
---|
456 | << "EPSG.DATUM:6674" << "EPSG.CRS:4988" << "EPSG.CRS:4989";
|
---|
457 | }
|
---|
458 | }
|
---|
459 | }
|
---|
460 |
|
---|
461 |
|
---|
462 | struct SsrCorr::CodeBias bias;
|
---|
463 | memset(&bias, 0, sizeof(bias));
|
---|
464 | bias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
|
---|
465 | bias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
|
---|
466 | bias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
|
---|
467 | bias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
|
---|
468 | bias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
|
---|
469 | bias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
|
---|
470 | bias.SSRIOD = _IOD;
|
---|
471 | bias.SSRProviderID = _PID;
|
---|
472 | bias.SSRSolutionID = _SID;
|
---|
473 |
|
---|
474 | struct SsrCorr::PhaseBias phasebias;
|
---|
475 | memset(&phasebias, 0, sizeof(phasebias));
|
---|
476 | unsigned int dispersiveBiasConsistenyIndicator = 0;
|
---|
477 | unsigned int mwConsistencyIndicator = 0;
|
---|
478 | phasebias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
|
---|
479 | phasebias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
|
---|
480 | phasebias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
|
---|
481 | phasebias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
|
---|
482 | phasebias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
|
---|
483 | phasebias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
|
---|
484 | phasebias.SSRIOD = _IOD;
|
---|
485 | phasebias.SSRProviderID = _PID;
|
---|
486 | phasebias.SSRSolutionID = _SID;
|
---|
487 |
|
---|
488 | struct SsrCorr::VTEC vtec;
|
---|
489 | memset(&vtec, 0, sizeof(vtec));
|
---|
490 | vtec.EpochTime = static_cast<int>(epoTime.gpssec());
|
---|
491 | vtec.SSRIOD = _IOD;
|
---|
492 | vtec.SSRProviderID = _PID;
|
---|
493 | vtec.SSRSolutionID = _SID;
|
---|
494 |
|
---|
495 | // Default Update Interval
|
---|
496 | // -----------------------
|
---|
497 | int clkUpdInd = 2; // 5 sec
|
---|
498 | int ephUpdInd = clkUpdInd; // default
|
---|
499 |
|
---|
500 | if (!_samplRtcmEphCorr) {
|
---|
501 | _samplRtcmEphCorr = 5.0;
|
---|
502 | }
|
---|
503 |
|
---|
504 | if (_samplRtcmClkCorr > 5.0 && _samplRtcmEphCorr <= 5.0) { // combined orb and clock
|
---|
505 | ephUpdInd = determineUpdateInd(_samplRtcmClkCorr);
|
---|
506 | }
|
---|
507 | if (_samplRtcmClkCorr > 5.0) {
|
---|
508 | clkUpdInd = determineUpdateInd(_samplRtcmClkCorr);
|
---|
509 | }
|
---|
510 | if (_samplRtcmEphCorr > 5.0) {
|
---|
511 | ephUpdInd = determineUpdateInd(_samplRtcmEphCorr);
|
---|
512 | }
|
---|
513 |
|
---|
514 | co.UpdateInterval = clkUpdInd;
|
---|
515 | bias.UpdateInterval = ephUpdInd;
|
---|
516 | phasebias.UpdateInterval = ephUpdInd;
|
---|
517 |
|
---|
518 | for (int ii = 1; ii < epochLines.size(); ii++) {
|
---|
519 | QString key; // prn or key VTEC, IND (phase bias indicators)
|
---|
520 | double rtnUra = 0.0; // [m]
|
---|
521 | ColumnVector rtnAPC; rtnAPC.ReSize(3); rtnAPC = 0.0; // [m, m, m]
|
---|
522 | ColumnVector rtnVel; rtnVel.ReSize(3); rtnVel = 0.0; // [m/s, m/s, m/s]
|
---|
523 | ColumnVector rtnCoM; rtnCoM.ReSize(3); rtnCoM = 0.0; // [m, m, m]
|
---|
524 | ColumnVector rtnClk; rtnClk.ReSize(3); rtnClk = 0.0; // [m, m/s, m/s²]
|
---|
525 | ColumnVector rtnClkSig; rtnClkSig.ReSize(3); rtnClkSig = 0.0; // [m, m/s, m/s²]
|
---|
526 | t_prn prn;
|
---|
527 |
|
---|
528 | QTextStream in(epochLines[ii].toLatin1());
|
---|
529 |
|
---|
530 | in >> key;
|
---|
531 |
|
---|
532 | // non-satellite specific parameters
|
---|
533 | if (key.contains("IND", Qt::CaseSensitive)) {
|
---|
534 | in >> dispersiveBiasConsistenyIndicator >> mwConsistencyIndicator;
|
---|
535 | continue;
|
---|
536 | }
|
---|
537 | // non-satellite specific parameters
|
---|
538 | if (key.contains("VTEC", Qt::CaseSensitive)) {
|
---|
539 | double ui;
|
---|
540 | in >> ui >> vtec.NumLayers;
|
---|
541 | vtec.UpdateInterval = (unsigned int) determineUpdateInd(ui);
|
---|
542 | for (unsigned ll = 0; ll < vtec.NumLayers; ll++) {
|
---|
543 | int dummy;
|
---|
544 | in >> dummy >> vtec.Layers[ll].Degree >> vtec.Layers[ll].Order
|
---|
545 | >> vtec.Layers[ll].Height;
|
---|
546 | for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
|
---|
547 | for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
|
---|
548 | in >> vtec.Layers[ll].Cosinus[iDeg][iOrd];
|
---|
549 | }
|
---|
550 | }
|
---|
551 | for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
|
---|
552 | for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
|
---|
553 | in >> vtec.Layers[ll].Sinus[iDeg][iOrd];
|
---|
554 | }
|
---|
555 | }
|
---|
556 | }
|
---|
557 | continue;
|
---|
558 | }
|
---|
559 | // satellite specific parameters
|
---|
560 | char sys = key.mid(0, 1).at(0).toLatin1();
|
---|
561 | int number = key.mid(1, 2).toInt();
|
---|
562 | int flags = 0;
|
---|
563 | if (sys == 'E') { // I/NAV
|
---|
564 | flags = 1;
|
---|
565 | }
|
---|
566 | if (number == 0) {
|
---|
567 | continue;
|
---|
568 | }
|
---|
569 | prn.set(sys, number, flags);
|
---|
570 | QString prnInternalStr = QString::fromStdString(prn.toInternalString());
|
---|
571 | QString prnStr = QString::fromStdString(prn.toString());
|
---|
572 |
|
---|
573 | const t_eph* ephLast = _ephUser->ephLast(prnInternalStr);
|
---|
574 | const t_eph* ephPrev = _ephUser->ephPrev(prnInternalStr);
|
---|
575 | const t_eph* eph = ephLast;
|
---|
576 | if (eph) {
|
---|
577 |
|
---|
578 | // Use previous ephemeris if the last one is too recent
|
---|
579 | // ----------------------------------------------------
|
---|
580 | const int MINAGE = 60; // seconds
|
---|
581 | if (ephPrev && eph->receptDateTime().isValid() &&
|
---|
582 | eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
|
---|
583 | eph = ephPrev;
|
---|
584 | }
|
---|
585 |
|
---|
586 | // Make sure the clock messages refer to same IOD as orbit messages
|
---|
587 | // ----------------------------------------------------------------
|
---|
588 | if (_usedEph) {
|
---|
589 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
590 | (*_usedEph)[prnInternalStr] = eph;
|
---|
591 | }
|
---|
592 | else {
|
---|
593 | eph = 0;
|
---|
594 | if (_usedEph->contains(prnInternalStr)) {
|
---|
595 | const t_eph* usedEph = _usedEph->value(prnInternalStr);
|
---|
596 | if (usedEph == ephLast) {
|
---|
597 | eph = ephLast;
|
---|
598 | }
|
---|
599 | else if (usedEph == ephPrev) {
|
---|
600 | eph = ephPrev;
|
---|
601 | }
|
---|
602 | }
|
---|
603 | }
|
---|
604 | }
|
---|
605 | }
|
---|
606 |
|
---|
607 | QDateTime now = currentDateAndTimeGPS();
|
---|
608 | bncTime currentTime(now.toString(Qt::ISODate).toStdString());
|
---|
609 | if (eph &&
|
---|
610 | !outDatedBcep(eph, currentTime) && // detected from storage because of no update
|
---|
611 | eph->checkState() != t_eph::bad &&
|
---|
612 | eph->checkState() != t_eph::unhealthy &&
|
---|
613 | eph->checkState() != t_eph::outdated) { // detected during reception (bncephuser)
|
---|
614 | QMap<QString, double> codeBiases;
|
---|
615 | QList<phaseBiasSignal> phaseBiasList;
|
---|
616 | phaseBiasesSat pbSat;
|
---|
617 | _phaseBiasInformationDecoded = false;
|
---|
618 |
|
---|
619 | while (true) {
|
---|
620 | QString key;
|
---|
621 | int numVal = 0;
|
---|
622 | in >> key;
|
---|
623 | if (in.status() != QTextStream::Ok) {
|
---|
624 | break;
|
---|
625 | }
|
---|
626 | if (key == "APC") {
|
---|
627 | in >> numVal;
|
---|
628 | rtnAPC.ReSize(3); rtnAPC = 0.0;
|
---|
629 | for (int ii = 0; ii < numVal; ii++) {
|
---|
630 | in >> rtnAPC[ii];
|
---|
631 | }
|
---|
632 | }
|
---|
633 | else if (key == "Ura") {
|
---|
634 | in >> numVal;
|
---|
635 | if (numVal == 1)
|
---|
636 | in >> rtnUra;
|
---|
637 | }
|
---|
638 | else if (key == "Clk") {
|
---|
639 | in >> numVal;
|
---|
640 | rtnClk.ReSize(3); rtnClk = 0.0;
|
---|
641 | for (int ii = 0; ii < numVal; ii++) {
|
---|
642 | in >> rtnClk[ii];
|
---|
643 | }
|
---|
644 | }
|
---|
645 | else if (key == "ClkSig") {
|
---|
646 | in >> numVal;
|
---|
647 | rtnClkSig.ReSize(3); rtnClkSig = 0.0;
|
---|
648 | for (int ii = 0; ii < numVal; ii++) {
|
---|
649 | in >> rtnClkSig[ii];
|
---|
650 | }
|
---|
651 | }
|
---|
652 | else if (key == "Vel") {
|
---|
653 | in >> numVal;
|
---|
654 | rtnVel.ReSize(3); rtnVel = 0.0;
|
---|
655 | for (int ii = 0; ii < numVal; ii++) {
|
---|
656 | in >> rtnVel[ii];
|
---|
657 | }
|
---|
658 | }
|
---|
659 | else if (key == "CoM") {
|
---|
660 | in >> numVal;
|
---|
661 | rtnCoM.ReSize(3); rtnCoM = 0.0;
|
---|
662 | for (int ii = 0; ii < numVal; ii++) {
|
---|
663 | in >> rtnCoM[ii];
|
---|
664 | }
|
---|
665 | }
|
---|
666 | else if (key == "CodeBias") {
|
---|
667 | in >> numVal;
|
---|
668 | for (int ii = 0; ii < numVal; ii++) {
|
---|
669 | QString type;
|
---|
670 | double value;
|
---|
671 | in >> type >> value;
|
---|
672 | codeBiases[type] = value;
|
---|
673 | }
|
---|
674 | }
|
---|
675 | else if (key == "YawAngle") {
|
---|
676 | _phaseBiasInformationDecoded = true;
|
---|
677 | in >> numVal >> pbSat.yawAngle;
|
---|
678 | if (pbSat.yawAngle < 0.0) {
|
---|
679 | pbSat.yawAngle += (2*M_PI);
|
---|
680 | }
|
---|
681 | else if (pbSat.yawAngle > 2*M_PI) {
|
---|
682 | pbSat.yawAngle -= (2*M_PI);
|
---|
683 | }
|
---|
684 | }
|
---|
685 | else if (key == "YawRate") {
|
---|
686 | _phaseBiasInformationDecoded = true;
|
---|
687 | in >> numVal >> pbSat.yawRate;
|
---|
688 | }
|
---|
689 | else if (key == "PhaseBias") {
|
---|
690 | _phaseBiasInformationDecoded = true;
|
---|
691 | in >> numVal;
|
---|
692 | for (int ii = 0; ii < numVal; ii++) {
|
---|
693 | phaseBiasSignal pb;
|
---|
694 | in >> pb.type >> pb.bias >> pb.integerIndicator
|
---|
695 | >> pb.wlIndicator >> pb.discontinuityCounter;
|
---|
696 | phaseBiasList.append(pb);
|
---|
697 | }
|
---|
698 | }
|
---|
699 | else {
|
---|
700 | in >> numVal;
|
---|
701 | for (int ii = 0; ii < numVal; ii++) {
|
---|
702 | double dummy;
|
---|
703 | in >> dummy;
|
---|
704 | }
|
---|
705 | emit(newMessage(" RTNET format error: "
|
---|
706 | + epochLines[ii].toLatin1(), false));
|
---|
707 | break;
|
---|
708 | }
|
---|
709 | }
|
---|
710 |
|
---|
711 | struct SsrCorr::ClockOrbit::SatData* sd = 0;
|
---|
712 | if (prn.system() == 'G') {
|
---|
713 | sd = co.Sat + co.NumberOfSat[CLOCKORBIT_SATGPS];
|
---|
714 | ++co.NumberOfSat[CLOCKORBIT_SATGPS];
|
---|
715 | }
|
---|
716 | else if (prn.system() == 'R') {
|
---|
717 | sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfSat[CLOCKORBIT_SATGLONASS];
|
---|
718 | ++co.NumberOfSat[CLOCKORBIT_SATGLONASS];
|
---|
719 | }
|
---|
720 | else if (prn.system() == 'E') {
|
---|
721 | sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
722 | + co.NumberOfSat[CLOCKORBIT_SATGALILEO];
|
---|
723 | ++co.NumberOfSat[CLOCKORBIT_SATGALILEO];
|
---|
724 | }
|
---|
725 | else if (prn.system() == 'J') {
|
---|
726 | sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
727 | + CLOCKORBIT_NUMGALILEO
|
---|
728 | + co.NumberOfSat[CLOCKORBIT_SATQZSS];
|
---|
729 | ++co.NumberOfSat[CLOCKORBIT_SATQZSS];
|
---|
730 | }
|
---|
731 | else if (prn.system() == 'S') {
|
---|
732 | sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
733 | + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
|
---|
734 | + co.NumberOfSat[CLOCKORBIT_SATSBAS];
|
---|
735 | ++co.NumberOfSat[CLOCKORBIT_SATSBAS];
|
---|
736 | }
|
---|
737 | else if (prn.system() == 'C') {
|
---|
738 | sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
739 | + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
|
---|
740 | + CLOCKORBIT_NUMSBAS
|
---|
741 | + co.NumberOfSat[CLOCKORBIT_SATBDS];
|
---|
742 | ++co.NumberOfSat[CLOCKORBIT_SATBDS];
|
---|
743 | }
|
---|
744 | if (sd) {
|
---|
745 | QString outLine;
|
---|
746 | t_irc irc = processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prnStr, rtnAPC,
|
---|
747 | rtnUra, rtnClk, rtnVel, rtnCoM, rtnClkSig, sd, outLine);
|
---|
748 | if (irc != success) {
|
---|
749 | continue;
|
---|
750 | }
|
---|
751 | }
|
---|
752 |
|
---|
753 | // Code Biases
|
---|
754 | // -----------
|
---|
755 | struct SsrCorr::CodeBias::BiasSat* biasSat = 0;
|
---|
756 | if (!codeBiases.isEmpty()) {
|
---|
757 | if (prn.system() == 'G') {
|
---|
758 | biasSat = bias.Sat + bias.NumberOfSat[CLOCKORBIT_SATGPS];
|
---|
759 | ++bias.NumberOfSat[CLOCKORBIT_SATGPS];
|
---|
760 | }
|
---|
761 | else if (prn.system() == 'R') {
|
---|
762 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS
|
---|
763 | + bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
|
---|
764 | ++bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
|
---|
765 | }
|
---|
766 | else if (prn.system() == 'E') {
|
---|
767 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
768 | + bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
|
---|
769 | ++bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
|
---|
770 | }
|
---|
771 | else if (prn.system() == 'J') {
|
---|
772 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
773 | + CLOCKORBIT_NUMGALILEO
|
---|
774 | + bias.NumberOfSat[CLOCKORBIT_SATQZSS];
|
---|
775 | ++bias.NumberOfSat[CLOCKORBIT_SATQZSS];
|
---|
776 | }
|
---|
777 | else if (prn.system() == 'S') {
|
---|
778 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
779 | + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
|
---|
780 | + bias.NumberOfSat[CLOCKORBIT_SATSBAS];
|
---|
781 | ++bias.NumberOfSat[CLOCKORBIT_SATSBAS];
|
---|
782 | }
|
---|
783 | else if (prn.system() == 'C') {
|
---|
784 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
785 | + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
|
---|
786 | + CLOCKORBIT_NUMSBAS
|
---|
787 | + bias.NumberOfSat[CLOCKORBIT_SATBDS];
|
---|
788 | ++bias.NumberOfSat[CLOCKORBIT_SATBDS];
|
---|
789 | }
|
---|
790 | }
|
---|
791 |
|
---|
792 | if (biasSat) {
|
---|
793 | biasSat->ID = prn.number();
|
---|
794 | biasSat->NumberOfCodeBiases = 0;
|
---|
795 | QMapIterator<QString, double> it(codeBiases);
|
---|
796 | while (it.hasNext()) {
|
---|
797 | it.next();
|
---|
798 | int ii = biasSat->NumberOfCodeBiases;
|
---|
799 | if (ii >= CLOCKORBIT_NUMBIAS)
|
---|
800 | break;
|
---|
801 | SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), it.key().toStdString());
|
---|
802 | if (type != _ssrCorr->RESERVED) {
|
---|
803 | biasSat->NumberOfCodeBiases += 1;
|
---|
804 | biasSat->Biases[ii].Type = type;
|
---|
805 | biasSat->Biases[ii].Bias = it.value();
|
---|
806 | if (_bsx) {
|
---|
807 | QString obsCode = 'C' + it.key();
|
---|
808 | _bsx->write(epoTime.gpsw(), epoTime.gpssec(), prnStr, obsCode, it.value());
|
---|
809 | }
|
---|
810 | }
|
---|
811 | }
|
---|
812 | }
|
---|
813 |
|
---|
814 | // Phase Biases
|
---|
815 | // ------------
|
---|
816 | struct SsrCorr::PhaseBias::PhaseBiasSat* phasebiasSat = 0;
|
---|
817 | if (prn.system() == 'G') {
|
---|
818 | phasebiasSat = phasebias.Sat
|
---|
819 | + phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
|
---|
820 | ++phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
|
---|
821 | }
|
---|
822 | else if (prn.system() == 'R') {
|
---|
823 | phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS
|
---|
824 | + phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
|
---|
825 | ++phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
|
---|
826 | }
|
---|
827 | else if (prn.system() == 'E') {
|
---|
828 | phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
829 | + phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
|
---|
830 | ++phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
|
---|
831 | }
|
---|
832 | else if (prn.system() == 'J') {
|
---|
833 | phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
834 | + CLOCKORBIT_NUMGALILEO
|
---|
835 | + phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
|
---|
836 | ++phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
|
---|
837 | }
|
---|
838 | else if (prn.system() == 'S') {
|
---|
839 | phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
840 | + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
|
---|
841 | + phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
|
---|
842 | ++phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
|
---|
843 | }
|
---|
844 | else if (prn.system() == 'C') {
|
---|
845 | phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
|
---|
846 | + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
|
---|
847 | + CLOCKORBIT_NUMSBAS
|
---|
848 | + phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
|
---|
849 | ++phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
|
---|
850 | }
|
---|
851 |
|
---|
852 | if (phasebiasSat && _phaseBiasInformationDecoded) {
|
---|
853 | phasebias.DispersiveBiasConsistencyIndicator = dispersiveBiasConsistenyIndicator;
|
---|
854 | phasebias.MWConsistencyIndicator = mwConsistencyIndicator;
|
---|
855 | phasebiasSat->ID = prn.number();
|
---|
856 | phasebiasSat->NumberOfPhaseBiases = 0;
|
---|
857 | phasebiasSat->YawAngle = pbSat.yawAngle;
|
---|
858 | phasebiasSat->YawRate = pbSat.yawRate;
|
---|
859 | QListIterator<phaseBiasSignal> it(phaseBiasList);
|
---|
860 | while (it.hasNext()) {
|
---|
861 | const phaseBiasSignal &pbSig = it.next();
|
---|
862 | int ii = phasebiasSat->NumberOfPhaseBiases;
|
---|
863 | if (ii >= CLOCKORBIT_NUMBIAS)
|
---|
864 | break;
|
---|
865 | SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), pbSig.type.toStdString());
|
---|
866 | if (type != _ssrCorr->RESERVED) {
|
---|
867 | phasebiasSat->NumberOfPhaseBiases += 1;
|
---|
868 | phasebiasSat->Biases[ii].Type = type;
|
---|
869 | phasebiasSat->Biases[ii].Bias = pbSig.bias;
|
---|
870 | phasebiasSat->Biases[ii].SignalIntegerIndicator = pbSig.integerIndicator;
|
---|
871 | phasebiasSat->Biases[ii].SignalsWideLaneIntegerIndicator = pbSig.wlIndicator;
|
---|
872 | phasebiasSat->Biases[ii].SignalDiscontinuityCounter = pbSig.discontinuityCounter;
|
---|
873 | if (_bsx) {
|
---|
874 | QString obsCode = 'L' + pbSig.type;
|
---|
875 | _bsx->write(epoTime.gpsw(), epoTime.gpssec(), prnStr, obsCode, pbSig.bias);
|
---|
876 | }
|
---|
877 | }
|
---|
878 | }
|
---|
879 | }
|
---|
880 | }
|
---|
881 | }
|
---|
882 |
|
---|
883 | QByteArray hlpBufferCo;
|
---|
884 |
|
---|
885 | // Orbit and Clock Corrections together
|
---|
886 | // ------------------------------------
|
---|
887 | if (_samplRtcmEphCorr == _samplRtcmClkCorr) {
|
---|
888 | if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0
|
---|
889 | || co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
|
---|
890 | || co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
|
---|
891 | || co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
|
---|
892 | || co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
|
---|
893 | || co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
|
---|
894 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
895 | int len = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
896 | if (len > 0) {
|
---|
897 | hlpBufferCo = QByteArray(obuffer, len);
|
---|
898 | }
|
---|
899 | }
|
---|
900 | }
|
---|
901 |
|
---|
902 | // Orbit and Clock Corrections separately
|
---|
903 | // --------------------------------------
|
---|
904 | else {
|
---|
905 | if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
|
---|
906 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
907 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
908 | co.UpdateInterval = ephUpdInd;
|
---|
909 | int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
910 | co.UpdateInterval = clkUpdInd;
|
---|
911 | if (len1 > 0) {
|
---|
912 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
913 | }
|
---|
914 | }
|
---|
915 | int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0 ||
|
---|
916 | co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
|
---|
917 | co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
|
---|
918 | co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
|
---|
919 | co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
|
---|
920 | int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
921 | if (len2 > 0) {
|
---|
922 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
923 | }
|
---|
924 | }
|
---|
925 | if (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
|
---|
926 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
927 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
928 | co.UpdateInterval = ephUpdInd;
|
---|
929 | int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
930 | co.UpdateInterval = clkUpdInd;
|
---|
931 | if (len1 > 0) {
|
---|
932 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
933 | }
|
---|
934 | }
|
---|
935 | int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
|
---|
936 | co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
|
---|
937 | co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
|
---|
938 | co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
|
---|
939 | int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
940 | if (len2 > 0) {
|
---|
941 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
942 | }
|
---|
943 | }
|
---|
944 | if (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
|
---|
945 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
946 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
947 | co.UpdateInterval = ephUpdInd;
|
---|
948 | int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer, sizeof(obuffer));
|
---|
949 | co.UpdateInterval = clkUpdInd;
|
---|
950 | if (len1 > 0) {
|
---|
951 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
952 | }
|
---|
953 | }
|
---|
954 | int mmsg = (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
|
---|
955 | co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
|
---|
956 | co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
|
---|
957 | int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
958 | if (len2 > 0) {
|
---|
959 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
960 | }
|
---|
961 | }
|
---|
962 | if (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
|
---|
963 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
964 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
965 | co.UpdateInterval = ephUpdInd;
|
---|
966 | int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
967 | co.UpdateInterval = clkUpdInd;
|
---|
968 | if (len1 > 0) {
|
---|
969 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
970 | }
|
---|
971 | }
|
---|
972 | int mmsg = (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
|
---|
973 | co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
|
---|
974 | int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
975 | if (len2 > 0) {
|
---|
976 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
977 | }
|
---|
978 | }
|
---|
979 | if (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
|
---|
980 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
981 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
982 | co.UpdateInterval = ephUpdInd;
|
---|
983 | int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer, sizeof(obuffer));
|
---|
984 | co.UpdateInterval = clkUpdInd;
|
---|
985 | if (len1 > 0) {
|
---|
986 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
987 | }
|
---|
988 | }
|
---|
989 | int mmsg = (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) ? 1 : 0;
|
---|
990 | int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASCLOCK, mmsg, obuffer,
|
---|
991 | sizeof(obuffer));
|
---|
992 | if (len2 > 0) {
|
---|
993 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
994 | }
|
---|
995 | }
|
---|
996 | if (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
|
---|
997 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
998 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
999 | co.UpdateInterval = ephUpdInd;
|
---|
1000 | int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
1001 | co.UpdateInterval = clkUpdInd;
|
---|
1002 | if (len1 > 0) {
|
---|
1003 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
1004 | }
|
---|
1005 | }
|
---|
1006 | int mmsg = 0;
|
---|
1007 | int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
1008 | if (len2 > 0) {
|
---|
1009 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
1010 | }
|
---|
1011 | }
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | // Code Biases
|
---|
1015 | // -----------
|
---|
1016 | QByteArray hlpBufferBias;
|
---|
1017 | if (bias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
|
---|
1018 | || bias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
|
---|
1019 | || bias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
|
---|
1020 | || bias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
|
---|
1021 | || bias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
|
---|
1022 | || bias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
|
---|
1023 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
1024 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
1025 | int len = _ssrCorr->MakeCodeBias(&bias, _ssrCorr->CBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
1026 | if (len > 0) {
|
---|
1027 | hlpBufferBias = QByteArray(obuffer, len);
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | // Phase Biases
|
---|
1033 | // ------------
|
---|
1034 | QByteArray hlpBufferPhaseBias;
|
---|
1035 | if ((phasebias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
|
---|
1036 | || phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
|
---|
1037 | || phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
|
---|
1038 | || phasebias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
|
---|
1039 | || phasebias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
|
---|
1040 | || phasebias.NumberOfSat[CLOCKORBIT_SATBDS] > 0)
|
---|
1041 | && (_phaseBiasInformationDecoded)) {
|
---|
1042 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
1043 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
1044 | int len = _ssrCorr->MakePhaseBias(&phasebias, _ssrCorr->PBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
1045 | if (len > 0) {
|
---|
1046 | hlpBufferPhaseBias = QByteArray(obuffer, len);
|
---|
1047 | }
|
---|
1048 | }
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | // VTEC
|
---|
1052 | // ----
|
---|
1053 | QByteArray hlpBufferVtec;
|
---|
1054 | if (vtec.NumLayers > 0) {
|
---|
1055 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
1056 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
1057 | int len = _ssrCorr->MakeVTEC(&vtec, 0, obuffer, sizeof(obuffer));
|
---|
1058 | if (len > 0) {
|
---|
1059 | hlpBufferVtec = QByteArray(obuffer, len);
|
---|
1060 | }
|
---|
1061 | }
|
---|
1062 | }
|
---|
1063 |
|
---|
1064 | // Service CRS
|
---|
1065 | // -----------
|
---|
1066 | QByteArray hlpBufferServiceCrs;
|
---|
1067 | if (sizeof(serviceCrs._name) > 0) {
|
---|
1068 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
1069 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
1070 | int len = t_crsEncoder::RTCM3(serviceCrs, obuffer, sizeof(obuffer));
|
---|
1071 | if (len > 0) {
|
---|
1072 | hlpBufferServiceCrs = QByteArray(obuffer, len);
|
---|
1073 | }
|
---|
1074 | }
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | // RTCM CRS
|
---|
1078 | // --------
|
---|
1079 | QByteArray hlpBufferRtcmCrs;
|
---|
1080 | if (sizeof(rtcmCrs._name) > 0) {
|
---|
1081 | char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
|
---|
1082 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
1083 | int len = t_crsEncoder::RTCM3(rtcmCrs, obuffer, sizeof(obuffer));
|
---|
1084 | if (len > 0) {
|
---|
1085 | hlpBufferRtcmCrs = QByteArray(obuffer, len);
|
---|
1086 | }
|
---|
1087 | }
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | // Create OutBuffer
|
---|
1091 | // ----------------
|
---|
1092 | _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias + hlpBufferVtec
|
---|
1093 | + hlpBufferServiceCrs + hlpBufferRtcmCrs + '\0';
|
---|
1094 | }
|
---|
1095 | //
|
---|
1096 | ////////////////////////////////////////////////////////////////////////////
|
---|
1097 | t_irc bncRtnetUploadCaster::processSatellite(const t_eph* eph, int GPSweek,
|
---|
1098 | double GPSweeks, const QString& prn, const ColumnVector& rtnAPC,
|
---|
1099 | double rtnUra, const ColumnVector& rtnClk, const ColumnVector& rtnVel,
|
---|
1100 | const ColumnVector& rtnCoM, const ColumnVector& rtnClkSig,
|
---|
1101 | struct SsrCorr::ClockOrbit::SatData* sd, QString& outLine) {
|
---|
1102 |
|
---|
1103 | // Broadcast Position and Velocity
|
---|
1104 | // -------------------------------
|
---|
1105 | ColumnVector xB(6);
|
---|
1106 | ColumnVector vB(3);
|
---|
1107 | t_irc irc = eph->getCrd(bncTime(GPSweek, GPSweeks), xB, vB, false);
|
---|
1108 |
|
---|
1109 | if (irc != success) {
|
---|
1110 | return irc;
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | // Precise Position
|
---|
1114 | // ----------------
|
---|
1115 | ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
|
---|
1116 |
|
---|
1117 | if (xP.size() == 0) {
|
---|
1118 | return failure;
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | double dc = 0.0;
|
---|
1122 | if (_crdTrafoStr != "IGS20") {
|
---|
1123 | crdTrafo14(GPSweek, xP, dc); // ITRF2020 => ITRF2014
|
---|
1124 | crdTrafo(GPSweek, xP, dc); // ITRF2014 to other reference frames
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | // Difference in xyz
|
---|
1128 | // -----------------
|
---|
1129 | ColumnVector dx = xB.Rows(1, 3) - xP;
|
---|
1130 | ColumnVector dv = vB - rtnVel;
|
---|
1131 |
|
---|
1132 | // Difference in RSW
|
---|
1133 | // -----------------
|
---|
1134 | ColumnVector rsw(3);
|
---|
1135 | XYZ_to_RSW(xB.Rows(1, 3), vB, dx, rsw);
|
---|
1136 |
|
---|
1137 | ColumnVector dotRsw(3);
|
---|
1138 | XYZ_to_RSW(xB.Rows(1, 3), vB, dv, dotRsw);
|
---|
1139 |
|
---|
1140 | // Clock Correction
|
---|
1141 | // ----------------
|
---|
1142 | double dClkA0 = rtnClk(1) - (xB(4) - dc) * t_CST::c;
|
---|
1143 | double dClkA1 = 0.0;
|
---|
1144 | if (rtnClk(2)) {
|
---|
1145 | dClkA1 = rtnClk(2) - xB(5) * t_CST::c;
|
---|
1146 | }
|
---|
1147 | double dClkA2 = 0.0;
|
---|
1148 | if (rtnClk(3)) {
|
---|
1149 | dClkA2 = rtnClk(3) - xB(6) * t_CST::c;
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 | if (sd) {
|
---|
1153 | sd->ID = prn.mid(1).toInt();
|
---|
1154 | sd->IOD = eph->IOD();
|
---|
1155 | sd->Clock.DeltaA0 = dClkA0;
|
---|
1156 | sd->Clock.DeltaA1 = dClkA1;
|
---|
1157 | sd->Clock.DeltaA2 = dClkA2;
|
---|
1158 | sd->UserRangeAccuracy = rtnUra;
|
---|
1159 | sd->Orbit.DeltaRadial = rsw(1);
|
---|
1160 | sd->Orbit.DeltaAlongTrack = rsw(2);
|
---|
1161 | sd->Orbit.DeltaCrossTrack = rsw(3);
|
---|
1162 | sd->Orbit.DotDeltaRadial = dotRsw(1);
|
---|
1163 | sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
|
---|
1164 | sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
|
---|
1165 |
|
---|
1166 | if (corrIsOutOfRange(sd)) {
|
---|
1167 | return failure;
|
---|
1168 | }
|
---|
1169 | }
|
---|
1170 |
|
---|
1171 | outLine = QString().asprintf("%d %.1f %s %u %10.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", GPSweek,
|
---|
1172 | GPSweeks, eph->prn().toString().c_str(), eph->IOD(), dClkA0, dClkA1, dClkA2,
|
---|
1173 | rsw(1), rsw(2), rsw(3)); //fprintf(stderr, "%s\n", outLine.toStdString().c_str());
|
---|
1174 |
|
---|
1175 | // RTNET full clock for RINEX and SP3 file
|
---|
1176 | // ---------------------------------------
|
---|
1177 | double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
|
---|
1178 | double clkRnx = (rtnClk[0] - relativity) / t_CST::c; // [s]
|
---|
1179 | double clkRnxRate = rtnClk[1] / t_CST::c; // [s/s = -]
|
---|
1180 | double clkRnxAcc = rtnClk[2] / t_CST::c; // [s/s² = -/s]
|
---|
1181 |
|
---|
1182 | if (_rnx) {
|
---|
1183 | double clkRnxSig, clkRnxRateSig, clkRnxAccSig;
|
---|
1184 | int s = rtnClkSig.size();
|
---|
1185 | switch (s) {
|
---|
1186 | case 1:
|
---|
1187 | clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
|
---|
1188 | clkRnxRateSig = 0.0; // [s/s = -]
|
---|
1189 | clkRnxAccSig = 0.0; // [s/s² ) -/s]
|
---|
1190 | break;
|
---|
1191 | case 2:
|
---|
1192 | clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
|
---|
1193 | clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
|
---|
1194 | clkRnxAccSig = 0.0; // [s/s² ) -/s]
|
---|
1195 | break;
|
---|
1196 | case 3:
|
---|
1197 | clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
|
---|
1198 | clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
|
---|
1199 | clkRnxAccSig = rtnClkSig[2] / t_CST::c; // [s/s² ) -/s]
|
---|
1200 | break;
|
---|
1201 | }
|
---|
1202 | _rnx->write(GPSweek, GPSweeks, prn, clkRnx, clkRnxRate, clkRnxAcc,
|
---|
1203 | clkRnxSig, clkRnxRateSig, clkRnxAccSig);
|
---|
1204 | }
|
---|
1205 | if (_sp3) {
|
---|
1206 | _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, clkRnx, rtnVel, clkRnxRate);
|
---|
1207 | }
|
---|
1208 | return success;
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 | // Transform Coordinates
|
---|
1212 | ////////////////////////////////////////////////////////////////////////////
|
---|
1213 | void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
|
---|
1214 | double& dc) {
|
---|
1215 |
|
---|
1216 | // Current epoch minus 2000.0 in years
|
---|
1217 | // ------------------------------------
|
---|
1218 | double dt = (GPSWeek - (1042.0 + 6.0 / 7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
|
---|
1219 |
|
---|
1220 | ColumnVector dx(3);
|
---|
1221 |
|
---|
1222 | dx(1) = _dx + dt * _dxr;
|
---|
1223 | dx(2) = _dy + dt * _dyr;
|
---|
1224 | dx(3) = _dz + dt * _dzr;
|
---|
1225 |
|
---|
1226 | static const double arcSec = 180.0 * 3600.0 / M_PI;
|
---|
1227 |
|
---|
1228 | double ox = (_ox + dt * _oxr) / arcSec;
|
---|
1229 | double oy = (_oy + dt * _oyr) / arcSec;
|
---|
1230 | double oz = (_oz + dt * _ozr) / arcSec;
|
---|
1231 |
|
---|
1232 | double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
|
---|
1233 |
|
---|
1234 | // Specify approximate center of area
|
---|
1235 | // ----------------------------------
|
---|
1236 | ColumnVector meanSta(3);
|
---|
1237 |
|
---|
1238 | if (_crdTrafoStr == "ETRF2000") {
|
---|
1239 | meanSta(1) = 3661090.0;
|
---|
1240 | meanSta(2) = 845230.0;
|
---|
1241 | meanSta(3) = 5136850.0;
|
---|
1242 | }
|
---|
1243 | else if (_crdTrafoStr == "GDA2020") {
|
---|
1244 | meanSta(1) = -4052050.0;
|
---|
1245 | meanSta(2) = 4212840.0;
|
---|
1246 | meanSta(3) = -2545110.0;
|
---|
1247 | }
|
---|
1248 | else if (_crdTrafoStr == "SIRGAS2000") {
|
---|
1249 | meanSta(1) = 3740860.0;
|
---|
1250 | meanSta(2) = -4964290.0;
|
---|
1251 | meanSta(3) = -1425420.0;
|
---|
1252 | }
|
---|
1253 | else if (_crdTrafoStr == "DREF91") {
|
---|
1254 | meanSta(1) = 3959579.0;
|
---|
1255 | meanSta(2) = 721719.0;
|
---|
1256 | meanSta(3) = 4931539.0;
|
---|
1257 | }
|
---|
1258 | else if (_crdTrafoStr == "Custom") {
|
---|
1259 | meanSta(1) = 0.0;
|
---|
1260 | meanSta(2) = 0.0;
|
---|
1261 | meanSta(3) = 0.0;
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | // Clock correction proportional to topocentric distance to satellites
|
---|
1265 | // -------------------------------------------------------------------
|
---|
1266 | double rho = (xyz - meanSta).NormFrobenius();
|
---|
1267 | dc = rho * (sc - 1.0) / sc / t_CST::c;
|
---|
1268 |
|
---|
1269 | Matrix rMat(3, 3);
|
---|
1270 | rMat(1, 1) = 1.0;
|
---|
1271 | rMat(1, 2) = -oz;
|
---|
1272 | rMat(1, 3) = oy;
|
---|
1273 | rMat(2, 1) = oz;
|
---|
1274 | rMat(2, 2) = 1.0;
|
---|
1275 | rMat(2, 3) = -ox;
|
---|
1276 | rMat(3, 1) = -oy;
|
---|
1277 | rMat(3, 2) = ox;
|
---|
1278 | rMat(3, 3) = 1.0;
|
---|
1279 |
|
---|
1280 | xyz = sc * rMat * xyz + dx;
|
---|
1281 | }
|
---|
1282 |
|
---|
1283 | // Transform Coordinates
|
---|
1284 | ////////////////////////////////////////////////////////////////////////////
|
---|
1285 | void bncRtnetUploadCaster::crdTrafo14(int GPSWeek, ColumnVector& xyz,
|
---|
1286 | double& dc) {
|
---|
1287 |
|
---|
1288 | // Current epoch minus 2000.0 in years
|
---|
1289 | // ------------------------------------
|
---|
1290 | double dt = (GPSWeek - (1042.0 + 6.0 / 7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
|
---|
1291 |
|
---|
1292 | ColumnVector dx(3);
|
---|
1293 |
|
---|
1294 | dx(1) = _dx14 + dt * _dxr14;
|
---|
1295 | dx(2) = _dy14 + dt * _dyr14;
|
---|
1296 | dx(3) = _dz14 + dt * _dzr14;
|
---|
1297 |
|
---|
1298 | static const double arcSec = 180.0 * 3600.0 / M_PI;
|
---|
1299 |
|
---|
1300 | double ox = (_ox14 + dt * _oxr14) / arcSec;
|
---|
1301 | double oy = (_oy14 + dt * _oyr14) / arcSec;
|
---|
1302 | double oz = (_oz14 + dt * _ozr14) / arcSec;
|
---|
1303 |
|
---|
1304 | double sc = 1.0 + _sc14 * 1e-9 + dt * _scr14 * 1e-9;
|
---|
1305 |
|
---|
1306 | // Specify approximate center of area
|
---|
1307 | // ----------------------------------
|
---|
1308 | ColumnVector meanSta(3);
|
---|
1309 | meanSta(1) = 0.0; // TODO
|
---|
1310 | meanSta(2) = 0.0; // TODO
|
---|
1311 | meanSta(3) = 0.0; // TODO
|
---|
1312 |
|
---|
1313 | // Clock correction proportional to topocentric distance to satellites
|
---|
1314 | // -------------------------------------------------------------------
|
---|
1315 | double rho = (xyz - meanSta).NormFrobenius();
|
---|
1316 | dc = rho * (sc - 1.0) / sc / t_CST::c;
|
---|
1317 |
|
---|
1318 | Matrix rMat(3, 3);
|
---|
1319 | rMat(1, 1) = 1.0;
|
---|
1320 | rMat(1, 2) = -oz;
|
---|
1321 | rMat(1, 3) = oy;
|
---|
1322 | rMat(2, 1) = oz;
|
---|
1323 | rMat(2, 2) = 1.0;
|
---|
1324 | rMat(2, 3) = -ox;
|
---|
1325 | rMat(3, 1) = -oy;
|
---|
1326 | rMat(3, 2) = ox;
|
---|
1327 | rMat(3, 3) = 1.0;
|
---|
1328 |
|
---|
1329 | xyz = sc * rMat * xyz + dx;
|
---|
1330 | }
|
---|
1331 |
|
---|
1332 | // Update Interval
|
---|
1333 | ////////////////////////////////////////////////////////////////////////////
|
---|
1334 | int bncRtnetUploadCaster::determineUpdateInd(double samplingRate) {
|
---|
1335 |
|
---|
1336 | if (samplingRate == 10.0) {
|
---|
1337 | return 3;
|
---|
1338 | }
|
---|
1339 | else if (samplingRate == 15.0) {
|
---|
1340 | return 4;
|
---|
1341 | }
|
---|
1342 | else if (samplingRate == 30.0) {
|
---|
1343 | return 5;
|
---|
1344 | }
|
---|
1345 | else if (samplingRate == 60.0) {
|
---|
1346 | return 6;
|
---|
1347 | }
|
---|
1348 | else if (samplingRate == 120.0) {
|
---|
1349 | return 7;
|
---|
1350 | }
|
---|
1351 | else if (samplingRate == 240.0) {
|
---|
1352 | return 8;
|
---|
1353 | }
|
---|
1354 | else if (samplingRate == 300.0) {
|
---|
1355 | return 9;
|
---|
1356 | }
|
---|
1357 | else if (samplingRate == 600.0) {
|
---|
1358 | return 10;
|
---|
1359 | }
|
---|
1360 | else if (samplingRate == 900.0) {
|
---|
1361 | return 11;
|
---|
1362 | }
|
---|
1363 | else if (samplingRate == 1800.0) {
|
---|
1364 | return 12;
|
---|
1365 | }
|
---|
1366 | else if (samplingRate == 3600.0) {
|
---|
1367 | return 13;
|
---|
1368 | }
|
---|
1369 | else if (samplingRate == 7200.0) {
|
---|
1370 | return 14;
|
---|
1371 | }
|
---|
1372 | else if (samplingRate == 10800.0) {
|
---|
1373 | return 15;
|
---|
1374 | }
|
---|
1375 | return 2; // default
|
---|
1376 | }
|
---|
1377 |
|
---|
1378 | // Check corrections
|
---|
1379 | ////////////////////////////////////////////////////////////////////////////
|
---|
1380 | bool bncRtnetUploadCaster::corrIsOutOfRange(struct SsrCorr::ClockOrbit::SatData* sd) {
|
---|
1381 |
|
---|
1382 | if (fabs(sd->Clock.DeltaA0) > 209.7151) {return true;}
|
---|
1383 | if (fabs(sd->Clock.DeltaA1) > 1.048575) {return true;}
|
---|
1384 | if (fabs(sd->Clock.DeltaA2) > 1.34217726) {return true;}
|
---|
1385 |
|
---|
1386 | if (fabs(sd->Orbit.DeltaRadial) > 209.7151) {return true;}
|
---|
1387 | if (fabs(sd->Orbit.DeltaAlongTrack) > 209.7148) {return true;}
|
---|
1388 | if (fabs(sd->Orbit.DeltaCrossTrack) > 209.7148) {return true;}
|
---|
1389 |
|
---|
1390 | if (fabs(sd->Orbit.DotDeltaRadial) > 1.048575) {return true;}
|
---|
1391 | if (fabs(sd->Orbit.DotDeltaAlongTrack) > 1.048572) {return true;}
|
---|
1392 | if (fabs(sd->Orbit.DotDeltaCrossTrack) > 1.048572) {return true;}
|
---|
1393 | return false;
|
---|
1394 | }
|
---|