Changeset 2918 in ntrip for trunk/BNC/combination/bnccomb.cpp


Ignore:
Timestamp:
Jan 27, 2011, 5:39:44 PM (13 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/combination/bnccomb.cpp

    r2915 r2918  
    3030
    3131  QStringList combineStreams = settings.value("combineStreams").toStringList();
    32  
    33   _nStreams = combineStreams.size();
    34  
    35   if (_nStreams >= 2) {
     32
     33  if (combineStreams.size() >= 2) {
    3634    QListIterator<QString> it(combineStreams);
    3735    while (it.hasNext()) {
    3836      QStringList hlp = it.next().split(" ");
    39       cout << "combination: " << hlp[0].toAscii().data() << endl;
     37      cmbAC* newAC = new cmbAC();
     38      newAC->mountPoint = hlp[0];
     39      newAC->name       = hlp[1];
     40      newAC->weight     = hlp[2].toDouble();
     41
     42      _ACs[newAC->mountPoint] = newAC;
    4043    }
    4144  }
     
    4548////////////////////////////////////////////////////////////////////////////
    4649bncComb::~bncComb() {
     50  QMapIterator<QString, cmbAC*> it(_ACs);
     51  while (it.hasNext()) {
     52    it.next();
     53    delete it.value();
     54  }
    4755}
    4856
     
    5260  QMutexLocker locker(&_mutex);
    5361
     62  // Find the relevant instance of cmbAC class
     63  // -----------------------------------------
     64  if (_ACs.find(staID) == _ACs.end()) {
     65    return;
     66  }
     67  cmbAC* AC = _ACs[staID];
     68
     69  // Read the Correction
     70  // -------------------
    5471  t_corr* newCorr = new t_corr();
    5572  if (!newCorr->readLine(line) == success) {
     
    5875  }
    5976
    60   cout << staID.toAscii().data() << " " << newCorr->prn.toAscii().data() << " "
    61        << newCorr->tt.datestr() << " " << newCorr->tt.timestr() << " "
    62        << newCorr->iod << " " << newCorr->dClk << endl;
     77  // Find/Create the instance of cmbEpoch class
     78  // ------------------------------------------
     79  cmbEpoch* newEpoch = 0;
     80  QListIterator<cmbEpoch*> it(AC->epochs);
     81  while (it.hasNext()) {
     82    cmbEpoch* hlpEpoch = it.next();
     83    if (hlpEpoch->time == newCorr->tt) {
     84      newEpoch = hlpEpoch;
     85      break;
     86    }
     87  }
     88  if (newEpoch == 0) {
     89    newEpoch = new cmbEpoch();
     90    newEpoch->time = newCorr->tt;
     91    AC->epochs.append(newEpoch);
     92  }
    6393
    64   delete newCorr;
     94  if (newEpoch->corr.find(newCorr->prn) != newEpoch->corr.end()) {
     95    delete newEpoch->corr[newCorr->prn];     
     96  }
     97  newEpoch->corr[newCorr->prn] = newCorr;
     98
     99  processEpochsBefore(newCorr->tt);
    65100}
    66101
     102//
     103////////////////////////////////////////////////////////////////////////////
     104void bncComb::processEpochsBefore(const bncTime& time) {
     105
     106  const double waitTime = 10.0; // wait 10 seconds
     107
     108  QMapIterator<QString, cmbAC*> itAC(_ACs);
     109  while (itAC.hasNext()) {
     110    itAC.next();
     111    cmbAC* AC = itAC.value();
     112
     113
     114    QMutableListIterator<cmbEpoch*> itEpo(AC->epochs);
     115    while (itEpo.hasNext()) {
     116      cmbEpoch* epoch = itEpo.next();
     117      double dt = time - epoch->time;
     118
     119      if      (dt == waitTime) {
     120        QMapIterator<QString, t_corr*> itCorr(epoch->corr);
     121        while (itCorr.hasNext()) {
     122          itCorr.next();
     123          t_corr* corr = itCorr.value();
     124          cout << AC->name.toAscii().data() << " "
     125               << AC->mountPoint.toAscii().data() << " "
     126               << corr->prn.toAscii().data() << " "
     127               << corr->tt.datestr() << " " << corr->tt.timestr() << " "
     128               << corr->iod << " " << corr->dClk << endl;
     129        }
     130      }
     131
     132      if (dt >= waitTime) {
     133        delete epoch;
     134        itEpo.remove();
     135      }
     136    }
     137  }
     138}
Note: See TracChangeset for help on using the changeset viewer.