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