Index: trunk/BNC/test_bnc_qt.cpp
===================================================================
--- trunk/BNC/test_bnc_qt.cpp	(revision 2259)
+++ trunk/BNC/test_bnc_qt.cpp	(revision 2704)
@@ -42,147 +42,137 @@
 #include <iostream>
 #include <iomanip>
-
-#include "RTCM/GPSDecoder.h"
-#include "bnctime.h"
-extern "C" {
-#include "RTCM3/rtcm3torinex.h"
-}
-
 #include <QTcpSocket>
 
 using namespace std;
 
-void RTCM3Error(const char*, ...) {}
+class t_obsInternal {
+  public:
+  int    flags;
+  char   StatID[20+1];  // Station ID
+  char   satSys;        // Satellite System ('G' or 'R')
+  int    satNum;        // Satellite Number (PRN for GPS NAVSTAR)
+  int    slot;          // Slot (Channel) Number (for Glonass)
+  int    GPSWeek;       // Week of GPS-Time
+  double GPSWeeks;      // Second of Week (GPS-Time)
+  double C1;            // CA-code pseudorange (meters)
+  double C2;            // CA-code pseudorange (meters)
+  double P1;            // P1-code pseudorange (meters)
+  double P2;            // P2-code pseudorange (meters)
+  double L1;            // L1 carrier phase (cycles)
+  double L2;            // L2 carrier phase (cycles)
+  int    slip_cnt_L1;   // L1 cumulative loss of continuity indicator (negative value = undefined)
+  int    slip_cnt_L2;   // L2 cumulative loss of continuity indicator (negative value = undefined)
+  int    lock_timei_L1; // L1 last lock time indicator                (negative value = undefined)
+  int    lock_timei_L2; // L2 last lock time indicator                (negative value = undefined)
+  double S1;            // L1 signal-to noise ratio
+  double S2;            // L2 signal-to noise ratio
+  int    SNR1;          // L1 signal-to noise ratio (mapped to integer)
+  int    SNR2;          // L2 signal-to noise ratio (mapped to integer)
+};
 
-int main(int /* argc */, char** /* argv */) {
+int main(int argc, char** argv) {
 
-  int    year  = 2010;
-  int    month =    1;
-  int    day   =   10;
-  int    hour  =   12;
-  int    min   =   30;
-  double sec   =  0.0;
+  if (argc != 2) {
+    cerr << "Usage: test_bnc_qt port\n";
+    exit(1);
+  }
 
-  bncTime tt;
-  tt.set(year, month, day, hour, min, sec);
-  cout << tt.timestr() << " Moscow time (UTC + 3h)" << endl;
-  cout << "GPS-UTC: " << gnumleap(year, month, day) << endl;
+  int port = atoi(argv[1]);
+
+  QTcpSocket socketObs;
+
+  socketObs.connectToHost("127.0.0.1", port);
+  if (!socketObs.waitForConnected(10000)) {
+    cerr << "socketObs: not connected on port " << port << endl;
+    exit(1);
+  }
+
+  cout.setf(ios::fixed);
+
+  // Receive Data
+  // ------------
+  const char begObs[] = "BEGOBS";
+  const char begEpoch[] = "BEGEPOCH";
+  const char endEpoch[] = "ENDEPOCH";
+  const unsigned begObsNBytes   = sizeof(begObs) - 1;
+  const unsigned begEpochNBytes = sizeof(begEpoch) - 1;
+  const unsigned endEpochNBytes = sizeof(endEpoch) - 1;
+
+  QByteArray buffer;
+
+  while (true) {
+    if (socketObs.state() != QAbstractSocket::ConnectedState) {
+      cerr << "socketObs: disconnected" << endl;
+      exit(1);
+    }
+
+    if ( socketObs.bytesAvailable() ) {
+      buffer += socketObs.readAll();
+
+      // Skip begEpoch and endEpoch Marks
+      // --------------------------------
+      for (;;) {
+        int i1 = buffer.indexOf(begEpoch);
+        if (i1 == -1) {
+          break;
+        }
+        else {
+          buffer.remove(i1, begEpochNBytes);
+          cout << endl;
+        }
+      }
+      for (;;) {
+        int i2 = buffer.indexOf(endEpoch);
+        if (i2 == -1) {
+          break;
+        }
+        else {
+          buffer.remove(i2, endEpochNBytes);
+        }
+      }
+      for (;;) {
+        int i3 = buffer.indexOf(begObs);
+        if (i3 == -1) {
+          break;
+        }
+        else {
+          buffer.remove(i3, begObsNBytes);
+        }
+      }
+
+      // Interpret a portion of buffer as observation
+      // --------------------------------------------
+      t_obsInternal* obs;
+      const int obsSize = sizeof(t_obsInternal);
 
 
-  int week = tt.gpsw();
-  int tow  = int(tt.gpssec());
-  updatetime(&week, &tow, tow*1000, 1);
-  bncTime t2(week, tow);
-  cout << t2.timestr() << " UTC " << endl;
+      while (buffer.size() >= obsSize) {
 
-  week = tt.gpsw();
-  tow  = int(tt.gpssec());
-  updatetime(&week, &tow, tow*1000, 0);
-  bncTime t3(week, tow);
-  cout << t3.timestr() << " GPS " << endl;
+        obs = (t_obsInternal*) (buffer.left(obsSize).data());
 
+        cout << obs->StatID                      << " "
+             << obs->satSys << obs->satNum       << " "
+             << obs->GPSWeek                     << " "
+             << setprecision(2) << obs->GPSWeeks << " "
+             << setprecision(4) << obs->C1       << " "
+             << setprecision(4) << obs->C2       << " "
+             << setprecision(4) << obs->P1       << " "
+             << setprecision(4) << obs->P2       << " "
+             << setprecision(4) << obs->L1       << " "
+             << setprecision(4) << obs->L2       << " "
+             <<                    obs->slip_cnt_L1 << " "
+             <<                    obs->slip_cnt_L2 << " "
+             << setprecision(4) << obs->S1       << " "
+             << setprecision(4) << obs->S2       << " "
+             <<                    obs->SNR1     << " "
+             <<                    obs->SNR2     << endl;
 
-//  if (argc != 2) {
-//    cerr << "Usage: test_bnc_qt port\n";
-//    exit(1);
-//  }
-//
-//  int port = atoi(argv[1]);
-//
-//  QTcpSocket socketObs;
-//
-//  socketObs.connectToHost("127.0.0.1", port);
-//  if (!socketObs.waitForConnected(10000)) {
-//    cerr << "socketObs: not connected on port " << port << endl;
-//    exit(1);
-//  }
-//
-//  cout.setf(ios::fixed);
-//
-//  // Receive Data
-//  // ------------
-//  const char begObs[] = "BEGOBS";
-//  const char begEpoch[] = "BEGEPOCH";
-//  const char endEpoch[] = "ENDEPOCH";
-//  const unsigned begObsNBytes   = sizeof(begObs) - 1;
-//  const unsigned begEpochNBytes = sizeof(begEpoch) - 1;
-//  const unsigned endEpochNBytes = sizeof(endEpoch) - 1;
-//
-//  QByteArray buffer;
-//
-//  while (true) {
-//    if (socketObs.state() != QAbstractSocket::ConnectedState) {
-//      cerr << "socketObs: disconnected" << endl;
-//      exit(1);
-//    }
-//
-//    if ( socketObs.bytesAvailable() ) {
-//      buffer += socketObs.readAll();
-//
-//      // Skip begEpoch and endEpoch Marks
-//      // --------------------------------
-//      for (;;) {
-//        int i1 = buffer.indexOf(begEpoch);
-//        if (i1 == -1) {
-//          break;
-//        }
-//        else {
-//          buffer.remove(i1, begEpochNBytes);
-//          cout << endl;
-//        }
-//      }
-//      for (;;) {
-//        int i2 = buffer.indexOf(endEpoch);
-//        if (i2 == -1) {
-//          break;
-//        }
-//        else {
-//          buffer.remove(i2, endEpochNBytes);
-//        }
-//      }
-//      for (;;) {
-//        int i3 = buffer.indexOf(begObs);
-//        if (i3 == -1) {
-//          break;
-//        }
-//        else {
-//          buffer.remove(i3, begObsNBytes);
-//        }
-//      }
-//
-//      // Interpret a portion of buffer as observation
-//      // --------------------------------------------
-//      t_obsInternal* obs;
-//      const int obsSize = sizeof(t_obsInternal);
-//
-//
-//      while (buffer.size() >= obsSize) {
-//
-//        obs = (t_obsInternal*) (buffer.left(obsSize).data());
-//
-//        cout << obs->StatID                      << " "
-//             << obs->satSys << obs->satNum       << " "
-//             << obs->GPSWeek                     << " "
-//             << setprecision(2) << obs->GPSWeeks << " "
-//             << setprecision(4) << obs->C1       << " "
-//             << setprecision(4) << obs->C2       << " "
-//             << setprecision(4) << obs->P1       << " "
-//             << setprecision(4) << obs->P2       << " "
-//             << setprecision(4) << obs->L1       << " "
-//             << setprecision(4) << obs->L2       << " "
-//             <<                    obs->slip_cnt_L1 << " "
-//             <<                    obs->slip_cnt_L2 << " "
-//             << setprecision(4) << obs->S1       << " "
-//             << setprecision(4) << obs->S2       << " "
-//             <<                    obs->SNR1     << " "
-//             <<                    obs->SNR2     << endl;
-//
-//        buffer.remove(0,obsSize);
-//      }
-//    }
-//    else {
-//      socketObs.waitForReadyRead(1);
-//    }
-//  }
+        buffer.remove(0,obsSize);
+      }
+    }
+    else {
+      socketObs.waitForReadyRead(1);
+    }
+  }
 
   return 0;
