Index: trunk/BNS/bns.cpp
===================================================================
--- trunk/BNS/bns.cpp	(revision 862)
+++ trunk/BNS/bns.cpp	(revision 863)
@@ -23,7 +23,4 @@
 #include "bnsrinex.h" 
 #include "bnssp3.h" 
-extern "C" {
-#include "RTCM/clock_orbit_rtcm.h"
-}
 
 using namespace std;
@@ -315,55 +312,6 @@
   in >> hlp >> GPSweek >> GPSweeks >> numSat;
 
-  for (int ii = 1; ii <= numSat; ii++) {
-    line = _clkSocket->readLine();
-
-    QTextStream in(line);
-
-    QString      prn;
-    ColumnVector xx(4);
-
-    in >> prn >> xx(1) >> xx(2) >> xx(3) >> xx(4); 
-    xx(4) *= 1e-6;
-
-    processSatellite(GPSweek, GPSweeks, prn, xx);
-  }
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-void t_bns::processSatellite(int GPSweek, double GPSweeks, const QString& prn, 
-                             const ColumnVector& xx) {
-
-  // No broadcast ephemeris available
-  // --------------------------------
-  if ( !_ephList.contains(prn) ) {
-    return;
-  }
-
-  t_ephPair* pair = _ephList[prn];
-  gpsEph*    ep   = pair->eph;
-
-  ColumnVector xB(4);
-  ColumnVector vv(3);
-
-  satellitePosition(GPSweek, GPSweeks, ep, xB(1), xB(2), xB(3), xB(4), 
-                    vv(1), vv(2), vv(3));
-
-  ColumnVector dx   = xx.Rows(1,3) - xB.Rows(1,3);
-  double       dClk = (xx(4) - xB(4)) * 299792458.0; 
-  ColumnVector rsw(3);
-
-  XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
-
-  QString line;
-  line.sprintf("%d %.1f %s   %3d %3d   %8.3f   %8.3f %8.3f %8.3f\n", 
-               GPSweek, GPSweeks, ep->prn.toAscii().data(),
-               int(ep->IODC), int(ep->IODE), dClk, rsw(1), rsw(2), rsw(3));
- 
-  if (_outStream) {
-    *_outStream << line;
-    _outStream->flush();
-  }
-  if (_outSocket) {
+  if (numSat > 0) {
+
     struct ClockOrbit co;
     memset(&co, 0, sizeof(co));
@@ -373,8 +321,69 @@
     co.SatRefPoint       = POINT_CENTER;
     co.SatRefDatum       = DATUM_ITRF;
-    co.NumberOfGPSSat    = 1;
-
-    struct ClockOrbit::SatData* sd = co.Sat;
-    ///    sd->ID                    = prn;
+
+    for (int ii = 1; ii <= numSat; ii++) {
+      line = _clkSocket->readLine();
+    
+      QTextStream in(line);
+    
+      QString      prn;
+      ColumnVector xx(4);
+    
+      in >> prn >> xx(1) >> xx(2) >> xx(3) >> xx(4); 
+      xx(4) *= 1e-6;
+    
+      struct ClockOrbit::SatData* sd = 0;
+      if      (prn[0] == 'G') {
+        sd = co.Sat + co.NumberOfGPSSat;
+        ++co.NumberOfGPSSat;
+      }
+      else if (prn[0] == 'R') {
+        sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
+        ++co.NumberOfGLONASSSat;
+      }
+
+      processSatellite(GPSweek, GPSweeks, prn, xx, sd);
+    }
+
+    if (_outSocket) {
+      char obuffer[CLOCKORBIT_BUFFERSIZE];
+      int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
+      if (len > 0) {
+        _outSocket->write(obuffer, len);
+        _outSocket->flush();
+      }
+    }
+  }
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_bns::processSatellite(int GPSweek, double GPSweeks, const QString& prn, 
+                             const ColumnVector& xx, 
+                             struct ClockOrbit::SatData* sd) {
+
+  // No broadcast ephemeris available
+  // --------------------------------
+  if ( !_ephList.contains(prn) ) {
+    return;
+  }
+
+  t_ephPair* pair = _ephList[prn];
+  gpsEph*    ep   = pair->eph;
+
+  ColumnVector xB(4);
+  ColumnVector vv(3);
+
+  satellitePosition(GPSweek, GPSweeks, ep, xB(1), xB(2), xB(3), xB(4), 
+                    vv(1), vv(2), vv(3));
+
+  ColumnVector dx   = xx.Rows(1,3) - xB.Rows(1,3);
+  double       dClk = (xx(4) - xB(4)) * 299792458.0; 
+  ColumnVector rsw(3);
+
+  XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
+
+  if (sd) {
+    sd->ID                    = prn.mid(1).toInt();
     sd->IOD                   = int(ep->IODE);
     sd->Clock.DeltaA0         = dClk;
@@ -382,11 +391,13 @@
     sd->Orbit.DeltaAlongTrack = rsw(2);
     sd->Orbit.DeltaCrossTrack = rsw(3);
-
-    char obuffer[CLOCKORBIT_BUFFERSIZE];
-    int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
-    if (len > 0) {
-      _outSocket->write(obuffer, len);
-      _outSocket->flush();
-    }
+  }
+
+  if (_outStream) {
+    QString line;
+    line.sprintf("%d %.1f %s   %3d %3d   %8.3f   %8.3f %8.3f %8.3f\n", 
+                 GPSweek, GPSweeks, ep->prn.toAscii().data(),
+                 int(ep->IODC), int(ep->IODE), dClk, rsw(1), rsw(2), rsw(3));
+     *_outStream << line;
+    _outStream->flush();
   }
   if (_rnx) {
Index: trunk/BNS/bns.h
===================================================================
--- trunk/BNS/bns.h	(revision 862)
+++ trunk/BNS/bns.h	(revision 863)
@@ -8,4 +8,7 @@
 
 #include "bnseph.h"
+extern "C" {
+#include "RTCM/clock_orbit_rtcm.h"
+}
 
 class bnsRinex;
@@ -52,5 +55,5 @@
   void readEpoch();
   void processSatellite(int GPSweek, double GPSweeks, const QString& prn, 
-                        const ColumnVector& xx);
+                        const ColumnVector& xx, struct ClockOrbit::SatData* sd);
 
   QTcpServer*               _clkServer;
