1 | /* -------------------------------------------------------------------------
|
---|
2 | * BKG NTRIP Server
|
---|
3 | * -------------------------------------------------------------------------
|
---|
4 | *
|
---|
5 | * Class: bncRtnetUploadCaster
|
---|
6 | *
|
---|
7 | * Purpose: Connection to NTRIP Caster
|
---|
8 | *
|
---|
9 | * Author: L. Mervart
|
---|
10 | *
|
---|
11 | * Created: 29-Mar-2011
|
---|
12 | *
|
---|
13 | * Changes:
|
---|
14 | *
|
---|
15 | * -----------------------------------------------------------------------*/
|
---|
16 |
|
---|
17 | #include <math.h>
|
---|
18 | #include "bncrtnetuploadcaster.h"
|
---|
19 | #include "bncsettings.h"
|
---|
20 | #include "bncephuser.h"
|
---|
21 | #include "bncclockrinex.h"
|
---|
22 | #include "bncsp3.h"
|
---|
23 |
|
---|
24 | using namespace std;
|
---|
25 |
|
---|
26 | // Constructor
|
---|
27 | ////////////////////////////////////////////////////////////////////////////
|
---|
28 | bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint,
|
---|
29 | const QString& outHost, int outPort,
|
---|
30 | const QString& password,
|
---|
31 | const QString& crdTrafo, bool CoM,
|
---|
32 | const QString& sp3FileName,
|
---|
33 | const QString& rnxFileName,
|
---|
34 | int PID, int SID, int IOD, int iRow) :
|
---|
35 | bncUploadCaster(mountpoint, outHost, outPort, password, iRow, 0) {
|
---|
36 |
|
---|
37 | _crdTrafo = crdTrafo;
|
---|
38 | _CoM = CoM;
|
---|
39 | _PID = PID;
|
---|
40 | _SID = SID;
|
---|
41 | _IOD = IOD;
|
---|
42 |
|
---|
43 | // Member that receives the ephemeris
|
---|
44 | // ----------------------------------
|
---|
45 | _ephUser = new bncEphUser();
|
---|
46 |
|
---|
47 | bncSettings settings;
|
---|
48 | QString intr = settings.value("uploadIntr").toString();
|
---|
49 |
|
---|
50 | _samplRtcmEphCorr = settings.value("uploadSamplRtcmEphCorr").toDouble();
|
---|
51 | int samplClkRnx = settings.value("uploadSamplClkRnx").toInt();
|
---|
52 | int samplSp3 = settings.value("uploadSamplSp3").toInt() * 60;
|
---|
53 |
|
---|
54 | if (_samplRtcmEphCorr == 0.0) {
|
---|
55 | _usedEph = 0;
|
---|
56 | }
|
---|
57 | else {
|
---|
58 | _usedEph = new QMap<QString, t_eph*>;
|
---|
59 | }
|
---|
60 |
|
---|
61 | // RINEX writer
|
---|
62 | // ------------
|
---|
63 | if (!rnxFileName.isEmpty()) {
|
---|
64 | _rnx = new bncClockRinex(rnxFileName, intr, samplClkRnx);
|
---|
65 | }
|
---|
66 | else {
|
---|
67 | _rnx = 0;
|
---|
68 | }
|
---|
69 |
|
---|
70 | // SP3 writer
|
---|
71 | // ----------
|
---|
72 | if (!sp3FileName.isEmpty()) {
|
---|
73 | _sp3 = new bncSP3(sp3FileName, intr, samplSp3);
|
---|
74 | }
|
---|
75 | else {
|
---|
76 | _sp3 = 0;
|
---|
77 | }
|
---|
78 |
|
---|
79 | // Set Transformation Parameters
|
---|
80 | // -----------------------------
|
---|
81 | if (_crdTrafo == "ETRF2000") {
|
---|
82 | _dx = 0.0521;
|
---|
83 | _dy = 0.0493;
|
---|
84 | _dz = -0.0585;
|
---|
85 | _dxr = 0.0001;
|
---|
86 | _dyr = 0.0001;
|
---|
87 | _dzr = -0.0018;
|
---|
88 | _ox = 0.000891;
|
---|
89 | _oy = 0.005390;
|
---|
90 | _oz = -0.008712;
|
---|
91 | _oxr = 0.000081;
|
---|
92 | _oyr = 0.000490;
|
---|
93 | _ozr = -0.000792;
|
---|
94 | _sc = 1.34;
|
---|
95 | _scr = 0.08;
|
---|
96 | _t0 = 2000.0;
|
---|
97 | }
|
---|
98 | else if (_crdTrafo == "NAD83") {
|
---|
99 | _dx = 0.9963;
|
---|
100 | _dy = -1.9024;
|
---|
101 | _dz = -0.5210;
|
---|
102 | _dxr = 0.0005;
|
---|
103 | _dyr = -0.0006;
|
---|
104 | _dzr = -0.0013;
|
---|
105 | _ox = -0.025915;
|
---|
106 | _oy = -0.009426;
|
---|
107 | _oz = -0.011599;
|
---|
108 | _oxr = -0.000067;
|
---|
109 | _oyr = 0.000757;
|
---|
110 | _ozr = 0.000051;
|
---|
111 | _sc = 0.78;
|
---|
112 | _scr = -0.10;
|
---|
113 | _t0 = 1997.0;
|
---|
114 | }
|
---|
115 | else if (_crdTrafo == "GDA94") {
|
---|
116 | _dx = -0.08468;
|
---|
117 | _dy = -0.01942;
|
---|
118 | _dz = 0.03201;
|
---|
119 | _dxr = 0.00142;
|
---|
120 | _dyr = 0.00134;
|
---|
121 | _dzr = 0.00090;
|
---|
122 | _ox = 0.0004254;
|
---|
123 | _oy = -0.0022578;
|
---|
124 | _oz = -0.0024015;
|
---|
125 | _oxr = -0.0015461;
|
---|
126 | _oyr = -0.0011820;
|
---|
127 | _ozr = -0.0011551;
|
---|
128 | _sc = 9.710;
|
---|
129 | _scr = 0.109;
|
---|
130 | _t0 = 1994.0;
|
---|
131 | }
|
---|
132 | else if (_crdTrafo == "SIRGAS2000") {
|
---|
133 | _dx = 0.0020;
|
---|
134 | _dy = 0.0041;
|
---|
135 | _dz = 0.0039;
|
---|
136 | _dxr = 0.0000;
|
---|
137 | _dyr = 0.0000;
|
---|
138 | _dzr = 0.0000;
|
---|
139 | _ox = 0.000170;
|
---|
140 | _oy = -0.000030;
|
---|
141 | _oz = 0.000070;
|
---|
142 | _oxr = 0.000000;
|
---|
143 | _oyr = 0.000000;
|
---|
144 | _ozr = 0.000000;
|
---|
145 | _sc = 0.000;
|
---|
146 | _scr = 0.000;
|
---|
147 | _t0 = 0000.0;
|
---|
148 | }
|
---|
149 | else if (_crdTrafo == "SIRGAS95") {
|
---|
150 | _dx = 0.0077;
|
---|
151 | _dy = 0.0058;
|
---|
152 | _dz = -0.0138;
|
---|
153 | _dxr = 0.0000;
|
---|
154 | _dyr = 0.0000;
|
---|
155 | _dzr = 0.0000;
|
---|
156 | _ox = 0.000000;
|
---|
157 | _oy = 0.000000;
|
---|
158 | _oz = -0.000030;
|
---|
159 | _oxr = 0.000000;
|
---|
160 | _oyr = 0.000000;
|
---|
161 | _ozr = 0.000000;
|
---|
162 | _sc = 1.570;
|
---|
163 | _scr = 0.000;
|
---|
164 | _t0 = 0000.0;
|
---|
165 | }
|
---|
166 | else if (_crdTrafo == "Custom") {
|
---|
167 | _dx = settings.value("trafo_dx").toDouble();
|
---|
168 | _dy = settings.value("trafo_dy").toDouble();
|
---|
169 | _dz = settings.value("trafo_dz").toDouble();
|
---|
170 | _dxr = settings.value("trafo_dxr").toDouble();
|
---|
171 | _dyr = settings.value("trafo_dyr").toDouble();
|
---|
172 | _dzr = settings.value("trafo_dzr").toDouble();
|
---|
173 | _ox = settings.value("trafo_ox").toDouble();
|
---|
174 | _oy = settings.value("trafo_oy").toDouble();
|
---|
175 | _oz = settings.value("trafo_oz").toDouble();
|
---|
176 | _oxr = settings.value("trafo_oxr").toDouble();
|
---|
177 | _oyr = settings.value("trafo_oyr").toDouble();
|
---|
178 | _ozr = settings.value("trafo_ozr").toDouble();
|
---|
179 | _sc = settings.value("trafo_sc").toDouble();
|
---|
180 | _scr = settings.value("trafo_scr").toDouble();
|
---|
181 | _t0 = settings.value("trafo_t0").toDouble();
|
---|
182 | }
|
---|
183 | }
|
---|
184 |
|
---|
185 | // Destructor
|
---|
186 | ////////////////////////////////////////////////////////////////////////////
|
---|
187 | bncRtnetUploadCaster::~bncRtnetUploadCaster() {
|
---|
188 | if (isRunning()) {
|
---|
189 | wait();
|
---|
190 | }
|
---|
191 | delete _rnx;
|
---|
192 | delete _sp3;
|
---|
193 | delete _ephUser;
|
---|
194 | delete _usedEph;
|
---|
195 | }
|
---|
196 |
|
---|
197 | //
|
---|
198 | ////////////////////////////////////////////////////////////////////////////
|
---|
199 | void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
|
---|
200 |
|
---|
201 | QMutexLocker locker(&_mutex);
|
---|
202 |
|
---|
203 | // Append to internal buffer
|
---|
204 | // -------------------------
|
---|
205 | _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
|
---|
206 |
|
---|
207 | // Select buffer part that contains last epoch
|
---|
208 | // -------------------------------------------
|
---|
209 | QStringList lines;
|
---|
210 | int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
|
---|
211 | if (iEpoBeg == -1) {
|
---|
212 | _rtnetStreamBuffer.clear();
|
---|
213 | return;
|
---|
214 | }
|
---|
215 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
|
---|
216 |
|
---|
217 | int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
|
---|
218 | if (iEpoEnd == -1) {
|
---|
219 | return;
|
---|
220 | }
|
---|
221 | else {
|
---|
222 | lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
|
---|
223 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd+3);
|
---|
224 | }
|
---|
225 |
|
---|
226 | if (lines.size() < 2) {
|
---|
227 | return;
|
---|
228 | }
|
---|
229 |
|
---|
230 | // Keep the last unfinished line in buffer
|
---|
231 | // ---------------------------------------
|
---|
232 | int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n');
|
---|
233 | if (iLastEOL != -1) {
|
---|
234 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1);
|
---|
235 | }
|
---|
236 |
|
---|
237 | // Read first line (with epoch time)
|
---|
238 | // ---------------------------------
|
---|
239 | QTextStream in(lines[0].toAscii());
|
---|
240 | QString hlp;
|
---|
241 | int year, month, day, hour, min;
|
---|
242 | double sec;
|
---|
243 | in >> hlp >> year >> month >> day >> hour >> min >> sec;
|
---|
244 | bncTime epoTime; epoTime.set( year, month, day, hour, min, sec);
|
---|
245 |
|
---|
246 | emit(newMessage("decodeRtnetStream: " + lines[0].toAscii(), false));
|
---|
247 |
|
---|
248 | struct ClockOrbit co;
|
---|
249 | memset(&co, 0, sizeof(co));
|
---|
250 | co.GPSEpochTime = static_cast<int>(epoTime.gpssec());
|
---|
251 | co.GLONASSEpochTime = static_cast<int>(fmod(epoTime.gpssec(), 86400.0))
|
---|
252 | + 3 * 3600 - gnumleap(year, month, day);
|
---|
253 | co.ClockDataSupplied = 1;
|
---|
254 | co.OrbitDataSupplied = 1;
|
---|
255 | co.SatRefDatum = DATUM_ITRF;
|
---|
256 | co.SSRIOD = _IOD;
|
---|
257 | co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
|
---|
258 | co.SSRSolutionID = _SID;
|
---|
259 |
|
---|
260 | struct Bias bias;
|
---|
261 | memset(&bias, 0, sizeof(bias));
|
---|
262 | bias.GPSEpochTime = co.GPSEpochTime;
|
---|
263 | bias.GLONASSEpochTime = co.GLONASSEpochTime;
|
---|
264 |
|
---|
265 | // Default Update Interval
|
---|
266 | // -----------------------
|
---|
267 | int clkUpdInd = 2; // 5 sec
|
---|
268 | int ephUpdInd = clkUpdInd; // default
|
---|
269 | if (_samplRtcmEphCorr == 10.0) {
|
---|
270 | ephUpdInd = 3;
|
---|
271 | }
|
---|
272 | else if (_samplRtcmEphCorr == 15.0) {
|
---|
273 | ephUpdInd = 4;
|
---|
274 | }
|
---|
275 | else if (_samplRtcmEphCorr == 30.0) {
|
---|
276 | ephUpdInd = 5;
|
---|
277 | }
|
---|
278 | else if (_samplRtcmEphCorr == 60.0) {
|
---|
279 | ephUpdInd = 6;
|
---|
280 | }
|
---|
281 | else if (_samplRtcmEphCorr == 120.0) {
|
---|
282 | ephUpdInd = 7;
|
---|
283 | }
|
---|
284 | else if (_samplRtcmEphCorr == 240.0) {
|
---|
285 | ephUpdInd = 8;
|
---|
286 | }
|
---|
287 | else if (_samplRtcmEphCorr == 300.0) {
|
---|
288 | ephUpdInd = 9;
|
---|
289 | }
|
---|
290 | else if (_samplRtcmEphCorr == 600.0) {
|
---|
291 | ephUpdInd = 10;
|
---|
292 | }
|
---|
293 | else if (_samplRtcmEphCorr == 900.0) {
|
---|
294 | ephUpdInd = 11;
|
---|
295 | }
|
---|
296 |
|
---|
297 | co.UpdateInterval = clkUpdInd;
|
---|
298 | bias.UpdateInterval = clkUpdInd;
|
---|
299 |
|
---|
300 | for (int ii = 1; ii < lines.size(); ii++) {
|
---|
301 |
|
---|
302 | QString prn;
|
---|
303 | ColumnVector rtnAPC;
|
---|
304 | ColumnVector rtnVel;
|
---|
305 | ColumnVector rtnCoM;
|
---|
306 | double rtnClk;
|
---|
307 |
|
---|
308 | QTextStream in(lines[ii].toAscii());
|
---|
309 |
|
---|
310 | in >> prn;
|
---|
311 |
|
---|
312 | t_eph* eph = 0;
|
---|
313 | const bncEphUser::t_ephPair* ephPair = _ephUser->ephPair(prn);
|
---|
314 | if (ephPair) {
|
---|
315 |
|
---|
316 | eph = ephPair->last;
|
---|
317 |
|
---|
318 | // Use previous ephemeris if the last one is too recent
|
---|
319 | // ----------------------------------------------------
|
---|
320 | const int MINAGE = 60; // seconds
|
---|
321 | if (ephPair->prev && eph->receptDateTime().isValid() &&
|
---|
322 | eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
|
---|
323 | eph = ephPair->prev;
|
---|
324 | }
|
---|
325 |
|
---|
326 | // Make sure the clock messages refer to same IOD as orbit messages
|
---|
327 | // ----------------------------------------------------------------
|
---|
328 | if (_usedEph) {
|
---|
329 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
330 | (*_usedEph)[prn] = eph;
|
---|
331 | }
|
---|
332 | else {
|
---|
333 | eph = 0;
|
---|
334 | if (_usedEph->contains(prn)) {
|
---|
335 | t_eph* usedEph = _usedEph->value(prn);
|
---|
336 | if (usedEph == ephPair->last) {
|
---|
337 | eph = ephPair->last;
|
---|
338 | }
|
---|
339 | else if (usedEph == ephPair->prev) {
|
---|
340 | eph = ephPair->prev;
|
---|
341 | }
|
---|
342 | }
|
---|
343 | }
|
---|
344 | }
|
---|
345 | }
|
---|
346 |
|
---|
347 | if (eph) {
|
---|
348 |
|
---|
349 | while (true) {
|
---|
350 | QString key;
|
---|
351 | int numVal = 0;
|
---|
352 | in >> key >> numVal;
|
---|
353 | if (in.status() != QTextStream::Ok) {
|
---|
354 | break;
|
---|
355 | }
|
---|
356 | if (key == "APC") {
|
---|
357 | rtnAPC.ReSize(3);
|
---|
358 | in >> rtnAPC[0] >> rtnAPC[1] >> rtnAPC[2];
|
---|
359 | }
|
---|
360 | else if (key == "Clk") {
|
---|
361 | in >> rtnClk;
|
---|
362 | }
|
---|
363 | else if (key == "Vel") {
|
---|
364 | rtnVel.ReSize(3);
|
---|
365 | in >> rtnVel[0] >> rtnVel[1] >> rtnVel[2];
|
---|
366 | }
|
---|
367 | else if (key == "CoM") {
|
---|
368 | rtnCoM.ReSize(3);
|
---|
369 | in >> rtnCoM[0] >> rtnCoM[1] >> rtnCoM[2];
|
---|
370 | }
|
---|
371 | else {
|
---|
372 | for (int ii = 0; ii < numVal; ii++) {
|
---|
373 | double dummy;
|
---|
374 | in >> dummy;
|
---|
375 | }
|
---|
376 | }
|
---|
377 | }
|
---|
378 | struct ClockOrbit::SatData* sd = 0;
|
---|
379 | if (prn[0] == 'G') {
|
---|
380 | sd = co.Sat + co.NumberOfGPSSat;
|
---|
381 | ++co.NumberOfGPSSat;
|
---|
382 | }
|
---|
383 | else if (prn[0] == 'R') {
|
---|
384 | sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
|
---|
385 | ++co.NumberOfGLONASSSat;
|
---|
386 | }
|
---|
387 | if (sd) {
|
---|
388 | QString outLine;
|
---|
389 | processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prn,
|
---|
390 | rtnAPC, rtnClk, rtnVel, rtnCoM, sd, outLine);
|
---|
391 | }
|
---|
392 |
|
---|
393 | struct Bias::BiasSat* biasSat = 0;
|
---|
394 | if (prn[0] == 'G') {
|
---|
395 | biasSat = bias.Sat + bias.NumberOfGPSSat;
|
---|
396 | ++bias.NumberOfGPSSat;
|
---|
397 | }
|
---|
398 | else if (prn[0] == 'R') {
|
---|
399 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
|
---|
400 | ++bias.NumberOfGLONASSSat;
|
---|
401 | }
|
---|
402 |
|
---|
403 | // Coefficient of Ionosphere-Free LC
|
---|
404 | // ---------------------------------
|
---|
405 | // const static double a_L1_GPS = 2.54572778;
|
---|
406 | // const static double a_L2_GPS = -1.54572778;
|
---|
407 | // const static double a_L1_Glo = 2.53125000;
|
---|
408 | // const static double a_L2_Glo = -1.53125000;
|
---|
409 |
|
---|
410 | if (biasSat) {
|
---|
411 | biasSat->ID = prn.mid(1).toInt();
|
---|
412 | biasSat->NumberOfCodeBiases = 3;
|
---|
413 | if (prn[0] == 'G') {
|
---|
414 | biasSat->Biases[0].Type = CODETYPEGPS_L1_Z;
|
---|
415 | // biasSat->Biases[0].Bias = - a_L2_GPS * xx(10);
|
---|
416 | biasSat->Biases[0].Bias = 0.0;
|
---|
417 | biasSat->Biases[1].Type = CODETYPEGPS_L1_CA;
|
---|
418 | // biasSat->Biases[1].Bias = - a_L2_GPS * xx(10) + xx(9);
|
---|
419 | biasSat->Biases[1].Bias = 0.0;
|
---|
420 | biasSat->Biases[2].Type = CODETYPEGPS_L2_Z;
|
---|
421 | // biasSat->Biases[2].Bias = a_L1_GPS * xx(10);
|
---|
422 | biasSat->Biases[2].Bias = 0.0;
|
---|
423 | }
|
---|
424 | else if (prn[0] == 'R') {
|
---|
425 | biasSat->Biases[0].Type = CODETYPEGLONASS_L1_P;
|
---|
426 | // biasSat->Biases[0].Bias = - a_L2_Glo * xx(10);
|
---|
427 | biasSat->Biases[0].Bias = 0.0;
|
---|
428 | biasSat->Biases[1].Type = CODETYPEGLONASS_L1_CA;
|
---|
429 | // biasSat->Biases[1].Bias = - a_L2_Glo * xx(10) + xx(9);
|
---|
430 | biasSat->Biases[1].Bias = 0.0;
|
---|
431 | biasSat->Biases[2].Type = CODETYPEGLONASS_L2_P;
|
---|
432 | // biasSat->Biases[2].Bias = a_L1_Glo * xx(10);
|
---|
433 | biasSat->Biases[2].Bias = 0.0;
|
---|
434 | }
|
---|
435 | }
|
---|
436 | }
|
---|
437 | }
|
---|
438 |
|
---|
439 | QByteArray hlpBufferCo;
|
---|
440 |
|
---|
441 | // Orbit and Clock Corrections together
|
---|
442 | // ------------------------------------
|
---|
443 | if (_samplRtcmEphCorr == 0.0) {
|
---|
444 | if (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) {
|
---|
445 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
446 | int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
447 | if (len > 0) {
|
---|
448 | hlpBufferCo = QByteArray(obuffer, len);
|
---|
449 | }
|
---|
450 | }
|
---|
451 | }
|
---|
452 |
|
---|
453 | // Orbit and Clock Corrections separately
|
---|
454 | // --------------------------------------
|
---|
455 | else {
|
---|
456 | if (co.NumberOfGPSSat > 0) {
|
---|
457 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
458 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
459 | co.UpdateInterval = ephUpdInd;
|
---|
460 | int len1 = MakeClockOrbit(&co, COTYPE_GPSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
461 | co.UpdateInterval = clkUpdInd;
|
---|
462 | if (len1 > 0) {
|
---|
463 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
464 | }
|
---|
465 | }
|
---|
466 | int mmsg = (co.NumberOfGLONASSSat > 0) ? 1 : 0;
|
---|
467 | int len2 = MakeClockOrbit(&co, COTYPE_GPSCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
468 | if (len2 > 0) {
|
---|
469 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
470 | }
|
---|
471 | }
|
---|
472 | if (co.NumberOfGLONASSSat > 0) {
|
---|
473 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
474 | if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
|
---|
475 | co.UpdateInterval = ephUpdInd;
|
---|
476 | int len1 = MakeClockOrbit(&co, COTYPE_GLONASSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
477 | co.UpdateInterval = clkUpdInd;
|
---|
478 | if (len1 > 0) {
|
---|
479 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
480 | }
|
---|
481 | }
|
---|
482 | int len2 = MakeClockOrbit(&co, COTYPE_GLONASSCLOCK, 0, obuffer, sizeof(obuffer));
|
---|
483 | if (len2 > 0) {
|
---|
484 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
485 | }
|
---|
486 | }
|
---|
487 | }
|
---|
488 |
|
---|
489 | // Biases
|
---|
490 | // ------
|
---|
491 | QByteArray hlpBufferBias;
|
---|
492 | if (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0) {
|
---|
493 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
494 | int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
495 | if (len > 0) {
|
---|
496 | hlpBufferBias = QByteArray(obuffer, len);
|
---|
497 | }
|
---|
498 | }
|
---|
499 |
|
---|
500 | _outBuffer += hlpBufferCo + hlpBufferBias;
|
---|
501 | }
|
---|
502 |
|
---|
503 | //
|
---|
504 | ////////////////////////////////////////////////////////////////////////////
|
---|
505 | void bncRtnetUploadCaster::processSatellite(t_eph* eph, int GPSweek,
|
---|
506 | double GPSweeks, const QString& prn,
|
---|
507 | const ColumnVector& rtnAPC,
|
---|
508 | double rtnClk,
|
---|
509 | const ColumnVector& rtnVel,
|
---|
510 | const ColumnVector& rtnCoM,
|
---|
511 | struct ClockOrbit::SatData* sd,
|
---|
512 | QString& outLine) {
|
---|
513 |
|
---|
514 | // Broadcast Position and Velocity
|
---|
515 | // -------------------------------
|
---|
516 | ColumnVector xB(4);
|
---|
517 | ColumnVector vB(3);
|
---|
518 | eph->position(GPSweek, GPSweeks, xB.data(), vB.data());
|
---|
519 |
|
---|
520 | // Precise Position
|
---|
521 | // ----------------
|
---|
522 | ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
|
---|
523 |
|
---|
524 | double dc = 0.0;
|
---|
525 | if (_crdTrafo != "IGS08") {
|
---|
526 | crdTrafo(GPSweek, xP, dc);
|
---|
527 | }
|
---|
528 |
|
---|
529 | // Difference in xyz
|
---|
530 | // -----------------
|
---|
531 | ColumnVector dx = xB.Rows(1,3) - xP;
|
---|
532 | ColumnVector dv = vB - rtnVel;
|
---|
533 |
|
---|
534 | // Difference in RSW
|
---|
535 | // -----------------
|
---|
536 | ColumnVector rsw(3);
|
---|
537 | XYZ_to_RSW(xB.Rows(1,3), vB, dx, rsw);
|
---|
538 |
|
---|
539 | ColumnVector dotRsw(3);
|
---|
540 | XYZ_to_RSW(xB.Rows(1,3), vB, dv, dotRsw);
|
---|
541 |
|
---|
542 | // Clock Correction
|
---|
543 | // ----------------
|
---|
544 | double dClk = rtnClk - (xB(4) - dc) * t_CST::c;
|
---|
545 |
|
---|
546 | if (sd) {
|
---|
547 | sd->ID = prn.mid(1).toInt();
|
---|
548 | sd->IOD = eph->IOD();
|
---|
549 | sd->Clock.DeltaA0 = dClk;
|
---|
550 | sd->Orbit.DeltaRadial = rsw(1);
|
---|
551 | sd->Orbit.DeltaAlongTrack = rsw(2);
|
---|
552 | sd->Orbit.DeltaCrossTrack = rsw(3);
|
---|
553 | sd->Orbit.DotDeltaRadial = dotRsw(1);
|
---|
554 | sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
|
---|
555 | sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
|
---|
556 | }
|
---|
557 |
|
---|
558 | outLine.sprintf("%d %.1f %s %3d %10.3f %8.3f %8.3f %8.3f\n",
|
---|
559 | GPSweek, GPSweeks, eph->prn().toAscii().data(),
|
---|
560 | eph->IOD(), dClk, rsw(1), rsw(2), rsw(3));
|
---|
561 |
|
---|
562 | double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
|
---|
563 | double sp3Clk = (rtnClk - relativity) / t_CST::c; // in seconds
|
---|
564 |
|
---|
565 | if (_rnx) {
|
---|
566 | _rnx->write(GPSweek, GPSweeks, prn, sp3Clk);
|
---|
567 | }
|
---|
568 | if (_sp3) {
|
---|
569 | _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, sp3Clk);
|
---|
570 | }
|
---|
571 | }
|
---|
572 |
|
---|
573 | // Transform Coordinates
|
---|
574 | ////////////////////////////////////////////////////////////////////////////
|
---|
575 | void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
|
---|
576 | double& dc) {
|
---|
577 |
|
---|
578 | // Current epoch minus 2000.0 in years
|
---|
579 | // ------------------------------------
|
---|
580 | double dt = (GPSWeek - (1042.0+6.0/7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
|
---|
581 |
|
---|
582 | ColumnVector dx(3);
|
---|
583 |
|
---|
584 | dx(1) = _dx + dt * _dxr;
|
---|
585 | dx(2) = _dy + dt * _dyr;
|
---|
586 | dx(3) = _dz + dt * _dzr;
|
---|
587 |
|
---|
588 | static const double arcSec = 180.0 * 3600.0 / M_PI;
|
---|
589 |
|
---|
590 | double ox = (_ox + dt * _oxr) / arcSec;
|
---|
591 | double oy = (_oy + dt * _oyr) / arcSec;
|
---|
592 | double oz = (_oz + dt * _ozr) / arcSec;
|
---|
593 |
|
---|
594 | double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
|
---|
595 |
|
---|
596 | // Specify approximate center of area
|
---|
597 | // ----------------------------------
|
---|
598 | ColumnVector meanSta(3);
|
---|
599 |
|
---|
600 | if (_crdTrafo == "ETRF2000") {
|
---|
601 | meanSta(1) = 3661090.0;
|
---|
602 | meanSta(2) = 845230.0;
|
---|
603 | meanSta(3) = 5136850.0;
|
---|
604 | }
|
---|
605 | else if (_crdTrafo == "NAD83") {
|
---|
606 | meanSta(1) = -1092950.0;
|
---|
607 | meanSta(2) = -4383600.0;
|
---|
608 | meanSta(3) = 4487420.0;
|
---|
609 | }
|
---|
610 | else if (_crdTrafo == "GDA94") {
|
---|
611 | meanSta(1) = -4052050.0;
|
---|
612 | meanSta(2) = 4212840.0;
|
---|
613 | meanSta(3) = -2545110.0;
|
---|
614 | }
|
---|
615 | else if (_crdTrafo == "SIRGAS2000") {
|
---|
616 | meanSta(1) = 3740860.0;
|
---|
617 | meanSta(2) = -4964290.0;
|
---|
618 | meanSta(3) = -1425420.0;
|
---|
619 | }
|
---|
620 | else if (_crdTrafo == "SIRGAS95") {
|
---|
621 | meanSta(1) = 3135390.0;
|
---|
622 | meanSta(2) = -5017670.0;
|
---|
623 | meanSta(3) = -2374440.0;
|
---|
624 | }
|
---|
625 | else if (_crdTrafo == "Custom") {
|
---|
626 | meanSta(1) = 0.0; // TODO
|
---|
627 | meanSta(2) = 0.0; // TODO
|
---|
628 | meanSta(3) = 0.0; // TODO
|
---|
629 | }
|
---|
630 |
|
---|
631 | // Clock correction proportional to topocentric distance to satellites
|
---|
632 | // -------------------------------------------------------------------
|
---|
633 | double rho = (xyz - meanSta).norm_Frobenius();
|
---|
634 | dc = rho * (sc - 1.0) / sc / t_CST::c;
|
---|
635 |
|
---|
636 | Matrix rMat(3,3);
|
---|
637 | rMat(1,1) = 1.0;
|
---|
638 | rMat(1,2) = -oz;
|
---|
639 | rMat(1,3) = oy;
|
---|
640 | rMat(2,1) = oz;
|
---|
641 | rMat(2,2) = 1.0;
|
---|
642 | rMat(2,3) = -ox;
|
---|
643 | rMat(3,1) = -oy;
|
---|
644 | rMat(3,2) = ox;
|
---|
645 | rMat(3,3) = 1.0;
|
---|
646 |
|
---|
647 | xyz = sc * rMat * xyz + dx;
|
---|
648 | }
|
---|
649 |
|
---|