Changeset 1223 in ntrip


Ignore:
Timestamp:
Nov 22, 2008, 2:24:34 PM (15 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/test_bnc_qt.cpp

    r1194 r1223  
    3939 * -----------------------------------------------------------------------*/
    4040
     41#include <stdlib.h>
    4142#include <iostream>
    4243#include <iomanip>
     
    5051using namespace std;
    5152
    52 int main(int /* argc */, char** /* argv */) {
     53int main(int argc, char** argv) {
     54
     55  if (argc != 2) {
     56    cerr << "Usage: test_bnc_qt port\n";
     57    exit(1);
     58  }
     59
     60  int port = atoi(argv[1]);
    5361
    5462  QTcpSocket socketObs;
    5563
    56   QFile obsFile("obs.txt");
    57  
    58   socketObs.connectToHost("127.0.0.1", 1968);
     64  socketObs.connectToHost("127.0.0.1", port);
    5965  if (!socketObs.waitForConnected(10000)) {
    60     cout << "socketObs: not connected" << endl;
     66    cerr << "socketObs: not connected on port " << port << endl;
    6167    exit(1);
    6268  }
    6369
    64   obsFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered);
    65 
    66   QTextStream outObs(&obsFile);
    67   outObs.setRealNumberNotation(QTextStream::FixedNotation);
     70  cout.setf(ios::fixed);
    6871
    6972  // Receive Data
    7073  // ------------
     74  const char begObs[] = "BEGOBS";
    7175  const char begEpoch[] = "BEGEPOCH";
    7276  const char endEpoch[] = "ENDEPOCH";
     77  const unsigned begObsNBytes   = sizeof(begObs) - 1;
    7378  const unsigned begEpochNBytes = sizeof(begEpoch) - 1;
    7479  const unsigned endEpochNBytes = sizeof(endEpoch) - 1;
     
    7883  while (true) {
    7984    if (socketObs.state() != QAbstractSocket::ConnectedState) {
    80       cout << "socketObs: disconnected" << endl;
    81       exit(0);
     85      cerr << "socketObs: disconnected" << endl;
     86      exit(1);
    8287    }
    8388
     
    9499        else {
    95100          buffer.remove(i1, begEpochNBytes);
    96           outObs << endl;
     101          cout << endl;
    97102        }
    98103      }
     
    104109        else {
    105110          buffer.remove(i2, endEpochNBytes);
     111        }
     112      }
     113      for (;;) {
     114        int i3 = buffer.indexOf(begObs);
     115        if (i3 == -1) {
     116          break;
     117        }
     118        else {
     119          buffer.remove(i3, begObsNBytes);
    106120        }
    107121      }
     
    117131        obs = (t_obsInternal*) (buffer.left(obsSize).data());
    118132
    119         outObs << obs->StatID                                 << " "
    120                << obs->satSys << obs->satNum                   << " "
    121                << obs->GPSWeek                                << " "
    122                << qSetRealNumberPrecision(2) << obs->GPSWeeks << " "
    123                << qSetRealNumberPrecision(4) << obs->C1       << " "
    124                << qSetRealNumberPrecision(4) << obs->C2       << " "
    125                << qSetRealNumberPrecision(4) << obs->P1       << " "
    126                << qSetRealNumberPrecision(4) << obs->P2       << " "
    127                << qSetRealNumberPrecision(4) << obs->L1       << " "
    128                << qSetRealNumberPrecision(4) << obs->L2       << " "
    129                << qSetRealNumberPrecision(4) << obs->S1       << " "
    130                << qSetRealNumberPrecision(4) << obs->S2       << " "
    131                <<                               obs->SNR1     << " "
    132                <<                               obs->SNR2     << endl;
     133        cout << obs->StatID                      << " "
     134             << obs->satSys << obs->satNum       << " "
     135             << obs->GPSWeek                     << " "
     136             << setprecision(2) << obs->GPSWeeks << " "
     137             << setprecision(4) << obs->C1       << " "
     138             << setprecision(4) << obs->C2       << " "
     139             << setprecision(4) << obs->P1       << " "
     140             << setprecision(4) << obs->P2       << " "
     141             << setprecision(4) << obs->L1       << " "
     142             << setprecision(4) << obs->L2       << " "
     143             << setprecision(4) << obs->S1       << " "
     144             << setprecision(4) << obs->S2       << " "
     145             <<                    obs->SNR1     << " "
     146             <<                    obs->SNR2     << endl;
    133147
    134148        buffer.remove(0,obsSize);
Note: See TracChangeset for help on using the changeset viewer.