Changeset 2253 in ntrip


Ignore:
Timestamp:
Jan 16, 2010, 10:54:46 AM (14 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/test_bnc_qt.cpp

    r1232 r2253  
    4444
    4545#include "RTCM/GPSDecoder.h"
     46#include "bnctime.h"
     47extern "C" {
     48#include "RTCM3/rtcm3torinex.h"
     49}
    4650
    4751#include <QTcpSocket>
     
    4953using namespace std;
    5054
    51 int main(int argc, char** argv) {
     55void RTCM3Error(const char*, ...) {}
    5256
    53   if (argc != 2) {
    54     cerr << "Usage: test_bnc_qt port\n";
    55     exit(1);
    56   }
     57int main(int /* argc */, char** /* argv */) {
    5758
    58   int port = atoi(argv[1]);
     59  bncTime tt;
     60  tt.set(2010, 1, 10, 10, 45, 0.0);
    5961
    60   QTcpSocket socketObs;
     62  cout << tt.timestr() << endl;
    6163
    62   socketObs.connectToHost("127.0.0.1", port);
    63   if (!socketObs.waitForConnected(10000)) {
    64     cerr << "socketObs: not connected on port " << port << endl;
    65     exit(1);
    66   }
    67 
    68   cout.setf(ios::fixed);
    69 
    70   // Receive Data
    71   // ------------
    72   const char begObs[] = "BEGOBS";
    73   const char begEpoch[] = "BEGEPOCH";
    74   const char endEpoch[] = "ENDEPOCH";
    75   const unsigned begObsNBytes   = sizeof(begObs) - 1;
    76   const unsigned begEpochNBytes = sizeof(begEpoch) - 1;
    77   const unsigned endEpochNBytes = sizeof(endEpoch) - 1;
    78 
    79   QByteArray buffer;
    80 
    81   while (true) {
    82     if (socketObs.state() != QAbstractSocket::ConnectedState) {
    83       cerr << "socketObs: disconnected" << endl;
    84       exit(1);
    85     }
    86 
    87     if ( socketObs.bytesAvailable() ) {
    88       buffer += socketObs.readAll();
    89 
    90       // Skip begEpoch and endEpoch Marks
    91       // --------------------------------
    92       for (;;) {
    93         int i1 = buffer.indexOf(begEpoch);
    94         if (i1 == -1) {
    95           break;
    96         }
    97         else {
    98           buffer.remove(i1, begEpochNBytes);
    99           cout << endl;
    100         }
    101       }
    102       for (;;) {
    103         int i2 = buffer.indexOf(endEpoch);
    104         if (i2 == -1) {
    105           break;
    106         }
    107         else {
    108           buffer.remove(i2, endEpochNBytes);
    109         }
    110       }
    111       for (;;) {
    112         int i3 = buffer.indexOf(begObs);
    113         if (i3 == -1) {
    114           break;
    115         }
    116         else {
    117           buffer.remove(i3, begObsNBytes);
    118         }
    119       }
    120 
    121       // Interpret a portion of buffer as observation
    122       // --------------------------------------------
    123       t_obsInternal* obs;
    124       const int obsSize = sizeof(t_obsInternal);
    125 
    126 
    127       while (buffer.size() >= obsSize) {
    128 
    129         obs = (t_obsInternal*) (buffer.left(obsSize).data());
    130 
    131         cout << obs->StatID                      << " "
    132              << obs->satSys << obs->satNum       << " "
    133              << obs->GPSWeek                     << " "
    134              << setprecision(2) << obs->GPSWeeks << " "
    135              << setprecision(4) << obs->C1       << " "
    136              << setprecision(4) << obs->C2       << " "
    137              << setprecision(4) << obs->P1       << " "
    138              << setprecision(4) << obs->P2       << " "
    139              << setprecision(4) << obs->L1       << " "
    140              << setprecision(4) << obs->L2       << " "
    141              <<                    obs->slip_cnt_L1 << " "
    142              <<                    obs->slip_cnt_L2 << " "
    143              << setprecision(4) << obs->S1       << " "
    144              << setprecision(4) << obs->S2       << " "
    145              <<                    obs->SNR1     << " "
    146              <<                    obs->SNR2     << endl;
    147 
    148         buffer.remove(0,obsSize);
    149       }
    150     }
    151     else {
    152       socketObs.waitForReadyRead(1);
    153     }
    154   }
     64//  if (argc != 2) {
     65//    cerr << "Usage: test_bnc_qt port\n";
     66//    exit(1);
     67//  }
     68//
     69//  int port = atoi(argv[1]);
     70//
     71//  QTcpSocket socketObs;
     72//
     73//  socketObs.connectToHost("127.0.0.1", port);
     74//  if (!socketObs.waitForConnected(10000)) {
     75//    cerr << "socketObs: not connected on port " << port << endl;
     76//    exit(1);
     77//  }
     78//
     79//  cout.setf(ios::fixed);
     80//
     81//  // Receive Data
     82//  // ------------
     83//  const char begObs[] = "BEGOBS";
     84//  const char begEpoch[] = "BEGEPOCH";
     85//  const char endEpoch[] = "ENDEPOCH";
     86//  const unsigned begObsNBytes   = sizeof(begObs) - 1;
     87//  const unsigned begEpochNBytes = sizeof(begEpoch) - 1;
     88//  const unsigned endEpochNBytes = sizeof(endEpoch) - 1;
     89//
     90//  QByteArray buffer;
     91//
     92//  while (true) {
     93//    if (socketObs.state() != QAbstractSocket::ConnectedState) {
     94//      cerr << "socketObs: disconnected" << endl;
     95//      exit(1);
     96//    }
     97//
     98//    if ( socketObs.bytesAvailable() ) {
     99//      buffer += socketObs.readAll();
     100//
     101//      // Skip begEpoch and endEpoch Marks
     102//      // --------------------------------
     103//      for (;;) {
     104//        int i1 = buffer.indexOf(begEpoch);
     105//        if (i1 == -1) {
     106//          break;
     107//        }
     108//        else {
     109//          buffer.remove(i1, begEpochNBytes);
     110//          cout << endl;
     111//        }
     112//      }
     113//      for (;;) {
     114//        int i2 = buffer.indexOf(endEpoch);
     115//        if (i2 == -1) {
     116//          break;
     117//        }
     118//        else {
     119//          buffer.remove(i2, endEpochNBytes);
     120//        }
     121//      }
     122//      for (;;) {
     123//        int i3 = buffer.indexOf(begObs);
     124//        if (i3 == -1) {
     125//          break;
     126//        }
     127//        else {
     128//          buffer.remove(i3, begObsNBytes);
     129//        }
     130//      }
     131//
     132//      // Interpret a portion of buffer as observation
     133//      // --------------------------------------------
     134//      t_obsInternal* obs;
     135//      const int obsSize = sizeof(t_obsInternal);
     136//
     137//
     138//      while (buffer.size() >= obsSize) {
     139//
     140//        obs = (t_obsInternal*) (buffer.left(obsSize).data());
     141//
     142//        cout << obs->StatID                      << " "
     143//             << obs->satSys << obs->satNum       << " "
     144//             << obs->GPSWeek                     << " "
     145//             << setprecision(2) << obs->GPSWeeks << " "
     146//             << setprecision(4) << obs->C1       << " "
     147//             << setprecision(4) << obs->C2       << " "
     148//             << setprecision(4) << obs->P1       << " "
     149//             << setprecision(4) << obs->P2       << " "
     150//             << setprecision(4) << obs->L1       << " "
     151//             << setprecision(4) << obs->L2       << " "
     152//             <<                    obs->slip_cnt_L1 << " "
     153//             <<                    obs->slip_cnt_L2 << " "
     154//             << setprecision(4) << obs->S1       << " "
     155//             << setprecision(4) << obs->S2       << " "
     156//             <<                    obs->SNR1     << " "
     157//             <<                    obs->SNR2     << endl;
     158//
     159//        buffer.remove(0,obsSize);
     160//      }
     161//    }
     162//    else {
     163//      socketObs.waitForReadyRead(1);
     164//    }
     165//  }
    155166
    156167  return 0;
  • trunk/BNC/test_bnc_qt.pro

    r381 r2253  
     1
     2DEFINES += NO_RTCM3_MAIN
    13
    24CONFIG += release console
    35
    4 HEADERS =
     6HEADERS = bnctime.h   RTCM3/rtcm3torinex.h RTCM3/timeutils.h
    57
    6 SOURCES = test_bnc_qt.cpp
     8SOURCES = test_bnc_qt.cpp \
     9          bnctime.cpp RTCM3/rtcm3torinex.c RTCM3/timeutils.cpp
    710
    811QT += network
Note: See TracChangeset for help on using the changeset viewer.