Changeset 10038 in ntrip


Ignore:
Timestamp:
May 10, 2023, 11:19:40 AM (14 months ago)
Author:
stuerze
Message:

minor changes

Location:
trunk/BNC/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/PPP/pppClient.cpp

    r10034 r10038  
    155155  // -------
    156156  epoTime.reset();
    157   //clearObs();
     157  clearObs();
    158158
    159159  // Create vector of valid observations
     
    636636      return finish(failure, 4);
    637637    }
    638    
     638
    639639      _offGlo = cmpOffGlo(_obsRover);
    640640      _offGal = cmpOffGal(_obsRover);
    641641      _offBds = cmpOffBds(_obsRover);
    642      
     642
    643643    // Prepare Pseudo Observations of the Rover
    644644    // ----------------------------------------
  • trunk/BNC/src/bnccore.cpp

    r10027 r10038  
    759759////////////////////////////////////////////////////////////////////////////
    760760void t_bncCore::initCombination() {
    761   _bncComb = new bncComb();
     761  _bncComb = bncComb::instance();
    762762  if (_bncComb->nStreams() < 1) {
    763763    delete _bncComb;
  • trunk/BNC/src/combination/bncbiassnx.cpp

    r9698 r10038  
    296296//
    297297////////////////////////////////////////////////////////////////////////////
    298 void bncBiasSnx::determineSsrSatCodeBiases(QString prn, double aIF1, double aIF2, t_satCodeBias& satCodeBias) {
     298void bncBiasSnx::determineSsrSatCodeBiases(QString prn, double aIF1, double aIF2,
     299                                           t_satCodeBias* satCodeBias) {
    299300  std::string rnxType2ch;
    300301  double value;
     
    518519
    519520
    520 void bncBiasSnx::setSsrSatCodeBias(std::string rnxType2ch, double value, t_satCodeBias& satCodeBias) {
     521void bncBiasSnx::setSsrSatCodeBias(std::string rnxType2ch, double value,
     522                                    t_satCodeBias* satCodeBias) {
    521523  t_frqCodeBias frqCodeBias;
    522524
     
    524526  frqCodeBias._value = value;
    525527
    526   satCodeBias._bias.push_back(frqCodeBias);
     528  satCodeBias->_bias.push_back(frqCodeBias);
    527529  return;
    528530}
  • trunk/BNC/src/combination/bncbiassnx.h

    r9677 r10038  
    5959  ~bncBiasSnx();
    6060  t_irc readFile(const QString& fileName);
    61   void determineSsrSatCodeBiases(QString prn, double aIF1, double aIF2, t_satCodeBias& satCodeBias);
    62   void setSsrSatCodeBias(std::string rnxType2ch, double value, t_satCodeBias& satCodeBias);
     61  void determineSsrSatCodeBiases(QString prn, double aIF1, double aIF2, t_satCodeBias* satCodeBias);
     62  void setSsrSatCodeBias(std::string rnxType2ch, double value, t_satCodeBias* satCodeBias);
    6363
    6464 private:
  • trunk/BNC/src/combination/bnccomb.cpp

    r10035 r10038  
    114114}
    115115
     116
     117// Define the static Singleton pointer
     118////////////////////////////////////////////////////////////////////////////
     119bncComb* bncComb::_instPtr = NULL;
     120
    116121// Singleton
    117122////////////////////////////////////////////////////////////////////////////
    118123bncComb* bncComb::instance() {
    119   static bncComb _bncComb;
    120   return &_bncComb;
     124  if (_instPtr == NULL) {
     125    _instPtr = new bncComb();
     126  }
     127  return(_instPtr);
    121128}
    122129
     
    318325  delete _antex;
    319326  delete _bsx;
     327
    320328  QMapIterator<char, unsigned> itSys(_cmbSysPrn);
    321329  while (itSys.hasNext()) {
     
    325333      delete _params[sys][iPar-1];
    326334    }
    327     QListIterator<bncTime> itTime(_buffer[sys].keys());
    328     while (itTime.hasNext()) {
    329       bncTime epoTime = itTime.next();
    330       _buffer[sys].remove(epoTime);
    331     }
    332   }
    333 
     335    _buffer.remove(sys);
     336  }
     337  while (!_epoClkData.empty()) {
     338    delete _epoClkData.front();
     339    _epoClkData.pop_front();
     340  }
    334341}
    335342
     
    389396    // Store the correction
    390397    // --------------------
    391     QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
    392     storage[orbCorr._prn] = orbCorr;
     398    QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
     399    if (storage[orbCorr._prn]) {
     400      delete  storage[orbCorr._prn];
     401    }
     402    storage[orbCorr._prn] = new t_orbCorr(orbCorr);
    393403  }
    394404}
     
    425435    // Store the correction
    426436    // --------------------
    427     QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
    428     storage[satCodeBias._prn] = satCodeBias;
     437    QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
     438    if (storage[satCodeBias._prn]) {
     439      delete storage[satCodeBias._prn];
     440    }
     441    storage[satCodeBias._prn] = new t_satCodeBias(satCodeBias);
    429442  }
    430443}
     
    434447void bncComb::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
    435448  QMutexLocker locker(&_mutex);
    436 
    437   bncTime lastTime;
    438 
     449  const double outWait = 1.0 * _cmbSampl;
     450
     451  // Loop over all observations (possible different epochs)
     452  // -----------------------------------------------------
    439453  for (int ii = 0; ii < clkCorrections.size(); ii++) {
    440     t_clkCorr& clkCorr = clkCorrections[ii];
    441     QString    staID(clkCorr._staID.c_str());
    442     QString    prn(clkCorr._prn.toInternalString().c_str());
    443     char       sys = clkCorr._prn.system();
    444 
     454    t_clkCorr* newClk = new t_clkCorr(clkCorrections[ii]);
     455
     456    char sys = newClk->_prn.system();
    445457    if (!_cmbSysPrn.contains(sys)){
     458      delete newClk;
     459      continue;
     460    }
     461
     462    // Check Modulo Time
     463    // -----------------
     464    int sec = int(nint(newClk->_time.gpssec()*10));
     465    if (sec % (_cmbSampl*10) != 0.0) {
     466      delete newClk;
     467      continue;
     468    }
     469
     470    // Find/Check the AC Name
     471    // ----------------------
     472    QString acName;
     473    QString staID(newClk->_staID.c_str());
     474    QListIterator<cmbAC*> icAC(_ACs);
     475    while (icAC.hasNext()) {
     476      cmbAC* AC = icAC.next();
     477      if (AC->mountPoint == staID) {
     478        acName = AC->name;
     479        break;
     480      }
     481    }
     482    if (acName.isEmpty()) {
     483      delete newClk;
    446484      continue;
    447485    }
     
    449487    // Set the last time
    450488    // -----------------
    451     if (lastTime.undef() || clkCorr._time > lastTime) {
    452       lastTime = clkCorr._time;
    453     }
     489    if (_lastClkCorrTime.undef() || newClk->_time > _lastClkCorrTime) {
     490      _lastClkCorrTime = newClk->_time;
     491    }
     492
     493    // Check Correction Age
     494    // --------------------
     495    //if (_lastEpoTimeOK.valid() && newClk->_time <= _lastEpoTimeOK) {
     496    if (_lastClkCorrTime.valid() && newClk->_time < _lastClkCorrTime) {
     497      emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + newClk->_prn.toString().c_str() +
     498                       //QString(" %1 ").arg(_lastEpoTimeOK.timestr().c_str()).toLatin1() + "vs. old" +
     499                       QString(" %1 ").arg(_lastClkCorrTime.timestr().c_str()).toLatin1() + "vs. old" +
     500                       QString(" %1 ").arg(newClk->_time.timestr().c_str()).toLatin1(), true);
     501      delete newClk;
     502      continue;
     503    }
     504
     505    // Find the corresponding data epoch or create a new one
     506    // -----------------------------------------------------
     507    epoClkData* epoch = 0;
     508    deque<epoClkData*>::const_iterator it;
     509    for (it = _epoClkData.begin(); it != _epoClkData.end(); it++) {
     510      if (newClk->_time == (*it)->_time) {
     511      epoch = *it;
     512        break;
     513      }
     514    }
     515    if (epoch == 0) {
     516      if (_epoClkData.empty() || newClk->_time > _epoClkData.back()->_time) {
     517        epoch = new epoClkData;
     518        epoch->_time = newClk->_time;
     519        _epoClkData.push_back(epoch);
     520      }
     521    }
     522
     523    // Put data into the epoch
     524    // -----------------------
     525    if (epoch != 0) {
     526      epoch->_clkCorr.push_back(newClk);
     527    }
     528    else {
     529      delete newClk;
     530    }
     531  }
     532
     533  // Make sure the buffer does not grow beyond any limit
     534  // ---------------------------------------------------
     535  const unsigned MAX_EPODATA_SIZE = 10;
     536  if (_epoClkData.size() > MAX_EPODATA_SIZE) {
     537    delete _epoClkData.front();
     538    _epoClkData.pop_front();
     539  }
     540
     541  // Process the oldest epochs
     542  // ------------------------
     543  while (_epoClkData.size()) {
     544
     545    if(!_lastClkCorrTime.valid()) {
     546      return;
     547    }
     548
     549    const vector<t_clkCorr*>& clkCorrVec = _epoClkData.front()->_clkCorr;
     550
     551    bncTime epoTime = _epoClkData.front()->_time;
     552
     553    // Process the front epoch
     554    // -----------------------
     555    if (epoTime < (_lastClkCorrTime - outWait)) {
     556      processEpoch(epoTime, clkCorrVec);
     557      delete _epoClkData.front();
     558      _epoClkData.pop_front();
     559    }
     560    else {
     561      return;
     562    }
     563  }
     564}
     565
     566// Change the correction so that it refers to last received ephemeris
     567////////////////////////////////////////////////////////////////////////////
     568void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
     569
     570  if (corr->_eph == lastEph) {
     571    return;
     572  }
     573
     574  ColumnVector oldXC(6);
     575  ColumnVector oldVV(3);
     576  if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
     577    return;
     578  }
     579
     580  ColumnVector newXC(6);
     581  ColumnVector newVV(3);
     582  if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
     583    return;
     584  }
     585
     586  ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
     587  ColumnVector dV = newVV           - oldVV;
     588  double       dC = newXC(4)        - oldXC(4);
     589
     590  ColumnVector dRAO(3);
     591  XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
     592
     593  ColumnVector dDotRAO(3);
     594  XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
     595
     596  QString msg = "switch corr " + corr->_prn.mid(0,3)
     597    + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
     598
     599  emit newMessage(msg.toLatin1(), false);
     600
     601  corr->_iod = lastEph->IOD();
     602  corr->_eph = lastEph;
     603
     604  corr->_orbCorr->_xr    += dRAO;
     605  corr->_orbCorr->_dotXr += dDotRAO;
     606  corr->_clkCorr->_dClk  -= dC;
     607}
     608
     609// Process Epoch
     610////////////////////////////////////////////////////////////////////////////
     611void bncComb::processEpoch(bncTime epoTime, const vector<t_clkCorr*>& clkCorrVec) {
     612
     613  for (unsigned ii = 0; ii < clkCorrVec.size(); ii++) {
     614    const t_clkCorr* clkCorr = clkCorrVec.at(ii);
     615    QString    staID(clkCorr->_staID.c_str());
     616    QString    prn(clkCorr->_prn.toInternalString().c_str());
     617    char       sys = clkCorr->_prn.system();
    454618
    455619    // Find/Check the AC Name
     
    466630      }
    467631    }
    468     if (acName.isEmpty()) {
    469       continue;
    470     }
    471 
    472     // Check Modulo Time
    473     // -----------------
    474     int sec = int(nint(clkCorr._time.gpssec()*10));
    475     if (sec % (_cmbSampl*10) != 0.0) {
    476       continue;
    477     }
    478 
    479     // Check Correction Age
    480     // --------------------
    481     if (_resTime.valid() && clkCorr._time <= _resTime) {
    482       emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + prn.mid(0,3).toLatin1() +
    483                        QString("%1").arg(_resTime.timestr().c_str()).toLatin1() + " vs. old " +
    484                        QString("%1").arg(clkCorr._time.timestr().c_str()).toLatin1(), true);
    485       continue;
    486     }
    487632
    488633    // Create new correction
    489634    // ---------------------
    490     cmbCorr* newCorr  = new cmbCorr();
    491     newCorr->_prn     = prn;
    492     newCorr->_time    = clkCorr._time;
    493     newCorr->_iod     = clkCorr._iod;
    494     newCorr->_acName  = acName;
    495     newCorr->_clkCorr = clkCorr;
     635    cmbCorr* newCorr       = new cmbCorr();
     636    newCorr->_prn          = prn;
     637    newCorr->_time         = clkCorr->_time;
     638    newCorr->_iod          = clkCorr->_iod;
     639    newCorr->_acName       = acName;
    496640    newCorr->_weightFactor = weigthFactor;
     641    newCorr->_clkCorr = new t_clkCorr(*clkCorrVec[ii]);
    497642
    498643    // Check orbit correction
     
    503648    }
    504649    else {
    505       QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
    506       if (!storage.contains(clkCorr._prn)  ||
    507            storage[clkCorr._prn]._iod != newCorr->_iod) {
     650      QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
     651      if (!storage.contains(clkCorr->_prn)  ||
     652           storage[clkCorr->_prn]->_iod != newCorr->_iod) {
    508653        delete newCorr;
    509654        continue;
    510655      }
    511656      else {
    512         newCorr->_orbCorr = storage[clkCorr._prn];
     657        newCorr->_orbCorr = storage[clkCorr->_prn];
    513658      }
    514659    }
     
    556701    // ----------------------------
    557702    if (_satCodeBiases.contains(acName)) {
    558       QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
    559       if (storage.contains(clkCorr._prn)) {
    560         newCorr->_satCodeBias = storage[clkCorr._prn];
     703      QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
     704      if (storage.contains(clkCorr->_prn)) {
     705        newCorr->_satCodeBias = storage[clkCorr->_prn];
    561706        QMap<t_frequency::type, double> codeBiasesRefSig;
    562707        for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
    563           t_frequency::type frqType = cmbRefSig::toFreq(sys,  static_cast<cmbRefSig::type>(ii));
     708          t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
    564709          char frqNum = t_frequency::toString(frqType)[1];
    565           char attrib = cmbRefSig::toAttrib(sys,  static_cast<cmbRefSig::type>(ii));
     710          char attrib = cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii));
    566711          QString rnxType2ch = QString("%1%2").arg(frqNum).arg(attrib);
    567           for (unsigned ii = 0; ii < newCorr->_satCodeBias._bias.size(); ii++) {
    568             const t_frqCodeBias& bias = newCorr->_satCodeBias._bias[ii];
     712          for (unsigned ii = 0; ii < newCorr->_satCodeBias->_bias.size(); ii++) {
     713            const t_frqCodeBias& bias = newCorr->_satCodeBias->_bias[ii];
    569714            if (rnxType2ch.toStdString() == bias._rnxType2ch) {
    570715              codeBiasesRefSig[frqType] = bias._value;
     
    582727          }
    583728        }
    584         newCorr->_satCodeBias._bias.clear();
     729        newCorr->_satCodeBias->_bias.clear();
    585730      }
    586731    }
     
    588733    // Store correction into the buffer
    589734    // --------------------------------
    590     QVector<cmbCorr*>& corrs = _buffer[sys][newCorr->_time].corrs;
    591     corrs.push_back(newCorr);
    592   }
    593 
    594   // Process previous Epoch(s)
    595   // -------------------------
    596   const double outWait = 1.0 * _cmbSampl;
     735    QVector<cmbCorr*>& corrs = _buffer[sys].corrs;
     736
     737    QVectorIterator<cmbCorr*> itCorr(corrs);
     738    bool available = false;
     739    while (itCorr.hasNext()) {
     740      cmbCorr* corr = itCorr.next();
     741      QString  prn  = corr->_prn;
     742      QString  acName = corr->_acName;
     743      if (newCorr->_acName == acName && newCorr->_prn == prn) {
     744        available = true;
     745      }
     746    }
     747    if (!available) {
     748      corrs.push_back(newCorr);
     749    }
     750    else {
     751      delete newCorr;
     752      continue;
     753    }
     754  }
     755
     756  // Process Systems of this Epoch
     757  // ------------------------------
    597758  QMapIterator<char, unsigned> itSys(_cmbSysPrn);
    598759  while (itSys.hasNext()) {
    599760    itSys.next();
    600761    char sys = itSys.key();
    601     QListIterator<bncTime> itTime(_buffer[sys].keys());
    602     while (itTime.hasNext()) {
    603       bncTime epoTime = itTime.next();
    604       if (epoTime < lastTime - outWait) {
    605         _resTime = epoTime;
    606         processEpoch(sys);
    607       }
    608     }
    609   }
    610 }
    611 
    612 // Change the correction so that it refers to last received ephemeris
    613 ////////////////////////////////////////////////////////////////////////////
    614 void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
    615 
    616   if (corr->_eph == lastEph) {
    617     return;
    618   }
    619 
    620   ColumnVector oldXC(6);
    621   ColumnVector oldVV(3);
    622   if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
    623     return;
    624   }
    625 
    626   ColumnVector newXC(6);
    627   ColumnVector newVV(3);
    628   if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
    629     return;
    630   }
    631 
    632   ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
    633   ColumnVector dV = newVV           - oldVV;
    634   double       dC = newXC(4)        - oldXC(4);
    635 
    636   ColumnVector dRAO(3);
    637   XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
    638 
    639   ColumnVector dDotRAO(3);
    640   XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
    641 
    642   QString msg = "switch corr " + corr->_prn.mid(0,3)
    643     + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
    644 
    645   emit newMessage(msg.toLatin1(), false);
    646 
    647   corr->_iod = lastEph->IOD();
    648   corr->_eph = lastEph;
    649 
    650   corr->_orbCorr._xr    += dRAO;
    651   corr->_orbCorr._dotXr += dDotRAO;
    652   corr->_clkCorr._dClk  -= dC;
    653 }
    654 
    655 // Process Epoch
    656 ////////////////////////////////////////////////////////////////////////////
    657 void bncComb::processEpoch(char sys) {
    658 
    659   _log.clear();
    660 
    661   QTextStream out(&_log, QIODevice::WriteOnly);
     762    _log.clear();
     763    QTextStream out(&_log, QIODevice::WriteOnly);
     764    processSystem(epoTime, sys, out);
     765    emit newMessage(_log, false);
     766  }
     767}
     768
     769void bncComb::processSystem(bncTime epoTime, char sys, QTextStream& out) {
    662770
    663771  out << "\n" <<           "Combination: " << sys << "\n"
     
    694802    if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
    695803      out << "Missing Master, Epoch skipped" << "\n";
    696       _buffer[sys].remove(_resTime);
     804      _buffer.remove(sys);
    697805      emit newMessage(_log, false);
    698806      return;
     
    707815              << _masterOrbitAC[sys].toLatin1().data() << " --> "
    708816              << AC->name.toLatin1().data()   << " "
    709               << _resTime.datestr().c_str()    << " "
    710               << _resTime.timestr().c_str()    << "\n";
     817              << epoTime.datestr().c_str()    << " "
     818              << epoTime.timestr().c_str()    << "\n";
    711819          _masterOrbitAC[sys] = AC->name;
    712820          break;
     
    723831  ColumnVector dx;
    724832  if (_method == filter) {
    725     irc = processEpoch_filter(sys, out, resCorr, dx);
     833    irc = processEpoch_filter(epoTime, sys, out, resCorr, dx);
    726834  }
    727835  else {
    728     irc = processEpoch_singleEpoch(sys, out, resCorr, dx);
     836    irc = processEpoch_singleEpoch(epoTime, sys, out, resCorr, dx);
    729837  }
    730838
     
    746854            t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
    747855            t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
     856            if (resCorr[pp->prn]->_satCodeBias == 0) {
     857              resCorr[pp->prn]->_satCodeBias = new t_satCodeBias();
     858            }
    748859            _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], resCorr[pp->prn]->_satCodeBias);
    749860          }
    750861        }
    751862      }
    752       out << _resTime.datestr().c_str() << " "
    753           << _resTime.timestr().c_str() << " ";
     863      out << epoTime.datestr().c_str() << " "
     864          << epoTime.timestr().c_str() << " ";
    754865      out.setRealNumberNotation(QTextStream::FixedNotation);
    755866      out.setFieldWidth(8);
     
    759870      out.setFieldWidth(0);
    760871    }
    761     printResults(out, resCorr);
    762     dumpResults(resCorr);
    763   }
    764 
    765   // Delete Data, emit Message
    766   // -------------------------
    767   _buffer[sys].remove(_resTime);
    768   emit newMessage(_log, false);
     872    printResults(epoTime, out, resCorr);
     873    dumpResults(epoTime, resCorr);
     874  }
     875  // Delete Data
     876  // -----------
     877  _buffer.remove(sys);
    769878}
    770879
    771880// Process Epoch - Filter Method
    772881////////////////////////////////////////////////////////////////////////////
    773 t_irc bncComb::processEpoch_filter(char sys, QTextStream& out,
     882t_irc bncComb::processEpoch_filter(bncTime epoTime, char sys, QTextStream& out,
    774883                                   QMap<QString, cmbCorr*>& resCorr,
    775884                                   ColumnVector& dx) {
     
    795904  // Check Satellite Positions for Outliers
    796905  // --------------------------------------
    797   if (checkOrbits(sys, out) != success) {
     906  if (checkOrbits(epoTime, sys, out) != success) {
    798907    return failure;
    799908  }
     
    821930    out.setRealNumberNotation(QTextStream::FixedNotation);
    822931    out.setRealNumberPrecision(3);
    823     out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
     932    out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
    824933        << " Maximum Residuum " << maxRes << ' '
    825934        << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
     
    846955      for (int ii = 0; ii < corrs(sys).size(); ii++) {
    847956      const cmbCorr* corr = corrs(sys)[ii];
    848         out << _resTime.datestr().c_str() << ' '
    849             << _resTime.timestr().c_str() << " "
     957        out << epoTime.datestr().c_str() << ' '
     958            << epoTime.timestr().c_str() << " "
    850959            << corr->_acName << ' ' << corr->_prn.mid(0,3);
    851960        out.setFieldWidth(10);
     
    862971// Print results
    863972////////////////////////////////////////////////////////////////////////////
    864 void bncComb::printResults(QTextStream& out,
     973void bncComb::printResults(bncTime epoTime, QTextStream& out,
    865974                           const QMap<QString, cmbCorr*>& resCorr) {
    866975
     
    873982      ColumnVector xc(6);
    874983      ColumnVector vv(3);
    875       if (eph->getCrd(_resTime, xc, vv, false) != success) {
     984      if (eph->getCrd(epoTime, xc, vv, false) != success) {
    876985        continue;
    877986      }
    878       out << _resTime.datestr().c_str() << " "
    879           << _resTime.timestr().c_str() << " ";
     987      out << epoTime.datestr().c_str() << " "
     988          << epoTime.timestr().c_str() << " ";
    880989      out.setFieldWidth(3);
    881990      out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
     
    8931002// Send results to RTNet Decoder and directly to PPP Client
    8941003////////////////////////////////////////////////////////////////////////////
    895 void bncComb::dumpResults(const QMap<QString, cmbCorr*>& resCorr) {
     1004void bncComb::dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr) {
    8961005
    8971006  QList<t_orbCorr> orbCorrections;
     
    9011010  unsigned year, month, day, hour, minute;
    9021011  double   sec;
    903   _resTime.civil_date(year, month, day);
    904   _resTime.civil_time(hour, minute, sec);
     1012  epoTime.civil_date(year, month, day);
     1013  epoTime.civil_time(hour, minute, sec);
    9051014
    9061015  QString outLines = QString().asprintf("*  %4d %2d %2d %d %d %12.8f\n",
     
    9111020    it.next();
    9121021    cmbCorr* corr = it.value();
     1022
    9131023    // ORBIT
    914     t_orbCorr orbCorr(corr->_orbCorr);
     1024    t_orbCorr orbCorr(static_cast<t_orbCorr>(*corr->_orbCorr));
    9151025    orbCorr._staID = "INTERNAL";
    9161026    orbCorrections.push_back(orbCorr);
     1027
    9171028    // CLOCK
    918     t_clkCorr clkCorr(corr->_clkCorr);
     1029    t_clkCorr clkCorr(static_cast<t_clkCorr>(*corr->_clkCorr));
    9191030    clkCorr._staID      = "INTERNAL";
    9201031    clkCorr._dClk       = corr->_dClkResult;
     
    9221033    clkCorr._dotDotDClk = 0.0;
    9231034    clkCorrections.push_back(clkCorr);
     1035
    9241036    // CODE BIASES
    925     t_satCodeBias satCodeBias(corr->_satCodeBias);
     1037    t_satCodeBias satCodeBias(static_cast<t_satCodeBias>(*corr->_satCodeBias));
    9261038    satCodeBias._staID = "INTERNAL";
    9271039    satCodeBiasList.push_back(satCodeBias);
     
    9311043    corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
    9321044    corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
    933     if (corr->_eph->getCrd(_resTime, xc, vv, true) != success) {
     1045    if (corr->_eph->getCrd(epoTime, xc, vv, true) != success) {
    9341046      delete corr;
    9351047      continue;
     
    9401052    ColumnVector dx(3); dx = 0.0;
    9411053    if (_antex) {
    942       double Mjd = _resTime.mjd() + _resTime.daysec()/86400.0;
     1054      double Mjd = epoTime.mjd() + epoTime.daysec()/86400.0;
    9431055      if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
    9441056        dx = 0;
     
    10341146    }
    10351147
    1036     ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
     1148    ll(iObs) = (corr->_clkCorr->_dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
    10371149
    10381150    PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
     
    10811193// Process Epoch - Single-Epoch Method
    10821194////////////////////////////////////////////////////////////////////////////
    1083 t_irc bncComb::processEpoch_singleEpoch(char sys, QTextStream& out,
     1195t_irc bncComb::processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out,
    10841196                                        QMap<QString, cmbCorr*>& resCorr,
    10851197                                        ColumnVector& dx) {
     
    10871199  // Check Satellite Positions for Outliers
    10881200  // --------------------------------------
    1089   if (checkOrbits(sys, out) != success) {
     1201  if (checkOrbits(epoTime, sys, out) != success) {
    10901202    return failure;
    10911203  }
     
    12031315    out.setRealNumberNotation(QTextStream::FixedNotation);
    12041316    out.setRealNumberPrecision(3);
    1205     out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
     1317    out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
    12061318        << " Maximum Residuum " << maxRes << ' '
    12071319        << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
     
    12181330      for (int ii = 0; ii < vv.Nrows(); ii++) {
    12191331        const cmbCorr* corr = corrs(sys)[ii];
    1220         out << _resTime.datestr().c_str() << ' '
    1221             << _resTime.timestr().c_str() << " "
     1332        out << epoTime.datestr().c_str() << ' '
     1333            << epoTime.timestr().c_str() << " "
    12221334            << corr->_acName << ' ' << corr->_prn.mid(0,3);
    12231335        out.setFieldWidth(6);
     
    12351347// Check Satellite Positions for Outliers
    12361348////////////////////////////////////////////////////////////////////////////
    1237 t_irc bncComb::checkOrbits(char sys, QTextStream& out) {
     1349t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out) {
    12381350
    12391351  const double MAX_DISPLACEMENT = 0.20;
     
    12831395      if (meanRao.find(prn) == meanRao.end()) {
    12841396        meanRao[prn].ReSize(4);
    1285         meanRao[prn].Rows(1,3) = corr->_orbCorr._xr;
     1397        meanRao[prn].Rows(1,3) = corr->_orbCorr->_xr;
    12861398        meanRao[prn](4)        = 1;
    12871399      }
    12881400      else {
    1289         meanRao[prn].Rows(1,3) += corr->_orbCorr._xr;
     1401        meanRao[prn].Rows(1,3) += corr->_orbCorr->_xr;
    12901402        meanRao[prn](4)        += 1;
    12911403      }
     
    13091421        meanRao[prn](4) = 0;
    13101422      }
    1311       corr->_diffRao = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
     1423      corr->_diffRao = corr->_orbCorr->_xr - meanRao[prn].Rows(1,3);
    13121424      if (maxDiff.find(prn) == maxDiff.end()) {
    13131425        maxDiff[prn] = corr;
     
    13401452        double norm = corr->_diffRao.NormFrobenius();
    13411453        if (norm > MAX_DISPLACEMENT) {
    1342           out << _resTime.datestr().c_str()    << " "
    1343               << _resTime.timestr().c_str()    << " "
     1454          out << epoTime.datestr().c_str()    << " "
     1455              << epoTime.timestr().c_str()    << " "
    13441456              << "Orbit Outlier: "
    13451457              << corr->_acName.toLatin1().data() << " "
     
    13741486  QListIterator<cmbAC*> icAC(_ACs);
    13751487  while (icAC.hasNext()) {
    1376     cmbAC* AC = icAC.next();
     1488    cmbAC *AC = icAC.next();
    13771489    if (AC->mountPoint == mountPoint) {
    13781490      acName = AC->name;
    1379       out << "Provider ID changed: AC " << AC->name.toLatin1().data()   << " "
    1380           << _resTime.datestr().c_str()    << " "
    1381           << _resTime.timestr().c_str()    << "\n";
     1491      out << "Provider ID changed: AC " << AC->name.toLatin1().data() << " "
     1492//          << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
     1493          << "\n";
    13821494      break;
    13831495    }
     
    13921504    // Remove all corrections of the corresponding AC
    13931505    // ----------------------------------------------
    1394     QListIterator<bncTime> itTime(_buffer[sys].keys());
    1395     while (itTime.hasNext()) {
    1396       bncTime epoTime = itTime.next();
    1397       QVector<cmbCorr*>& corrVec = _buffer[sys][epoTime].corrs;
    1398       QMutableVectorIterator<cmbCorr*> it(corrVec);
    1399       while (it.hasNext()) {
    1400         cmbCorr* corr = it.next();
    1401         if (acName == corr->_acName) {
    1402           delete corr;
    1403           it.remove();
    1404         }
    1405       }
    1406     }
    1407 
     1506    QVector<cmbCorr*> &corrVec = _buffer[sys].corrs;
     1507    QMutableVectorIterator<cmbCorr*> it(corrVec);
     1508    while (it.hasNext()) {
     1509      cmbCorr *corr = it.next();
     1510      if (acName == corr->_acName) {
     1511        delete corr;
     1512        it.remove();
     1513      }
     1514    }
    14081515    // Reset Satellite Offsets
    14091516    // -----------------------
    14101517    if (_method == filter) {
    14111518      for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
    1412         cmbParam* pp = _params[sys][iPar-1];
     1519        cmbParam *pp = _params[sys][iPar - 1];
    14131520        if (pp->AC == acName && pp->type == cmbParam::offACSat) {
    14141521          pp->xx = 0.0;
    1415           _QQ[sys].Row(iPar)    = 0.0;
     1522          _QQ[sys].Row(iPar) = 0.0;
    14161523          _QQ[sys].Column(iPar) = 0.0;
    1417           _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
     1524          _QQ[sys](iPar, iPar) = pp->sig0 * pp->sig0;
    14181525        }
    14191526      }
  • trunk/BNC/src/combination/bnccomb.h

    r9821 r10038  
    44
    55#include <fstream>
     6#include <iostream>
    67#include <map>
    78#include <newmat.h>
     9#include <deque>
    810#include "bncephuser.h"
    911#include "satObs.h"
     
    2022 Q_OBJECT
    2123 public:
    22   bncComb();
    2324  virtual ~bncComb();
    2425  static bncComb* instance();
     
    4243
    4344 private:
     45  static bncComb* _instPtr;   // The one, single instance
     46  bncComb();                  // private constructor
     47  bncComb(const bncComb&);
     48  bncComb& operator=(const bncComb&);
     49
    4450  enum e_method{singleEpoch, filter};
    4551
     
    8591    cmbCorr() {
    8692      _eph                        = 0;
     93      _orbCorr                    = 0;
     94      _clkCorr                    = 0;
     95      _satCodeBias                = 0;
    8796      _iod                        = 0;
    8897      _dClkResult                 = 0.0;
    8998      _satCodeBiasIF              = 0.0;
     99      _weightFactor               = 1.0;
    90100    }
    91101    ~cmbCorr() {}
     
    94104    unsigned long  _iod;
    95105    t_eph*         _eph;
    96     t_orbCorr      _orbCorr;
    97     t_clkCorr      _clkCorr;
    98     t_satCodeBias  _satCodeBias;
     106    t_orbCorr*      _orbCorr;
     107    t_clkCorr*      _clkCorr;
     108    t_satCodeBias* _satCodeBias;
    99109    QString        _acName;
    100110    double         _satCodeBiasIF;
     
    109119    cmbEpoch() {}
    110120    ~cmbEpoch() {
     121      clear();
     122    }
     123    void clear() {
    111124      QVectorIterator<cmbCorr*> it(corrs);
    112125      while (it.hasNext()) {
     
    115128    }
    116129    QVector<cmbCorr*> corrs;
     130  };
     131
     132  class epoClkData {
     133   public:
     134    epoClkData() {}
     135    ~epoClkData() {
     136      for (unsigned ii = 0; ii < _clkCorr.size(); ii++) {
     137        delete _clkCorr[ii];
     138      }
     139    }
     140    bncTime                 _time;
     141    std::vector<t_clkCorr*> _clkCorr;
    117142  };
    118143
     
    196221  };
    197222
    198 
    199   void  processEpoch(char sys);
    200   t_irc processEpoch_filter(char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
    201                             ColumnVector& dx);
    202   t_irc processEpoch_singleEpoch(char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
    203                                  ColumnVector& dx);
     223  void  processEpoch(bncTime epoTime, const std::vector<t_clkCorr*>& clkCorrVec);
     224  void  processSystem(bncTime epoTime, char sys, QTextStream& out);
     225  t_irc processEpoch_filter(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
     226  t_irc processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
    204227  t_irc createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
    205228                   const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr);
    206   void  dumpResults(const QMap<QString, cmbCorr*>& resCorr);
    207   void  printResults(QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
     229  void  dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr);
     230  void  printResults(bncTime epoTime, QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
    208231  void  switchToLastEph(t_eph* lastEph, cmbCorr* corr);
    209   t_irc checkOrbits(char sys, QTextStream& out);
    210   QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys][_resTime].corrs;}
     232  t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out);
     233  QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys].corrs;}
    211234
    212235  QMutex                                     _mutex;
    213236  QList<cmbAC*>                              _ACs;
    214   bncTime                                    _resTime;
     237  std::deque<epoClkData*>                    _epoClkData;
     238  bncTime                                    _lastClkCorrTime;
    215239  QMap<char, QVector<cmbParam*>>             _params;
    216   QMap<char, QMap<bncTime, cmbEpoch>>        _buffer;
     240  QMap<char, cmbEpoch>                       _buffer;
    217241  bncRtnetDecoder*                           _rtnetDecoder;
    218242  QMap<char, SymmetricMatrix>                _QQ;
     
    227251  int                                        _ms;
    228252  QString                                    _cmbRefAttributes;
    229   QMap<QString, QMap<t_prn, t_orbCorr> >     _orbCorrections;
    230   QMap<QString, QMap<t_prn, t_satCodeBias> > _satCodeBiases;
     253  QMap<QString, QMap<t_prn, t_orbCorr*> >     _orbCorrections;
     254  QMap<QString, QMap<t_prn, t_satCodeBias*> > _satCodeBiases;
    231255  bncEphUser                                 _ephUser;
    232256  SsrCorr*                                   _ssrCorr;
  • trunk/BNC/src/satObs.h

    r9567 r10038  
    4949class t_satObs {
    5050 public:
    51   t_satObs() {}
     51  t_satObs() {
     52    _type = 0;
     53  }
    5254  t_satObs(const t_satObs& old) { // copy constructor (deep copy)
    5355    _staID = old._staID;
     
    6264   * Destructor of satellite measurement storage class
    6365   */
    64   ~t_satObs()
    65   {
     66  ~t_satObs() {
    6667    clear();
    6768  }
     
    7071   * Cleanup function resets all elements to initial state.
    7172   */
    72   inline void clear(void)
    73   {
     73  inline void clear(void) {
    7474    for (unsigned ii = 0; ii < _obs.size(); ii++)
    7575      delete _obs[ii];
     
    9292 public:
    9393  t_orbCorr();
     94  t_orbCorr(const t_orbCorr& old) { // copy constructor (deep copy)
     95    _staID      = old._staID;
     96    _prn        = old._prn;
     97    _iod        = old._iod;
     98    _time       = old._time;
     99    _updateInt  = old._updateInt;
     100    _system     = old._system;
     101    _xr         = old._xr;
     102    _dotXr      = old._dotXr;
     103  }
    94104  static void writeEpoch(std::ostream* out, const QList<t_orbCorr>& corrList);
    95105  static void readEpoch(const std::string& epoLine, std::istream& in, QList<t_orbCorr>& corrList);
     
    107117 public:
    108118  t_clkCorr();
     119  t_clkCorr(const t_clkCorr& old) { // copy constructor (deep copy)
     120    _staID      = old._staID;
     121    _prn        = old._prn;
     122    _iod        = old._iod;
     123    _time       = old._time;
     124    _updateInt  = old._updateInt;
     125    _dClk       = old._dClk;
     126    _dotDClk    = old._dotDClk;
     127    _dotDotDClk = old._dotDotDClk;
     128  }
    109129  static void writeEpoch(std::ostream* out, const QList<t_clkCorr>& corrList);
    110130  static void readEpoch(const std::string& epoLine, std::istream& in, QList<t_clkCorr>& corrList);
     
    143163class t_satCodeBias {
    144164 public:
     165  t_satCodeBias() {
     166    _updateInt = 0;
     167  }
     168  t_satCodeBias(const t_satCodeBias& old) { // copy constructor (deep copy)
     169    _staID      = old._staID;
     170    _prn        = old._prn;
     171    _time       = old._time;
     172    _updateInt  = old._updateInt;
     173    for (unsigned ii = 0; ii < old._bias.size(); ii++) {
     174      _bias.push_back(old._bias[ii]);
     175    }
     176  }
    145177  static void writeEpoch(std::ostream* out, const QList<t_satCodeBias>& biasList);
    146178  static void readEpoch(const std::string& epoLine, std::istream& in, QList<t_satCodeBias>& biasList);
     
    175207    _yaw        = 0.0;
    176208    _yawRate    = 0.0;
     209  }
     210  t_satPhaseBias(const t_satPhaseBias& old) { // copy constructor (deep copy)
     211    _staID      = old._staID;
     212    _prn        = old._prn;
     213    _time       = old._time;
     214    _updateInt  = old._updateInt;
     215    _dispBiasConstistInd = old._dispBiasConstistInd;
     216    _MWConsistInd        = old._MWConsistInd;
     217    _yaw                 = old._yaw;
     218    _yawRate             = old._yawRate;
     219    for (unsigned ii = 0; ii < old._bias.size(); ii++) {
     220      _bias.push_back(old._bias[ii]);
     221    }
    177222  }
    178223  static void writeEpoch(std::ostream* out, const QList<t_satPhaseBias>& biasList);
     
    201246class t_vTec {
    202247 public:
     248  t_vTec(){
     249    _updateInt = 0;
     250  }
     251  t_vTec(const t_vTec& old) { // copy constructor (deep copy)
     252    _staID      = old._staID;
     253    _time       = old._time;
     254    _updateInt  = old._updateInt;
     255    for (unsigned ii = 0; ii < old._layers.size(); ii++) {
     256      _layers.push_back(old._layers[ii]);
     257    }
     258  }
    203259  static void write(std::ostream* out, const t_vTec& vTec);
    204260  static void read(const std::string& epoLine, std::istream& in, t_vTec& vTec);
Note: See TracChangeset for help on using the changeset viewer.