Index: trunk/BNC/upload/bncrtnetdecoder.cpp
===================================================================
--- trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3192)
+++ trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3203)
@@ -49,4 +49,18 @@
 //////////////////////////////////////////////////////////////////////// 
 bncRtnetDecoder::bncRtnetDecoder() {
+}
+
+// Destructor
+//////////////////////////////////////////////////////////////////////// 
+bncRtnetDecoder::~bncRtnetDecoder() {
+  for (int ic = 0; ic < _casters->size(); ic++) {
+    delete _casters->at(ic);
+  }
+  delete _casters;
+}
+
+// Run
+//////////////////////////////////////////////////////////////////////// 
+void bncRtnetDecoder::run() {
 
   bncSettings settings;
@@ -54,4 +68,5 @@
   // List of upload casters
   // ----------------------
+  _casters = new QVector<bncUploadCaster*>;
   QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
   while (it.hasNext()) {
@@ -60,28 +75,16 @@
       int  outPort = hlp[1].toInt();
       bool CoM     = (hlp[5].toInt() == Qt::Checked);
-      _caster.push_back(new bncUploadCaster(hlp[2], hlp[0], outPort,
-                                            hlp[3], hlp[4], CoM,
-                                            hlp[6], "", ""));
+      _casters->push_back(new bncUploadCaster(hlp[2], hlp[0], outPort,
+                                             hlp[3], hlp[4], CoM,
+                                             hlp[6], "", ""));
     }
   }
-}
 
-// Destructor
-//////////////////////////////////////////////////////////////////////// 
-bncRtnetDecoder::~bncRtnetDecoder() {
-  for (int ic = 0; ic < _caster.size(); ic++) {
-    delete _caster[ic];
+  // Endless Loop - Decode
+  // ---------------------
+  while (true) {
+    DecodeInThread();
+    msleep(10);
   }
-}
-
-// 
-//////////////////////////////////////////////////////////////////////// 
-void bncRtnetDecoder::readEpochTime(const QString& line) {
-  QTextStream in(line.toAscii());
-  QString hlp;
-  int     year, month, day, hour, min;
-  double  sec;
-  in >> hlp >> year >> month >> day >> hour >> min >> sec;
-  _epoTime.set( year, month, day, hour, min, sec);
 }
 
@@ -89,7 +92,14 @@
 //////////////////////////////////////////////////////////////////////// 
 t_irc bncRtnetDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
-
+  QMutexLocker locker(&_mutex);
   errmsg.clear();
   _buffer.append(QByteArray(buffer, bufLen));
+  return success;
+}
+
+// Decode and upload in separate thread
+//////////////////////////////////////////////////////////////////////// 
+void bncRtnetDecoder::DecodeInThread() {
+  QMutexLocker locker(&_mutex);
 
   // Prepare list of lines with satellite positions in SP3-like format
@@ -102,5 +112,10 @@
     for (int ii = 0; ii < hlpLines.size(); ii++) {
       if      (hlpLines[ii].indexOf('*') != -1) {
-        readEpochTime(hlpLines[ii]);
+        QTextStream in(hlpLines[ii].toAscii());
+        QString hlp;
+        int     year, month, day, hour, min;
+        double  sec;
+        in >> hlp >> year >> month >> day >> hour >> min >> sec;
+        _epoTime.set( year, month, day, hour, min, sec);
       }
       else if (_epoTime.valid()) {
@@ -113,10 +128,8 @@
   // -----------------------------------
   if (lines.size() > 0) {
-    for (int ic = 0; ic < _caster.size(); ic++) {
-      _caster[ic]->uploadClockOrbitBias(_epoTime, _eph, lines);
+    for (int ic = 0; ic < _casters->size(); ic++) {
+      _casters->at(ic)->uploadClockOrbitBias(_epoTime, _eph, lines);
     }
   }
-
-  return success;
 }
 
Index: trunk/BNC/upload/bncrtnetdecoder.h
===================================================================
--- trunk/BNC/upload/bncrtnetdecoder.h	(revision 3192)
+++ trunk/BNC/upload/bncrtnetdecoder.h	(revision 3203)
@@ -33,14 +33,17 @@
 #include "RTCM/GPSDecoder.h"
 
-class bncRtnetDecoder: public GPSDecoder, public bncEphUser {
+class bncRtnetDecoder: public GPSDecoder, public bncEphUser, public QThread {
  public:
   bncRtnetDecoder();
   ~bncRtnetDecoder();
-  virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
+  virtual void run();
+  virtual t_irc Decode(char* buffer, int bufLen, 
+                       std::vector<std::string>& errmsg);
  private:
-  void readEpochTime(const QString& line);
-  QVector<bncUploadCaster*> _caster;
-  QString                   _buffer;
-  bncTime                   _epoTime;
+  void DecodeInThread();
+  QVector<bncUploadCaster*>* _casters;
+  QString                    _buffer;
+  bncTime                    _epoTime;
+  QMutex                     _mutex;
 };
 
