Changeset 5883 in ntrip for trunk/BNC/src/PPP/pppRun.cpp


Ignore:
Timestamp:
Aug 8, 2014, 3:51:27 PM (10 years ago)
Author:
mervart
Message:
 
File:
1 moved

Legend:

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

    r5879 r5883  
    2828 * -------------------------------------------------------------------------
    2929 *
    30  * Class:      t_pppRunRealTime
     30 * Class:      t_pppRun
    3131 *
    3232 * Purpose:    Single Real-Time PPP Client
     
    4646#include <map>
    4747
    48 #include "pppRunRealTime.h"
     48#include "pppRun.h"
    4949#include "bnccore.h"
    5050#include "bncephuser.h"
     51#include "rinex/rnxobsfile.h"
     52#include "rinex/rnxnavfile.h"
     53#include "rinex/corrfile.h"
    5154
    5255using namespace BNC_PPP;
     
    5558// Constructor
    5659////////////////////////////////////////////////////////////////////////////
    57 t_pppRunRealTime::t_pppRunRealTime(const t_pppOptions* opt) {
     60t_pppRun::t_pppRun(const t_pppOptions* opt) {
     61
    5862  _opt = opt;
     63
    5964  connect(this, SIGNAL(newMessage(QByteArray,bool)),
    6065          BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
     66
     67  connect(this, SIGNAL(newPosition(bncTime, QVector<double>)),
     68          BNC_CORE, SIGNAL(newPosition(bncTime, QVector<double>)));
     69
     70  for (unsigned iPrn = 0; iPrn <= t_prn::MAXPRN; iPrn++) {
     71    _lastOrbCorrIOD[iPrn]   = -1;
     72    _lastClkCorrValue[iPrn] = 0.0;
     73  }
     74
     75  _pppClient = new t_pppClient(_opt);
     76
    6177  if (_opt->_realTime) {
    6278    connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
     
    7490    connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
    7591            this, SLOT(slotNewCorrections(QStringList)));
    76 
    77     connect(this, SIGNAL(newPosition(bncTime, QVector<double>)),
    78             BNC_CORE, SIGNAL(newPosition(bncTime, QVector<double>)));
    79 
    80     for (unsigned iPrn = 0; iPrn <= t_prn::MAXPRN; iPrn++) {
    81       _lastOrbCorrIOD[iPrn]   = -1;
    82       _lastClkCorrValue[iPrn] = 0.0;
    83     }
    84 
    85     _pppClient = new t_pppClient(_opt);
    8692  }
    8793  else {
    88     throw t_except("t_pppRunRealTime: post-processing not yet implemented");
     94    processFiles();
    8995  }
    9096}
     
    9298// Destructor
    9399////////////////////////////////////////////////////////////////////////////
    94 t_pppRunRealTime::~t_pppRunRealTime() {
     100t_pppRun::~t_pppRun() {
    95101}
    96102
    97103//
    98104////////////////////////////////////////////////////////////////////////////
    99 void t_pppRunRealTime::slotNewEphGPS(gpsephemeris gpseph) {
     105void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
    100106  QMutexLocker locker(&_mutex);
    101107  t_ephGPS eph;
     
    106112//
    107113////////////////////////////////////////////////////////////////////////////
    108 void t_pppRunRealTime::slotNewEphGlonass(glonassephemeris gloeph) {
     114void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
    109115  QMutexLocker locker(&_mutex);
    110116  t_ephGlo eph;
     
    115121//
    116122////////////////////////////////////////////////////////////////////////////
    117 void t_pppRunRealTime::slotNewEphGalileo(galileoephemeris galeph) {
     123void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
    118124  QMutexLocker locker(&_mutex);
    119125  t_ephGal eph;
     
    124130//
    125131////////////////////////////////////////////////////////////////////////////
    126 void t_pppRunRealTime::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
     132void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
    127133  QMutexLocker locker(&_mutex);
    128134
     
    222228//
    223229////////////////////////////////////////////////////////////////////////////
    224 void t_pppRunRealTime::slotNewCorrections(QStringList corrList) {
     230void t_pppRun::slotNewCorrections(QStringList corrList) {
    225231  QMutexLocker locker(&_mutex);
    226232
     
    330336  }
    331337}
     338
     339
     340//
     341////////////////////////////////////////////////////////////////////////////
     342void t_pppRun::processFiles() {
     343
     344  try {
     345    _rnxObsFile = new t_rnxObsFile(_opt->obsFileName, t_rnxObsFile::input);
     346  }
     347  catch (...) {
     348    delete _rnxObsFile; _rnxObsFile = 0;
     349    emit finished();
     350    return;
     351  }
     352
     353  _rnxNavFile = new t_rnxNavFile(_opt->navFileName, t_rnxNavFile::input);
     354  _pppClient  = new bncPPPclient("POST", _opt, false);
     355
     356  if (!_opt->corrFileName.isEmpty()) {
     357    _corrFile = new t_corrFile(_opt->corrFileName);
     358    connect(_corrFile, SIGNAL(newCorrections(QStringList)),
     359            _pppClient, SLOT(slotNewCorrections(QStringList)));
     360  }
     361
     362  // Read/Process Observations
     363  // -------------------------
     364  int   nEpo = 0;
     365  const t_rnxObsFile::t_rnxEpo* epo = 0;
     366  while ( (epo = _rnxObsFile->nextEpoch()) != 0 ) {
     367    ++nEpo;
     368
     369    if (_maxSpeed != 0) {
     370      QMutexLocker locker(&_mutex);
     371      if (_speed < _maxSpeed) {
     372        double sleepTime = 0.02 * _maxSpeed / _speed;
     373        msleep(sleepTime*1.e3);
     374      }
     375    }
     376
     377    // Get Corrections
     378    // ---------------
     379    if (_corrFile) {
     380      _corrFile->syncRead(epo->tt);
     381    }
     382
     383    // Get Ephemerides
     384    // ----------------
     385    t_eph* eph = 0;
     386    const QMap<QString, int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
     387    while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
     388      if (_pppClient->putNewEph(eph) != success) {
     389        delete eph; eph = 0;
     390      }
     391    }
     392
     393    for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
     394
     395      if (_isToBeDeleted) {
     396        QThread::exit(0);
     397        return;
     398      }
     399
     400      const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
     401   
     402      t_obs obs;
     403      t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
     404
     405      _pppClient->putNewObs(obs);
     406    }
     407    if (nEpo % 10 == 0) {
     408      emit progress(nEpo);
     409    }
     410  }
     411
     412  if (BNC_CORE->mode() != t_bncCore::interactive) {
     413    qApp->exit(0);
     414  }
     415  else {
     416    emit finished();
     417    deleteLater();
     418  }
     419}
     420
     421// 
     422////////////////////////////////////////////////////////////////////////////
     423void t_pppRun::slotSetSpeed(int speed) {
     424  QMutexLocker locker(&_mutex);
     425  _speed = speed;
     426}
Note: See TracChangeset for help on using the changeset viewer.