Index: /trunk/BNC/src/bnccaster.cpp
===================================================================
--- /trunk/BNC/src/bnccaster.cpp	(revision 7179)
+++ /trunk/BNC/src/bnccaster.cpp	(revision 7180)
@@ -96,20 +96,4 @@
   }
 
-  int nmeaPort = settings.value("PPP/nmeaPort").toInt();
-  if (nmeaPort != 0) {
-    _nmeaServer = new QTcpServer;
-    if ( !_nmeaServer->listen(QHostAddress::Any, nmeaPort) ) {
-      emit newMessage("bncCaster: Cannot listen on port", true);
-    }
-    connect(_nmeaServer, SIGNAL(newConnection()), this, SLOT(slotNewNMEAConnection()));
-    connect(BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)), 
-            this,     SLOT(slotNewNMEAstr(QByteArray, QByteArray)));
-    _nmeaSockets = new QList<QTcpSocket*>;
-  }
-  else {
-    _nmeaServer  = 0;
-    _nmeaSockets = 0;
-  }
-
   _samplingRate = settings.value("binSampl").toInt();
   _waitTime     = settings.value("waitTime").toDouble();
@@ -154,6 +138,4 @@
   delete _uServer;
   delete _uSockets;
-  delete _nmeaServer;
-  delete _nmeaSockets;
   delete _miscServer;
   delete _miscSockets;
@@ -254,10 +236,4 @@
   emit( newMessage(QString("New client connection on usync port: # %1")
                    .arg(_uSockets->size()).toAscii(), true) );
-}
-
-void bncCaster::slotNewNMEAConnection() {
-  _nmeaSockets->push_back( _nmeaServer->nextPendingConnection() );
-  emit( newMessage(QString("New PPP client on port: # %1")
-                   .arg(_nmeaSockets->size()).toAscii(), true) );
 }
 
@@ -337,5 +313,5 @@
             firstObs = false;
             oStr << "> " << obs._time.gpsw() << ' ' 
-                 << setprecision(7) << obs._time.gpssec() << endl;;
+                 << setprecision(7) << obs._time.gpssec() << endl;
           }
           oStr << obs._staID << ' ' << bncRinex::asciiSatLine(obs) << endl;
@@ -436,4 +412,5 @@
                                         longitude, nmea, ntripVersion);
       addGetThread(getThread);
+
     }
   }
@@ -519,22 +496,4 @@
   }
   return -1;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-void bncCaster::slotNewNMEAstr(QByteArray /* staID */, QByteArray str) {
-  if (_nmeaSockets) {
-    QMutableListIterator<QTcpSocket*> is(*_nmeaSockets);
-    while (is.hasNext()) {
-      QTcpSocket* sock = is.next();
-      if (sock->state() == QAbstractSocket::ConnectedState) {
-	sock->write(str);
-      }
-      else if (sock->state() != QAbstractSocket::ConnectingState) {
-        delete sock;
-        is.remove();
-      }
-    }
-  }
 }
 
Index: /trunk/BNC/src/bnccaster.h
===================================================================
--- /trunk/BNC/src/bnccaster.h	(revision 7179)
+++ /trunk/BNC/src/bnccaster.h	(revision 7180)
@@ -46,5 +46,4 @@
    void slotNewObs(QByteArray staID, QList<t_satObs> obsList);
    void slotNewRawData(QByteArray staID, QByteArray data);
-   void slotNewNMEAstr(QByteArray staID, QByteArray str);
    void slotNewMiscConnection();
 
@@ -55,9 +54,8 @@
    void newObs(QByteArray staID, QList<t_satObs> obsList);
 
- private slots:
+   private slots:
    void slotReadMountPoints();
    void slotNewConnection();
    void slotNewUConnection();
-   void slotNewNMEAConnection();
    void slotGetThreadFinished(QByteArray staID);
 
@@ -67,24 +65,22 @@
    void reopenOutFile();
 
-   QFile*                          _outFile;
-   QTextStream*                    _out;
-   QMap<bncTime, QList<t_satObs> > _epochs;
-   bncTime                         _lastDumpTime;
-   QTcpServer*                     _server;
-   QTcpServer*                     _uServer;
-   QTcpServer*                     _nmeaServer;
-   QList<QTcpSocket*>*             _sockets;
-   QList<QTcpSocket*>*             _uSockets;
-   QList<QTcpSocket*>*             _nmeaSockets;
-   QList<QByteArray>               _staIDs;
-   QList<bncGetThread*>            _threads;
-   int                             _samplingRate;
-   double                          _waitTime;
-   QMutex                          _mutex;
-   int                             _confInterval;
-   QString                         _miscMount;
-   int                             _miscPort;
-   QTcpServer*                     _miscServer;
-   QList<QTcpSocket*>*             _miscSockets;
+   QFile*                                 _outFile;
+   QTextStream*                           _out;
+   QMap<bncTime, QList<t_satObs> >        _epochs;
+   bncTime                                _lastDumpTime;
+   QTcpServer*                            _server;
+   QTcpServer*                            _uServer;
+   QList<QTcpSocket*>*                    _sockets;
+   QList<QTcpSocket*>*                    _uSockets;
+   QList<QByteArray>                      _staIDs;
+   QList<bncGetThread*>                   _threads;
+   int                                    _samplingRate;
+   double                                 _waitTime;
+   QMutex                                 _mutex;
+   int                                    _confInterval;
+   QString                                _miscMount;
+   int                                    _miscPort;
+   QTcpServer*                            _miscServer;
+   QList<QTcpSocket*>*                    _miscSockets;
 };
 
Index: /trunk/BNC/src/bncgetthread.cpp
===================================================================
--- /trunk/BNC/src/bncgetthread.cpp	(revision 7179)
+++ /trunk/BNC/src/bncgetthread.cpp	(revision 7180)
@@ -128,4 +128,33 @@
   _decoder   = 0;
 
+  // NMEA Port
+  // -----------
+  QListIterator<QString> iSta(settings.value("PPP/staTable").toStringList());
+  int nmeaPort = 0;
+  while (iSta.hasNext()) {
+    QStringList hlp = iSta.next().split(",");
+    if (hlp.size() < 10) {continue;}
+    QByteArray mp = hlp[0].toAscii();
+    if (_staID == mp) {
+      nmeaPort = hlp[9].toInt();
+    }
+  }
+  if (nmeaPort != 0) {
+    _nmeaServer = new QTcpServer;
+    if ( !_nmeaServer->listen(QHostAddress::Any, nmeaPort) ) {
+      emit newMessage("bncCaster: Cannot listen on port", true);
+    }
+    else {
+      connect(_nmeaServer, SIGNAL(newConnection()), this, SLOT(slotNewNMEAConnection()));
+      connect(BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)),
+              this, SLOT(slotNewNMEAstr(QByteArray, QByteArray)));
+      _nmeaSockets = new QList<QTcpSocket*>;
+      _nmeaPortsMap[_staID] = nmeaPort;
+    }
+  } else {
+    _nmeaServer = 0;
+    _nmeaSockets = 0;
+  }
+
   // Serial Port
   // -----------
@@ -371,4 +400,7 @@
     delete this;
   }
+  _nmeaPortsMap.remove(_staID);
+  delete _nmeaServer;
+  delete _nmeaSockets;
 }
 
@@ -879,2 +911,29 @@
   }
 }
+
+void bncGetThread::slotNewNMEAConnection() {
+  _nmeaSockets->push_back(_nmeaServer->nextPendingConnection());
+  emit( newMessage(QString("New PPP client on port: # %1")
+                   .arg(_nmeaSockets->size()).toAscii(), true) );
+}
+
+//
+////////////////////////////////////////////////////////////////////////////
+void bncGetThread::slotNewNMEAstr(QByteArray staID, QByteArray str) {
+  if (_nmeaPortsMap.contains(staID)) {
+    int nmeaPort = _nmeaPortsMap.value(staID);
+    QMutableListIterator<QTcpSocket*> is(*_nmeaSockets);
+    while (is.hasNext()) {
+      QTcpSocket* sock = is.next();
+      if (sock->localPort() == nmeaPort) {
+        if (sock->state() == QAbstractSocket::ConnectedState) {
+          sock->write(str);
+        }
+        else if (sock->state() != QAbstractSocket::ConnectingState) {
+          delete sock;
+          is.remove();
+        }
+      }
+    }
+  }
+}
Index: /trunk/BNC/src/bncgetthread.h
===================================================================
--- /trunk/BNC/src/bncgetthread.h	(revision 7179)
+++ /trunk/BNC/src/bncgetthread.h	(revision 7180)
@@ -89,6 +89,10 @@
    virtual void run();
 
+ public slots:
+   void slotNewNMEAstr(QByteArray staID, QByteArray str);
+
  private slots:
    void slotSerialReadyRead();
+   void slotNewNMEAConnection();
 
  private:
@@ -128,4 +132,7 @@
    QMap<char, QVector<QString> > _rnxTypes;
    QStringList                _gloSlots;
+   QList<QTcpSocket*>*        _nmeaSockets;
+   QMap<QByteArray, int>      _nmeaPortsMap;
+   QTcpServer*                _nmeaServer;
 };
 
Index: /trunk/BNC/src/pppWidgets.cpp
===================================================================
--- /trunk/BNC/src/pppWidgets.cpp	(revision 7179)
+++ /trunk/BNC/src/pppWidgets.cpp	(revision 7180)
@@ -431,5 +431,5 @@
      if (iCol == 7) _staTable->setItem(iRow, iCol, new QTableWidgetItem("0.1"));
      if (iCol == 8) _staTable->setItem(iRow, iCol, new QTableWidgetItem("3e-6"));
-     if (iCol == 9) _staTable->setItem(iRow, iCol, new QTableWidgetItem(""));
+     if (iCol == 9) _staTable->setItem(iRow, iCol, new QTableWidgetItem("0"));
   }
 }
