Changeset 6151 in ntrip for trunk/BNC/src/bnccore.cpp


Ignore:
Timestamp:
Sep 14, 2014, 8:24:57 AM (10 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bnccore.cpp

    r6141 r6151  
    116116#endif
    117117  expandEnvVar(_userName);
    118   _userName = _userName.leftJustified(20, ' ', true);
    119 
    120   _corrs = new QMultiMap<bncTime, t_clkCorr>;
    121 
     118
     119  _userName       = _userName.leftJustified(20, ' ', true);
    122120  _dateAndTimeGPS = 0;
    123 
    124   for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
    125     _GLOFreq[ii] = 0;
    126   }
    127 
    128   _mainWindow = 0;
     121  _mainWindow     = 0;
    129122
    130123  _pppMain = new BNC_PPP::t_pppMain();
     
    158151  }
    159152
    160   delete _corrs;
    161 
    162153  delete _dateAndTimeGPS;
    163 
    164154  delete _rawFile;
    165155
     
    640630////////////////////////////////////////////////////////////////////////////
    641631void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
     632  QMutexLocker locker(&_mutex);
    642633  emit newOrbCorrections(orbCorrections);
     634  if (_socketsCorr) {
     635    QListIterator<t_orbCorr> it(orbCorrections);
     636    while (it.hasNext()) {
     637      const t_orbCorr& corr = it.next();
     638      QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
     639      while (is.hasNext()) {
     640        QTcpSocket* sock = is.next();
     641        if (sock->state() == QAbstractSocket::ConnectedState) {
     642          if (sock->write(corr.toString().c_str()) == -1) {
     643            delete sock;
     644            is.remove();
     645          }
     646        }
     647        else if (sock->state() != QAbstractSocket::ConnectingState) {
     648          delete sock;
     649          is.remove();
     650        }
     651      }
     652    }
     653  }
    643654}
    644655
     
    647658void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
    648659  QMutexLocker locker(&_mutex);
    649 
    650   if (clkCorrections.size() == 0) {
    651     return;
    652   }
    653   bncTime coTime = clkCorrections[0]._time;
    654   QString staID(clkCorrections[0]._staID.c_str());
    655 
    656   // Combination of Corrections
    657   // --------------------------
    658 #ifdef USE_COMBINATION
    659   if (_bncComb) {
    660     _bncComb->processClkCorrections(clkCorrections);
    661   }
    662 #endif
    663 
    664   bncSettings settings;
    665   _waitCoTime = settings.value("corrTime").toDouble();
    666   if (_waitCoTime < 0.0) {
    667     _waitCoTime = 0.0;
    668   }
    669 
    670   // First time, set the _lastCorrDumpTime
    671   // -------------------------------------
    672   if (!_lastCorrDumpTime[staID].valid()) {
    673     _lastCorrDumpTime[staID] = coTime - 1.0;
    674   }
    675 
    676   // An old correction - throw it away
    677   // ---------------------------------
    678   if (_waitCoTime > 0.0 && coTime <= _lastCorrDumpTime[staID]) {
    679     if (!_bncComb) {
    680       QString line = staID + ": Correction for one sat neglected because overaged by " +
    681                       QString().sprintf(" %f sec",
    682                       _lastCorrDumpTime[staID] - coTime + _waitCoTime);
    683       messagePrivate(line.toAscii());
    684       emit( newMessage(line.toAscii(), true) );
    685     }
    686     return;
    687   }
    688 
    689   for (int ii = 0; ii < clkCorrections.size(); ii++) {
    690     _corrs->insert(coTime, clkCorrections[ii]);
    691   }
    692 
    693   // Dump Corrections
    694   // ----------------
    695   if      (_waitCoTime == 0.0) {
    696     dumpCorrs();
    697   }
    698   else if (coTime - _waitCoTime > _lastCorrDumpTime[staID]) {
    699     dumpCorrs(_lastCorrDumpTime[staID] + 1, coTime - _waitCoTime);
    700     _lastCorrDumpTime[staID] = coTime - _waitCoTime;
    701   }
    702 }
    703 
    704 // Dump Complete Correction Epochs
    705 ////////////////////////////////////////////////////////////////////////////
    706 void t_bncCore::dumpCorrs(bncTime minTime, bncTime maxTime) {
    707   QList<t_clkCorr> allCorrs;
    708   QMutableMapIterator<bncTime, t_clkCorr> it(*_corrs);
    709   while (it.hasNext()) {
    710     it.next();
    711     const bncTime& corrTime = it.key();
    712     if (minTime <= corrTime && corrTime <= maxTime) {
    713       allCorrs << it.value();
    714       it.remove();
    715     }
    716   }
    717   dumpCorrs(allCorrs);
    718 }
    719 
    720 // Dump all corrections
    721 ////////////////////////////////////////////////////////////////////////////
    722 void t_bncCore::dumpCorrs() {
    723   QList<t_clkCorr> allCorrs;
    724   QMutableMapIterator<bncTime, t_clkCorr> it(*_corrs);
    725   while (it.hasNext()) {
    726     allCorrs << it.next().value();
    727     it.remove();
    728   }
    729   dumpCorrs(allCorrs);
    730 }
    731 
    732 // Dump List of Corrections
    733 ////////////////////////////////////////////////////////////////////////////
    734 void t_bncCore::dumpCorrs(const QList<t_clkCorr>& allCorrs) {
    735   emit newClkCorrections(allCorrs);
     660  emit newClkCorrections(clkCorrections);
    736661  if (_socketsCorr) {
    737     QListIterator<t_clkCorr> it(allCorrs);
     662    QListIterator<t_clkCorr> it(clkCorrections);
    738663    while (it.hasNext()) {
    739664      const t_clkCorr& corr = it.next();
     
    790715}
    791716
    792 // Get Glonass Slot Numbers from Global Array
    793 ////////////////////////////////////////////////////////////////////////////
    794 void t_bncCore::getGlonassSlotNums(int GLOFreq[]) {
    795 
    796   QMutexLocker locker(&_mutex);
    797 
    798   for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
    799     if (_GLOFreq[ii] != 0) {
    800       GLOFreq[ii] = _GLOFreq[ii];
    801     }
    802   }
    803 }
    804 
    805 // Store Glonass Slot Numbers to Global Array
    806 ////////////////////////////////////////////////////////////////////////////
    807 void t_bncCore::storeGlonassSlotNums(const int GLOFreq[]) {
    808 
    809   QMutexLocker locker(&_mutex);
    810 
    811   for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
    812     if (GLOFreq[ii] != 0) {
    813       _GLOFreq[ii] = GLOFreq[ii];
    814     }
    815   }
    816 }
    817 
    818717//
    819718////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.