Changeset 1223 in ntrip for trunk/BNC/test_bnc_qt.cpp
- Timestamp:
- Nov 22, 2008, 2:24:34 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/test_bnc_qt.cpp
r1194 r1223 39 39 * -----------------------------------------------------------------------*/ 40 40 41 #include <stdlib.h> 41 42 #include <iostream> 42 43 #include <iomanip> … … 50 51 using namespace std; 51 52 52 int main(int /* argc */, char** /* argv */) { 53 int 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]); 53 61 54 62 QTcpSocket socketObs; 55 63 56 QFile obsFile("obs.txt"); 57 58 socketObs.connectToHost("127.0.0.1", 1968); 64 socketObs.connectToHost("127.0.0.1", port); 59 65 if (!socketObs.waitForConnected(10000)) { 60 c out << "socketObs: not connected"<< endl;66 cerr << "socketObs: not connected on port " << port << endl; 61 67 exit(1); 62 68 } 63 69 64 obsFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered); 65 66 QTextStream outObs(&obsFile); 67 outObs.setRealNumberNotation(QTextStream::FixedNotation); 70 cout.setf(ios::fixed); 68 71 69 72 // Receive Data 70 73 // ------------ 74 const char begObs[] = "BEGOBS"; 71 75 const char begEpoch[] = "BEGEPOCH"; 72 76 const char endEpoch[] = "ENDEPOCH"; 77 const unsigned begObsNBytes = sizeof(begObs) - 1; 73 78 const unsigned begEpochNBytes = sizeof(begEpoch) - 1; 74 79 const unsigned endEpochNBytes = sizeof(endEpoch) - 1; … … 78 83 while (true) { 79 84 if (socketObs.state() != QAbstractSocket::ConnectedState) { 80 c out<< "socketObs: disconnected" << endl;81 exit( 0);85 cerr << "socketObs: disconnected" << endl; 86 exit(1); 82 87 } 83 88 … … 94 99 else { 95 100 buffer.remove(i1, begEpochNBytes); 96 outObs<< endl;101 cout << endl; 97 102 } 98 103 } … … 104 109 else { 105 110 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); 106 120 } 107 121 } … … 117 131 obs = (t_obsInternal*) (buffer.left(obsSize).data()); 118 132 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; 133 147 134 148 buffer.remove(0,obsSize);
Note:
See TracChangeset
for help on using the changeset viewer.