Changeset 1193 in ntrip


Ignore:
Timestamp:
Nov 13, 2008, 5:38:54 PM (15 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/test_bnc_qt.cpp

    r734 r1193  
    5050using namespace std;
    5151
    52 const char begEpoch = 'A';
    53 const char begObs   = 'B';
    54 const char endEpoch = 'C';
    55 
    5652int main(int /* argc */, char** /* argv */) {
    5753
     
    7369  // Receive Data
    7470  // ------------
    75   t_obsInternal obs;
    76   char flag = ' ';
    77   cout.setf(ios::showpoint | ios::fixed);
     71  const char begEpoch[] = "BEGEPOCH";
     72  const char endEpoch[] = "ENDEPOCH";
     73  const unsigned begEpochNBytes = sizeof(begEpoch) - 1;
     74  const unsigned endEpochNBytes = sizeof(endEpoch) - 1;
     75
     76  QByteArray buffer;
    7877
    7978  while (true) {
     
    8382    }
    8483
    85     if ( socketObs.bytesAvailable() > sizeof(obs) ) {
    86       socketObs.read(&flag, 1);
    87       if (flag == begObs) {
    88         socketObs.read((char*) &obs, sizeof(obs));
    89         outObs << obs.StatID                                 << " "
    90                << obs.satSys << obs.satNum                   << " "
    91                << obs.GPSWeek                                << " "
    92                << qSetRealNumberPrecision(2) << obs.GPSWeeks << " "
    93                << qSetRealNumberPrecision(4) << obs.C1       << " "
    94                << qSetRealNumberPrecision(4) << obs.C2       << " "
    95                << qSetRealNumberPrecision(4) << obs.P1       << " "
    96                << qSetRealNumberPrecision(4) << obs.P2       << " "
    97                << qSetRealNumberPrecision(4) << obs.L1       << " "
    98                << qSetRealNumberPrecision(4) << obs.L2       << " "
    99                << qSetRealNumberPrecision(4) << obs.S1       << " "
    100                << qSetRealNumberPrecision(4) << obs.S2       << " "
    101                <<                               obs.SNR1     << " "
    102                <<                               obs.SNR2     << endl;
     84    if ( socketObs.bytesAvailable() ) {
     85      buffer += socketObs.readAll();
     86
     87      // Skip begEpoch and endEpoch Marks
     88      // --------------------------------
     89      for (;;) {
     90        int i1 = buffer.indexOf(begEpoch);
     91        if (i1 == -1) {
     92          break;
     93        }
     94        else {
     95          buffer.remove(i1, begEpochNBytes);
     96        }
     97      }
     98      for (;;) {
     99        int i2 = buffer.indexOf(endEpoch);
     100        if (i2 == -1) {
     101          break;
     102        }
     103        else {
     104          buffer.remove(i2, endEpochNBytes);
     105        }
     106      }
     107
     108      // Interpret a portion of buffer as observation
     109      // --------------------------------------------
     110      t_obsInternal* obs;
     111      const int obsSize = sizeof(t_obsInternal);
     112
     113
     114      while (buffer.size() >= obsSize) {
     115
     116        cout << buffer.size() << " " << obsSize << endl;
     117
     118        obs = (t_obsInternal*) (buffer.left(obsSize).data());
     119
     120        outObs << obs->StatID                                 << " "
     121               << obs->satSys << obs->satNum                   << " "
     122               << obs->GPSWeek                                << " "
     123               << qSetRealNumberPrecision(2) << obs->GPSWeeks << " "
     124               << qSetRealNumberPrecision(4) << obs->C1       << " "
     125               << qSetRealNumberPrecision(4) << obs->C2       << " "
     126               << qSetRealNumberPrecision(4) << obs->P1       << " "
     127               << qSetRealNumberPrecision(4) << obs->P2       << " "
     128               << qSetRealNumberPrecision(4) << obs->L1       << " "
     129               << qSetRealNumberPrecision(4) << obs->L2       << " "
     130               << qSetRealNumberPrecision(4) << obs->S1       << " "
     131               << qSetRealNumberPrecision(4) << obs->S2       << " "
     132               <<                               obs->SNR1     << " "
     133               <<                               obs->SNR2     << endl;
     134
     135        buffer.remove(0,obsSize);
    103136      }
    104137    }
Note: See TracChangeset for help on using the changeset viewer.