| 1 | /* -------------------------------------------------------------------------
|
|---|
| 2 | * BKG NTRIP Client
|
|---|
| 3 | * -------------------------------------------------------------------------
|
|---|
| 4 | *
|
|---|
| 5 | * Class: bncComb
|
|---|
| 6 | *
|
|---|
| 7 | * Purpose: Combinations of Orbit/Clock Corrections
|
|---|
| 8 | *
|
|---|
| 9 | * Author: L. Mervart
|
|---|
| 10 | *
|
|---|
| 11 | * Created: 22-Jan-2011
|
|---|
| 12 | *
|
|---|
| 13 | * Changes:
|
|---|
| 14 | *
|
|---|
| 15 | * -----------------------------------------------------------------------*/
|
|---|
| 16 |
|
|---|
| 17 | #include <newmatio.h>
|
|---|
| 18 | #include <iomanip>
|
|---|
| 19 | #include <sstream>
|
|---|
| 20 | #include <map>
|
|---|
| 21 |
|
|---|
| 22 | #include "bnccomb.h"
|
|---|
| 23 | #include <combination/bncbiassnx.h>
|
|---|
| 24 | #include "bnccore.h"
|
|---|
| 25 | #include "upload/bncrtnetdecoder.h"
|
|---|
| 26 | #include "bncsettings.h"
|
|---|
| 27 | #include "bncutils.h"
|
|---|
| 28 | #include "bncantex.h"
|
|---|
| 29 | #include "t_prn.h"
|
|---|
| 30 |
|
|---|
| 31 | const double sig0_offAC = 1000.0;
|
|---|
| 32 | const double sig0_offACSat = 100.0;
|
|---|
| 33 | const double sigP_offACSat = 0.01;
|
|---|
| 34 | const double sig0_clkSat = 100.0;
|
|---|
| 35 |
|
|---|
| 36 | const double sigObs = 0.05;
|
|---|
| 37 |
|
|---|
| 38 | using namespace std;
|
|---|
| 39 |
|
|---|
| 40 | // Constructor
|
|---|
| 41 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 42 | bncComb::cmbParam::cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_) {
|
|---|
| 43 |
|
|---|
| 44 | type = type_;
|
|---|
| 45 | index = index_;
|
|---|
| 46 | AC = ac_;
|
|---|
| 47 | prn = prn_;
|
|---|
| 48 | xx = 0.0;
|
|---|
| 49 | eph = 0;
|
|---|
| 50 |
|
|---|
| 51 | if (type == offACgnss) {
|
|---|
| 52 | epoSpec = true;
|
|---|
| 53 | sig0 = sig0_offAC;
|
|---|
| 54 | sigP = sig0;
|
|---|
| 55 | }
|
|---|
| 56 | else if (type == offACSat) {
|
|---|
| 57 | epoSpec = false;
|
|---|
| 58 | sig0 = sig0_offACSat;
|
|---|
| 59 | sigP = sigP_offACSat;
|
|---|
| 60 | }
|
|---|
| 61 | else if (type == clkSat) {
|
|---|
| 62 | epoSpec = true;
|
|---|
| 63 | sig0 = sig0_clkSat;
|
|---|
| 64 | sigP = sig0;
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | // Destructor
|
|---|
| 69 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 70 | bncComb::cmbParam::~cmbParam() {
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | // Partial
|
|---|
| 74 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 75 | double bncComb::cmbParam::partial(char sys, const QString& AC_, const QString& prn_) {
|
|---|
| 76 |
|
|---|
| 77 | if (type == offACgnss) {
|
|---|
| 78 | if (AC == AC_ && prn_[0].toLatin1() == sys) {
|
|---|
| 79 | return 1.0;
|
|---|
| 80 | }
|
|---|
| 81 | }
|
|---|
| 82 | else if (type == offACSat) {
|
|---|
| 83 | if (AC == AC_ && prn == prn_) {
|
|---|
| 84 | return 1.0;
|
|---|
| 85 | }
|
|---|
| 86 | }
|
|---|
| 87 | else if (type == clkSat) {
|
|---|
| 88 | if (prn == prn_) {
|
|---|
| 89 | return 1.0;
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | return 0.0;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | //
|
|---|
| 97 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 98 | QString bncComb::cmbParam::toString(char sys) const {
|
|---|
| 99 |
|
|---|
| 100 | QString outStr;
|
|---|
| 101 |
|
|---|
| 102 | if (type == offACgnss) {
|
|---|
| 103 | outStr = "AC Offset " + AC + " " + sys + " ";
|
|---|
| 104 | }
|
|---|
| 105 | else if (type == offACSat) {
|
|---|
| 106 | outStr = "Sat Offset " + AC + " " + prn.mid(0,3);
|
|---|
| 107 | }
|
|---|
| 108 | else if (type == clkSat) {
|
|---|
| 109 | outStr = "Clk Corr " + prn.mid(0,3);
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | return outStr;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // Singleton: definition class variable
|
|---|
| 116 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 117 | bncComb* bncComb::instance = nullptr;
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | // Constructor
|
|---|
| 121 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 122 | bncComb::bncComb() : _ephUser(true) {
|
|---|
| 123 |
|
|---|
| 124 | bncSettings settings;
|
|---|
| 125 |
|
|---|
| 126 | _running = true;
|
|---|
| 127 |
|
|---|
| 128 | QStringList cmbStreams = settings.value("cmbStreams").toStringList();
|
|---|
| 129 |
|
|---|
| 130 | _cmbSampl = settings.value("cmbSampl").toString().split("sec").first().toInt();
|
|---|
| 131 | if (_cmbSampl <= 0) {
|
|---|
| 132 | _cmbSampl = 5;
|
|---|
| 133 | }
|
|---|
| 134 | _useGps = (Qt::CheckState(settings.value("cmbGps").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 135 | if (_useGps) {
|
|---|
| 136 | _cmbSysPrn['G'] = t_prn::MAXPRN_GPS;
|
|---|
| 137 | _masterMissingEpochs['G'] = 0;
|
|---|
| 138 | }
|
|---|
| 139 | _useGlo = (Qt::CheckState(settings.value("cmbGlo").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 140 | if (_useGlo) {
|
|---|
| 141 | _cmbSysPrn['R'] = t_prn::MAXPRN_GLONASS;
|
|---|
| 142 | _masterMissingEpochs['R'] = 0;
|
|---|
| 143 | }
|
|---|
| 144 | _useGal = (Qt::CheckState(settings.value("cmbGal").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 145 | if (_useGal) {
|
|---|
| 146 | _cmbSysPrn['E'] = t_prn::MAXPRN_GALILEO;
|
|---|
| 147 | _masterMissingEpochs['E'] = 0;
|
|---|
| 148 | }
|
|---|
| 149 | _useBds = (Qt::CheckState(settings.value("cmbBds").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 150 | if (_useBds) {
|
|---|
| 151 | _cmbSysPrn['C'] = t_prn::MAXPRN_BDS;
|
|---|
| 152 | _masterMissingEpochs['C'] = 0;
|
|---|
| 153 | }
|
|---|
| 154 | _useQzss = (Qt::CheckState(settings.value("cmbQzss").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 155 | if (_useQzss) {
|
|---|
| 156 | _cmbSysPrn['J'] = t_prn::MAXPRN_QZSS;
|
|---|
| 157 | _masterMissingEpochs['J'] = 0;
|
|---|
| 158 | }
|
|---|
| 159 | _useSbas = (Qt::CheckState(settings.value("cmbSbas").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 160 | if (_useSbas) {
|
|---|
| 161 | _cmbSysPrn['S'] = t_prn::MAXPRN_SBAS;
|
|---|
| 162 | _masterMissingEpochs['S'] = 0;
|
|---|
| 163 | }
|
|---|
| 164 | _useNavic = (Qt::CheckState(settings.value("cmbNavic").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 165 | if (_useNavic) {
|
|---|
| 166 | _cmbSysPrn['I'] = t_prn::MAXPRN_NavIC;
|
|---|
| 167 | _masterMissingEpochs['I'] = 0;
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | if (cmbStreams.size() >= 1 && !cmbStreams[0].isEmpty()) {
|
|---|
| 171 | QListIterator<QString> it(cmbStreams);
|
|---|
| 172 | while (it.hasNext()) {
|
|---|
| 173 | QStringList hlp = it.next().split(" ");
|
|---|
| 174 | cmbAC* newAC = new cmbAC();
|
|---|
| 175 | newAC->mountPoint = hlp[0];
|
|---|
| 176 | newAC->name = hlp[1];
|
|---|
| 177 | newAC->weightFactor = hlp[2].toDouble();
|
|---|
| 178 | newAC->excludeSats = hlp[3].split(QRegExp("[ ,]"), Qt::SkipEmptyParts);
|
|---|
| 179 | newAC->isAPC = bool(newAC->mountPoint.mid(0,4) == "SSRA");
|
|---|
| 180 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 181 | // init
|
|---|
| 182 | while (itSys.hasNext()) {
|
|---|
| 183 | itSys.next();
|
|---|
| 184 | char sys = itSys.key();
|
|---|
| 185 | if (!_masterOrbitAC.contains(sys) &&
|
|---|
| 186 | !newAC->excludeSats.contains(QString(sys), Qt::CaseSensitive)) {
|
|---|
| 187 | _masterOrbitAC[sys] = newAC->name;
|
|---|
| 188 | _masterIsAPC[sys] = newAC->isAPC;
|
|---|
| 189 | }
|
|---|
| 190 | }
|
|---|
| 191 | _ACs.append(newAC);
|
|---|
| 192 | }
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | QString ssrFormat;
|
|---|
| 196 | _ssrCorr = 0;
|
|---|
| 197 | QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
|
|---|
| 198 | while (it.hasNext()) {
|
|---|
| 199 | QStringList hlp = it.next().split(",");
|
|---|
| 200 | if (hlp.size() > 7) {
|
|---|
| 201 | ssrFormat = hlp[7];
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 | if (ssrFormat == "IGS-SSR") {
|
|---|
| 205 | _ssrCorr = new SsrCorrIgs();
|
|---|
| 206 | }
|
|---|
| 207 | else if (ssrFormat == "RTCM-SSR") {
|
|---|
| 208 | _ssrCorr = new SsrCorrRtcm();
|
|---|
| 209 | }
|
|---|
| 210 | else if (ssrFormat == "RTCM-NEW-SSR") {
|
|---|
| 211 | _ssrCorr = new SsrCorrRtcmNew();
|
|---|
| 212 | }
|
|---|
| 213 | else { // default
|
|---|
| 214 | _ssrCorr = new SsrCorrIgs();
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | _rtnetDecoder = new bncRtnetDecoder();
|
|---|
| 218 |
|
|---|
| 219 | connect(this, SIGNAL(newMessage(QByteArray,bool)), BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| 220 | connect(BNC_CORE, SIGNAL(providerIDChanged(QString)), this, SLOT(slotProviderIDChanged(QString)));
|
|---|
| 221 | connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
|---|
| 222 | connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)), this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
|---|
| 223 | connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)), this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
|---|
| 224 | connect(BNC_CORE, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)), this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)));
|
|---|
| 225 |
|
|---|
| 226 | // Combination Method
|
|---|
| 227 | // ------------------
|
|---|
| 228 | if (settings.value("cmbMethod").toString() == "Single-Epoch") {
|
|---|
| 229 | _method = singleEpoch;
|
|---|
| 230 | }
|
|---|
| 231 | else {
|
|---|
| 232 | _method = filter;
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
|
|---|
| 236 | // ----------------------------------------------------------------------
|
|---|
| 237 | if (_method == filter) {
|
|---|
| 238 | // SYSTEM
|
|---|
| 239 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 240 | while (itSys.hasNext()) {
|
|---|
| 241 | itSys.next();
|
|---|
| 242 | int nextPar = 0;
|
|---|
| 243 | char sys = itSys.key();
|
|---|
| 244 | int maxPrn = itSys.value();
|
|---|
| 245 | // AC
|
|---|
| 246 | QListIterator<cmbAC*> itAc(_ACs);
|
|---|
| 247 | while (itAc.hasNext()) {
|
|---|
| 248 | cmbAC* AC = itAc.next();
|
|---|
| 249 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC->name, ""));
|
|---|
| 250 | for (int iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
|---|
| 251 | int flag = t_corrSSR::getSsrNavTypeFlag(sys, iGnss);
|
|---|
| 252 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
|---|
| 253 | _params[sys].push_back(new cmbParam(cmbParam::offACSat, ++nextPar, AC->name, prn));
|
|---|
| 254 | }
|
|---|
| 255 | }
|
|---|
| 256 | for (int iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
|---|
| 257 | int flag = t_corrSSR::getSsrNavTypeFlag(sys, iGnss);
|
|---|
| 258 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
|---|
| 259 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
|---|
| 260 | }
|
|---|
| 261 | // Initialize Variance-Covariance Matrix
|
|---|
| 262 | // -------------------------------------
|
|---|
| 263 | _QQ[sys].ReSize(_params[sys].size());
|
|---|
| 264 | _QQ[sys] = 0.0;
|
|---|
| 265 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 266 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 267 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | // ANTEX File
|
|---|
| 273 | // ----------
|
|---|
| 274 | _antex = 0;
|
|---|
| 275 | QString antexFileName = settings.value("uploadAntexFile").toString();
|
|---|
| 276 | if (!antexFileName.isEmpty()) {
|
|---|
| 277 | _antex = new bncAntex();
|
|---|
| 278 | if (_antex->readFile(antexFileName) != success) {
|
|---|
| 279 | emit newMessage("bncComb: wrong ANTEX file", true);
|
|---|
| 280 | delete _antex;
|
|---|
| 281 | _antex = 0;
|
|---|
| 282 | }
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 | // Bias SINEX File
|
|---|
| 287 | // ---------------
|
|---|
| 288 | _bsx = 0;
|
|---|
| 289 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
|---|
| 290 | if (!bsxFileName.isEmpty()) {
|
|---|
| 291 | _bsx = new bncBiasSnx();
|
|---|
| 292 | if (_bsx->readFile(bsxFileName) != success) {
|
|---|
| 293 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
|---|
| 294 | delete _bsx;
|
|---|
| 295 | _bsx = 0;
|
|---|
| 296 | }
|
|---|
| 297 | }
|
|---|
| 298 | if (_bsx) {
|
|---|
| 299 | _ms = 3.0 * 3600 * 1000.0;
|
|---|
| 300 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | // Maximal Residuum
|
|---|
| 304 | // ----------------
|
|---|
| 305 | _MAX_RES = settings.value("cmbMaxres").toDouble();
|
|---|
| 306 | if (_MAX_RES <= 0.0) {
|
|---|
| 307 | _MAX_RES = 999.0;
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | // Maximal Displacement
|
|---|
| 311 | // --------------------
|
|---|
| 312 | _MAX_DISPLACEMENT = settings.value("cmbMaxdisplacement").toDouble();
|
|---|
| 313 | if (_MAX_DISPLACEMENT <= 0.0) {
|
|---|
| 314 | _MAX_DISPLACEMENT = 2.0;
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | // Logfile
|
|---|
| 318 | // -------
|
|---|
| 319 | QString intr = "1 day";
|
|---|
| 320 | QString logFileCmb = settings.value("cmbLogpath").toString();
|
|---|
| 321 | int l = logFileCmb.length();
|
|---|
| 322 | if (logFileCmb.isEmpty()) {
|
|---|
| 323 | _logFile = 0;
|
|---|
| 324 | }
|
|---|
| 325 | else {
|
|---|
| 326 | if (l && logFileCmb[l-1] != QDir::separator() ) {
|
|---|
| 327 | logFileCmb += QDir::separator();
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | logFileCmb = logFileCmb + "COMB00BNC" + "${V3PROD}" + ".CMB";
|
|---|
| 331 |
|
|---|
| 332 | _logFile = new bncoutf(logFileCmb, intr, _cmbSampl);
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | _newCorr = 0;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | // Destructor
|
|---|
| 339 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 340 | bncComb::~bncComb() {
|
|---|
| 341 |
|
|---|
| 342 | _running = false;
|
|---|
| 343 | #ifndef WIN32
|
|---|
| 344 | sleep(2);
|
|---|
| 345 | #else
|
|---|
| 346 | Sleep(2000);
|
|---|
| 347 | #endif
|
|---|
| 348 |
|
|---|
| 349 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 350 | while (icAC.hasNext()) {
|
|---|
| 351 | delete icAC.next();
|
|---|
| 352 | }
|
|---|
| 353 | _ACs.clear();
|
|---|
| 354 |
|
|---|
| 355 | delete _rtnetDecoder;
|
|---|
| 356 |
|
|---|
| 357 | if (_ssrCorr) {
|
|---|
| 358 | delete _ssrCorr;
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | if (_newCorr) {
|
|---|
| 362 | delete _newCorr;
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | delete _antex;
|
|---|
| 366 | delete _bsx;
|
|---|
| 367 | delete _logFile;
|
|---|
| 368 |
|
|---|
| 369 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 370 | while (itSys.hasNext()) {
|
|---|
| 371 | itSys.next();
|
|---|
| 372 | char sys = itSys.key();
|
|---|
| 373 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 374 | delete _params[sys][iPar-1];
|
|---|
| 375 | }
|
|---|
| 376 | _buffer.remove(sys);
|
|---|
| 377 | }
|
|---|
| 378 | _params.clear();
|
|---|
| 379 | _buffer.clear();
|
|---|
| 380 | _cmbSysPrn.clear();
|
|---|
| 381 |
|
|---|
| 382 | while (!_epoClkData.empty()) {
|
|---|
| 383 | delete _epoClkData.front();
|
|---|
| 384 | _epoClkData.pop_front();
|
|---|
| 385 | }
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | void bncComb::slotReadBiasSnxFile() {
|
|---|
| 389 | bncSettings settings;
|
|---|
| 390 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
|---|
| 391 |
|
|---|
| 392 | if (bsxFileName.isEmpty()) {
|
|---|
| 393 | emit newMessage("bncComb: no Bias SINEX file specified", true);
|
|---|
| 394 | return;
|
|---|
| 395 | }
|
|---|
| 396 | if (!_bsx) {
|
|---|
| 397 | _bsx = new bncBiasSnx();
|
|---|
| 398 | }
|
|---|
| 399 | if (_bsx->readFile(bsxFileName) != success) {
|
|---|
| 400 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
|---|
| 401 | delete _bsx;
|
|---|
| 402 | _bsx = 0;
|
|---|
| 403 | }
|
|---|
| 404 | else {
|
|---|
| 405 | emit newMessage("bncComb: successfully read Bias SINEX file", true);
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
|---|
| 409 | }
|
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 | // Remember orbit corrections
|
|---|
| 413 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 414 | void bncComb::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
|
|---|
| 415 | QMutexLocker locker(&_mutex);
|
|---|
| 416 | for (int ii = 0; ii < orbCorrections.size(); ii++) {
|
|---|
| 417 | t_orbCorr& orbCorr = orbCorrections[ii];
|
|---|
| 418 | QString staID(orbCorr._staID.c_str());
|
|---|
| 419 | char sys = orbCorr._prn.system();
|
|---|
| 420 |
|
|---|
| 421 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 422 | continue;
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 | // Find/Check the AC Name
|
|---|
| 426 | // ----------------------
|
|---|
| 427 | QString acName;
|
|---|
| 428 | QStringList excludeSats;
|
|---|
| 429 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 430 | while (icAC.hasNext()) {
|
|---|
| 431 | cmbAC* AC = icAC.next();
|
|---|
| 432 | if (AC->mountPoint == staID) {
|
|---|
| 433 | acName = AC->name;
|
|---|
| 434 | excludeSats = AC->excludeSats;
|
|---|
| 435 | break;
|
|---|
| 436 | }
|
|---|
| 437 | }
|
|---|
| 438 | if (acName.isEmpty() || excludeSat(orbCorr._prn, excludeSats)) {
|
|---|
| 439 | continue;
|
|---|
| 440 | }
|
|---|
| 441 |
|
|---|
| 442 | // Store the correction
|
|---|
| 443 | // --------------------
|
|---|
| 444 | QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
|
|---|
| 445 | storage[orbCorr._prn] = orbCorr;
|
|---|
| 446 | }
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | // Remember Satellite Code Biases
|
|---|
| 450 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 451 | void bncComb::slotNewCodeBiases(QList<t_satCodeBias> satCodeBiases) {
|
|---|
| 452 | QMutexLocker locker(&_mutex);
|
|---|
| 453 |
|
|---|
| 454 | for (int ii = 0; ii < satCodeBiases.size(); ii++) {
|
|---|
| 455 | t_satCodeBias& satCodeBias = satCodeBiases[ii];
|
|---|
| 456 | QString staID(satCodeBias._staID.c_str());
|
|---|
| 457 | char sys = satCodeBias._prn.system();
|
|---|
| 458 |
|
|---|
| 459 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 460 | continue;
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 | // Find/Check the AC Name
|
|---|
| 464 | // ----------------------
|
|---|
| 465 | QString acName;
|
|---|
| 466 | QStringList excludeSats;
|
|---|
| 467 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 468 | while (icAC.hasNext()) {
|
|---|
| 469 | cmbAC* AC = icAC.next();
|
|---|
| 470 | if (AC->mountPoint == staID) {
|
|---|
| 471 | acName = AC->name;
|
|---|
| 472 | excludeSats = AC->excludeSats;
|
|---|
| 473 | break;
|
|---|
| 474 | }
|
|---|
| 475 | }
|
|---|
| 476 | if (acName.isEmpty() || excludeSat(satCodeBias._prn, excludeSats)) {
|
|---|
| 477 | continue;
|
|---|
| 478 | }
|
|---|
| 479 |
|
|---|
| 480 | // Store the correction
|
|---|
| 481 | // --------------------
|
|---|
| 482 | QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
|
|---|
| 483 | storage[satCodeBias._prn] = satCodeBias;
|
|---|
| 484 | }
|
|---|
| 485 | return;
|
|---|
| 486 | }
|
|---|
| 487 |
|
|---|
| 488 | // Remember Satellite Phase Biases
|
|---|
| 489 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 490 | void bncComb::slotNewPhaseBiases(QList<t_satPhaseBias> satPhaseBiases) {
|
|---|
| 491 | QMutexLocker locker(&_mutex);
|
|---|
| 492 |
|
|---|
| 493 | for (int ii = 0; ii < satPhaseBiases.size(); ii++) {
|
|---|
| 494 | t_satPhaseBias& satPhaseBias = satPhaseBiases[ii];
|
|---|
| 495 | QString staID(satPhaseBias._staID.c_str());
|
|---|
| 496 | char sys = satPhaseBias._prn.system();
|
|---|
| 497 |
|
|---|
| 498 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 499 | continue;
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | // Find/Check the AC Name
|
|---|
| 503 | // ----------------------
|
|---|
| 504 | QString acName;
|
|---|
| 505 | QStringList excludeSats;
|
|---|
| 506 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 507 | while (icAC.hasNext()) {
|
|---|
| 508 | cmbAC* AC = icAC.next();
|
|---|
| 509 | if (AC->mountPoint == staID) {
|
|---|
| 510 | acName = AC->name;
|
|---|
| 511 | excludeSats = AC->excludeSats;
|
|---|
| 512 | break;
|
|---|
| 513 | }
|
|---|
| 514 | }
|
|---|
| 515 | if (acName.isEmpty() || excludeSat(satPhaseBias._prn, excludeSats)) {
|
|---|
| 516 | continue;
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | // Store the correction
|
|---|
| 520 | // --------------------
|
|---|
| 521 | QMap<t_prn, t_satPhaseBias>& storage = _satPhaseBiases[acName];
|
|---|
| 522 | storage[satPhaseBias._prn] = satPhaseBias;
|
|---|
| 523 | }
|
|---|
| 524 | return;
|
|---|
| 525 | }
|
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 | // Process clock corrections
|
|---|
| 529 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 530 | void bncComb::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
|
|---|
| 531 | QMutexLocker locker(&_mutex);
|
|---|
| 532 | const double outWait = 1.0 * _cmbSampl;
|
|---|
| 533 | int currentWeek = 0;
|
|---|
| 534 | double currentSec = 0.0;
|
|---|
| 535 | currentGPSWeeks(currentWeek, currentSec);
|
|---|
| 536 | bncTime currentTime(currentWeek, currentSec);
|
|---|
| 537 |
|
|---|
| 538 | // Loop over all observations (possible different epochs)
|
|---|
| 539 | // -----------------------------------------------------
|
|---|
| 540 | for (int ii = 0; ii < clkCorrections.size(); ii++) {
|
|---|
| 541 | t_clkCorr& newClk = clkCorrections[ii];
|
|---|
| 542 | char sys = newClk._prn.system();
|
|---|
| 543 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 544 | continue;
|
|---|
| 545 | }
|
|---|
| 546 |
|
|---|
| 547 | // Check Modulo Time
|
|---|
| 548 | // -----------------
|
|---|
| 549 | int sec = int(nint(newClk._time.gpssec()*10));
|
|---|
| 550 | if (sec % (_cmbSampl*10) != 0.0) {
|
|---|
| 551 | continue;
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | // Find/Check the AC Name
|
|---|
| 555 | // ----------------------
|
|---|
| 556 | QString acName;
|
|---|
| 557 | QStringList excludeSats;
|
|---|
| 558 | bool isAPC;
|
|---|
| 559 | QString staID(newClk._staID.c_str());
|
|---|
| 560 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 561 | while (icAC.hasNext()) {
|
|---|
| 562 | cmbAC* AC = icAC.next();
|
|---|
| 563 | if (AC->mountPoint == staID) {
|
|---|
| 564 | acName = AC->name;
|
|---|
| 565 | excludeSats = AC->excludeSats;
|
|---|
| 566 | isAPC = AC->isAPC;
|
|---|
| 567 | break;
|
|---|
| 568 | }
|
|---|
| 569 | }
|
|---|
| 570 | if (acName.isEmpty() ||
|
|---|
| 571 | isAPC != _masterIsAPC[sys] ||
|
|---|
| 572 | excludeSat(newClk._prn, excludeSats)) {
|
|---|
| 573 | continue;
|
|---|
| 574 | }
|
|---|
| 575 |
|
|---|
| 576 | // Check regarding current time
|
|---|
| 577 | // ----------------------------
|
|---|
| 578 | if (BNC_CORE->mode() != t_bncCore::batchPostProcessing) {
|
|---|
| 579 | if (fabs(currentTime - newClk._time) > 60.0) { // future or very old data sets
|
|---|
| 580 | #ifdef BNC_DEBUG_CMB
|
|---|
| 581 | emit newMessage("bncComb: future or very old data sets: " + acName.toLatin1() + " " + newClk._prn.toString().c_str() +
|
|---|
| 582 | QString(" %1 ").arg(newClk._time.timestr().c_str()).toLatin1() + "vs. current time" +
|
|---|
| 583 | QString(" %1 ").arg(currentTime.timestr().c_str()).toLatin1(), true);
|
|---|
| 584 | #endif
|
|---|
| 585 | continue;
|
|---|
| 586 | }
|
|---|
| 587 | }
|
|---|
| 588 |
|
|---|
| 589 | // Check Correction Age
|
|---|
| 590 | // --------------------
|
|---|
| 591 | if (_resTime.valid() && newClk._time <= _resTime) {
|
|---|
| 592 | #ifdef BNC_DEBUG_CMB
|
|---|
| 593 | emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + newClk._prn.toString().c_str() +
|
|---|
| 594 | QString(" %1 ").arg(newClk._time.timestr().c_str()).toLatin1() + "vs. last processing Epoch" +
|
|---|
| 595 | QString(" %1 ").arg(_resTime.timestr().c_str()).toLatin1(), true);
|
|---|
| 596 | #endif
|
|---|
| 597 | continue;
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 | // Set the last time
|
|---|
| 601 | // -----------------
|
|---|
| 602 | if (_lastClkCorrTime.undef() || newClk._time > _lastClkCorrTime) {
|
|---|
| 603 | _lastClkCorrTime = newClk._time;
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | // Find the corresponding data epoch or create a new one
|
|---|
| 607 | // -----------------------------------------------------
|
|---|
| 608 | epoClkData* epoch = 0;
|
|---|
| 609 | deque<epoClkData*>::const_iterator it;
|
|---|
| 610 | for (it = _epoClkData.begin(); it != _epoClkData.end(); it++) {
|
|---|
| 611 | if (newClk._time == (*it)->_time) {
|
|---|
| 612 | epoch = *it;
|
|---|
| 613 | break;
|
|---|
| 614 | }
|
|---|
| 615 | }
|
|---|
| 616 | if (epoch == 0) {
|
|---|
| 617 | if (_epoClkData.empty() || newClk._time > _epoClkData.back()->_time) {
|
|---|
| 618 | epoch = new epoClkData;
|
|---|
| 619 | epoch->_time = newClk._time;
|
|---|
| 620 | _epoClkData.push_back(epoch);
|
|---|
| 621 | }
|
|---|
| 622 | }
|
|---|
| 623 |
|
|---|
| 624 | // Put data into the epoch
|
|---|
| 625 | // -----------------------
|
|---|
| 626 | if (epoch != 0) {
|
|---|
| 627 | epoch->_clkCorr.push_back(newClk);
|
|---|
| 628 | }
|
|---|
| 629 | }
|
|---|
| 630 |
|
|---|
| 631 | // Make sure the buffer does not grow beyond any limit
|
|---|
| 632 | // ---------------------------------------------------
|
|---|
| 633 | const unsigned MAX_EPODATA_SIZE = 60.0 / _cmbSampl;
|
|---|
| 634 | if (_epoClkData.size() > MAX_EPODATA_SIZE) {
|
|---|
| 635 | delete _epoClkData.front();
|
|---|
| 636 | _epoClkData.pop_front();
|
|---|
| 637 | }
|
|---|
| 638 |
|
|---|
| 639 | // Process the oldest epochs
|
|---|
| 640 | // ------------------------
|
|---|
| 641 | while (_epoClkData.size()) {
|
|---|
| 642 |
|
|---|
| 643 | if (!_lastClkCorrTime.valid()) {
|
|---|
| 644 | return;
|
|---|
| 645 | }
|
|---|
| 646 |
|
|---|
| 647 | const vector<t_clkCorr>& clkCorrVec = _epoClkData.front()->_clkCorr;
|
|---|
| 648 |
|
|---|
| 649 | bncTime epoTime = _epoClkData.front()->_time;
|
|---|
| 650 |
|
|---|
| 651 | if (BNC_CORE->mode() != t_bncCore::batchPostProcessing) {
|
|---|
| 652 | if ((currentTime - epoTime) > 60.0) {
|
|---|
| 653 | delete _epoClkData.front();
|
|---|
| 654 | _epoClkData.pop_front();
|
|---|
| 655 | continue;
|
|---|
| 656 | }
|
|---|
| 657 | }
|
|---|
| 658 | // Process the front epoch
|
|---|
| 659 | // -----------------------
|
|---|
| 660 | if (epoTime < (_lastClkCorrTime - outWait)) {
|
|---|
| 661 | _resTime = epoTime;
|
|---|
| 662 | processEpoch(_resTime, clkCorrVec);
|
|---|
| 663 | delete _epoClkData.front();
|
|---|
| 664 | _epoClkData.pop_front();
|
|---|
| 665 | }
|
|---|
| 666 | else {
|
|---|
| 667 | return;
|
|---|
| 668 | }
|
|---|
| 669 | }
|
|---|
| 670 | }
|
|---|
| 671 |
|
|---|
| 672 | // Change the correction so that it refers to last received ephemeris
|
|---|
| 673 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 674 | void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
|
|---|
| 675 |
|
|---|
| 676 | if (corr->_eph == lastEph) {
|
|---|
| 677 | return;
|
|---|
| 678 | }
|
|---|
| 679 |
|
|---|
| 680 | ColumnVector oldXC(6);
|
|---|
| 681 | ColumnVector oldVV(3);
|
|---|
| 682 | if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
|
|---|
| 683 | return;
|
|---|
| 684 | }
|
|---|
| 685 |
|
|---|
| 686 | ColumnVector newXC(6);
|
|---|
| 687 | ColumnVector newVV(3);
|
|---|
| 688 | if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
|
|---|
| 689 | return;
|
|---|
| 690 | }
|
|---|
| 691 |
|
|---|
| 692 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
|---|
| 693 | ColumnVector dV = newVV - oldVV;
|
|---|
| 694 | double dC = newXC(4) - oldXC(4);
|
|---|
| 695 |
|
|---|
| 696 | ColumnVector dRAO(3);
|
|---|
| 697 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
|---|
| 698 |
|
|---|
| 699 | ColumnVector dDotRAO(3);
|
|---|
| 700 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
|---|
| 701 |
|
|---|
| 702 | QString msg = "bncComb: switch corr " + corr->_prn.mid(0,3)
|
|---|
| 703 | + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
|---|
| 704 |
|
|---|
| 705 | emit newMessage(msg.toLatin1(), false);
|
|---|
| 706 |
|
|---|
| 707 | corr->_iod = lastEph->IOD();
|
|---|
| 708 | corr->_eph = lastEph;
|
|---|
| 709 |
|
|---|
| 710 | corr->_orbCorr._xr += dRAO;
|
|---|
| 711 | corr->_orbCorr._dotXr += dDotRAO;
|
|---|
| 712 | corr->_clkCorr._dClk -= dC;
|
|---|
| 713 | }
|
|---|
| 714 |
|
|---|
| 715 | // Process Epoch
|
|---|
| 716 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 717 | void bncComb::processEpoch(bncTime epoTime, const vector<t_clkCorr>& clkCorrVec) {
|
|---|
| 718 | QDateTime now = currentDateAndTimeGPS();
|
|---|
| 719 | bncTime currentTime(now.toString(Qt::ISODate).toStdString());
|
|---|
| 720 | for (unsigned ii = 0; ii < clkCorrVec.size(); ii++) {
|
|---|
| 721 | const t_clkCorr& clkCorr = clkCorrVec[ii];
|
|---|
| 722 | QString staID(clkCorr._staID.c_str());
|
|---|
| 723 | QString prnStr(clkCorr._prn.toInternalString().c_str());
|
|---|
| 724 | char sys = clkCorr._prn.system();
|
|---|
| 725 |
|
|---|
| 726 | // Find/Check the AC Name
|
|---|
| 727 | // ----------------------
|
|---|
| 728 | QString acName;
|
|---|
| 729 | double weigthFactor;
|
|---|
| 730 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 731 | while (icAC.hasNext()) {
|
|---|
| 732 | cmbAC* AC = icAC.next();
|
|---|
| 733 | if (AC->mountPoint == staID) {
|
|---|
| 734 | acName = AC->name;
|
|---|
| 735 | weigthFactor = AC->weightFactor;
|
|---|
| 736 | break;
|
|---|
| 737 | }
|
|---|
| 738 | }
|
|---|
| 739 |
|
|---|
| 740 | // Create new correction
|
|---|
| 741 | // ---------------------
|
|---|
| 742 | _newCorr = new cmbCorr();
|
|---|
| 743 | _newCorr->_prn = prnStr;
|
|---|
| 744 | _newCorr->_time = clkCorr._time;
|
|---|
| 745 | _newCorr->_iod = clkCorr._iod;
|
|---|
| 746 | _newCorr->_acName = acName;
|
|---|
| 747 | _newCorr->_weightFactor = weigthFactor;
|
|---|
| 748 | _newCorr->_clkCorr = clkCorr;
|
|---|
| 749 |
|
|---|
| 750 | // Check orbit correction
|
|---|
| 751 | // ----------------------
|
|---|
| 752 | if (!_orbCorrections.contains(acName)) {
|
|---|
| 753 | delete _newCorr; _newCorr = 0;
|
|---|
| 754 | continue;
|
|---|
| 755 | }
|
|---|
| 756 | else {
|
|---|
| 757 | QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
|
|---|
| 758 | if (!storage.contains(clkCorr._prn) ||
|
|---|
| 759 | storage[clkCorr._prn]._iod != _newCorr->_iod) {
|
|---|
| 760 | delete _newCorr; _newCorr = 0;
|
|---|
| 761 | continue;
|
|---|
| 762 | }
|
|---|
| 763 | else {
|
|---|
| 764 | _newCorr->_orbCorr = storage[clkCorr._prn];
|
|---|
| 765 | }
|
|---|
| 766 | }
|
|---|
| 767 |
|
|---|
| 768 | // Check the Ephemeris
|
|---|
| 769 | //--------------------
|
|---|
| 770 | t_eph* ephLast = _ephUser.ephLast(prnStr);
|
|---|
| 771 | t_eph* ephPrev = _ephUser.ephPrev(prnStr);
|
|---|
| 772 | if (ephLast == 0) {
|
|---|
| 773 | #ifdef BNC_DEBUG_CMB
|
|---|
| 774 | emit newMessage("bncComb: eph not found for " + prnStr.mid(0,3).toLatin1(), true);
|
|---|
| 775 | #endif
|
|---|
| 776 | delete _newCorr; _newCorr = 0;
|
|---|
| 777 | continue;
|
|---|
| 778 | }
|
|---|
| 779 | else if (outDatedBcep(ephLast, currentTime) ||
|
|---|
| 780 | ephLast->checkState() == t_eph::bad ||
|
|---|
| 781 | ephLast->checkState() == t_eph::outdated ||
|
|---|
| 782 | ephLast->checkState() == t_eph::unhealthy) {
|
|---|
| 783 | #ifdef BNC_DEBUG_CMB
|
|---|
| 784 | emit newMessage("bncComb: ephLast not ok (checkState: " + ephLast->checkStateToString().toLatin1() + ") for " + prnStr.mid(0,3).toLatin1(), true);
|
|---|
| 785 | #endif
|
|---|
| 786 | delete _newCorr; _newCorr = 0;
|
|---|
| 787 | continue;
|
|---|
| 788 | }
|
|---|
| 789 | else {
|
|---|
| 790 | if (ephLast->IOD() == _newCorr->_iod) {
|
|---|
| 791 | _newCorr->_eph = ephLast;
|
|---|
| 792 | }
|
|---|
| 793 | else if (ephPrev &&
|
|---|
| 794 | !outDatedBcep(ephPrev, currentTime) && // if not updated in storage
|
|---|
| 795 | ephPrev->checkState() == t_eph::ok && // received
|
|---|
| 796 | ephPrev->IOD() == _newCorr->_iod) {
|
|---|
| 797 | _newCorr->_eph = ephPrev;
|
|---|
| 798 | switchToLastEph(ephLast, _newCorr);
|
|---|
| 799 | }
|
|---|
| 800 | else {
|
|---|
| 801 | #ifdef BNC_DEBUG_CMB
|
|---|
| 802 | emit newMessage("bncComb: eph not found for " + prnStr.mid(0,3).toLatin1() +
|
|---|
| 803 | QString(" with IOD %1").arg(_newCorr->_iod).toLatin1(), true);
|
|---|
| 804 | #endif
|
|---|
| 805 | delete _newCorr; _newCorr = 0;
|
|---|
| 806 | continue;
|
|---|
| 807 | }
|
|---|
| 808 | }
|
|---|
| 809 |
|
|---|
| 810 | // Check satellite code biases
|
|---|
| 811 | // ----------------------------
|
|---|
| 812 | if (_satCodeBiases.contains(acName)) {
|
|---|
| 813 | QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
|
|---|
| 814 | if (storage.contains(clkCorr._prn)) {
|
|---|
| 815 | _newCorr->_satCodeBias = storage[clkCorr._prn];
|
|---|
| 816 | QMap<t_frequency::type, double> codeBiasesRefSig;
|
|---|
| 817 | for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
|
|---|
| 818 | t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
|
|---|
| 819 | char frqNum = t_frequency::toString(frqType)[1];
|
|---|
| 820 | char attrib = cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii));
|
|---|
| 821 | QString rnxType2ch = QString("%1%2").arg(frqNum).arg(attrib);
|
|---|
| 822 | for (unsigned ii = 0; ii < _newCorr->_satCodeBias._bias.size(); ii++) {
|
|---|
| 823 | const t_frqCodeBias& bias = _newCorr->_satCodeBias._bias[ii];
|
|---|
| 824 | if (rnxType2ch.toStdString() == bias._rnxType2ch) {
|
|---|
| 825 | codeBiasesRefSig[frqType] = bias._value;
|
|---|
| 826 | }
|
|---|
| 827 | }
|
|---|
| 828 | }
|
|---|
| 829 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 830 | double channel = double(_newCorr->_eph->slotNum());
|
|---|
| 831 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
|---|
| 832 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 833 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 834 | t_frequency::type frqType = it->first;
|
|---|
| 835 | double codeCoeff = it->second;
|
|---|
| 836 | _newCorr->_satCodeBiasIF += codeCoeff * codeBiasesRefSig[frqType];
|
|---|
| 837 | }
|
|---|
| 838 | _newCorr->_satCodeBias._bias.clear();
|
|---|
| 839 | }
|
|---|
| 840 | }
|
|---|
| 841 |
|
|---|
| 842 | // Check satellite phase biases
|
|---|
| 843 | // ----------------------------
|
|---|
| 844 | if (_satPhaseBiases.contains(acName)) {
|
|---|
| 845 | QMap<t_prn, t_satPhaseBias>& storage = _satPhaseBiases[acName];
|
|---|
| 846 | if (storage.contains(clkCorr._prn)) {
|
|---|
| 847 | // Yaw angle
|
|---|
| 848 | t_satPhaseBias& pb = storage[clkCorr._prn];
|
|---|
| 849 | double dt = _newCorr->_time - pb._time;
|
|---|
| 850 | if (pb._updateInt) {
|
|---|
| 851 | dt -= (0.5 * ssrUpdateInt[pb._updateInt]);
|
|---|
| 852 | }
|
|---|
| 853 | _newCorr->_satYawAngle = pb._yaw + pb._yawRate * dt;
|
|---|
| 854 |
|
|---|
| 855 | // _lambdaIF
|
|---|
| 856 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 857 | double channel = double(_newCorr->_eph->slotNum());
|
|---|
| 858 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
|---|
| 859 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 860 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 861 | t_frequency::type frqType = it->first;
|
|---|
| 862 | double codeCoeff = it->second;
|
|---|
| 863 | _newCorr->_lambdaIF += codeCoeff * t_CST::c / t_CST::freq(frqType, channel);
|
|---|
| 864 | }
|
|---|
| 865 | }
|
|---|
| 866 | }
|
|---|
| 867 |
|
|---|
| 868 | // Store correction into the buffer
|
|---|
| 869 | // --------------------------------
|
|---|
| 870 | QVector<cmbCorr*>& corrs = _buffer[sys].corrs;
|
|---|
| 871 | QVectorIterator<cmbCorr*> itCorr(corrs);
|
|---|
| 872 | bool available = false;
|
|---|
| 873 | while (itCorr.hasNext()) {
|
|---|
| 874 | cmbCorr* corr = itCorr.next();
|
|---|
| 875 | QString prnStr = corr->_prn;
|
|---|
| 876 | QString acName = corr->_acName;
|
|---|
| 877 | if (_newCorr->_acName == acName &&
|
|---|
| 878 | _newCorr->_prn == prnStr) {
|
|---|
| 879 | available = true;
|
|---|
| 880 | }
|
|---|
| 881 | }
|
|---|
| 882 |
|
|---|
| 883 | if (!available) {
|
|---|
| 884 | corrs.push_back(_newCorr); _newCorr = 0;
|
|---|
| 885 | }
|
|---|
| 886 | else {
|
|---|
| 887 | delete _newCorr; _newCorr = 0;
|
|---|
| 888 | continue;
|
|---|
| 889 | }
|
|---|
| 890 | }
|
|---|
| 891 |
|
|---|
| 892 | // Process Systems of this Epoch
|
|---|
| 893 | // ------------------------------
|
|---|
| 894 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 895 | while (itSys.hasNext()) {
|
|---|
| 896 | itSys.next();
|
|---|
| 897 | char sys = itSys.key();
|
|---|
| 898 | _log.clear();
|
|---|
| 899 | QTextStream out(&_log, QIODevice::WriteOnly);
|
|---|
| 900 | processSystem(epoTime, sys, out);
|
|---|
| 901 | _buffer.remove(sys);
|
|---|
| 902 | if (_logFile) {
|
|---|
| 903 | _logFile->write(epoTime.gpsw(),epoTime.gpssec(), QString(_log));
|
|---|
| 904 | }
|
|---|
| 905 | }
|
|---|
| 906 | }
|
|---|
| 907 |
|
|---|
| 908 | void bncComb::processSystem(bncTime epoTime, char sys, QTextStream& out) {
|
|---|
| 909 |
|
|---|
| 910 | out << "\n"
|
|---|
| 911 | << epoTime.datestr().c_str() << " "
|
|---|
| 912 | << epoTime.timestr().c_str() << " "
|
|---|
| 913 | << "Combination: " << sys << "\n"
|
|---|
| 914 | << "--------------------------------------" << "\n";
|
|---|
| 915 |
|
|---|
| 916 | // Observation Statistics
|
|---|
| 917 | // ----------------------
|
|---|
| 918 | bool masterPresent = false;
|
|---|
| 919 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 920 | while (icAC.hasNext()) {
|
|---|
| 921 | cmbAC* AC = icAC.next();
|
|---|
| 922 | AC->numObs[sys] = 0;
|
|---|
| 923 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
|---|
| 924 | while (itCorr.hasNext()) {
|
|---|
| 925 | cmbCorr* corr = itCorr.next();
|
|---|
| 926 | if (corr->_acName == AC->name) {
|
|---|
| 927 | AC->numObs[sys] += 1;
|
|---|
| 928 | if (AC->name == _masterOrbitAC[sys]) {
|
|---|
| 929 | masterPresent = true;
|
|---|
| 930 | }
|
|---|
| 931 | }
|
|---|
| 932 | }
|
|---|
| 933 | out << epoTime.datestr().c_str() << " "
|
|---|
| 934 | << epoTime.timestr().c_str() << " "
|
|---|
| 935 | << "Sat Num " << sys << " "
|
|---|
| 936 | << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << "\n";
|
|---|
| 937 | }
|
|---|
| 938 |
|
|---|
| 939 | // If Master not present, switch to another one
|
|---|
| 940 | // --------------------------------------------
|
|---|
| 941 | const unsigned switchMasterAfterGap = 1;
|
|---|
| 942 | if (masterPresent) {
|
|---|
| 943 | _masterMissingEpochs[sys] = 0;
|
|---|
| 944 | }
|
|---|
| 945 | else {
|
|---|
| 946 | ++_masterMissingEpochs[sys];
|
|---|
| 947 | if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
|
|---|
| 948 | out << "Missing Master, Epoch skipped" << "\n";
|
|---|
| 949 | _buffer.remove(sys);
|
|---|
| 950 | emit newMessage(_log, false);
|
|---|
| 951 | return;
|
|---|
| 952 | }
|
|---|
| 953 | else {
|
|---|
| 954 | _masterMissingEpochs[sys] = 0;
|
|---|
| 955 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 956 | while (icAC.hasNext()) {
|
|---|
| 957 | cmbAC* AC = icAC.next();
|
|---|
| 958 | if (AC->numObs[sys] > 0) {
|
|---|
| 959 | out << epoTime.datestr().c_str() << " "
|
|---|
| 960 | << epoTime.timestr().c_str() << " "
|
|---|
| 961 | << "Switching Master " << sys << " "
|
|---|
| 962 | << _masterOrbitAC[sys].toLatin1().data() << " --> "
|
|---|
| 963 | << AC->name.toLatin1().data() << "\n";
|
|---|
| 964 | _masterOrbitAC[sys] = AC->name;
|
|---|
| 965 | _masterIsAPC[sys] = AC->isAPC;
|
|---|
| 966 | break;
|
|---|
| 967 | }
|
|---|
| 968 | }
|
|---|
| 969 | }
|
|---|
| 970 | }
|
|---|
| 971 |
|
|---|
| 972 | QMap<QString, cmbCorr*> masterCorr;
|
|---|
| 973 |
|
|---|
| 974 | // Perform the actual Combination using selected Method
|
|---|
| 975 | // ----------------------------------------------------
|
|---|
| 976 | t_irc irc;
|
|---|
| 977 | ColumnVector dx;
|
|---|
| 978 | if (_method == filter) {
|
|---|
| 979 | irc = processEpoch_filter(epoTime, sys, out, masterCorr, dx);
|
|---|
| 980 | }
|
|---|
| 981 | else {
|
|---|
| 982 | irc = processEpoch_singleEpoch(epoTime, sys, out, masterCorr, dx);
|
|---|
| 983 | }
|
|---|
| 984 |
|
|---|
| 985 | // Update Parameter Values, Print Results
|
|---|
| 986 | // --------------------------------------
|
|---|
| 987 | if (irc == success) {
|
|---|
| 988 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 989 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 990 | pp->xx += dx(iPar);
|
|---|
| 991 | if (pp->type == cmbParam::clkSat) {
|
|---|
| 992 | if (masterCorr.find(pp->prn) != masterCorr.end()) {
|
|---|
| 993 | // set clock result
|
|---|
| 994 | masterCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
|
|---|
| 995 | // Add Code Biases from SINEX File
|
|---|
| 996 | if (_bsx) {
|
|---|
| 997 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 998 | double channel = double(masterCorr[pp->prn]->_eph->slotNum());
|
|---|
| 999 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
|---|
| 1000 | t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
|
|---|
| 1001 | t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
|
|---|
| 1002 | _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], masterCorr[pp->prn]->_satCodeBias);
|
|---|
| 1003 | }
|
|---|
| 1004 | }
|
|---|
| 1005 | }
|
|---|
| 1006 | out << epoTime.datestr().c_str() << " "
|
|---|
| 1007 | << epoTime.timestr().c_str() << " ";
|
|---|
| 1008 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1009 | out.setFieldWidth(8);
|
|---|
| 1010 | out.setRealNumberPrecision(4);
|
|---|
| 1011 | out << pp->toString(sys) << " "
|
|---|
| 1012 | << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << "\n";
|
|---|
| 1013 | out.setFieldWidth(0);
|
|---|
| 1014 | out.flush();
|
|---|
| 1015 | }
|
|---|
| 1016 | printResults(epoTime, out, masterCorr);
|
|---|
| 1017 | dumpResults(epoTime, masterCorr);
|
|---|
| 1018 | }
|
|---|
| 1019 | }
|
|---|
| 1020 |
|
|---|
| 1021 | // Process Epoch - Filter Method
|
|---|
| 1022 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1023 | t_irc bncComb::processEpoch_filter(bncTime epoTime, char sys, QTextStream& out,
|
|---|
| 1024 | QMap<QString, cmbCorr*>& masterCorr,
|
|---|
| 1025 | ColumnVector& dx) {
|
|---|
| 1026 |
|
|---|
| 1027 | // Prediction Step
|
|---|
| 1028 | // ---------------
|
|---|
| 1029 | int nPar = _params[sys].size();
|
|---|
| 1030 | ColumnVector x0(nPar);
|
|---|
| 1031 | for (int iPar = 1; iPar <= nPar; iPar++) {
|
|---|
| 1032 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1033 | if (pp->epoSpec) {
|
|---|
| 1034 | pp->xx = 0.0;
|
|---|
| 1035 | _QQ[sys].Row(iPar) = 0.0;
|
|---|
| 1036 | _QQ[sys].Column(iPar) = 0.0;
|
|---|
| 1037 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
|---|
| 1038 | }
|
|---|
| 1039 | else {
|
|---|
| 1040 | _QQ[sys](iPar,iPar) += pp->sigP * pp->sigP;
|
|---|
| 1041 | }
|
|---|
| 1042 | x0(iPar) = pp->xx;
|
|---|
| 1043 | }
|
|---|
| 1044 |
|
|---|
| 1045 | // Check Satellite Positions for Outliers
|
|---|
| 1046 | // --------------------------------------
|
|---|
| 1047 | if (checkOrbits(epoTime, sys, out, masterCorr) != success) {
|
|---|
| 1048 | return failure;
|
|---|
| 1049 | }
|
|---|
| 1050 |
|
|---|
| 1051 | // Update and outlier detection loop
|
|---|
| 1052 | // ---------------------------------
|
|---|
| 1053 | SymmetricMatrix QQ_sav = _QQ[sys];
|
|---|
| 1054 | while (_running) {
|
|---|
| 1055 |
|
|---|
| 1056 | Matrix AA;
|
|---|
| 1057 | ColumnVector ll;
|
|---|
| 1058 | DiagonalMatrix PP;
|
|---|
| 1059 |
|
|---|
| 1060 | if (createAmat(sys, AA, ll, PP, x0) != success) {
|
|---|
| 1061 | return failure;
|
|---|
| 1062 | }
|
|---|
| 1063 |
|
|---|
| 1064 | dx.ReSize(nPar); dx = 0.0;
|
|---|
| 1065 | kalman(AA, ll, PP, _QQ[sys], dx);
|
|---|
| 1066 |
|
|---|
| 1067 | ColumnVector vv = ll - AA * dx;
|
|---|
| 1068 |
|
|---|
| 1069 | int maxResIndex;
|
|---|
| 1070 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
|---|
| 1071 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1072 | out.setRealNumberPrecision(3);
|
|---|
| 1073 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
|---|
| 1074 | << " Maximum Residuum " << maxRes << ' '
|
|---|
| 1075 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
|---|
| 1076 | if (maxRes > _MAX_RES) {
|
|---|
| 1077 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1078 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1079 | if (pp->type == cmbParam::offACSat &&
|
|---|
| 1080 | pp->AC == corrs(sys)[maxResIndex-1]->_acName &&
|
|---|
| 1081 | pp->prn == corrs(sys)[maxResIndex-1]->_prn.mid(0,3)) {
|
|---|
| 1082 | QQ_sav.Row(iPar) = 0.0;
|
|---|
| 1083 | QQ_sav.Column(iPar) = 0.0;
|
|---|
| 1084 | QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
|
|---|
| 1085 | }
|
|---|
| 1086 | }
|
|---|
| 1087 |
|
|---|
| 1088 | out << " Outlier" << "\n";
|
|---|
| 1089 | _QQ[sys] = QQ_sav;
|
|---|
| 1090 | delete corrs(sys)[maxResIndex-1];
|
|---|
| 1091 | corrs(sys).remove(maxResIndex-1);
|
|---|
| 1092 | }
|
|---|
| 1093 | else {
|
|---|
| 1094 | out << " OK" << "\n";
|
|---|
| 1095 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1096 | out.setRealNumberPrecision(4);
|
|---|
| 1097 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
|---|
| 1098 | const cmbCorr* corr = corrs(sys)[ii];
|
|---|
| 1099 | out << epoTime.datestr().c_str() << ' '
|
|---|
| 1100 | << epoTime.timestr().c_str() << " "
|
|---|
| 1101 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
|---|
| 1102 | out.setFieldWidth(10);
|
|---|
| 1103 | out << " res = " << vv[ii] << "\n";
|
|---|
| 1104 | out.setFieldWidth(0);
|
|---|
| 1105 | }
|
|---|
| 1106 | break;
|
|---|
| 1107 | }
|
|---|
| 1108 | }
|
|---|
| 1109 |
|
|---|
| 1110 | return success;
|
|---|
| 1111 | }
|
|---|
| 1112 |
|
|---|
| 1113 | // Print results
|
|---|
| 1114 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1115 | void bncComb::printResults(bncTime epoTime, QTextStream& out,
|
|---|
| 1116 | const QMap<QString, cmbCorr*>& masterCorr) {
|
|---|
| 1117 |
|
|---|
| 1118 | QMapIterator<QString, cmbCorr*> it(masterCorr);
|
|---|
| 1119 | while (it.hasNext()) {
|
|---|
| 1120 | it.next();
|
|---|
| 1121 | cmbCorr* corr = it.value();
|
|---|
| 1122 | const t_eph* eph = corr->_eph;
|
|---|
| 1123 | if (eph) {
|
|---|
| 1124 | ColumnVector xc(6);
|
|---|
| 1125 | ColumnVector vv(3);
|
|---|
| 1126 | if (eph->getCrd(epoTime, xc, vv, false) != success) {
|
|---|
| 1127 | continue;
|
|---|
| 1128 | }
|
|---|
| 1129 | out << epoTime.datestr().c_str() << " "
|
|---|
| 1130 | << epoTime.timestr().c_str() << " ";
|
|---|
| 1131 | out.setFieldWidth(3);
|
|---|
| 1132 | out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
|
|---|
| 1133 | out.setFieldWidth(14);
|
|---|
| 1134 | out << (xc(4) + corr->_dClkResult) * t_CST::c << "\n";
|
|---|
| 1135 | out.setFieldWidth(0);
|
|---|
| 1136 | out.flush();
|
|---|
| 1137 | }
|
|---|
| 1138 | else {
|
|---|
| 1139 | out << "bncComb::printResults bug" << "\n";
|
|---|
| 1140 | }
|
|---|
| 1141 | }
|
|---|
| 1142 | }
|
|---|
| 1143 |
|
|---|
| 1144 | // Send results to RTNet Decoder and directly to PPP Client
|
|---|
| 1145 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1146 | void bncComb::dumpResults(bncTime epoTime, QMap<QString, cmbCorr*>& masterCorr) {
|
|---|
| 1147 |
|
|---|
| 1148 | QList<t_orbCorr> orbCorrections;
|
|---|
| 1149 | QList<t_clkCorr> clkCorrections;
|
|---|
| 1150 | QList<t_satCodeBias> satCodeBiasList;
|
|---|
| 1151 | QList<t_satPhaseBias> satPhaseBiasList;
|
|---|
| 1152 |
|
|---|
| 1153 | unsigned year, month, day, hour, minute;
|
|---|
| 1154 | double sec;
|
|---|
| 1155 | epoTime.civil_date(year, month, day);
|
|---|
| 1156 | epoTime.civil_time(hour, minute, sec);
|
|---|
| 1157 |
|
|---|
| 1158 | QString outLines = QString().asprintf("* %4d %2d %2d %d %d %12.8f\n",
|
|---|
| 1159 | year, month, day, hour, minute, sec);
|
|---|
| 1160 |
|
|---|
| 1161 | QMutableMapIterator<QString, cmbCorr*> it(masterCorr);
|
|---|
| 1162 | while (it.hasNext()) {
|
|---|
| 1163 | it.next();
|
|---|
| 1164 | cmbCorr* corr = it.value();
|
|---|
| 1165 |
|
|---|
| 1166 | // ORBIT
|
|---|
| 1167 | t_orbCorr orbCorr(corr->_orbCorr);
|
|---|
| 1168 | orbCorr._staID = "INTERNAL";
|
|---|
| 1169 | orbCorrections.push_back(orbCorr);
|
|---|
| 1170 |
|
|---|
| 1171 | // CLOCK
|
|---|
| 1172 | t_clkCorr clkCorr(corr->_clkCorr);
|
|---|
| 1173 | clkCorr._staID = "INTERNAL";
|
|---|
| 1174 | clkCorr._dClk = corr->_dClkResult;
|
|---|
| 1175 | clkCorr._dotDClk = 0.0;
|
|---|
| 1176 | clkCorr._dotDotDClk = 0.0;
|
|---|
| 1177 | clkCorrections.push_back(clkCorr);
|
|---|
| 1178 |
|
|---|
| 1179 | ColumnVector xc(6);
|
|---|
| 1180 | ColumnVector vv(3);
|
|---|
| 1181 | corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
|
|---|
| 1182 | corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
|
|---|
| 1183 | if (corr->_eph->getCrd(epoTime, xc, vv, true) != success) {
|
|---|
| 1184 | delete corr;
|
|---|
| 1185 | it.remove();
|
|---|
| 1186 | continue;
|
|---|
| 1187 | }
|
|---|
| 1188 |
|
|---|
| 1189 | // Correction Phase Center --> CoM
|
|---|
| 1190 | // -------------------------------
|
|---|
| 1191 | ColumnVector dx(3); dx = 0.0;
|
|---|
| 1192 | ColumnVector apc(3); apc = 0.0;
|
|---|
| 1193 | ColumnVector com(3); com = 0.0;
|
|---|
| 1194 | bool masterIsAPC = true;
|
|---|
| 1195 | if (_antex) {
|
|---|
| 1196 | double Mjd = epoTime.mjd() + epoTime.daysec()/86400.0;
|
|---|
| 1197 | char sys = corr->_eph->prn().system();
|
|---|
| 1198 | masterIsAPC = _masterIsAPC[sys];
|
|---|
| 1199 | if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
|
|---|
| 1200 | dx = 0;
|
|---|
| 1201 | _log += "antenna not found " + corr->_prn.mid(0,3).toLatin1() + '\n';
|
|---|
| 1202 | }
|
|---|
| 1203 | }
|
|---|
| 1204 | if (masterIsAPC) {
|
|---|
| 1205 | apc(1) = xc(1);
|
|---|
| 1206 | apc(2) = xc(2);
|
|---|
| 1207 | apc(3) = xc(3);
|
|---|
| 1208 | com(1) = xc(1)-dx(1);
|
|---|
| 1209 | com(2) = xc(2)-dx(2);
|
|---|
| 1210 | com(3) = xc(3)-dx(3);
|
|---|
| 1211 | }
|
|---|
| 1212 | else {
|
|---|
| 1213 | com(1) = xc(1);
|
|---|
| 1214 | com(2) = xc(2);
|
|---|
| 1215 | com(3) = xc(3);
|
|---|
| 1216 | apc(1) = xc(1)+dx(1);
|
|---|
| 1217 | apc(2) = xc(2)+dx(2);
|
|---|
| 1218 | apc(3) = xc(3)+dx(3);
|
|---|
| 1219 | }
|
|---|
| 1220 |
|
|---|
| 1221 | outLines += corr->_prn.mid(0,3);
|
|---|
| 1222 | QString hlp = QString().asprintf(
|
|---|
| 1223 | " APC 3 %15.4f %15.4f %15.4f"
|
|---|
| 1224 | " Clk 1 %15.4f"
|
|---|
| 1225 | " Vel 3 %15.4f %15.4f %15.4f"
|
|---|
| 1226 | " CoM 3 %15.4f %15.4f %15.4f"
|
|---|
| 1227 | " YawAngle %1.4f",
|
|---|
| 1228 | apc(1), apc(2), apc(3),
|
|---|
| 1229 | xc(4) * t_CST::c,
|
|---|
| 1230 | vv(1), vv(2), vv(3),
|
|---|
| 1231 | com(1), com(2), com(3),
|
|---|
| 1232 | corr->_satYawAngle);
|
|---|
| 1233 | outLines += hlp;
|
|---|
| 1234 | hlp.clear();
|
|---|
| 1235 |
|
|---|
| 1236 | // CODE BIASES
|
|---|
| 1237 | if (corr->_satCodeBias._bias.size()) {
|
|---|
| 1238 | t_satCodeBias satCodeBias(corr->_satCodeBias);
|
|---|
| 1239 | satCodeBias._staID = "INTERNAL";
|
|---|
| 1240 | satCodeBiasList.push_back(satCodeBias);
|
|---|
| 1241 | hlp = QString().asprintf(" CodeBias %2lu", satCodeBias._bias.size());
|
|---|
| 1242 | outLines += hlp;
|
|---|
| 1243 | hlp.clear();
|
|---|
| 1244 | for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
|
|---|
| 1245 | const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
|
|---|
| 1246 | if (!frqCodeBias._rnxType2ch.empty()) {
|
|---|
| 1247 | hlp = QString().asprintf(" %s%10.6f", frqCodeBias._rnxType2ch.c_str(), frqCodeBias._value);
|
|---|
| 1248 | outLines += hlp;
|
|---|
| 1249 | hlp.clear();
|
|---|
| 1250 | }
|
|---|
| 1251 | }
|
|---|
| 1252 | }
|
|---|
| 1253 |
|
|---|
| 1254 | outLines += "\n";
|
|---|
| 1255 | delete corr;
|
|---|
| 1256 | it.remove();
|
|---|
| 1257 | }
|
|---|
| 1258 |
|
|---|
| 1259 | outLines += "EOE\n"; // End Of Epoch flag
|
|---|
| 1260 | //cout << outLines.toStdString();
|
|---|
| 1261 |
|
|---|
| 1262 | vector<string> errmsg;
|
|---|
| 1263 | _rtnetDecoder->Decode(outLines.toLatin1().data(), outLines.length(), errmsg);
|
|---|
| 1264 |
|
|---|
| 1265 | // Send new Corrections to PPP etc.
|
|---|
| 1266 | // --------------------------------
|
|---|
| 1267 | if (orbCorrections.size() > 0 && clkCorrections.size() > 0) {
|
|---|
| 1268 | emit newOrbCorrections(orbCorrections);
|
|---|
| 1269 | emit newClkCorrections(clkCorrections);
|
|---|
| 1270 | }
|
|---|
| 1271 | if (satCodeBiasList.size()) {
|
|---|
| 1272 | emit newCodeBiases(satCodeBiasList);
|
|---|
| 1273 | }
|
|---|
| 1274 | }
|
|---|
| 1275 |
|
|---|
| 1276 | // Create First Design Matrix and Vector of Measurements
|
|---|
| 1277 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1278 | t_irc bncComb::createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP, const ColumnVector& x0) {
|
|---|
| 1279 |
|
|---|
| 1280 | unsigned nPar = _params[sys].size();
|
|---|
| 1281 | unsigned nObs = corrs(sys).size();
|
|---|
| 1282 |
|
|---|
| 1283 | if (nObs == 0) {
|
|---|
| 1284 | return failure;
|
|---|
| 1285 | }
|
|---|
| 1286 |
|
|---|
| 1287 | int maxSat = _cmbSysPrn[sys];
|
|---|
| 1288 |
|
|---|
| 1289 | const int nCon = (_method == filter) ? 1 + maxSat : 0;
|
|---|
| 1290 |
|
|---|
| 1291 | AA.ReSize(nObs+nCon, nPar); AA = 0.0;
|
|---|
| 1292 | ll.ReSize(nObs+nCon); ll = 0.0;
|
|---|
| 1293 | PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
|
|---|
| 1294 |
|
|---|
| 1295 | int iObs = 0;
|
|---|
| 1296 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
|---|
| 1297 | while (itCorr.hasNext()) {
|
|---|
| 1298 | cmbCorr* corr = itCorr.next();
|
|---|
| 1299 | QString prn = corr->_prn;
|
|---|
| 1300 |
|
|---|
| 1301 | ++iObs;
|
|---|
| 1302 |
|
|---|
| 1303 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1304 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1305 | AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
|
|---|
| 1306 | }
|
|---|
| 1307 | // Consistency corrections to keep the combined clock consistent to masterOrbit
|
|---|
| 1308 | // ----------------------------------------------------------------------------
|
|---|
| 1309 | double dC_orb = dotproduct(corr->_orbCorr._xr, corr->_diffRao) / corr->_orbCorr._xr.NormFrobenius();
|
|---|
| 1310 | double dC_att = corr->_diffYaw / (2 * M_PI);
|
|---|
| 1311 | dC_att *= corr->_lambdaIF;
|
|---|
| 1312 |
|
|---|
| 1313 | ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_satCodeBiasIF - dC_orb - dC_att) - DotProduct(AA.Row(iObs), x0);
|
|---|
| 1314 |
|
|---|
| 1315 | PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
|
|---|
| 1316 | }
|
|---|
| 1317 |
|
|---|
| 1318 | // Regularization
|
|---|
| 1319 | // --------------
|
|---|
| 1320 | if (_method == filter) {
|
|---|
| 1321 | const double Ph = 1.e6;
|
|---|
| 1322 | PP(nObs+1) = Ph;
|
|---|
| 1323 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1324 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1325 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
|---|
| 1326 | pp->type == cmbParam::clkSat ) {
|
|---|
| 1327 | AA(nObs+1, iPar) = 1.0;
|
|---|
| 1328 | }
|
|---|
| 1329 | }
|
|---|
| 1330 | // if (sys == 'R') {
|
|---|
| 1331 | // return success;
|
|---|
| 1332 | // }
|
|---|
| 1333 | int iCond = 1;
|
|---|
| 1334 | // GNSS
|
|---|
| 1335 | for (unsigned iGnss = 1; iGnss <= _cmbSysPrn[sys]; iGnss++) {
|
|---|
| 1336 | int flag = t_corrSSR::getSsrNavTypeFlag(sys, iGnss);
|
|---|
| 1337 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
|---|
| 1338 | ++iCond;
|
|---|
| 1339 | PP(nObs+iCond) = Ph;
|
|---|
| 1340 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1341 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1342 | if ( pp &&
|
|---|
| 1343 | AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
|---|
| 1344 | pp->type == cmbParam::offACSat &&
|
|---|
| 1345 | pp->prn == prn) {
|
|---|
| 1346 | AA(nObs+iCond, iPar) = 1.0;
|
|---|
| 1347 | }
|
|---|
| 1348 | }
|
|---|
| 1349 | }
|
|---|
| 1350 | }
|
|---|
| 1351 |
|
|---|
| 1352 | return success;
|
|---|
| 1353 | }
|
|---|
| 1354 |
|
|---|
| 1355 | // Process Epoch - Single-Epoch Method
|
|---|
| 1356 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1357 | t_irc bncComb::processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out,
|
|---|
| 1358 | QMap<QString, cmbCorr*>& masterCorr,
|
|---|
| 1359 | ColumnVector& dx) {
|
|---|
| 1360 |
|
|---|
| 1361 | // Check Satellite Positions for Outliers
|
|---|
| 1362 | // --------------------------------------
|
|---|
| 1363 | if (checkOrbits(epoTime, sys, out, masterCorr) != success) {
|
|---|
| 1364 | return failure;
|
|---|
| 1365 | }
|
|---|
| 1366 |
|
|---|
| 1367 | // Outlier Detection Loop
|
|---|
| 1368 | // ----------------------
|
|---|
| 1369 | while (_running) {
|
|---|
| 1370 | // Count Number of Observations per Satellite and per AC
|
|---|
| 1371 | // -----------------------------------------------------
|
|---|
| 1372 | QMap<QString, int> numObsPrn;
|
|---|
| 1373 | QMap<QString, int> numObsAC;
|
|---|
| 1374 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
|---|
| 1375 | while (itCorr.hasNext()) {
|
|---|
| 1376 | cmbCorr* corr = itCorr.next();
|
|---|
| 1377 | QString prn = corr->_prn;
|
|---|
| 1378 | QString AC = corr->_acName;
|
|---|
| 1379 | if (numObsPrn.find(prn) == numObsPrn.end()) {
|
|---|
| 1380 | numObsPrn[prn] = 1;
|
|---|
| 1381 | }
|
|---|
| 1382 | else {
|
|---|
| 1383 | numObsPrn[prn] += 1;
|
|---|
| 1384 | }
|
|---|
| 1385 | if (numObsAC.find(AC) == numObsAC.end()) {
|
|---|
| 1386 | numObsAC[AC] = 1;
|
|---|
| 1387 | }
|
|---|
| 1388 | else {
|
|---|
| 1389 | numObsAC[AC] += 1;
|
|---|
| 1390 | }
|
|---|
| 1391 | }
|
|---|
| 1392 |
|
|---|
| 1393 | // Clean-Up the Parameters
|
|---|
| 1394 | // -----------------------
|
|---|
| 1395 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1396 | delete _params[sys][iPar-1];
|
|---|
| 1397 | }
|
|---|
| 1398 | _params[sys].clear();
|
|---|
| 1399 |
|
|---|
| 1400 | // Set new Parameters
|
|---|
| 1401 | // ------------------
|
|---|
| 1402 | int nextPar = 0;
|
|---|
| 1403 |
|
|---|
| 1404 | QMapIterator<QString, int> itAC(numObsAC);
|
|---|
| 1405 | while (itAC.hasNext()) {
|
|---|
| 1406 | itAC.next();
|
|---|
| 1407 | const QString& AC = itAC.key();
|
|---|
| 1408 | int numObs = itAC.value();
|
|---|
| 1409 | if (AC != _masterOrbitAC[sys] && numObs > 0) {
|
|---|
| 1410 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC, ""));
|
|---|
| 1411 | }
|
|---|
| 1412 | }
|
|---|
| 1413 |
|
|---|
| 1414 | QMapIterator<QString, int> itPrn(numObsPrn);
|
|---|
| 1415 | while (itPrn.hasNext()) {
|
|---|
| 1416 | itPrn.next();
|
|---|
| 1417 | const QString& prn = itPrn.key();
|
|---|
| 1418 | int numObs = itPrn.value();
|
|---|
| 1419 | if (numObs > 0) {
|
|---|
| 1420 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
|---|
| 1421 | }
|
|---|
| 1422 | }
|
|---|
| 1423 |
|
|---|
| 1424 | int nPar = _params[sys].size();
|
|---|
| 1425 | ColumnVector x0(nPar);
|
|---|
| 1426 | x0 = 0.0;
|
|---|
| 1427 |
|
|---|
| 1428 | // Create First-Design Matrix
|
|---|
| 1429 | // --------------------------
|
|---|
| 1430 | Matrix AA;
|
|---|
| 1431 | ColumnVector ll;
|
|---|
| 1432 | DiagonalMatrix PP;
|
|---|
| 1433 | if (createAmat(sys, AA, ll, PP, x0) != success) {
|
|---|
| 1434 | return failure;
|
|---|
| 1435 | }
|
|---|
| 1436 |
|
|---|
| 1437 | ColumnVector vv;
|
|---|
| 1438 | try {
|
|---|
| 1439 | Matrix ATP = AA.t() * PP;
|
|---|
| 1440 | SymmetricMatrix NN; NN << ATP * AA;
|
|---|
| 1441 | ColumnVector bb = ATP * ll;
|
|---|
| 1442 | _QQ[sys] = NN.i();
|
|---|
| 1443 | dx = _QQ[sys] * bb;
|
|---|
| 1444 | vv = ll - AA * dx;
|
|---|
| 1445 | }
|
|---|
| 1446 | catch (Exception& exc) {
|
|---|
| 1447 | out << exc.what() << "\n";
|
|---|
| 1448 | return failure;
|
|---|
| 1449 | }
|
|---|
| 1450 |
|
|---|
| 1451 | int maxResIndex;
|
|---|
| 1452 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
|---|
| 1453 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1454 | out.setRealNumberPrecision(3);
|
|---|
| 1455 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
|---|
| 1456 | << " Maximum Residuum " << maxRes << ' '
|
|---|
| 1457 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
|---|
| 1458 |
|
|---|
| 1459 | if (maxRes > _MAX_RES) {
|
|---|
| 1460 | out << " Outlier" << "\n";
|
|---|
| 1461 | delete corrs(sys)[maxResIndex-1];
|
|---|
| 1462 | corrs(sys).remove(maxResIndex-1);
|
|---|
| 1463 | }
|
|---|
| 1464 | else {
|
|---|
| 1465 | out << " OK" << "\n";
|
|---|
| 1466 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1467 | out.setRealNumberPrecision(3);
|
|---|
| 1468 | for (int ii = 0; ii < vv.Nrows(); ii++) {
|
|---|
| 1469 | const cmbCorr* corr = corrs(sys)[ii];
|
|---|
| 1470 | out << epoTime.datestr().c_str() << ' '
|
|---|
| 1471 | << epoTime.timestr().c_str() << " "
|
|---|
| 1472 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
|---|
| 1473 | out.setFieldWidth(6);
|
|---|
| 1474 | out << " res = " << vv[ii] << "\n";
|
|---|
| 1475 | out.setFieldWidth(0);
|
|---|
| 1476 | }
|
|---|
| 1477 | return success;
|
|---|
| 1478 | }
|
|---|
| 1479 |
|
|---|
| 1480 | }
|
|---|
| 1481 |
|
|---|
| 1482 | return failure;
|
|---|
| 1483 | }
|
|---|
| 1484 |
|
|---|
| 1485 | // Check Satellite Positions for Outliers
|
|---|
| 1486 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1487 | t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& masterCorr) {
|
|---|
| 1488 |
|
|---|
| 1489 | // Switch to last ephemeris (if possible)
|
|---|
| 1490 | // --------------------------------------
|
|---|
| 1491 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
|---|
| 1492 | while (im.hasNext()) {
|
|---|
| 1493 | cmbCorr* corr = im.next();
|
|---|
| 1494 | QString prn = corr->_prn;
|
|---|
| 1495 |
|
|---|
| 1496 | t_eph* ephLast = _ephUser.ephLast(prn);
|
|---|
| 1497 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
|---|
| 1498 |
|
|---|
| 1499 | if (ephLast == 0) {
|
|---|
| 1500 | out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << "\n";
|
|---|
| 1501 | delete corr;
|
|---|
| 1502 | im.remove();
|
|---|
| 1503 | }
|
|---|
| 1504 | else if (corr->_eph == 0) {
|
|---|
| 1505 | out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << "\n";
|
|---|
| 1506 | delete corr;
|
|---|
| 1507 | im.remove();
|
|---|
| 1508 | }
|
|---|
| 1509 | else {
|
|---|
| 1510 | if ( corr->_eph == ephLast ||
|
|---|
| 1511 | corr->_eph == ephPrev ) {
|
|---|
| 1512 | switchToLastEph(ephLast, corr);
|
|---|
| 1513 | }
|
|---|
| 1514 | else {
|
|---|
| 1515 | out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << "\n";
|
|---|
| 1516 | delete corr;
|
|---|
| 1517 | im.remove();
|
|---|
| 1518 | }
|
|---|
| 1519 | }
|
|---|
| 1520 | }
|
|---|
| 1521 |
|
|---|
| 1522 | while (_running) {
|
|---|
| 1523 |
|
|---|
| 1524 | // Compute Mean Corrections for all Satellites
|
|---|
| 1525 | // -------------------------------------------
|
|---|
| 1526 | QMap<QString, int> numCorr;
|
|---|
| 1527 | QMap<QString, ColumnVector> meanRao;
|
|---|
| 1528 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
|---|
| 1529 | while (it.hasNext()) {
|
|---|
| 1530 | cmbCorr* corr = it.next();
|
|---|
| 1531 | QString prn = corr->_prn;
|
|---|
| 1532 | if (meanRao.find(prn) == meanRao.end()) {
|
|---|
| 1533 | meanRao[prn].ReSize(4);
|
|---|
| 1534 | meanRao[prn].Rows(1,3) = corr->_orbCorr._xr;
|
|---|
| 1535 | meanRao[prn](4) = 1;
|
|---|
| 1536 | }
|
|---|
| 1537 | else {
|
|---|
| 1538 | meanRao[prn].Rows(1,3) += corr->_orbCorr._xr;
|
|---|
| 1539 | meanRao[prn](4) += 1;
|
|---|
| 1540 | }
|
|---|
| 1541 | if (numCorr.find(prn) == numCorr.end()) {
|
|---|
| 1542 | numCorr[prn] = 1;
|
|---|
| 1543 | }
|
|---|
| 1544 | else {
|
|---|
| 1545 | numCorr[prn] += 1;
|
|---|
| 1546 | }
|
|---|
| 1547 | }
|
|---|
| 1548 |
|
|---|
| 1549 | // Compute Differences wrt. Mean, find Maximum
|
|---|
| 1550 | // -------------------------------------------
|
|---|
| 1551 | QMap<QString, cmbCorr*> maxDiff;
|
|---|
| 1552 | it.toFront();
|
|---|
| 1553 | while (it.hasNext()) {
|
|---|
| 1554 | cmbCorr* corr = it.next();
|
|---|
| 1555 | QString prn = corr->_prn;
|
|---|
| 1556 | if (meanRao[prn](4) != 0) {
|
|---|
| 1557 | meanRao[prn] /= meanRao[prn](4);
|
|---|
| 1558 | meanRao[prn](4) = 0;
|
|---|
| 1559 | }
|
|---|
| 1560 | corr->_diffRao = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
|
|---|
| 1561 |
|
|---|
| 1562 | if (maxDiff.find(prn) == maxDiff.end()) {
|
|---|
| 1563 | maxDiff[prn] = corr;
|
|---|
| 1564 | }
|
|---|
| 1565 | else {
|
|---|
| 1566 | double normMax = maxDiff[prn]->_diffRao.NormFrobenius();
|
|---|
| 1567 | double norm = corr->_diffRao.NormFrobenius();
|
|---|
| 1568 | if (norm > normMax) {
|
|---|
| 1569 | maxDiff[prn] = corr;
|
|---|
| 1570 | }
|
|---|
| 1571 | }
|
|---|
| 1572 | }
|
|---|
| 1573 |
|
|---|
| 1574 | if (_ACs.size() == 1) {
|
|---|
| 1575 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
|---|
| 1576 | while (it.hasNext()) {
|
|---|
| 1577 | cmbCorr* corr = it.next();
|
|---|
| 1578 | QString prn = corr->_prn;
|
|---|
| 1579 | if (corr->_acName == _masterOrbitAC[sys] &&
|
|---|
| 1580 | masterCorr.find(prn) == masterCorr.end()) {
|
|---|
| 1581 | masterCorr[prn] = new cmbCorr(*corr);
|
|---|
| 1582 | masterCorr[prn]->_diffRao = 0.0;
|
|---|
| 1583 | masterCorr[prn]->_diffYaw = 0.0;
|
|---|
| 1584 | }
|
|---|
| 1585 | }
|
|---|
| 1586 | break;
|
|---|
| 1587 | }
|
|---|
| 1588 |
|
|---|
| 1589 | // Remove Outliers
|
|---|
| 1590 | // ---------------
|
|---|
| 1591 | bool removed = false;
|
|---|
| 1592 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
|---|
| 1593 | while (im.hasNext()) {
|
|---|
| 1594 | cmbCorr* corr = im.next();
|
|---|
| 1595 | QString prn = corr->_prn;
|
|---|
| 1596 | if (numCorr[prn] < 2) {
|
|---|
| 1597 | delete corr;
|
|---|
| 1598 | im.remove();
|
|---|
| 1599 | }
|
|---|
| 1600 | else if (corr == maxDiff[prn]) {
|
|---|
| 1601 | double norm = corr->_diffRao.NormFrobenius();
|
|---|
| 1602 | double facSys = 1.0;
|
|---|
| 1603 | if (sys == 'C' && prn.mid(1,2).toInt() <= 16) { // BDS-2
|
|---|
| 1604 | facSys *= 5.0;
|
|---|
| 1605 | }
|
|---|
| 1606 | if (norm > (_MAX_DISPLACEMENT * facSys)) {
|
|---|
| 1607 | out << epoTime.datestr().c_str() << " "
|
|---|
| 1608 | << epoTime.timestr().c_str() << " "
|
|---|
| 1609 | << "Orbit Outlier: "
|
|---|
| 1610 | << corr->_acName.toLatin1().data() << " "
|
|---|
| 1611 | << prn.mid(0,3).toLatin1().data() << " "
|
|---|
| 1612 | << corr->_iod << " "
|
|---|
| 1613 | << norm << "\n";
|
|---|
| 1614 | delete corr;
|
|---|
| 1615 | im.remove();
|
|---|
| 1616 | removed = true;
|
|---|
| 1617 | }
|
|---|
| 1618 | }
|
|---|
| 1619 | }
|
|---|
| 1620 | // Set master orbit
|
|---|
| 1621 | // -----------------------------------------
|
|---|
| 1622 | if (!removed) {
|
|---|
| 1623 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
|---|
| 1624 | while (it.hasNext()) {
|
|---|
| 1625 | cmbCorr* corr = it.next();
|
|---|
| 1626 | QString prn = corr->_prn;
|
|---|
| 1627 | if (corr->_acName == _masterOrbitAC[sys] &&
|
|---|
| 1628 | masterCorr.find(prn) == masterCorr.end()) {
|
|---|
| 1629 | masterCorr[prn] = new cmbCorr(*corr);
|
|---|
| 1630 | }
|
|---|
| 1631 | }
|
|---|
| 1632 | // Remove satellites that are not in masterOrbit
|
|---|
| 1633 | // and compute differences wrt. masterOrbit
|
|---|
| 1634 | // ----------------------------------------------
|
|---|
| 1635 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
|---|
| 1636 | while (im.hasNext()) {
|
|---|
| 1637 | cmbCorr* corr = im.next();
|
|---|
| 1638 | QString prn = corr->_prn;
|
|---|
| 1639 | if (masterCorr.find(prn) == masterCorr.end()) {
|
|---|
| 1640 | delete corr;
|
|---|
| 1641 | im.remove();
|
|---|
| 1642 | }
|
|---|
| 1643 | else {
|
|---|
| 1644 | corr->_diffRao = corr->_orbCorr._xr - masterCorr[prn]->_orbCorr._xr;
|
|---|
| 1645 | corr->_diffYaw = corr->_satYawAngle - masterCorr[prn]->_satYawAngle;
|
|---|
| 1646 | }
|
|---|
| 1647 | }
|
|---|
| 1648 | break;
|
|---|
| 1649 | }
|
|---|
| 1650 | }
|
|---|
| 1651 |
|
|---|
| 1652 | return success;
|
|---|
| 1653 | }
|
|---|
| 1654 |
|
|---|
| 1655 | //
|
|---|
| 1656 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1657 | void bncComb::slotProviderIDChanged(QString mountPoint) {
|
|---|
| 1658 | QMutexLocker locker(&_mutex);
|
|---|
| 1659 |
|
|---|
| 1660 | QTextStream out(&_log, QIODevice::WriteOnly);
|
|---|
| 1661 |
|
|---|
| 1662 | // Find the AC Name
|
|---|
| 1663 | // ----------------
|
|---|
| 1664 | QString acName;
|
|---|
| 1665 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 1666 | while (icAC.hasNext()) {
|
|---|
| 1667 | cmbAC *AC = icAC.next();
|
|---|
| 1668 | if (AC->mountPoint == mountPoint) {
|
|---|
| 1669 | acName = AC->name;
|
|---|
| 1670 | out << "Provider ID changed: AC " << AC->name.toLatin1().data() << " "
|
|---|
| 1671 | << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
|---|
| 1672 | << "\n";
|
|---|
| 1673 | break;
|
|---|
| 1674 | }
|
|---|
| 1675 | }
|
|---|
| 1676 | if (acName.isEmpty()) {
|
|---|
| 1677 | return;
|
|---|
| 1678 | }
|
|---|
| 1679 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 1680 | while (itSys.hasNext()) {
|
|---|
| 1681 | itSys.next();
|
|---|
| 1682 | char sys = itSys.key();
|
|---|
| 1683 | // Remove all corrections of the corresponding AC
|
|---|
| 1684 | // ----------------------------------------------
|
|---|
| 1685 | QVector<cmbCorr*> &corrVec = _buffer[sys].corrs;
|
|---|
| 1686 | QMutableVectorIterator<cmbCorr*> it(corrVec);
|
|---|
| 1687 | while (it.hasNext()) {
|
|---|
| 1688 | cmbCorr *corr = it.next();
|
|---|
| 1689 | if (acName == corr->_acName) {
|
|---|
| 1690 | delete corr;
|
|---|
| 1691 | it.remove();
|
|---|
| 1692 | }
|
|---|
| 1693 | }
|
|---|
| 1694 | // Reset Satellite Offsets
|
|---|
| 1695 | // -----------------------
|
|---|
| 1696 | if (_method == filter) {
|
|---|
| 1697 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1698 | cmbParam *pp = _params[sys][iPar - 1];
|
|---|
| 1699 | if (pp->AC == acName && pp->type == cmbParam::offACSat) {
|
|---|
| 1700 | pp->xx = 0.0;
|
|---|
| 1701 | _QQ[sys].Row(iPar) = 0.0;
|
|---|
| 1702 | _QQ[sys].Column(iPar) = 0.0;
|
|---|
| 1703 | _QQ[sys](iPar, iPar) = pp->sig0 * pp->sig0;
|
|---|
| 1704 | }
|
|---|
| 1705 | }
|
|---|
| 1706 | }
|
|---|
| 1707 | }
|
|---|
| 1708 | }
|
|---|
| 1709 |
|
|---|
| 1710 | //
|
|---|
| 1711 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1712 | bool bncComb::excludeSat(const t_prn& prn, const QStringList excludeSats) const {
|
|---|
| 1713 | QStringListIterator it(excludeSats);
|
|---|
| 1714 | while (it.hasNext()) {
|
|---|
| 1715 | string prnStr = it.next().toLatin1().data();
|
|---|
| 1716 | if (prnStr == prn.toString() || // prn
|
|---|
| 1717 | prnStr == prn.toString().substr(0,1)) { // sys
|
|---|
| 1718 | return true;
|
|---|
| 1719 | }
|
|---|
| 1720 | }
|
|---|
| 1721 | return false;
|
|---|
| 1722 | }
|
|---|