[4757] | 1 |
|
---|
| 2 | #include <iostream>
|
---|
[4775] | 3 | #include <iomanip>
|
---|
[4757] | 4 | #include <string.h>
|
---|
| 5 |
|
---|
[4758] | 6 | #include "bncrtrover.h"
|
---|
[5068] | 7 | #include "bnccore.h"
|
---|
[4757] | 8 | #include "bncsettings.h"
|
---|
| 9 | #include "bnctime.h"
|
---|
| 10 |
|
---|
[4758] | 11 | #include "rtrover_interface.h"
|
---|
[4757] | 12 |
|
---|
| 13 | using namespace std;
|
---|
| 14 |
|
---|
| 15 | // Constructor
|
---|
| 16 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4763] | 17 | t_bncRtrover::t_bncRtrover() : QThread(0) {
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | // Destructor
|
---|
| 21 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 22 | t_bncRtrover::~t_bncRtrover() {
|
---|
| 23 | rtrover_destroy();
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | // Run (virtual)
|
---|
| 27 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 28 | void t_bncRtrover::run() {
|
---|
[4757] | 29 | bncSettings settings;
|
---|
| 30 |
|
---|
[4768] | 31 | // User Options
|
---|
| 32 | // ------------
|
---|
| 33 | _mode = settings.value("rtroverMode").toByteArray();
|
---|
| 34 | _roverMount = settings.value("rtroverRoverMount").toByteArray();
|
---|
| 35 | _baseMount = settings.value("rtroverBaseMount").toByteArray();
|
---|
| 36 | _corrMount = settings.value("rtroverCorrMount").toByteArray();
|
---|
| 37 | _outputFile.setFileName(settings.value("rtroverOutput").toString());
|
---|
| 38 | _outputFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
---|
[4757] | 39 |
|
---|
| 40 | // Define Input Options
|
---|
| 41 | // --------------------
|
---|
[4760] | 42 | rtrover_opt opt;
|
---|
[4779] | 43 | rtrover_initOptions(&opt);
|
---|
[4769] | 44 |
|
---|
[4794] | 45 | if (_mode == "PPP_DF") {
|
---|
| 46 | opt._mode = mode_PPP_DF;
|
---|
| 47 | }
|
---|
| 48 | else if (_mode == "SPP_DF") {
|
---|
| 49 | opt._mode = mode_SPP_DF;
|
---|
| 50 | }
|
---|
| 51 | else if (_mode == "PPP_SF") {
|
---|
| 52 | opt._mode = mode_PPP_SF;
|
---|
| 53 | }
|
---|
| 54 | else if (_mode == "SPP_SF") {
|
---|
| 55 | opt._mode = mode_SPP_SF;
|
---|
| 56 | }
|
---|
| 57 | else if (_mode == "PPP_AR") {
|
---|
| 58 | opt._mode = mode_PPP_AR;
|
---|
| 59 | }
|
---|
| 60 | else if (_mode == "RTK") {
|
---|
| 61 | opt._mode = mode_RTK;
|
---|
| 62 | }
|
---|
| 63 | else if (_mode == "PPP_FTTF") {
|
---|
| 64 | opt._mode = mode_PPP_FTTF;
|
---|
| 65 | }
|
---|
[4795] | 66 |
|
---|
| 67 | QByteArray antNameRover = settings.value("rtroverRoverAntenna").toByteArray();
|
---|
| 68 | QByteArray antNameBase = settings.value("rtroverBaseAntenna").toByteArray();
|
---|
| 69 | QByteArray antexFileName = settings.value("rtroverAntex").toByteArray();
|
---|
| 70 |
|
---|
| 71 | if (!_roverMount.isEmpty()) opt._roverName = _roverMount.data();
|
---|
| 72 | if (!_baseMount.isEmpty()) opt._baseName = _baseMount.data();
|
---|
| 73 | if (!antNameRover.isEmpty()) opt._antNameRover = antNameRover.data();
|
---|
| 74 | if (!antNameBase.isEmpty()) opt._antNameBase = antNameBase.data();
|
---|
| 75 | if (!antexFileName.isEmpty()) opt._antexFileName = antexFileName.data();
|
---|
| 76 |
|
---|
[4768] | 77 | opt._xyzAprRover[0] = settings.value("rtroverRoverRefCrdX").toDouble();
|
---|
| 78 | opt._xyzAprRover[1] = settings.value("rtroverRoverRefCrdY").toDouble();
|
---|
| 79 | opt._xyzAprRover[2] = settings.value("rtroverRoverRefCrdZ").toDouble();
|
---|
| 80 | opt._xyzAprBase[0] = settings.value("rtroverBaseRefCrdX").toDouble();
|
---|
| 81 | opt._xyzAprBase[1] = settings.value("rtroverBaseRefCrdY").toDouble();
|
---|
| 82 | opt._xyzAprBase[2] = settings.value("rtroverBaseRefCrdZ").toDouble();
|
---|
[4794] | 83 | opt._neuEccRover[0] = settings.value("rtroverRoverDN").toDouble();
|
---|
| 84 | opt._neuEccRover[1] = settings.value("rtroverRoverDE").toDouble();
|
---|
| 85 | opt._neuEccRover[2] = settings.value("rtroverRoverDU").toDouble();
|
---|
| 86 | opt._neuEccBase[0] = settings.value("rtroverBaseDN").toDouble();
|
---|
| 87 | opt._neuEccBase[1] = settings.value("rtroverBaseDE").toDouble();
|
---|
| 88 | opt._neuEccBase[2] = settings.value("rtroverBaseDU").toDouble();
|
---|
| 89 | opt._logLevel = 2;
|
---|
[4769] | 90 |
|
---|
[4760] | 91 | rtrover_setOptions(&opt);
|
---|
[4757] | 92 |
|
---|
| 93 | // Connect to BNC Signals
|
---|
| 94 | // ----------------------
|
---|
[5068] | 95 | connect(BNC_CORE, SIGNAL(newCorrections(QList<QString>)),
|
---|
[4757] | 96 | this, SLOT(slotNewCorrections(QList<QString>)));
|
---|
| 97 |
|
---|
[5068] | 98 | connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
|
---|
[4757] | 99 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
---|
| 100 |
|
---|
[5068] | 101 | connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
[4757] | 102 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
---|
| 103 |
|
---|
[5068] | 104 | connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
|
---|
[4757] | 105 | this, SLOT(slotNewEphGalileo(galileoephemeris)));
|
---|
[4764] | 106 |
|
---|
| 107 | // Start processing loop
|
---|
| 108 | // ---------------------
|
---|
| 109 | QThread::exec();
|
---|
[4757] | 110 | }
|
---|
| 111 |
|
---|
| 112 | //
|
---|
| 113 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4758] | 114 | void t_bncRtrover::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
[4757] | 115 | QMutexLocker locker(&_mutex);
|
---|
[4760] | 116 |
|
---|
| 117 | bncTime toc(gpseph.GPSweek, gpseph.TOC);
|
---|
| 118 | bncTime toe(gpseph.GPSweek, gpseph.TOE);
|
---|
| 119 |
|
---|
| 120 | rtrover_ephGPS eph;
|
---|
| 121 | eph._satellite._system = 'G';
|
---|
| 122 | eph._satellite._number = gpseph.satellite;
|
---|
| 123 | eph._TOC._mjd = toc.mjd();
|
---|
| 124 | eph._TOC._sec = toc.daysec();
|
---|
| 125 | eph._TOE._mjd = toe.mjd();
|
---|
| 126 | eph._TOE._sec = toe.daysec();
|
---|
| 127 | eph._IODE = gpseph.IODE;
|
---|
| 128 | eph._IODC = gpseph.IODC;
|
---|
| 129 | eph._clock_bias = gpseph.clock_bias;
|
---|
| 130 | eph._clock_drift = gpseph.clock_drift;
|
---|
| 131 | eph._clock_driftrate = gpseph.clock_driftrate;
|
---|
| 132 | eph._Crs = gpseph.Crs;
|
---|
| 133 | eph._Delta_n = gpseph.Delta_n;
|
---|
| 134 | eph._M0 = gpseph.M0;
|
---|
| 135 | eph._Cuc = gpseph.Cuc;
|
---|
| 136 | eph._e = gpseph.e;
|
---|
| 137 | eph._Cus = gpseph.Cus;
|
---|
| 138 | eph._sqrt_A = gpseph.sqrt_A;
|
---|
| 139 | eph._Cic = gpseph.Cic;
|
---|
| 140 | eph._OMEGA0 = gpseph.OMEGA0;
|
---|
| 141 | eph._Cis = gpseph.Cis;
|
---|
| 142 | eph._i0 = gpseph.i0;
|
---|
| 143 | eph._Crc = gpseph.Crc;
|
---|
| 144 | eph._omega = gpseph.omega;
|
---|
| 145 | eph._OMEGADOT = gpseph.OMEGADOT;
|
---|
| 146 | eph._IDOT = gpseph.IDOT;
|
---|
| 147 | eph._TGD = gpseph.TGD;
|
---|
| 148 | eph._health = gpseph.SVhealth;
|
---|
| 149 |
|
---|
| 150 | rtrover_putGPSEphemeris(&eph);
|
---|
[4757] | 151 | }
|
---|
| 152 |
|
---|
| 153 | //
|
---|
| 154 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4758] | 155 | void t_bncRtrover::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
[4757] | 156 | QMutexLocker locker(&_mutex);
|
---|
| 157 |
|
---|
| 158 | int wwUTC = gloeph.GPSWeek;
|
---|
| 159 | int towUTC = gloeph.GPSTOW;
|
---|
| 160 | updatetime(&wwUTC, &towUTC, gloeph.tb*1000, 1); // Moscow -> UTC
|
---|
| 161 | bncTime tUTC(wwUTC,towUTC);
|
---|
| 162 |
|
---|
| 163 | int wwGPS = gloeph.GPSWeek;
|
---|
| 164 | int towGPS = gloeph.GPSTOW;
|
---|
| 165 | updatetime(&wwGPS, &towGPS, gloeph.tb*1000, 0); // Moscow -> GPS
|
---|
| 166 | bncTime tGPS(wwGPS,towGPS);
|
---|
[4760] | 167 |
|
---|
| 168 | rtrover_ephGlo eph;
|
---|
[4761] | 169 | eph._satellite._system = 'R';
|
---|
| 170 | eph._satellite._number = gloeph.almanac_number;
|
---|
| 171 | eph._timeUTC._mjd = tUTC.mjd();
|
---|
| 172 | eph._timeUTC._sec = tUTC.daysec();
|
---|
| 173 | eph._gps_utc = int(tGPS-tUTC);
|
---|
| 174 | eph._E = gloeph.E;
|
---|
| 175 | eph._tau = gloeph.tau;
|
---|
| 176 | eph._gamma = gloeph.gamma;
|
---|
| 177 | eph._x_pos = gloeph.x_pos;
|
---|
| 178 | eph._x_velocity = gloeph.x_velocity;
|
---|
| 179 | eph._x_acceleration = gloeph.x_acceleration;
|
---|
| 180 | eph._y_pos = gloeph.y_pos;
|
---|
| 181 | eph._y_velocity = gloeph.y_velocity;
|
---|
| 182 | eph._y_acceleration = gloeph.y_acceleration;
|
---|
| 183 | eph._z_pos = gloeph.z_pos;
|
---|
| 184 | eph._z_velocity = gloeph.z_velocity;
|
---|
| 185 | eph._z_acceleration = gloeph.z_acceleration;
|
---|
| 186 | eph._health = 0; // TODO ?
|
---|
| 187 | eph._frequency_number = gloeph.frequency_number;
|
---|
[4760] | 188 |
|
---|
| 189 | rtrover_putGloEphemeris(&eph);
|
---|
[4757] | 190 | }
|
---|
| 191 |
|
---|
| 192 | //
|
---|
| 193 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4758] | 194 | void t_bncRtrover::slotNewEphGalileo(galileoephemeris /* galeph */) {
|
---|
[4757] | 195 | // not yet implemented
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | //
|
---|
| 199 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4758] | 200 | void t_bncRtrover::slotNewCorrections(QList<QString> corrList) {
|
---|
[4757] | 201 | QMutexLocker locker(&_mutex);
|
---|
| 202 |
|
---|
| 203 | if (corrList.size() == 0) {
|
---|
| 204 | return;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
[4770] | 207 | int numOrbCorr = 0;
|
---|
| 208 | int numClkCorr = 0;
|
---|
[4788] | 209 | int numBiases = 0;
|
---|
[4770] | 210 |
|
---|
[4797] | 211 | rtrover_orbCorr orbCorr[corrList.size()];
|
---|
| 212 | rtrover_clkCorr clkCorr[corrList.size()];
|
---|
| 213 | rtrover_satBiases biases[corrList.size()];
|
---|
[4770] | 214 |
|
---|
[4757] | 215 | QListIterator<QString> it(corrList);
|
---|
| 216 | while (it.hasNext()) {
|
---|
| 217 | QString line = it.next();
|
---|
| 218 |
|
---|
[4770] | 219 | // Check the Mountpoint
|
---|
| 220 | // --------------------
|
---|
| 221 | QStringList hlp = line.split(" ");
|
---|
| 222 | if (hlp.size() > 0) {
|
---|
| 223 | QString mountpoint = hlp[hlp.size()-1];
|
---|
| 224 | if (mountpoint != _corrMount) {
|
---|
| 225 | continue;
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
[4757] | 228 |
|
---|
[4788] | 229 | // Orbit and clock corrections
|
---|
| 230 | // ---------------------------
|
---|
[4770] | 231 | t_corr corr;
|
---|
| 232 | if (corr.readLine(line) == success) {
|
---|
| 233 |
|
---|
| 234 | if (corr.messageType == COTYPE_GPSCOMBINED ||
|
---|
| 235 | corr.messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 236 | corr.messageType == COTYPE_GPSORBIT ||
|
---|
| 237 | corr.messageType == COTYPE_GLONASSORBIT ) {
|
---|
[4800] | 238 |
|
---|
| 239 | _IODs[corr.prn] = corr.iod; // remember iod;
|
---|
| 240 |
|
---|
[4770] | 241 | ++numOrbCorr;
|
---|
| 242 | rtrover_orbCorr& orbC = orbCorr[numOrbCorr-1];
|
---|
[4771] | 243 | orbC._satellite._system = corr.prn.toAscii()[0];
|
---|
| 244 | orbC._satellite._number = corr.prn.mid(1).toInt();
|
---|
| 245 | orbC._iod = corr.iod;
|
---|
| 246 | orbC._time._mjd = corr.tRao.mjd();
|
---|
| 247 | orbC._time._sec = corr.tRao.daysec();
|
---|
| 248 | for (int ii = 0; ii < 3; ii++) {
|
---|
| 249 | orbC._rao[ii] = corr.rao[ii];
|
---|
| 250 | orbC._dotRao[ii] = corr.dotRao[ii];
|
---|
| 251 | }
|
---|
[4770] | 252 | }
|
---|
| 253 |
|
---|
| 254 | if (corr.messageType == COTYPE_GPSCOMBINED ||
|
---|
| 255 | corr.messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 256 | corr.messageType == COTYPE_GPSCLOCK ||
|
---|
| 257 | corr.messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 258 | ++numClkCorr;
|
---|
| 259 | rtrover_clkCorr& clkC = clkCorr[numClkCorr-1];
|
---|
[4771] | 260 | clkC._satellite._system = corr.prn.toAscii()[0];
|
---|
| 261 | clkC._satellite._number = corr.prn.mid(1).toInt();
|
---|
[4800] | 262 | if (_IODs.contains(corr.prn)) {
|
---|
| 263 | clkC._iod = _IODs[corr.prn];
|
---|
| 264 | }
|
---|
| 265 | else {
|
---|
| 266 | clkC._iod = 0;
|
---|
| 267 | }
|
---|
[4771] | 268 | clkC._time._mjd = corr.tClk.mjd();
|
---|
| 269 | clkC._time._sec = corr.tClk.daysec();
|
---|
| 270 | clkC._dClk = corr.dClk;
|
---|
| 271 | clkC._dotDClk = corr.dotDClk;
|
---|
| 272 | clkC._dotDotDClk = corr.dotDotDClk;
|
---|
[4770] | 273 | }
|
---|
[4757] | 274 | }
|
---|
[4788] | 275 |
|
---|
| 276 | // Code Biases
|
---|
| 277 | // -----------
|
---|
| 278 | t_bias bias;
|
---|
| 279 | if (bias.readLine(line) == success) {
|
---|
| 280 | ++numBiases;
|
---|
[4797] | 281 | rtrover_satBiases& satBiases = biases[numBiases-1];
|
---|
| 282 | satBiases._satellite._system = bias._prn.toAscii()[0];
|
---|
| 283 | satBiases._satellite._number = bias._prn.mid(1).toInt();
|
---|
| 284 | satBiases._time._mjd = bias._time.mjd();
|
---|
| 285 | satBiases._time._sec = bias._time.daysec();
|
---|
| 286 | satBiases._numBiases = bias._value.size();
|
---|
| 287 | satBiases._biases = new rtrover_bias[satBiases._numBiases];
|
---|
[4788] | 288 | int iBias = -1;
|
---|
| 289 | QMapIterator<QByteArray, double> it(bias._value);
|
---|
| 290 | while (it.hasNext()) {
|
---|
| 291 | it.next();
|
---|
| 292 | ++iBias;
|
---|
[4797] | 293 | rtrover_bias& singleBias = satBiases._biases[iBias];
|
---|
[4798] | 294 | singleBias._rnxType3ch[0] = 'C';
|
---|
| 295 | singleBias._rnxType3ch[1] = it.key()[0];
|
---|
| 296 | singleBias._rnxType3ch[2] = it.key()[1];
|
---|
| 297 | singleBias._value = it.value();
|
---|
[4788] | 298 | }
|
---|
| 299 | }
|
---|
[4757] | 300 | }
|
---|
[4788] | 301 |
|
---|
| 302 | // Pass Corrections and Biases to client library
|
---|
| 303 | // ---------------------------------------------
|
---|
[4770] | 304 | if (numOrbCorr > 0) {
|
---|
| 305 | rtrover_putOrbCorrections(numOrbCorr, orbCorr);
|
---|
| 306 | }
|
---|
| 307 | if (numClkCorr > 0) {
|
---|
| 308 | rtrover_putClkCorrections(numClkCorr, clkCorr);
|
---|
| 309 | }
|
---|
[4788] | 310 | if (numBiases > 0) {
|
---|
| 311 | rtrover_putBiases(numBiases, biases);
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | // Clean the memory
|
---|
| 315 | // ----------------
|
---|
| 316 | for (int ii = 0; ii < numBiases; ii++) {
|
---|
| 317 | delete [] biases[ii]._biases;
|
---|
| 318 | }
|
---|
[4757] | 319 | }
|
---|
| 320 |
|
---|
[4773] | 321 | // Auxiliary function - copy observation data
|
---|
| 322 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 323 | void copyObs(const t_obs& obsBnc, rtrover_satObs& satObs) {
|
---|
[4781] | 324 |
|
---|
[4778] | 325 | bncTime obsTime(obsBnc.GPSWeek, obsBnc.GPSWeeks);
|
---|
[4775] | 326 | satObs._satellite._system = obsBnc.satSys;
|
---|
| 327 | satObs._satellite._number = obsBnc.satNum;
|
---|
[4778] | 328 | satObs._time._mjd = obsTime.mjd();
|
---|
| 329 | satObs._time._sec = obsTime.daysec();
|
---|
| 330 | satObs._slotNumber = obsBnc.slotNum;
|
---|
[4781] | 331 |
|
---|
[4776] | 332 | QMap<QByteArray, rtrover_obs> allObs;
|
---|
[4775] | 333 | for (int iEntry = 0; iEntry < GNSSENTRY_NUMBER; ++iEntry) {
|
---|
[4776] | 334 | if (obsBnc._measdata[iEntry] != 0.0) {
|
---|
| 335 | QByteArray rnxStr = obsBnc.rnxStr(iEntry).toAscii();
|
---|
[5493] | 336 | if (rnxStr.length() >= 2) {
|
---|
| 337 | if (rnxStr == "L1") {
|
---|
| 338 | rnxStr = "L1C";
|
---|
| 339 | }
|
---|
| 340 | else if (rnxStr == "L2") {
|
---|
| 341 | rnxStr = "L2P";
|
---|
| 342 | }
|
---|
[4776] | 343 | QByteArray codeType = rnxStr.mid(1);
|
---|
[4781] | 344 |
|
---|
| 345 | bool existed = allObs.contains(codeType);
|
---|
| 346 | rtrover_obs& currObs = allObs[codeType];
|
---|
| 347 | if (!existed) {
|
---|
| 348 | rtrover_initObs(&currObs);
|
---|
[4798] | 349 | currObs._rnxType2ch[0] = codeType[0];
|
---|
| 350 | currObs._rnxType2ch[1] = codeType[1];
|
---|
[4776] | 351 | }
|
---|
[4781] | 352 |
|
---|
[4776] | 353 | if (rnxStr[0] == 'C') {
|
---|
[4780] | 354 | currObs._code = obsBnc._measdata[iEntry];
|
---|
| 355 | currObs._codeValid = true;
|
---|
[4776] | 356 | }
|
---|
| 357 | else if (rnxStr[0] == 'L') {
|
---|
[4780] | 358 | currObs._phase = obsBnc._measdata[iEntry];
|
---|
| 359 | currObs._phaseValid = true;
|
---|
| 360 | if (codeType[0] == '1') {
|
---|
| 361 | currObs._slip = obsBnc.slipL1;
|
---|
| 362 | currObs._slipCounter = obsBnc.slip_cnt_L1;
|
---|
| 363 | }
|
---|
| 364 | else if (codeType[0] == '2') {
|
---|
| 365 | currObs._slip = obsBnc.slipL2;
|
---|
| 366 | currObs._slipCounter = obsBnc.slip_cnt_L2;
|
---|
| 367 | }
|
---|
| 368 | else if (codeType[0] == '5') {
|
---|
| 369 | currObs._slip = obsBnc.slipL5;
|
---|
| 370 | currObs._slipCounter = obsBnc.slip_cnt_L5;
|
---|
| 371 | }
|
---|
[4776] | 372 | }
|
---|
| 373 | else if (rnxStr[0] == 'D') {
|
---|
[4780] | 374 | currObs._doppler = obsBnc._measdata[iEntry];
|
---|
| 375 | currObs._dopplerValid = true;
|
---|
[4776] | 376 | }
|
---|
| 377 | else if (rnxStr[0] == 'S') {
|
---|
[4780] | 378 | currObs._snr = obsBnc._measdata[iEntry];
|
---|
| 379 | currObs._snrValid = true;
|
---|
[4776] | 380 | }
|
---|
| 381 | }
|
---|
| 382 | }
|
---|
[4775] | 383 | }
|
---|
[4781] | 384 | satObs._numObs = allObs.size();
|
---|
| 385 | satObs._obs = new rtrover_obs[satObs._numObs];
|
---|
[4782] | 386 | int iObs = -1;
|
---|
[4781] | 387 | QMapIterator<QByteArray, rtrover_obs> it(allObs);
|
---|
| 388 | while (it.hasNext()) {
|
---|
| 389 | it.next();
|
---|
| 390 | ++iObs;
|
---|
| 391 | satObs._obs[iObs] = it.value();
|
---|
| 392 | }
|
---|
[4773] | 393 | }
|
---|
| 394 |
|
---|
[4757] | 395 | //
|
---|
| 396 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5525] | 397 | void t_bncRtrover::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
|
---|
[4757] | 398 | QMutexLocker locker(&_mutex);
|
---|
| 399 |
|
---|
[4768] | 400 | if (staID != _roverMount && staID != _baseMount) {
|
---|
| 401 | return;
|
---|
[4757] | 402 | }
|
---|
| 403 |
|
---|
[5590] | 404 | // Store Observations into epochs
|
---|
| 405 | // ------------------------------
|
---|
[5525] | 406 | QListIterator<t_obs> it(obsList);
|
---|
| 407 | while (it.hasNext()) {
|
---|
[4773] | 408 |
|
---|
[5525] | 409 | const t_obs& obsIn = it.next();
|
---|
| 410 |
|
---|
| 411 | bncTime obsTime(obsIn.GPSWeek, obsIn.GPSWeeks);
|
---|
| 412 |
|
---|
| 413 | // Find corresponding epoch or create a new one
|
---|
| 414 | // --------------------------------------------
|
---|
| 415 | t_epoData* epoData = 0;
|
---|
| 416 | for (unsigned ii = 0; ii < _epochs.size(); ii++) {
|
---|
| 417 | if (_epochs[ii]->_time == obsTime) {
|
---|
| 418 | epoData = _epochs[ii];
|
---|
| 419 | break;
|
---|
| 420 | }
|
---|
[4773] | 421 | }
|
---|
[5525] | 422 | if (epoData == 0) {
|
---|
| 423 | if (_epochs.size() == 0 || _epochs.back()->_time < obsTime) {
|
---|
| 424 | epoData = new t_epoData();
|
---|
| 425 | epoData->_time = obsTime;
|
---|
| 426 | _epochs.push_back(epoData);
|
---|
| 427 | }
|
---|
| 428 | else {
|
---|
[5588] | 429 | continue;
|
---|
[5525] | 430 | }
|
---|
[4773] | 431 | }
|
---|
[5525] | 432 |
|
---|
| 433 | // Store observation into epoch class
|
---|
| 434 | // ----------------------------------
|
---|
| 435 | if (staID == _roverMount) {
|
---|
| 436 | epoData->_obsRover.push_back(obsIn);
|
---|
| 437 | }
|
---|
| 438 | else if (staID == _baseMount) {
|
---|
| 439 | epoData->_obsBase.push_back(obsIn);
|
---|
| 440 | }
|
---|
[5590] | 441 | }
|
---|
[5525] | 442 |
|
---|
[5590] | 443 | // Process Epochs
|
---|
| 444 | // --------------
|
---|
| 445 | while (_epochs.size() > 1) {
|
---|
[5525] | 446 | const double WAITTIME = 5.0;
|
---|
[5590] | 447 | double dt = _epochs.back()->_time - _epochs.front()->_time;
|
---|
| 448 | if (dt > WAITTIME) {
|
---|
| 449 | processFrontEpoch();
|
---|
[5525] | 450 | }
|
---|
[5590] | 451 | else {
|
---|
| 452 | break;
|
---|
[5525] | 453 | }
|
---|
[5589] | 454 | }
|
---|
| 455 | }
|
---|
[5525] | 456 |
|
---|
[5589] | 457 | //
|
---|
| 458 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 459 | void t_bncRtrover::processFrontEpoch() {
|
---|
| 460 |
|
---|
| 461 | // Copy observations into rtrover_satObs structures
|
---|
| 462 | // ------------------------------------------------
|
---|
| 463 | t_epoData* frontEpoData = _epochs.front();
|
---|
| 464 | _epochs.erase(_epochs.begin());
|
---|
| 465 |
|
---|
| 466 | int numSatRover = frontEpoData->_obsRover.size();
|
---|
| 467 | rtrover_satObs satObsRover[numSatRover];
|
---|
| 468 | for (int ii = 0; ii < numSatRover; ii++) {
|
---|
| 469 | const t_obs& obsBnc = frontEpoData->_obsRover[ii];
|
---|
| 470 | rtrover_satObs& satObs = satObsRover[ii];
|
---|
| 471 | copyObs(obsBnc, satObs);
|
---|
[4773] | 472 | }
|
---|
[5590] | 473 |
|
---|
[5589] | 474 | int numSatBase = frontEpoData->_obsBase.size();
|
---|
| 475 | rtrover_satObs satObsBase[numSatBase];
|
---|
| 476 | for (int ii = 0; ii < numSatBase; ii++) {
|
---|
| 477 | const t_obs& obsBnc = frontEpoData->_obsBase[ii];
|
---|
| 478 | rtrover_satObs& satObs = satObsBase[ii];
|
---|
| 479 | copyObs(obsBnc, satObs);
|
---|
| 480 | }
|
---|
| 481 |
|
---|
| 482 | delete frontEpoData;
|
---|
| 483 |
|
---|
| 484 | // Process single epoch
|
---|
| 485 | // --------------------
|
---|
| 486 | rtrover_output output;
|
---|
| 487 | rtrover_processEpoch(numSatRover, satObsRover, numSatBase, satObsBase, &output);
|
---|
| 488 |
|
---|
| 489 | // Write output
|
---|
| 490 | // ---------------------
|
---|
| 491 | _outputFile.write(output._log);
|
---|
| 492 | _outputFile.flush();
|
---|
| 493 |
|
---|
| 494 | // Free memory
|
---|
| 495 | // -----------
|
---|
| 496 | rtrover_freeOutput(&output);
|
---|
| 497 | for (int ii = 0; ii < numSatRover; ii++) {
|
---|
| 498 | rtrover_satObs& satObs = satObsRover[ii];
|
---|
| 499 | delete [] satObs._obs;
|
---|
| 500 | }
|
---|
| 501 | for (int ii = 0; ii < numSatBase; ii++) {
|
---|
| 502 | rtrover_satObs& satObs = satObsBase[ii];
|
---|
| 503 | delete [] satObs._obs;
|
---|
| 504 | }
|
---|
[4757] | 505 | }
|
---|