[3222] | 1 | /* -------------------------------------------------------------------------
|
---|
| 2 | * BKG NTRIP Server
|
---|
| 3 | * -------------------------------------------------------------------------
|
---|
| 4 | *
|
---|
[3224] | 5 | * Class: bncRtnetUploadCaster
|
---|
[3222] | 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>
|
---|
[3224] | 18 | #include "bncrtnetuploadcaster.h"
|
---|
[3222] | 19 | #include "bncsettings.h"
|
---|
[3224] | 20 | #include "bncephuser.h"
|
---|
[3222] | 21 | #include "bncclockrinex.h"
|
---|
| 22 | #include "bncsp3.h"
|
---|
| 23 |
|
---|
| 24 | using namespace std;
|
---|
| 25 |
|
---|
| 26 | // Constructor
|
---|
| 27 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3224] | 28 | bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint,
|
---|
[3222] | 29 | const QString& outHost, int outPort,
|
---|
| 30 | const QString& password,
|
---|
| 31 | const QString& crdTrafo, bool CoM,
|
---|
| 32 | const QString& sp3FileName,
|
---|
| 33 | const QString& rnxFileName,
|
---|
[3233] | 34 | const QString& outFileName, int iRow) :
|
---|
[3273] | 35 | bncUploadCaster(mountpoint, outHost, outPort, password, iRow, 0) {
|
---|
[3224] | 36 |
|
---|
[3222] | 37 | _crdTrafo = crdTrafo;
|
---|
| 38 | _CoM = CoM;
|
---|
| 39 |
|
---|
[3224] | 40 | // Member that receives the ephemeris
|
---|
| 41 | // ----------------------------------
|
---|
| 42 | _ephUser = new bncEphUser();
|
---|
[3222] | 43 |
|
---|
[3272] | 44 | bncSettings settings;
|
---|
| 45 | QString intr = settings.value("uploadIntr").toString();
|
---|
| 46 | int sampl = settings.value("uploadSampl").toInt();
|
---|
[3587] | 47 | _samplOrb = settings.value("uploadSamplOrb").toDouble();
|
---|
[3753] | 48 | if (_samplOrb == 0.0) {
|
---|
| 49 | _usedEph = 0;
|
---|
| 50 | }
|
---|
| 51 | else {
|
---|
| 52 | _usedEph = new QMap<QString, t_eph*>;
|
---|
| 53 | }
|
---|
[3272] | 54 |
|
---|
[3222] | 55 | // Raw Output
|
---|
| 56 | // ----------
|
---|
| 57 | if (!outFileName.isEmpty()) {
|
---|
[3272] | 58 | _outFile = new bncoutf(outFileName, intr, sampl);
|
---|
[3222] | 59 | }
|
---|
| 60 | else {
|
---|
| 61 | _outFile = 0;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | // RINEX writer
|
---|
| 65 | // ------------
|
---|
| 66 | if (!rnxFileName.isEmpty()) {
|
---|
[3272] | 67 | _rnx = new bncClockRinex(rnxFileName, intr, sampl);
|
---|
[3222] | 68 | }
|
---|
| 69 | else {
|
---|
| 70 | _rnx = 0;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | // SP3 writer
|
---|
| 74 | // ----------
|
---|
| 75 | if (!sp3FileName.isEmpty()) {
|
---|
[3272] | 76 | _sp3 = new bncSP3(sp3FileName, intr, sampl);
|
---|
[3222] | 77 | }
|
---|
| 78 | else {
|
---|
| 79 | _sp3 = 0;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | // Set Transformation Parameters
|
---|
| 83 | // -----------------------------
|
---|
| 84 | if (_crdTrafo == "ETRF2000") {
|
---|
[3890] | 85 | _dx = 0.0521;
|
---|
| 86 | _dy = 0.0493;
|
---|
| 87 | _dz = -0.0585;
|
---|
| 88 | _dxr = 0.0001;
|
---|
[3222] | 89 | _dyr = 0.0001;
|
---|
| 90 | _dzr = -0.0018;
|
---|
| 91 | _ox = 0.000891;
|
---|
| 92 | _oy = 0.005390;
|
---|
| 93 | _oz = -0.008712;
|
---|
| 94 | _oxr = 0.000081;
|
---|
| 95 | _oyr = 0.000490;
|
---|
| 96 | _ozr = -0.000792;
|
---|
[3890] | 97 | _sc = 1.34;
|
---|
[3222] | 98 | _scr = 0.08;
|
---|
| 99 | _t0 = 2000.0;
|
---|
| 100 | }
|
---|
| 101 | else if (_crdTrafo == "NAD83") {
|
---|
| 102 | _dx = 0.9963;
|
---|
| 103 | _dy = -1.9024;
|
---|
| 104 | _dz = -0.5210;
|
---|
| 105 | _dxr = 0.0005;
|
---|
| 106 | _dyr = -0.0006;
|
---|
| 107 | _dzr = -0.0013;
|
---|
[3498] | 108 | _ox = -0.025915;
|
---|
| 109 | _oy = -0.009426;
|
---|
| 110 | _oz = -0.011599;
|
---|
| 111 | _oxr = -0.000067;
|
---|
| 112 | _oyr = 0.000757;
|
---|
| 113 | _ozr = 0.000051;
|
---|
[3222] | 114 | _sc = 0.78;
|
---|
| 115 | _scr = -0.10;
|
---|
| 116 | _t0 = 1997.0;
|
---|
| 117 | }
|
---|
| 118 | else if (_crdTrafo == "GDA94") {
|
---|
| 119 | _dx = -0.07973;
|
---|
| 120 | _dy = -0.00686;
|
---|
| 121 | _dz = 0.03803;
|
---|
| 122 | _dxr = 0.00225;
|
---|
| 123 | _dyr = -0.00062;
|
---|
| 124 | _dzr = -0.00056;
|
---|
| 125 | _ox = 0.0000351;
|
---|
| 126 | _oy = -0.0021211;
|
---|
| 127 | _oz = -0.0021411;
|
---|
| 128 | _oxr = -0.0014707;
|
---|
| 129 | _oyr = -0.0011443;
|
---|
| 130 | _ozr = -0.0011701;
|
---|
| 131 | _sc = 6.636;
|
---|
| 132 | _scr = 0.294;
|
---|
| 133 | _t0 = 1994.0;
|
---|
| 134 | }
|
---|
| 135 | else if (_crdTrafo == "SIRGAS2000") {
|
---|
| 136 | _dx = -0.0051;
|
---|
| 137 | _dy = -0.0065;
|
---|
| 138 | _dz = -0.0099;
|
---|
| 139 | _dxr = 0.0000;
|
---|
| 140 | _dyr = 0.0000;
|
---|
| 141 | _dzr = 0.0000;
|
---|
| 142 | _ox = 0.000150;
|
---|
| 143 | _oy = 0.000020;
|
---|
| 144 | _oz = 0.000021;
|
---|
| 145 | _oxr = 0.000000;
|
---|
| 146 | _oyr = 0.000000;
|
---|
| 147 | _ozr = 0.000000;
|
---|
| 148 | _sc = 0.000;
|
---|
| 149 | _scr = 0.000;
|
---|
| 150 | _t0 = 0000.0;
|
---|
| 151 | }
|
---|
| 152 | else if (_crdTrafo == "SIRGAS95") {
|
---|
| 153 | _dx = 0.0077;
|
---|
| 154 | _dy = 0.0058;
|
---|
| 155 | _dz = -0.0138;
|
---|
| 156 | _dxr = 0.0000;
|
---|
| 157 | _dyr = 0.0000;
|
---|
| 158 | _dzr = 0.0000;
|
---|
| 159 | _ox = 0.000000;
|
---|
| 160 | _oy = 0.000000;
|
---|
| 161 | _oz = -0.000030;
|
---|
| 162 | _oxr = 0.000000;
|
---|
| 163 | _oyr = 0.000000;
|
---|
| 164 | _ozr = 0.000000;
|
---|
| 165 | _sc = 1.570;
|
---|
| 166 | _scr = 0.000;
|
---|
| 167 | _t0 = 0000.0;
|
---|
| 168 | }
|
---|
| 169 | else if (_crdTrafo == "Custom") {
|
---|
| 170 | _dx = settings.value("trafo_dx").toDouble();
|
---|
| 171 | _dy = settings.value("trafo_dy").toDouble();
|
---|
| 172 | _dz = settings.value("trafo_dz").toDouble();
|
---|
| 173 | _dxr = settings.value("trafo_dxr").toDouble();
|
---|
| 174 | _dyr = settings.value("trafo_dyr").toDouble();
|
---|
| 175 | _dzr = settings.value("trafo_dzr").toDouble();
|
---|
| 176 | _ox = settings.value("trafo_ox").toDouble();
|
---|
| 177 | _oy = settings.value("trafo_oy").toDouble();
|
---|
| 178 | _oz = settings.value("trafo_oz").toDouble();
|
---|
| 179 | _oxr = settings.value("trafo_oxr").toDouble();
|
---|
| 180 | _oyr = settings.value("trafo_oyr").toDouble();
|
---|
| 181 | _ozr = settings.value("trafo_ozr").toDouble();
|
---|
| 182 | _sc = settings.value("trafo_sc").toDouble();
|
---|
| 183 | _scr = settings.value("trafo_scr").toDouble();
|
---|
| 184 | _t0 = settings.value("trafo_t0").toDouble();
|
---|
| 185 | }
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | // Destructor
|
---|
| 189 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3224] | 190 | bncRtnetUploadCaster::~bncRtnetUploadCaster() {
|
---|
[3222] | 191 | if (isRunning()) {
|
---|
| 192 | wait();
|
---|
| 193 | }
|
---|
| 194 | delete _outFile;
|
---|
| 195 | delete _rnx;
|
---|
| 196 | delete _sp3;
|
---|
| 197 | delete _ephUser;
|
---|
[3753] | 198 | delete _usedEph;
|
---|
[3222] | 199 | }
|
---|
| 200 |
|
---|
| 201 | //
|
---|
| 202 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3224] | 203 | void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
|
---|
[3222] | 204 |
|
---|
| 205 | QMutexLocker locker(&_mutex);
|
---|
| 206 |
|
---|
[3230] | 207 | // Append to internal buffer
|
---|
| 208 | // -------------------------
|
---|
[3222] | 209 | _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
|
---|
[3230] | 210 |
|
---|
| 211 | // Select buffer part that contains last epoch
|
---|
| 212 | // -------------------------------------------
|
---|
| 213 | QStringList lines;
|
---|
| 214 | int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
|
---|
| 215 | if (iEpoBeg == -1) {
|
---|
[3226] | 216 | _rtnetStreamBuffer.clear();
|
---|
| 217 | return;
|
---|
[3222] | 218 | }
|
---|
[3230] | 219 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
|
---|
| 220 |
|
---|
| 221 | int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
|
---|
| 222 | if (iEpoEnd == -1) {
|
---|
| 223 | return;
|
---|
| 224 | }
|
---|
[3226] | 225 | else {
|
---|
[3230] | 226 | lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
|
---|
| 227 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd+3);
|
---|
[3226] | 228 | }
|
---|
[3222] | 229 |
|
---|
[3226] | 230 | if (lines.size() < 2) {
|
---|
[3222] | 231 | return;
|
---|
| 232 | }
|
---|
| 233 |
|
---|
[3226] | 234 | // Keep the last unfinished line in buffer
|
---|
| 235 | // ---------------------------------------
|
---|
| 236 | int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n');
|
---|
| 237 | if (iLastEOL != -1) {
|
---|
| 238 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1);
|
---|
| 239 | }
|
---|
| 240 |
|
---|
| 241 | // Read first line (with epoch time)
|
---|
| 242 | // ---------------------------------
|
---|
| 243 | QTextStream in(lines[0].toAscii());
|
---|
| 244 | QString hlp;
|
---|
| 245 | int year, month, day, hour, min;
|
---|
| 246 | double sec;
|
---|
| 247 | in >> hlp >> year >> month >> day >> hour >> min >> sec;
|
---|
| 248 | bncTime epoTime; epoTime.set( year, month, day, hour, min, sec);
|
---|
| 249 |
|
---|
[3222] | 250 | struct ClockOrbit co;
|
---|
| 251 | memset(&co, 0, sizeof(co));
|
---|
[3226] | 252 | co.GPSEpochTime = static_cast<int>(epoTime.gpssec());
|
---|
| 253 | co.GLONASSEpochTime = static_cast<int>(fmod(epoTime.gpssec(), 86400.0))
|
---|
[3222] | 254 | + 3 * 3600 - gnumleap(year, month, day);
|
---|
| 255 | co.ClockDataSupplied = 1;
|
---|
| 256 | co.OrbitDataSupplied = 1;
|
---|
| 257 | co.SatRefDatum = DATUM_ITRF;
|
---|
| 258 |
|
---|
| 259 | struct Bias bias;
|
---|
| 260 | memset(&bias, 0, sizeof(bias));
|
---|
[3226] | 261 | bias.GPSEpochTime = co.GPSEpochTime;
|
---|
| 262 | bias.GLONASSEpochTime = co.GLONASSEpochTime;
|
---|
[3222] | 263 |
|
---|
[3226] | 264 | for (int ii = 1; ii < lines.size(); ii++) {
|
---|
| 265 |
|
---|
[3222] | 266 | QString prn;
|
---|
| 267 | ColumnVector xx(14); xx = 0.0;
|
---|
| 268 |
|
---|
| 269 | QTextStream in(lines[ii].toAscii());
|
---|
| 270 |
|
---|
| 271 | in >> prn;
|
---|
| 272 | if (prn[0] == 'P') {
|
---|
| 273 | prn.remove(0,1);
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[3753] | 276 | t_eph* eph = 0;
|
---|
[3222] | 277 | const bncEphUser::t_ephPair* ephPair = _ephUser->ephPair(prn);
|
---|
| 278 | if (ephPair) {
|
---|
| 279 |
|
---|
[3754] | 280 | eph = ephPair->last;
|
---|
| 281 |
|
---|
| 282 | // receptDateTime() not (yet?) defined
|
---|
| 283 | // if (ephPair->prev &&
|
---|
| 284 | // eph->receptDateTime().secsTo(QDateTime::currentDateTime()) < 60) {
|
---|
| 285 | // eph = ephPair->prev;
|
---|
| 286 | // }
|
---|
| 287 |
|
---|
[3753] | 288 | // Make sure the clock messages refer to same IOD as orbit messages
|
---|
| 289 | // ----------------------------------------------------------------
|
---|
| 290 | if (_usedEph) {
|
---|
| 291 | if (fmod(epoTime.gpssec(), _samplOrb) == 0.0) {
|
---|
| 292 | (*_usedEph)[prn] = eph;
|
---|
| 293 | }
|
---|
| 294 | else {
|
---|
| 295 | eph = 0;
|
---|
| 296 | if (_usedEph->contains(prn)) {
|
---|
| 297 | t_eph* usedEph = _usedEph->value(prn);
|
---|
| 298 | if (usedEph == ephPair->last) {
|
---|
| 299 | eph = ephPair->last;
|
---|
| 300 | }
|
---|
| 301 | else if (usedEph == ephPair->prev) {
|
---|
| 302 | eph = ephPair->prev;
|
---|
| 303 | }
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 | }
|
---|
| 308 |
|
---|
| 309 | if (eph) {
|
---|
| 310 |
|
---|
[3222] | 311 | in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5)
|
---|
| 312 | >> xx(6) >> xx(7) >> xx(8) >> xx(9) >> xx(10)
|
---|
| 313 | >> xx(11) >> xx(12) >> xx(13) >> xx(14);
|
---|
| 314 | xx(1) *= 1e3; // x-crd
|
---|
| 315 | xx(2) *= 1e3; // y-crd
|
---|
| 316 | xx(3) *= 1e3; // z-crd
|
---|
| 317 | xx(4) *= 1e-6; // clk
|
---|
| 318 | xx(5) *= 1e-6; // rel. corr.
|
---|
| 319 | // xx(6), xx(7), xx(8) ... PhaseCent - CoM
|
---|
| 320 | // xx(9) ... P1-C1 DCB in meters
|
---|
| 321 | // xx(10) ... P1-P2 DCB in meters
|
---|
| 322 | // xx(11) ... dT
|
---|
| 323 | xx(12) *= 1e3; // x-crd at time + dT
|
---|
| 324 | xx(13) *= 1e3; // y-crd at time + dT
|
---|
| 325 | xx(14) *= 1e3; // z-crd at time + dT
|
---|
| 326 |
|
---|
| 327 | struct ClockOrbit::SatData* sd = 0;
|
---|
| 328 | if (prn[0] == 'G') {
|
---|
| 329 | sd = co.Sat + co.NumberOfGPSSat;
|
---|
| 330 | ++co.NumberOfGPSSat;
|
---|
| 331 | }
|
---|
| 332 | else if (prn[0] == 'R') {
|
---|
| 333 | sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
|
---|
| 334 | ++co.NumberOfGLONASSSat;
|
---|
| 335 | }
|
---|
| 336 | if (sd) {
|
---|
| 337 | QString outLine;
|
---|
[3226] | 338 | processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prn,
|
---|
[3222] | 339 | xx, sd, outLine);
|
---|
| 340 | if (_outFile) {
|
---|
[3226] | 341 | _outFile->write(epoTime.gpsw(), epoTime.gpssec(), outLine);
|
---|
[3222] | 342 | }
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | struct Bias::BiasSat* biasSat = 0;
|
---|
| 346 | if (prn[0] == 'G') {
|
---|
| 347 | biasSat = bias.Sat + bias.NumberOfGPSSat;
|
---|
| 348 | ++bias.NumberOfGPSSat;
|
---|
| 349 | }
|
---|
| 350 | else if (prn[0] == 'R') {
|
---|
| 351 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
|
---|
| 352 | ++bias.NumberOfGLONASSSat;
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | // Coefficient of Ionosphere-Free LC
|
---|
| 356 | // ---------------------------------
|
---|
| 357 | const static double a_L1_GPS = 2.54572778;
|
---|
| 358 | const static double a_L2_GPS = -1.54572778;
|
---|
| 359 | const static double a_L1_Glo = 2.53125000;
|
---|
| 360 | const static double a_L2_Glo = -1.53125000;
|
---|
| 361 |
|
---|
| 362 | if (biasSat) {
|
---|
| 363 | biasSat->ID = prn.mid(1).toInt();
|
---|
| 364 | biasSat->NumberOfCodeBiases = 3;
|
---|
| 365 | if (prn[0] == 'G') {
|
---|
| 366 | biasSat->Biases[0].Type = CODETYPEGPS_L1_Z;
|
---|
| 367 | biasSat->Biases[0].Bias = - a_L2_GPS * xx(10);
|
---|
| 368 | biasSat->Biases[1].Type = CODETYPEGPS_L1_CA;
|
---|
| 369 | biasSat->Biases[1].Bias = - a_L2_GPS * xx(10) + xx(9);
|
---|
| 370 | biasSat->Biases[2].Type = CODETYPEGPS_L2_Z;
|
---|
| 371 | biasSat->Biases[2].Bias = a_L1_GPS * xx(10);
|
---|
| 372 | }
|
---|
| 373 | else if (prn[0] == 'R') {
|
---|
| 374 | biasSat->Biases[0].Type = CODETYPEGLONASS_L1_P;
|
---|
| 375 | biasSat->Biases[0].Bias = - a_L2_Glo * xx(10);
|
---|
| 376 | biasSat->Biases[1].Type = CODETYPEGLONASS_L1_CA;
|
---|
| 377 | biasSat->Biases[1].Bias = - a_L2_Glo * xx(10) + xx(9);
|
---|
| 378 | biasSat->Biases[2].Type = CODETYPEGLONASS_L2_P;
|
---|
| 379 | biasSat->Biases[2].Bias = a_L1_Glo * xx(10);
|
---|
| 380 | }
|
---|
| 381 | }
|
---|
| 382 | }
|
---|
| 383 | }
|
---|
[3227] | 384 |
|
---|
| 385 | QByteArray hlpBufferCo;
|
---|
[3493] | 386 |
|
---|
| 387 | // Orbit and Clock Corrections together
|
---|
| 388 | // ------------------------------------
|
---|
[3587] | 389 | if (_samplOrb == 0.0) {
|
---|
[3493] | 390 | if (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) {
|
---|
| 391 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
| 392 | int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
| 393 | if (len > 0) {
|
---|
| 394 | hlpBufferCo = QByteArray(obuffer, len);
|
---|
| 395 | }
|
---|
[3222] | 396 | }
|
---|
| 397 | }
|
---|
[3493] | 398 |
|
---|
| 399 | // Orbit and Clock Corrections separately
|
---|
| 400 | // --------------------------------------
|
---|
| 401 | else {
|
---|
| 402 | if (co.NumberOfGPSSat > 0) {
|
---|
| 403 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
[3587] | 404 | if (fmod(epoTime.gpssec(), _samplOrb) == 0.0) {
|
---|
[3591] | 405 | int len1 = MakeClockOrbit(&co, COTYPE_GPSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
[3493] | 406 | if (len1 > 0) {
|
---|
| 407 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
| 408 | }
|
---|
| 409 | }
|
---|
[3591] | 410 | int mmsg = (co.NumberOfGLONASSSat > 0) ? 1 : 0;
|
---|
| 411 | int len2 = MakeClockOrbit(&co, COTYPE_GPSCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
[3493] | 412 | if (len2 > 0) {
|
---|
| 413 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
| 414 | }
|
---|
| 415 | }
|
---|
| 416 | if (co.NumberOfGLONASSSat > 0) {
|
---|
| 417 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
[3587] | 418 | if (fmod(epoTime.gpssec(), _samplOrb) == 0.0) {
|
---|
[3591] | 419 | int len1 = MakeClockOrbit(&co, COTYPE_GLONASSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
[3493] | 420 | if (len1 > 0) {
|
---|
| 421 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
| 422 | }
|
---|
| 423 | }
|
---|
| 424 | int len2 = MakeClockOrbit(&co, COTYPE_GLONASSCLOCK, 0, obuffer, sizeof(obuffer));
|
---|
| 425 | if (len2 > 0) {
|
---|
| 426 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
| 427 | }
|
---|
| 428 | }
|
---|
| 429 | }
|
---|
[3222] | 430 |
|
---|
[3493] | 431 | // Biases
|
---|
| 432 | // ------
|
---|
[3227] | 433 | QByteArray hlpBufferBias;
|
---|
[3222] | 434 | if (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0) {
|
---|
| 435 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
| 436 | int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
| 437 | if (len > 0) {
|
---|
[3227] | 438 | hlpBufferBias = QByteArray(obuffer, len);
|
---|
[3222] | 439 | }
|
---|
| 440 | }
|
---|
[3227] | 441 |
|
---|
| 442 | if (hlpBufferCo.size() > 0) {
|
---|
| 443 | _outBuffer = hlpBufferCo + hlpBufferBias;
|
---|
| 444 | }
|
---|
[3222] | 445 | }
|
---|
| 446 |
|
---|
| 447 | //
|
---|
| 448 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3224] | 449 | void bncRtnetUploadCaster::processSatellite(t_eph* eph, int GPSweek,
|
---|
[3222] | 450 | double GPSweeks, const QString& prn,
|
---|
| 451 | const ColumnVector& xx,
|
---|
| 452 | struct ClockOrbit::SatData* sd,
|
---|
| 453 | QString& outLine) {
|
---|
| 454 |
|
---|
| 455 | const double secPerWeek = 7.0 * 86400.0;
|
---|
| 456 |
|
---|
| 457 | ColumnVector rsw(3);
|
---|
| 458 | ColumnVector rsw2(3);
|
---|
| 459 | double dClk;
|
---|
| 460 |
|
---|
| 461 | for (int ii = 1; ii <= 2; ++ii) {
|
---|
| 462 |
|
---|
| 463 | int GPSweek12 = GPSweek;
|
---|
| 464 | double GPSweeks12 = GPSweeks;
|
---|
| 465 | if (ii == 2) {
|
---|
| 466 | GPSweeks12 += xx(11);
|
---|
| 467 | if (GPSweeks12 > secPerWeek) {
|
---|
| 468 | GPSweek12 += 1;
|
---|
| 469 | GPSweeks12 -= secPerWeek;
|
---|
| 470 | }
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 | ColumnVector xB(4);
|
---|
| 474 | ColumnVector vv(3);
|
---|
| 475 |
|
---|
| 476 | eph->position(GPSweek12, GPSweeks12, xB.data(), vv.data());
|
---|
| 477 |
|
---|
| 478 | ColumnVector xyz;
|
---|
| 479 | if (ii == 1) {
|
---|
| 480 | xyz = xx.Rows(1,3);
|
---|
| 481 | }
|
---|
| 482 | else {
|
---|
| 483 | xyz = xx.Rows(12,14);
|
---|
| 484 | }
|
---|
| 485 |
|
---|
| 486 | // Correction Center of Mass -> Antenna Phase Center
|
---|
| 487 | // -------------------------------------------------
|
---|
| 488 | if (! _CoM) {
|
---|
| 489 | xyz(1) += xx(6);
|
---|
| 490 | xyz(2) += xx(7);
|
---|
| 491 | xyz(3) += xx(8);
|
---|
| 492 | }
|
---|
| 493 |
|
---|
[3793] | 494 | if (_crdTrafo != "IGS08") {
|
---|
[3222] | 495 | crdTrafo(GPSweek12, xyz);
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 | ColumnVector dx = xB.Rows(1,3) - xyz ;
|
---|
| 499 |
|
---|
| 500 | if (ii == 1) {
|
---|
| 501 | XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
|
---|
| 502 | dClk = (xx(4) + xx(5) - xB(4)) * 299792458.0;
|
---|
| 503 | }
|
---|
| 504 | else {
|
---|
| 505 | XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw2);
|
---|
| 506 | }
|
---|
| 507 | }
|
---|
| 508 |
|
---|
| 509 | if (sd) {
|
---|
| 510 | sd->ID = prn.mid(1).toInt();
|
---|
| 511 | sd->IOD = eph->IOD();
|
---|
| 512 | sd->Clock.DeltaA0 = dClk;
|
---|
| 513 | sd->Orbit.DeltaRadial = rsw(1);
|
---|
| 514 | sd->Orbit.DeltaAlongTrack = rsw(2);
|
---|
| 515 | sd->Orbit.DeltaCrossTrack = rsw(3);
|
---|
| 516 | sd->Orbit.DotDeltaRadial = (rsw2(1) - rsw(1)) / xx(11);
|
---|
| 517 | sd->Orbit.DotDeltaAlongTrack = (rsw2(2) - rsw(2)) / xx(11);
|
---|
| 518 | sd->Orbit.DotDeltaCrossTrack = (rsw2(3) - rsw(3)) / xx(11);
|
---|
| 519 | }
|
---|
| 520 |
|
---|
| 521 | outLine.sprintf("%d %.1f %s %3d %10.3f %8.3f %8.3f %8.3f\n",
|
---|
[3255] | 522 | GPSweek, GPSweeks, eph->prn().toAscii().data(),
|
---|
[3222] | 523 | eph->IOD(), dClk, rsw(1), rsw(2), rsw(3));
|
---|
| 524 |
|
---|
| 525 | if (_rnx) {
|
---|
| 526 | _rnx->write(GPSweek, GPSweeks, prn, xx);
|
---|
| 527 | }
|
---|
| 528 | if (_sp3) {
|
---|
| 529 | _sp3->write(GPSweek, GPSweeks, prn, xx);
|
---|
| 530 | }
|
---|
| 531 | }
|
---|
| 532 |
|
---|
| 533 | // Transform Coordinates
|
---|
| 534 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3224] | 535 | void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz) {
|
---|
[3222] | 536 |
|
---|
| 537 | // Current epoch minus 2000.0 in years
|
---|
| 538 | // ------------------------------------
|
---|
| 539 | double dt = (GPSWeek - (1042.0+6.0/7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
|
---|
| 540 |
|
---|
| 541 | ColumnVector dx(3);
|
---|
| 542 |
|
---|
| 543 | dx(1) = _dx + dt * _dxr;
|
---|
| 544 | dx(2) = _dy + dt * _dyr;
|
---|
| 545 | dx(3) = _dz + dt * _dzr;
|
---|
| 546 |
|
---|
| 547 | static const double arcSec = 180.0 * 3600.0 / M_PI;
|
---|
| 548 |
|
---|
| 549 | double ox = (_ox + dt * _oxr) / arcSec;
|
---|
| 550 | double oy = (_oy + dt * _oyr) / arcSec;
|
---|
| 551 | double oz = (_oz + dt * _ozr) / arcSec;
|
---|
| 552 |
|
---|
| 553 | double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
|
---|
| 554 |
|
---|
| 555 | Matrix rMat(3,3);
|
---|
| 556 | rMat(1,1) = 1.0;
|
---|
| 557 | rMat(1,2) = -oz;
|
---|
| 558 | rMat(1,3) = oy;
|
---|
| 559 | rMat(2,1) = oz;
|
---|
| 560 | rMat(2,2) = 1.0;
|
---|
| 561 | rMat(2,3) = -ox;
|
---|
| 562 | rMat(3,1) = -oy;
|
---|
| 563 | rMat(3,2) = ox;
|
---|
| 564 | rMat(3,3) = 1.0;
|
---|
| 565 |
|
---|
| 566 | xyz = sc * rMat * xyz + dx;
|
---|
| 567 | }
|
---|
| 568 |
|
---|