Ignore:
Timestamp:
Sep 7, 2014, 11:23:53 AM (10 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/PPP_free/bncpppclient.cpp

    r6072 r6073  
    4949#include "bncmodel.h"
    5050#include "pppOptions.h"
     51#include "pppClient.h"
    5152
    5253using namespace BNC_PPP;
     
    5758bncPPPclient::bncPPPclient(QByteArray staID, const t_pppOptions* opt) : bncEphUser(false) {
    5859
    59   _opt   = opt;
    60   _staID = staID;
    61   _model = new bncModel(this);
     60  _opt     = opt;
     61  _staID   = staID;
     62  _model   = new bncModel(this);
     63  _epoData = new t_epoData();
    6264}
    6365
     
    6567////////////////////////////////////////////////////////////////////////////
    6668bncPPPclient::~bncPPPclient() {
    67   while (!_epoData.empty()) {
    68     delete _epoData.front();
    69     _epoData.pop();
    70   }
     69  _epoData->clear();
     70
    7171  QMapIterator<QString, t_corr*> ic(_corr);
    7272  while (ic.hasNext()) {
     
    7474    delete ic.value();
    7575  }
     76
    7677  QMapIterator<QString, t_bias*> ib(_bias);
    7778  while (ib.hasNext()) {
     
    7980    delete ib.value();
    8081  }
     82
    8183  delete _model;
    8284}
     
    8486//
    8587////////////////////////////////////////////////////////////////////////////
    86 void bncPPPclient::putNewObs(t_satData* satData, t_output* output) {
     88void bncPPPclient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
    8789  QMutexLocker locker(&_mutex);
    8890
    89   // Add new epoch, process the older ones
    90   // -------------------------------------
    91   if      (_epoData.size() == 0) {
    92     _epoData.push(new t_epoData());
    93     _epoData.back()->tt = satData->tt;
    94   }
    95   else if (satData->tt != _epoData.back()->tt) {
    96     processEpochs(output);
    97     _epoData.push(new t_epoData());
    98     _epoData.back()->tt = satData->tt;
    99   }
     91  _epoData->clear();
     92
     93  output->_numSat = 0;
     94  output->_pDop   = 0.0;
     95  output->_error  = false;
     96  output->_log.clear();
     97
     98  for (unsigned ii = 0; ii < satObs.size(); ii++) {
     99    const t_satObs* obs     = satObs[ii];
     100    t_satData*      satData = new t_satData();
     101    satData->tt       = obs->_time;
     102    satData->prn      = QString(obs->_prn.toString().c_str());
     103    satData->slipFlag = false;
     104    satData->P1       = 0.0;
     105    satData->P2       = 0.0;
     106    satData->P5       = 0.0;
     107    satData->L1       = 0.0;
     108    satData->L2       = 0.0;
     109    satData->L5       = 0.0;
     110    for (unsigned ifrq = 0; ifrq < obs->_obs.size(); ifrq++) {
     111      t_frqObs* frqObs = obs->_obs[ifrq];
     112      if      (frqObs->_rnxType2ch[0] == '1') {
     113        if (frqObs->_codeValid)  satData->P1       = frqObs->_code;
     114        if (frqObs->_phaseValid) satData->L1       = frqObs->_phase;
     115        if (frqObs->_slip)       satData->slipFlag = true;
     116      }
     117      else if (frqObs->_rnxType2ch[0] == '2') {
     118        if (frqObs->_codeValid)  satData->P2       = frqObs->_code;
     119        if (frqObs->_phaseValid) satData->L2       = frqObs->_phase;
     120        if (frqObs->_slip)       satData->slipFlag = true;
     121      }
     122      else if (frqObs->_rnxType2ch[0] == '5') {
     123        if (frqObs->_codeValid)  satData->P5       = frqObs->_code;
     124        if (frqObs->_phaseValid) satData->L5       = frqObs->_phase;
     125        if (frqObs->_slip)       satData->slipFlag = true;
     126      }
     127    }
     128    putNewObs(satData);
     129  }
     130
     131  // Data Pre-Processing
     132  // -------------------
     133  QMutableMapIterator<QString, t_satData*> it(_epoData->satData);
     134  while (it.hasNext()) {
     135    it.next();
     136    QString    prn     = it.key();
     137    t_satData* satData = it.value();
     138
     139    if (cmpToT(satData) != success) {
     140      delete satData;
     141      it.remove();
     142      continue;
     143    }
     144  }
     145
     146  // Filter Solution
     147  // ---------------
     148  if (_model->update(_epoData) == success) {
     149    ///    emit newPosition(_model->time(), _model->x(), _model->y(), _model->z());
     150  }
     151  else {
     152    output->_error = true;
     153  }
     154
     155  output->_log = LOG.str(); 
     156}
     157
     158//
     159////////////////////////////////////////////////////////////////////////////
     160void bncPPPclient::putNewObs(t_satData* satData) {
    100161
    101162  // Set Observations GPS and Glonass
     
    120181      satData->L3      = a1 * satData->L1 + a2 * satData->L2;
    121182      satData->lambda3 = a1 * t_CST::c / f1 + a2 * t_CST::c / f2;
    122       _epoData.back()->satData[satData->prn] = satData;
     183      _epoData->satData[satData->prn] = satData;
    123184    }
    124185    else {
     
    139200      satData->L3      = a1 * satData->L1 + a5 * satData->L5;
    140201      satData->lambda3 = a1 * t_CST::c / f1 + a5 * t_CST::c / f5;
    141       _epoData.back()->satData[satData->prn] = satData;
     202      _epoData->satData[satData->prn] = satData;
    142203    }
    143204    else {
     
    321382}
    322383
    323 //
    324 ////////////////////////////////////////////////////////////////////////////
    325 void bncPPPclient::processFrontEpoch(t_output* output) {
    326 
    327 #ifdef BNC_DEBUG
    328   QString msg = "List of Corrections\n";
    329   QMapIterator<QString, t_corr*> itC(_corr);
    330   while (itC.hasNext()) {
    331     itC.next();
    332     QString       src  = itC.key();
    333     const t_corr* corr = itC.value();
    334     msg += QString("%1 %2 %3 %4\n")
    335       .arg(corr->prn)
    336       .arg(corr->iod)
    337       .arg(QString(corr->tClk.datestr().c_str()) + "_" + QString(corr->tClk.timestr().c_str()))
    338       .arg(QString(corr->tRao.datestr().c_str()) + "_" + QString(corr->tRao.timestr().c_str()));
    339   }
    340 
    341   msg += "List of Ephemeris\n";
    342   QMapIterator<QString, t_ephPair*> itE(_eph);
    343   while (itE.hasNext()) {
    344     itE.next();
    345     QString          prn     = itE.key();
    346     const t_ephPair* ephPair = itE.value();
    347     if (ephPair->prev) {
    348       msg += QString("%1 %2 %3 %4 %5\n")
    349         .arg(prn)
    350         .arg(ephPair->last->IOD())
    351         .arg(QString(ephPair->last->TOC().datestr().c_str()) + "_" +
    352              QString(ephPair->last->TOC().timestr().c_str()))
    353         .arg(ephPair->prev->IOD())
    354         .arg(QString(ephPair->prev->TOC().datestr().c_str()) + "_" +
    355              QString(ephPair->prev->TOC().timestr().c_str()));
    356     }
    357     else {
    358       msg += QString("%1 %2 %3\n")
    359         .arg(prn)
    360         .arg(ephPair->last->IOD())
    361         .arg(QString(ephPair->last->TOC().datestr().c_str()) + "_" +
    362              QString(ephPair->last->TOC().timestr().c_str()));
    363     }
    364   }
    365 
    366   LOG << msg.toAscii() << endl;
    367 #endif // BNC_DEBUG
    368 
    369   // Data Pre-Processing
    370   // -------------------
    371   QMutableMapIterator<QString, t_satData*> it(_epoData.front()->satData);
    372   while (it.hasNext()) {
    373     it.next();
    374     QString    prn     = it.key();
    375     t_satData* satData = it.value();
    376 
    377     if (cmpToT(satData) != success) {
    378       delete satData;
    379       it.remove();
    380       continue;
    381     }
    382   }
    383 
    384   // Filter Solution
    385   // ---------------
    386   if (_model->update(_epoData.front()) == success) {
    387     ///    emit newPosition(_model->time(), _model->x(), _model->y(), _model->z());
    388   }
    389 }
    390 
    391 //
    392 ////////////////////////////////////////////////////////////////////////////
    393 void bncPPPclient::processEpochs(t_output* output) {
    394 
    395   // Make sure the buffer does not grow beyond any limit
    396   // ---------------------------------------------------
    397   const unsigned MAX_EPODATA_SIZE = 120;
    398   if (_epoData.size() > MAX_EPODATA_SIZE) {
    399     delete _epoData.front();
    400     _epoData.pop();
    401   }
    402 
    403   // Loop over all unprocessed epochs
    404   // --------------------------------
    405   while (!_epoData.empty()) {
    406 
    407     t_epoData* frontEpoData = _epoData.front();
    408 
    409     // No corrections yet, skip the epoch
    410     // ----------------------------------
    411     if (_opt->useOrbClkCorr() && !_corr_tt.valid()) {
    412       return;
    413     }
    414 
    415     // Process the front epoch
    416     // -----------------------
    417     if (_opt->_corrWaitTime == 0.0 || frontEpoData->tt - _corr_tt >= _opt->_corrWaitTime) {
    418       processFrontEpoch(output);
    419       delete _epoData.front();
    420       _epoData.pop();
    421     }
    422     else {
    423       return;
    424     }
    425   }
    426 }
Note: See TracChangeset for help on using the changeset viewer.