- Timestamp:
- Jan 16, 2010, 10:54:46 AM (15 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/test_bnc_qt.cpp
r1232 r2253 44 44 45 45 #include "RTCM/GPSDecoder.h" 46 #include "bnctime.h" 47 extern "C" { 48 #include "RTCM3/rtcm3torinex.h" 49 } 46 50 47 51 #include <QTcpSocket> … … 49 53 using namespace std; 50 54 51 int main(int argc, char** argv) { 55 void RTCM3Error(const char*, ...) {} 52 56 53 if (argc != 2) { 54 cerr << "Usage: test_bnc_qt port\n"; 55 exit(1); 56 } 57 int main(int /* argc */, char** /* argv */) { 57 58 58 int port = atoi(argv[1]); 59 bncTime tt; 60 tt.set(2010, 1, 10, 10, 45, 0.0); 59 61 60 QTcpSocket socketObs;62 cout << tt.timestr() << endl; 61 63 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 // } 155 166 156 167 return 0; -
trunk/BNC/test_bnc_qt.pro
r381 r2253 1 2 DEFINES += NO_RTCM3_MAIN 1 3 2 4 CONFIG += release console 3 5 4 HEADERS = 6 HEADERS = bnctime.h RTCM3/rtcm3torinex.h RTCM3/timeutils.h 5 7 6 SOURCES = test_bnc_qt.cpp 8 SOURCES = test_bnc_qt.cpp \ 9 bnctime.cpp RTCM3/rtcm3torinex.c RTCM3/timeutils.cpp 7 10 8 11 QT += network
Note:
See TracChangeset
for help on using the changeset viewer.