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