Index: trunk/BNS/bns.cpp
===================================================================
--- trunk/BNS/bns.cpp	(revision 783)
+++ trunk/BNS/bns.cpp	(revision 784)
@@ -116,4 +116,35 @@
 }
 
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_bns::slotNewEph(gpsEph* ep) {
+
+  QMutexLocker locker(&_mutex);
+
+  t_ephPair* pair;
+  if ( !_ephList.contains(ep->prn) ) {
+    pair = new t_ephPair();
+    _ephList.insert(ep->prn, pair);
+  }
+  else {
+    pair = _ephList[ep->prn];
+  }
+
+  if (pair->eph == 0) {
+    pair->eph = ep;
+  }
+  else {
+    if (ep->GPSweek >  pair->eph->GPSweek ||
+        (ep->GPSweek == pair->eph->GPSweek && ep->TOC > pair->eph->TOC)) {
+      delete pair->oldEph;
+      pair->oldEph = pair->eph;
+      pair->eph    = ep;
+    }
+    else {
+      delete ep;
+    }
+  }
+}
+
 // Start 
 ////////////////////////////////////////////////////////////////////////////
@@ -141,5 +172,15 @@
   while (true) {
     if (_clkSocket) {
-
+      if (_clkSocket->state() != QAbstractSocket::ConnectedState) {
+        delete _clkSocket;
+        _clkSocket = 0;
+        continue;
+      }
+      if (!_clkSocket->canReadLine()) {
+        _clkSocket->waitForReadyRead();
+      }
+      else {
+        readEpoch();
+      }
     }
     else {
@@ -151,34 +192,39 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-void t_bns::slotNewEph(gpsEph* ep) {
-
-  QMutexLocker locker(&_mutex);
-
-  t_ephPair* pair;
-  if ( !_ephList.contains(ep->prn) ) {
-    pair = new t_ephPair();
-    _ephList.insert(ep->prn, pair);
-  }
-  else {
-    pair = _ephList[ep->prn];
-  }
-
-  if (pair->eph == 0) {
-    pair->eph = ep;
-      cout << "A: new eph: " << ep->prn.toAscii().data() << " "
-           << ep->GPSweek << " " << ep->TOC << endl;
-  }
-  else {
-    if (ep->GPSweek >  pair->eph->GPSweek ||
-        (ep->GPSweek == pair->eph->GPSweek && ep->TOC > pair->eph->TOC)) {
-      cout << "B: new eph: " << ep->prn.toAscii().data() << " "
-           << ep->GPSweek << " " << ep->TOC << endl;
-      delete pair->oldEph;
-      pair->oldEph = pair->eph;
-      pair->eph    = ep;
-    }
-    else {
-      delete ep;
-    }
-  }
-}
+void t_bns::readEpoch() {
+
+  QByteArray line = _clkSocket->readLine();
+  if (line.indexOf('*') == -1) {
+    return;
+  }
+
+  QTextStream in(line);
+
+  QString hlp;
+  int     mjd, numSat;
+  double  sec;
+
+  in >> hlp >> mjd >> sec >> numSat;
+
+  for (int ii = 1; ii <= numSat; ii++) {
+    if (!_clkSocket->canReadLine()) {
+      _clkSocket->waitForReadyRead();
+    }
+    line = _clkSocket->readLine();
+    QTextStream in(line);
+
+    QString      prn;
+    ColumnVector xx(4);
+
+    in >> prn >> xx(1) >> xx(2) >> xx(3) >> xx(4);
+
+    processSatellite(mjd, sec, prn, xx);
+  }
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_bns::processSatellite(int mjd, double sec, const QString& prn, 
+                             const ColumnVector& xx) {
+
+}
Index: trunk/BNS/bns.h
===================================================================
--- trunk/BNS/bns.h	(revision 783)
+++ trunk/BNS/bns.h	(revision 784)
@@ -1,4 +1,6 @@
 #ifndef BNS_H
 #define BNS_H
+
+#include <newmat.h>
 
 #include <QtNetwork>
@@ -43,4 +45,8 @@
   void deleteBnsEph();
   void openCaster();
+  void readEpoch();
+  void processSatellite(int mjd, double sec, const QString& prn, 
+                        const ColumnVector& xx);
+
   QTcpServer*               _clkServer;
   QTcpSocket*               _clkSocket;
Index: trunk/BNS/bns.pro
===================================================================
--- trunk/BNS/bns.pro	(revision 783)
+++ trunk/BNS/bns.pro	(revision 784)
@@ -9,4 +9,9 @@
 unix:QMAKE_CFLAGS_RELEASE   -= -O2
 unix:QMAKE_CXXFLAGS_RELEASE -= -O2
+
+# Location of the NewMat Library
+# ------------------------------
+unix:NEWMAT_ROOT = $$(NEWMAT_ROOT)
+win32:NEWMAT_ROOT = ../../Source/newmat
 
 # Get rid of mingwm10.dll
@@ -21,4 +26,9 @@
 release:MOC_DIR=.moc/release
 
+# Include Path and additional Libraries
+# -------------------------------------
+INCLUDEPATH = . $$NEWMAT_ROOT/include
+LIBS        = -L$$NEWMAT_ROOT/lib -lnewmat
+
 HEADERS =             bns.h   bnswindow.h   bnshlpdlg.h   bnshtml.h   \
           bnseph.h    bnsutils.h
