- Timestamp:
- Nov 13, 2008, 5:38:54 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/test_bnc_qt.cpp
r734 r1193 50 50 using namespace std; 51 51 52 const char begEpoch = 'A';53 const char begObs = 'B';54 const char endEpoch = 'C';55 56 52 int main(int /* argc */, char** /* argv */) { 57 53 … … 73 69 // Receive Data 74 70 // ------------ 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; 78 77 79 78 while (true) { … … 83 82 } 84 83 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); 103 136 } 104 137 }
Note:
See TracChangeset
for help on using the changeset viewer.