Index: trunk/BNC/src/PPP/pppMain.cpp
===================================================================
--- trunk/BNC/src/PPP/pppMain.cpp	(revision 5859)
+++ trunk/BNC/src/PPP/pppMain.cpp	(revision 5860)
@@ -57,5 +57,5 @@
 //////////////////////////////////////////////////////////////////////////////
 t_pppMain::~t_pppMain() {
-  stop();
+  slotStop();
 }
 
@@ -81,5 +81,5 @@
   catch (t_except exc) {
     _running = true;
-    stop();
+    slotStop();
   }
 }
@@ -87,5 +87,5 @@
 // 
 //////////////////////////////////////////////////////////////////////////////
-void t_pppMain::stop() {
+void t_pppMain::slotStop() {
   if (!_running) {
     return;
Index: trunk/BNC/src/PPP/pppMain.h
===================================================================
--- trunk/BNC/src/PPP/pppMain.h	(revision 5859)
+++ trunk/BNC/src/PPP/pppMain.h	(revision 5860)
@@ -8,10 +8,11 @@
 namespace BNC_PPP {
 
-class t_pppMain {
+class t_pppMain : public QObject {
  public:
   t_pppMain();                                                      
   ~t_pppMain();
   void start();                                                     
-  void stop();                                                     
+ public slots:
+  void slotStop();                                                     
 
  private:
Index: trunk/BNC/src/PPP/pppRunPostProc.cpp
===================================================================
--- trunk/BNC/src/PPP/pppRunPostProc.cpp	(revision 5860)
+++ trunk/BNC/src/PPP/pppRunPostProc.cpp	(revision 5860)
@@ -0,0 +1,266 @@
+// Part of BNC, a utility for retrieving decoding and
+// converting GNSS data streams from NTRIP broadcasters.
+//
+// Copyright (C) 2007
+// German Federal Agency for Cartography and Geodesy (BKG)
+// http://www.bkg.bund.de
+// Czech Technical University Prague, Department of Geodesy
+// http://www.fsv.cvut.cz
+//
+// Email: euref-ip@bkg.bund.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/* -------------------------------------------------------------------------
+ * BKG NTRIP Client
+ * -------------------------------------------------------------------------
+ *
+ * Class:      t_postProcessing
+ *
+ * Purpose:    Precise Point Positioning in Post-Processing Mode
+ *
+ * Author:     L. Mervart
+ *
+ * Created:    22-Jan-2012
+ *
+ * Changes:    
+ *
+ * -----------------------------------------------------------------------*/
+
+#include <iostream>
+#include "bncpostprocess.h"
+#include "bnccore.h"
+#include "bncsettings.h"
+#include "pppopt.h"
+#include "bncpppclient.h"
+#include "rinex/rnxobsfile.h"
+#include "rnxnavfile.h"
+#include "corrfile.h"
+#include "bncsettings.h"
+#include "bncutils.h"
+
+using namespace std;
+
+// Constructor
+////////////////////////////////////////////////////////////////////////////
+t_postProcessing::t_postProcessing(QObject* parent, int maxSpeed, int speed) : QThread(parent) {
+
+  _maxSpeed   = maxSpeed;
+  _speed      = speed;
+  _opt        = new t_pppOpt();
+  _rnxObsFile = 0;
+  _rnxNavFile = 0;
+  _corrFile   = 0;
+  _pppClient  = 0;
+  _isToBeDeleted = false;
+
+  bncSettings settings;
+
+  QString outFileName = settings.value("postOutFile").toString();
+  if (outFileName.isEmpty()) {
+    _outFile   = 0;
+    _outStream = 0;
+  }
+  else {
+    expandEnvVar(outFileName);
+    _outFile = new QFile(outFileName);
+    _outFile->open(QIODevice::WriteOnly | QIODevice::Text);
+    _outStream = new QTextStream();
+    _outStream->setDevice(_outFile);
+  }
+}
+
+// Destructor
+////////////////////////////////////////////////////////////////////////////
+t_postProcessing::~t_postProcessing() {
+  delete _pppClient;
+  delete _rnxNavFile;
+  delete _rnxObsFile;
+  delete _corrFile;
+  delete _opt;
+  delete _outStream;
+  delete _outFile;
+}
+
+// Write a Program Message
+////////////////////////////////////////////////////////////////////////////
+void t_postProcessing::slotMessage(QByteArray msg, bool /* showOnScreen */) {
+  if (_outStream) {
+    *_outStream << endl << msg;
+    _outStream->flush();
+  }
+  else {
+    BNC_CORE->slotMessage(msg, false);
+  }
+}
+
+// Set Observations from RINEX File
+////////////////////////////////////////////////////////////////////////////
+void t_postProcessing::setObsFromRnx(const t_rnxObsFile* rnxObsFile,
+                                     const t_rnxObsFile::t_rnxEpo* epo, 
+                                     const t_rnxObsFile::t_rnxSat& rnxSat, 
+                                     t_obs& obs) {
+
+  strncpy(obs.StatID, rnxObsFile->markerName().toAscii().constData(),
+          sizeof(obs.StatID));
+
+  obs.satSys   = rnxSat.satSys;
+  obs.satNum   = rnxSat.satNum;
+  obs.GPSWeek  = epo->tt.gpsw();
+  obs.GPSWeeks = epo->tt.gpssec();
+
+  for (int iType = 0; iType < rnxObsFile->nTypes(obs.satSys); iType++) {
+    QString type = rnxObsFile->obsType(obs.satSys,iType).toAscii();
+    obs.setMeasdata(type, rnxObsFile->version(), rnxSat.obs[iType]);
+    if      (type.indexOf("L1") == 0) {
+      obs.snrL1  = rnxSat.snr[iType];
+      obs.slipL1 = (rnxSat.lli[iType] & 1);
+    }
+    else if (type.indexOf("L2") == 0) {
+      obs.snrL2  = rnxSat.snr[iType];
+      obs.slipL2 = (rnxSat.lli[iType] & 1);
+    }
+    else if (type.indexOf("L5") == 0) {
+      obs.snrL5  = rnxSat.snr[iType];
+      obs.slipL5 = (rnxSat.lli[iType] & 1);
+    }
+  }
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_postProcessing::terminate() {
+  _isToBeDeleted = true;
+  if (!isRunning()) {
+    delete this;
+  }
+}
+
+//  
+////////////////////////////////////////////////////////////////////////////
+void t_postProcessing::run() {
+
+  if (_pppClient) {
+    return;
+  }
+  else {
+    try {
+      _rnxObsFile = new t_rnxObsFile(_opt->obsFileName, t_rnxObsFile::input);
+    }
+    catch (...) {
+      delete _rnxObsFile; _rnxObsFile = 0;
+      emit finished();
+      return;
+    }
+    _rnxNavFile = new t_rnxNavFile(_opt->navFileName, t_rnxNavFile::input);
+    _pppClient  = new bncPPPclient("POST", _opt, false);
+
+    if (!_opt->corrFileName.isEmpty()) {
+      _corrFile = new t_corrFile(_opt->corrFileName);
+      connect(_corrFile, SIGNAL(newCorrections(QStringList)),
+              _pppClient, SLOT(slotNewCorrections(QStringList)),
+              Qt::DirectConnection);
+    }
+
+    connect(_pppClient, SIGNAL(newMessage(QByteArray,bool)), 
+            this, SLOT(slotMessage(const QByteArray,bool)));
+    qRegisterMetaType<bncTime>("bncTime");
+    connect(_pppClient, SIGNAL(newPosition(bncTime, double, double, double)), 
+            this, SIGNAL(newPosition(bncTime, double, double, double)));
+  }
+
+  // Read/Process Observations
+  // -------------------------
+  int   nEpo = 0;
+  const t_rnxObsFile::t_rnxEpo* epo = 0;
+  while ( (epo = _rnxObsFile->nextEpoch()) != 0 ) {
+    ++nEpo;
+
+    if (_maxSpeed != 0) {
+      QMutexLocker locker(&_mutex);
+      if (_speed < _maxSpeed) {
+        double sleepTime = 0.02 * _maxSpeed / _speed;
+        msleep(sleepTime*1.e3);
+      }
+    }
+
+    // Get Corrections
+    // ---------------
+    if (_corrFile) {
+      _corrFile->syncRead(epo->tt);
+    }
+
+    // Get Ephemerides
+    // ----------------
+    t_eph* eph = 0;
+    const QMap<QString, int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
+    while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
+      if (_pppClient->putNewEph(eph) != success) {
+        delete eph; eph = 0;
+      }
+    }
+
+    for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
+
+      if (_isToBeDeleted) {
+        QThread::exit(0);
+        return;
+      }
+
+      const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
+    
+      t_obs obs;
+      t_postProcessing::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
+
+      // Get Glonass Channel Number
+      // -------------------------
+      bool obsOK = true;
+      if (obs.satSys == 'R') {
+        QString prn = QString("%1%2").arg(obs.satSys)
+                                     .arg(obs.satNum, 2, 10, QChar('0'));
+        const bncEphUser::t_ephPair* ephPair = _pppClient->ephPair(prn);
+        if (ephPair && ephPair->last) {
+          obs.slotNum = ((t_ephGlo*) ephPair->last)->slotNum();
+        }
+        else {
+          obsOK = false;
+        }
+      }
+
+      // Put the new Observation to the Client
+      // -------------------------------------
+      if (obsOK) {
+        _pppClient->putNewObs(obs);
+      }
+    }
+    if (nEpo % 10 == 0) {
+      emit progress(nEpo);
+    }
+  }
+
+  if (BNC_CORE->mode() != t_bncCore::interactive) {
+    qApp->exit(0);
+  }
+  else {
+    emit finished();
+    deleteLater();
+  }
+}
+
+//  
+////////////////////////////////////////////////////////////////////////////
+void t_postProcessing::slotSetSpeed(int speed) {
+  QMutexLocker locker(&_mutex);
+  _speed = speed;
+}
Index: trunk/BNC/src/PPP/pppRunPostProc.h
===================================================================
--- trunk/BNC/src/PPP/pppRunPostProc.h	(revision 5860)
+++ trunk/BNC/src/PPP/pppRunPostProc.h	(revision 5860)
@@ -0,0 +1,80 @@
+// Part of BNC, a utility for retrieving decoding and
+// converting GNSS data streams from NTRIP broadcasters.
+//
+// Copyright (C) 2007
+// German Federal Agency for Cartography and Geodesy (BKG)
+// http://www.bkg.bund.de
+// Czech Technical University Prague, Department of Geodesy
+// http://www.fsv.cvut.cz
+//
+// Email: euref-ip@bkg.bund.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef BNCPOSTPROCESS_H
+#define BNCPOSTPROCESS_H
+
+#include <QtCore>
+#include "bncconst.h"
+#include "rnxobsfile.h"
+extern "C" {
+#include "rtcm3torinex.h"
+}
+
+class t_pppOpt;
+class bncPPPclient;
+class t_rnxNavFile;
+class t_corrFile;
+class t_obs;
+
+class t_postProcessing : public QThread {
+Q_OBJECT
+ 
+ public:
+  t_postProcessing(QObject* parent, int maxSpeed, int speed);
+  static void setObsFromRnx(const t_rnxObsFile* rnxObsFile,
+                            const t_rnxObsFile::t_rnxEpo* epo, 
+                            const t_rnxObsFile::t_rnxSat& rnxSat, 
+                            t_obs& obs);
+
+  ~t_postProcessing();
+
+ signals:
+  void progress(int);
+  void finished();
+  void newPosition(bncTime time, double x, double y, double z);
+   
+ public slots:
+  void slotMessage(QByteArray msg, bool showOnScreen);
+  void slotSetSpeed(int speed);
+
+ public:
+  virtual void run();
+  void terminate();
+ 
+ private:
+  t_pppOpt*     _opt;
+  bncPPPclient* _pppClient;
+  t_rnxObsFile* _rnxObsFile;
+  t_rnxNavFile* _rnxNavFile;
+  t_corrFile*   _corrFile;
+  QFile*        _outFile;
+  QTextStream*  _outStream;
+  bool          _isToBeDeleted;
+  int           _maxSpeed;
+  int           _speed;
+  QMutex        _mutex;
+};
+
+#endif
Index: trunk/BNC/src/PPP/pppRunRealTime.cpp
===================================================================
--- trunk/BNC/src/PPP/pppRunRealTime.cpp	(revision 5860)
+++ trunk/BNC/src/PPP/pppRunRealTime.cpp	(revision 5860)
@@ -0,0 +1,321 @@
+
+// Part of BNC, a utility for retrieving decoding and
+// converting GNSS data streams from NTRIP broadcasters.
+//
+// Copyright (C) 2007
+// German Federal Agency for Cartography and Geodesy (BKG)
+// http://www.bkg.bund.de
+// Czech Technical University Prague, Department of Geodesy
+// http://www.fsv.cvut.cz
+//
+// Email: euref-ip@bkg.bund.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/* -------------------------------------------------------------------------
+ * BKG NTRIP Client
+ * -------------------------------------------------------------------------
+ *
+ * Class:      t_pppRunRealTime
+ *
+ * Purpose:    Single Real-Time PPP Client
+ *
+ * Author:     L. Mervart
+ *
+ * Created:    29-Jul-2014
+ *
+ * Changes:    
+ *
+ * -----------------------------------------------------------------------*/
+
+
+#include <iostream>
+#include <iomanip>
+#include <string.h>
+#include <map>
+
+#include "pppRunRealTime.h"
+#include "bnccore.h"
+#include "bncephuser.h"
+
+using namespace BNC_PPP;
+using namespace std;
+
+// Constructor
+////////////////////////////////////////////////////////////////////////////
+t_pppRunRealTime::t_pppRunRealTime(const t_pppOptions* opt) {
+  _opt = opt;
+  connect(this, SIGNAL(newMessage(QByteArray,bool)), 
+          BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
+  if (_opt->_realTime) {
+    connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
+            this, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
+
+    connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
+            this, SLOT(slotNewEphGPS(gpsephemeris)));
+  
+    connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
+            this, SLOT(slotNewEphGlonass(glonassephemeris)));
+  
+    connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
+            this, SLOT(slotNewEphGalileo(galileoephemeris)));
+
+    connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
+            this, SLOT(slotNewCorrections(QStringList)));
+
+    for (unsigned iPrn = 0; iPrn <= t_prn::MAXPRN; iPrn++) {
+      _lastOrbCorrIOD[iPrn]   = -1;
+      _lastClkCorrValue[iPrn] = 0.0;
+    }
+
+    _pppClient = new t_pppClient(_opt);
+  }
+  else {
+    throw t_except("t_pppRunRealTime: post-processing not yet implemented");
+  }
+}
+
+// Destructor
+////////////////////////////////////////////////////////////////////////////
+t_pppRunRealTime::~t_pppRunRealTime() {
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_pppRunRealTime::slotNewEphGPS(gpsephemeris gpseph) {
+  QMutexLocker locker(&_mutex);
+  t_ephGPS eph;
+  eph.set(&gpseph);
+  _pppClient->putEphemeris(&eph);
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_pppRunRealTime::slotNewEphGlonass(glonassephemeris gloeph) {
+  QMutexLocker locker(&_mutex);
+  t_ephGlo eph;
+  eph.set(&gloeph);
+  _pppClient->putEphemeris(&eph);
+}
+  
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_pppRunRealTime::slotNewEphGalileo(galileoephemeris galeph) {
+  QMutexLocker locker(&_mutex);
+  t_ephGal eph;
+  eph.set(&galeph);
+  _pppClient->putEphemeris(&eph);
+}
+
+//
+////////////////////////////////////////////////////////////////////////////
+void t_pppRunRealTime::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
+  QMutexLocker locker(&_mutex);
+
+  if (string(staID.data()) != _opt->_roverName) {
+    return;
+  }
+
+  // Loop over all obsevations (possible different epochs)
+  // -----------------------------------------------------
+  QListIterator<t_obs> it(obsList);
+  while (it.hasNext()) {
+    const t_obs& oldObs = it.next();
+    t_satObs* newObs = new t_satObs;
+   
+    newObs->_prn.set(oldObs.satSys, oldObs.satNum);
+    newObs->_time.set(oldObs.GPSWeek, oldObs.GPSWeeks);
+
+    // Find the corresponding data epoch or create a new one
+    // -----------------------------------------------------
+    t_epoData* epoch = 0;
+    deque<t_epoData*>::const_iterator it;
+    for (it = _epoData.begin(); it != _epoData.end(); it++) {
+      if (newObs->_time == (*it)->_time) {
+        epoch = *it;
+        break;
+      }
+    }
+    if (epoch == 0) {
+      if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
+        epoch = new t_epoData;
+        epoch->_time = newObs->_time;
+        _epoData.push_back(epoch);
+      }
+    }
+
+    // Fill the new observation and add it to the corresponding epoch
+    // --------------------------------------------------------------
+    if (epoch != 0) {
+      epoch->_satObs.push_back(newObs);
+      map<string, t_frqObs*> frqObsMap;
+      for (unsigned iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
+        string hlp(oldObs.rnxStr(iEntry).toAscii().data());
+        if (hlp.length() == 3) {
+          char   obsType    = hlp[0];
+          string rnxType2ch = hlp.substr(1);
+          if (obsType == 'C' || obsType == 'L') {
+            t_frqObs* frqObs = 0;
+            if (frqObsMap.find(rnxType2ch) == frqObsMap.end()) {
+              frqObs                = new t_frqObs();
+              frqObsMap[rnxType2ch] = frqObs;
+              frqObs->_rnxType2ch   = rnxType2ch;
+              newObs->_obs.push_back(frqObs);
+            }
+            else {
+              frqObs = frqObsMap[rnxType2ch];
+            }
+            if      (obsType == 'C') {
+              frqObs->_code      = oldObs._measdata[iEntry];
+              frqObs->_codeValid = true;
+            }
+            else if (obsType == 'L') {
+              frqObs->_phase      = oldObs._measdata[iEntry];
+              frqObs->_phaseValid = true;
+            }
+          }
+        }
+      }
+    }
+  }
+
+  // Process the oldest epochs
+  // ------------------------
+  while (_epoData.size() && _epoData.front()->_time < _lastClkCorrTime + 10.0) {
+
+    const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
+
+    t_output output;
+    _pppClient->processEpoch(satObs, &output);
+
+    delete _epoData.front(); _epoData.pop_front();
+
+    //// beg test
+    cout << output._log << endl; cout.flush();
+    //// end test
+    
+    emit newMessage(QByteArray(output._log.c_str()), true);
+  }
+}
+    
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_pppRunRealTime::slotNewCorrections(QStringList corrList) {
+  QMutexLocker locker(&_mutex);
+
+  if (_opt->_corrMount.empty()) {
+    return;
+  }
+
+  // Check the Mountpoint (source of corrections)
+  // --------------------------------------------
+  QMutableListIterator<QString> itm(corrList);
+  while (itm.hasNext()) {
+    QStringList hlp = itm.next().split(" ");
+    if (hlp.size() > 0) {
+      QString mountpoint = hlp[hlp.size()-1];
+      if (mountpoint != QString(_opt->_corrMount.c_str())) {
+        itm.remove();     
+      }
+    }
+  }
+
+  if (corrList.size() == 0) {
+    return;
+  }
+
+  vector<t_orbCorr*> orbCorr;
+  vector<t_clkCorr*> clkCorr;
+  vector<t_satBias*> satBias;
+
+  QListIterator<QString> it(corrList);
+  while (it.hasNext()) {
+    QString line = it.next();
+
+    QTextStream in(&line);
+    int     messageType;
+    int     updateInterval;
+    int     GPSweek;
+    double  GPSweeks;
+    QString prn;
+    in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
+
+    if ( t_corr::relevantMessageType(messageType) ) {
+      t_corr corr;
+      corr.readLine(line);
+      if      (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
+               messageType == COTYPE_GPSORBIT    || messageType == COTYPE_GLONASSORBIT    ) {
+        t_orbCorr* cc = new t_orbCorr();
+        cc->_prn.set(corr.prn.toAscii().data());
+        cc->_iod       = corr.iod;
+        cc->_time      = corr.tRao;
+        cc->_system    = 'R';
+        cc->_xr[0]     = corr.rao[0]; 
+        cc->_xr[1]     = corr.rao[1]; 
+        cc->_xr[2]     = corr.rao[2]; 
+        cc->_dotXr[0]  = corr.dotRao[0]; 
+        cc->_dotXr[0]  = corr.dotRao[1]; 
+        cc->_dotXr[0]  = corr.dotRao[2]; 
+        orbCorr.push_back(cc);
+
+        _lastOrbCorrIOD[cc->_prn.toInt()] = cc->_iod;
+      }
+      else if (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
+               messageType == COTYPE_GPSCLOCK    || messageType == COTYPE_GLONASSCLOCK    ) {
+        t_clkCorr* cc = new t_clkCorr();
+        cc->_prn.set(corr.prn.toAscii().data());
+        cc->_iod         = corr.iod;
+        cc->_time        = corr.tClk;
+        cc->_dClk        = corr.dClk;
+        cc->_dotDClk     = corr.dotDClk;
+        cc->_dotDotDClk  = corr.dotDotDClk;
+        cc->_clkPartial  = 0.0;
+        if (messageType == COTYPE_GPSCLOCK || messageType == COTYPE_GLONASSCLOCK) {
+          int lastIOD = _lastOrbCorrIOD[cc->_prn.toInt()];
+          if (lastIOD != -1) {
+            cc->_iod = lastIOD;
+          }
+          else {
+            delete cc;
+            cc = 0;
+          }
+        }
+        if (cc) {
+          clkCorr.push_back(cc);        
+          if (_lastClkCorrTime.undef() || cc->_time > _lastClkCorrTime) {
+            _lastClkCorrTime = cc->_time;
+          }
+        }
+      }
+    }
+    else if ( messageType == BTYPE_GPS || messageType == BTYPE_GLONASS ) { 
+      t_bias bias;
+      bias.readLine(line);
+    }
+  }
+
+  _pppClient->putOrbCorrections(orbCorr); 
+  _pppClient->putClkCorrections(clkCorr); 
+  _pppClient->putBiases(satBias);   
+
+  for (unsigned ii = 0; ii < orbCorr.size(); ii++) {
+    delete orbCorr[ii];
+  }
+  for (unsigned ii = 0; ii < clkCorr.size(); ii++) {
+    delete clkCorr[ii];
+  }
+  for (unsigned ii = 0; ii < satBias.size(); ii++) {
+    delete satBias[ii];
+  }
+}
Index: trunk/BNC/src/PPP/pppRunRealTime.h
===================================================================
--- trunk/BNC/src/PPP/pppRunRealTime.h	(revision 5860)
+++ trunk/BNC/src/PPP/pppRunRealTime.h	(revision 5860)
@@ -0,0 +1,56 @@
+#ifndef PPPRUNREALTIME_H
+#define PPPRUNREALTIME_H
+
+#include <deque>
+#include <vector>
+#include <QtCore>
+
+#include "GPSDecoder.h"
+#include "pppOptions.h"
+#include "pppClient.h"
+
+namespace BNC_PPP {
+
+class t_pppRunRealTime : public QObject {
+ Q_OBJECT
+ public:
+  t_pppRunRealTime(const t_pppOptions* opt);
+  ~t_pppRunRealTime();
+
+ signals:
+  void newMessage(QByteArray msg, bool showOnScreen);
+  void newPosition(bncTime time, double x, double y, double z);
+  void newNMEAstr(QByteArray str);
+
+ public slots:
+  void slotNewEphGPS(gpsephemeris gpseph);
+  void slotNewEphGlonass(glonassephemeris gloeph);
+  void slotNewEphGalileo(galileoephemeris galeph);
+  void slotNewCorrections(QStringList corrList);
+  void slotNewObs(QByteArray staID, QList<t_obs> obsList);
+
+ private:
+  class t_epoData {
+   public:
+    t_epoData() {}
+    ~t_epoData() {
+      for (unsigned ii = 0; ii < _satObs.size(); ii++) {
+        delete _satObs[ii];
+      }
+    }
+    bncTime                _time;
+    std::vector<t_satObs*> _satObs;
+  };
+
+  QMutex                 _mutex;
+  const t_pppOptions*    _opt;
+  t_pppClient*           _pppClient;
+  std::deque<t_epoData*> _epoData;
+  int                    _lastOrbCorrIOD[t_prn::MAXPRN+1];
+  double                 _lastClkCorrValue[t_prn::MAXPRN+1];
+  bncTime                _lastClkCorrTime;
+};
+
+}
+
+#endif
Index: trunk/BNC/src/PPP/pppThread.cpp
===================================================================
--- trunk/BNC/src/PPP/pppThread.cpp	(revision 5859)
+++ trunk/BNC/src/PPP/pppThread.cpp	(revision 5860)
@@ -56,6 +56,6 @@
 ////////////////////////////////////////////////////////////////////////////
 t_pppThread::t_pppThread(const t_pppOptions* opt) : QThread(0) {
-  _opt   = opt;
-  _pppRun = 0;
+  _opt            = opt;
+  _pppRunRealTime = 0;
   connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
 
@@ -67,5 +67,5 @@
 ////////////////////////////////////////////////////////////////////////////
 t_pppThread::~t_pppThread() {
-  delete _pppRun;
+  delete _pppRunRealTime;
 }
 
@@ -74,278 +74,11 @@
 void t_pppThread::run() {
   try {
-    _pppRun = new t_pppRun(_opt);
+    _pppRunRealTime = new t_pppRunRealTime(_opt);
     QThread::exec();
   }
   catch (t_except exc) {
-    _pppRun = 0;
+    _pppRunRealTime = 0;
     emit newMessage(QByteArray(exc.what().c_str()), true);
   }
 }
 
-// Constructor
-////////////////////////////////////////////////////////////////////////////
-t_pppRun::t_pppRun(const t_pppOptions* opt) {
-  _opt = opt;
-  connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-          BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
-  if (_opt->_realTime) {
-    connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
-            this, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
-
-    connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
-            this, SLOT(slotNewEphGPS(gpsephemeris)));
-  
-    connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
-            this, SLOT(slotNewEphGlonass(glonassephemeris)));
-  
-    connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
-            this, SLOT(slotNewEphGalileo(galileoephemeris)));
-
-    connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
-            this, SLOT(slotNewCorrections(QStringList)));
-
-    for (unsigned iPrn = 0; iPrn <= t_prn::MAXPRN; iPrn++) {
-      _lastOrbCorrIOD[iPrn]   = -1;
-      _lastClkCorrValue[iPrn] = 0.0;
-    }
-
-    _pppClient = new t_pppClient(_opt);
-  }
-  else {
-    throw t_except("t_pppRun: post-processing not yet implemented");
-  }
-}
-
-// Destructor
-////////////////////////////////////////////////////////////////////////////
-t_pppRun::~t_pppRun() {
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
-  QMutexLocker locker(&_mutex);
-  t_ephGPS eph;
-  eph.set(&gpseph);
-  _pppClient->putEphemeris(&eph);
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
-  QMutexLocker locker(&_mutex);
-  t_ephGlo eph;
-  eph.set(&gloeph);
-  _pppClient->putEphemeris(&eph);
-}
-  
-// 
-////////////////////////////////////////////////////////////////////////////
-void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
-  QMutexLocker locker(&_mutex);
-  t_ephGal eph;
-  eph.set(&galeph);
-  _pppClient->putEphemeris(&eph);
-}
-
-//
-////////////////////////////////////////////////////////////////////////////
-void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
-  QMutexLocker locker(&_mutex);
-
-  if (string(staID.data()) != _opt->_roverName) {
-    return;
-  }
-
-  // Loop over all obsevations (possible different epochs)
-  // -----------------------------------------------------
-  QListIterator<t_obs> it(obsList);
-  while (it.hasNext()) {
-    const t_obs& oldObs = it.next();
-    t_satObs* newObs = new t_satObs;
-   
-    newObs->_prn.set(oldObs.satSys, oldObs.satNum);
-    newObs->_time.set(oldObs.GPSWeek, oldObs.GPSWeeks);
-
-    // Find the corresponding data epoch or create a new one
-    // -----------------------------------------------------
-    t_epoData* epoch = 0;
-    deque<t_epoData*>::const_iterator it;
-    for (it = _epoData.begin(); it != _epoData.end(); it++) {
-      if (newObs->_time == (*it)->_time) {
-        epoch = *it;
-        break;
-      }
-    }
-    if (epoch == 0) {
-      if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
-        epoch = new t_epoData;
-        epoch->_time = newObs->_time;
-        _epoData.push_back(epoch);
-      }
-    }
-
-    // Fill the new observation and add it to the corresponding epoch
-    // --------------------------------------------------------------
-    if (epoch != 0) {
-      epoch->_satObs.push_back(newObs);
-      map<string, t_frqObs*> frqObsMap;
-      for (unsigned iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
-        string hlp(oldObs.rnxStr(iEntry).toAscii().data());
-        if (hlp.length() == 3) {
-          char   obsType    = hlp[0];
-          string rnxType2ch = hlp.substr(1);
-          if (obsType == 'C' || obsType == 'L') {
-            t_frqObs* frqObs = 0;
-            if (frqObsMap.find(rnxType2ch) == frqObsMap.end()) {
-              frqObs                = new t_frqObs();
-              frqObsMap[rnxType2ch] = frqObs;
-              frqObs->_rnxType2ch   = rnxType2ch;
-              newObs->_obs.push_back(frqObs);
-            }
-            else {
-              frqObs = frqObsMap[rnxType2ch];
-            }
-            if      (obsType == 'C') {
-              frqObs->_code      = oldObs._measdata[iEntry];
-              frqObs->_codeValid = true;
-            }
-            else if (obsType == 'L') {
-              frqObs->_phase      = oldObs._measdata[iEntry];
-              frqObs->_phaseValid = true;
-            }
-          }
-        }
-      }
-    }
-  }
-
-  // Process the oldest epochs
-  // ------------------------
-  while (_epoData.size() && _epoData.front()->_time < _lastClkCorrTime + 10.0) {
-
-    const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
-
-    t_output output;
-    _pppClient->processEpoch(satObs, &output);
-
-    delete _epoData.front(); _epoData.pop_front();
-
-    //// beg test
-    cout << output._log << endl; cout.flush();
-    //// end test
-    
-    emit newMessage(QByteArray(output._log.c_str()), true);
-  }
-}
-    
-// 
-////////////////////////////////////////////////////////////////////////////
-void t_pppRun::slotNewCorrections(QStringList corrList) {
-  QMutexLocker locker(&_mutex);
-
-  if (_opt->_corrMount.empty()) {
-    return;
-  }
-
-  // Check the Mountpoint (source of corrections)
-  // --------------------------------------------
-  QMutableListIterator<QString> itm(corrList);
-  while (itm.hasNext()) {
-    QStringList hlp = itm.next().split(" ");
-    if (hlp.size() > 0) {
-      QString mountpoint = hlp[hlp.size()-1];
-      if (mountpoint != QString(_opt->_corrMount.c_str())) {
-        itm.remove();     
-      }
-    }
-  }
-
-  if (corrList.size() == 0) {
-    return;
-  }
-
-  vector<t_orbCorr*> orbCorr;
-  vector<t_clkCorr*> clkCorr;
-  vector<t_satBias*> satBias;
-
-  QListIterator<QString> it(corrList);
-  while (it.hasNext()) {
-    QString line = it.next();
-
-    QTextStream in(&line);
-    int     messageType;
-    int     updateInterval;
-    int     GPSweek;
-    double  GPSweeks;
-    QString prn;
-    in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
-
-    if ( t_corr::relevantMessageType(messageType) ) {
-      t_corr corr;
-      corr.readLine(line);
-      if      (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
-               messageType == COTYPE_GPSORBIT    || messageType == COTYPE_GLONASSORBIT    ) {
-        t_orbCorr* cc = new t_orbCorr();
-        cc->_prn.set(corr.prn.toAscii().data());
-        cc->_iod       = corr.iod;
-        cc->_time      = corr.tRao;
-        cc->_system    = 'R';
-        cc->_xr[0]     = corr.rao[0]; 
-        cc->_xr[1]     = corr.rao[1]; 
-        cc->_xr[2]     = corr.rao[2]; 
-        cc->_dotXr[0]  = corr.dotRao[0]; 
-        cc->_dotXr[0]  = corr.dotRao[1]; 
-        cc->_dotXr[0]  = corr.dotRao[2]; 
-        orbCorr.push_back(cc);
-
-        _lastOrbCorrIOD[cc->_prn.toInt()] = cc->_iod;
-      }
-      else if (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
-               messageType == COTYPE_GPSCLOCK    || messageType == COTYPE_GLONASSCLOCK    ) {
-        t_clkCorr* cc = new t_clkCorr();
-        cc->_prn.set(corr.prn.toAscii().data());
-        cc->_iod         = corr.iod;
-        cc->_time        = corr.tClk;
-        cc->_dClk        = corr.dClk;
-        cc->_dotDClk     = corr.dotDClk;
-        cc->_dotDotDClk  = corr.dotDotDClk;
-        cc->_clkPartial  = 0.0;
-        if (messageType == COTYPE_GPSCLOCK || messageType == COTYPE_GLONASSCLOCK) {
-          int lastIOD = _lastOrbCorrIOD[cc->_prn.toInt()];
-          if (lastIOD != -1) {
-            cc->_iod = lastIOD;
-          }
-          else {
-            delete cc;
-            cc = 0;
-          }
-        }
-        if (cc) {
-          clkCorr.push_back(cc);        
-          if (_lastClkCorrTime.undef() || cc->_time > _lastClkCorrTime) {
-            _lastClkCorrTime = cc->_time;
-          }
-        }
-      }
-    }
-    else if ( messageType == BTYPE_GPS || messageType == BTYPE_GLONASS ) { 
-      t_bias bias;
-      bias.readLine(line);
-    }
-  }
-
-  _pppClient->putOrbCorrections(orbCorr); 
-  _pppClient->putClkCorrections(clkCorr); 
-  _pppClient->putBiases(satBias);   
-
-  for (unsigned ii = 0; ii < orbCorr.size(); ii++) {
-    delete orbCorr[ii];
-  }
-  for (unsigned ii = 0; ii < clkCorr.size(); ii++) {
-    delete clkCorr[ii];
-  }
-  for (unsigned ii = 0; ii < satBias.size(); ii++) {
-    delete satBias[ii];
-  }
-}
Index: trunk/BNC/src/PPP/pppThread.h
===================================================================
--- trunk/BNC/src/PPP/pppThread.h	(revision 5859)
+++ trunk/BNC/src/PPP/pppThread.h	(revision 5860)
@@ -9,44 +9,7 @@
 #include "pppOptions.h"
 #include "pppClient.h"
+#include "pppRunRealTime.h"
 
 namespace BNC_PPP {
-
-class t_pppRun : public QObject {
- Q_OBJECT
- public:
-  t_pppRun(const t_pppOptions* opt);
-  ~t_pppRun();
-
- signals:
-  void newMessage(QByteArray msg, bool showOnScreen);
-
- public slots:
-  void slotNewEphGPS(gpsephemeris gpseph);
-  void slotNewEphGlonass(glonassephemeris gloeph);
-  void slotNewEphGalileo(galileoephemeris galeph);
-  void slotNewCorrections(QStringList corrList);
-  void slotNewObs(QByteArray staID, QList<t_obs> obsList);
-
- private:
-  class t_epoData {
-   public:
-    t_epoData() {}
-    ~t_epoData() {
-      for (unsigned ii = 0; ii < _satObs.size(); ii++) {
-        delete _satObs[ii];
-      }
-    }
-    bncTime                _time;
-    std::vector<t_satObs*> _satObs;
-  };
-
-  QMutex                 _mutex;
-  const t_pppOptions*    _opt;
-  t_pppClient*           _pppClient;
-  std::deque<t_epoData*> _epoData;
-  int                    _lastOrbCorrIOD[t_prn::MAXPRN+1];
-  double                 _lastClkCorrValue[t_prn::MAXPRN+1];
-  bncTime                _lastClkCorrTime;
-};
 
 class t_pppThread : public QThread {
@@ -62,5 +25,5 @@
  private:
   const t_pppOptions* _opt;
-  t_pppRun*           _pppRun;
+  t_pppRunRealTime*   _pppRunRealTime;
 };
 
