Changeset 136 in ntrip for trunk/BNC/bncgetthread.cpp
- Timestamp:
- Sep 8, 2006, 9:24:23 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncgetthread.cpp
r93 r136 28 28 using namespace std; 29 29 30 const int timeOut = 300*1000;31 32 30 // Constructor 33 31 //////////////////////////////////////////////////////////////////////////// 34 32 bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format) { 33 _decoder = 0; 35 34 _mountPoint = mountPoint; 36 35 _staID = mountPoint.path().mid(1).toAscii(); 37 36 _format = format; 38 37 _socket = 0; 38 _timeOut = 10*1000; // 10 seconds 39 39 } 40 40 … … 43 43 bncGetThread::~bncGetThread() { 44 44 delete _socket; 45 delete _decoder; 45 46 } 46 47 47 48 // Connect to Caster, send the Request (static) 48 49 //////////////////////////////////////////////////////////////////////////// 49 QTcpSocket* bncGetThread::request(const QUrl& mountPoint, QString& msg) { 50 QTcpSocket* bncGetThread::request(const QUrl& mountPoint, int timeOut, 51 QString& msg) { 50 52 51 53 // Connect the Socket … … 98 100 } 99 101 100 // Run102 // Init Run 101 103 //////////////////////////////////////////////////////////////////////////// 102 void bncGetThread:: run() {104 void bncGetThread::initRun() { 103 105 104 106 // Send the Request … … 106 108 QString msg; 107 109 108 _socket = bncGetThread::request(_mountPoint, msg);110 _socket = bncGetThread::request(_mountPoint, _timeOut, msg); 109 111 110 112 emit(newMessage(msg.toAscii())); … … 116 118 // Read Caster Response 117 119 // -------------------- 118 _socket->waitForReadyRead( timeOut);120 _socket->waitForReadyRead(_timeOut); 119 121 if (_socket->canReadLine()) { 120 122 QString line = _socket->readLine(); … … 131 133 // Instantiate the filter 132 134 // ---------------------- 133 GPSDecoder* decoder; 135 if (!_decoder) { 136 if (_format.indexOf("RTCM_2") != -1) { 137 emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format")); 138 _decoder = new RTCM('A',true); 139 } 140 else if (_format.indexOf("RTCM_3") != -1) { 141 emit(newMessage("Get Data: " + _staID + " in RTCM 3.0 format")); 142 _decoder = new rtcm3(); 143 } 144 else if (_format.indexOf("RTIGS") != -1) { 145 emit(newMessage("Get Data: " + _staID + " in RTIGS format")); 146 _decoder = new rtigs(); 147 } 148 else { 149 emit(newMessage(_staID + " Unknown data format " + _format)); 150 return exit(1); 151 } 152 } 153 } 134 154 135 if (_format.indexOf("RTCM_2") != -1) { 136 emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format")); 137 decoder = new RTCM('A',true); 138 } 139 else if (_format.indexOf("RTCM_3") != -1) { 140 emit(newMessage("Get Data: " + _staID + " in RTCM 3.0 format")); 141 decoder = new rtcm3(); 142 } 143 else if (_format.indexOf("RTIGS") != -1) { 144 emit(newMessage("Get Data: " + _staID + " in RTIGS format")); 145 decoder = new rtigs(); 146 } 147 else { 148 emit(newMessage(_staID + " Unknown data format " + _format)); 149 return exit(1); 150 } 155 // Run 156 //////////////////////////////////////////////////////////////////////////// 157 void bncGetThread::run() { 158 159 initRun(); 151 160 152 161 // Read Incoming Data 153 162 // ------------------ 154 163 while (true) { 155 _socket->waitForReadyRead( timeOut);164 _socket->waitForReadyRead(_timeOut); 156 165 qint64 nBytes = _socket->bytesAvailable(); 157 166 if (nBytes > 0) { 158 167 char* data = new char[nBytes]; 159 168 _socket->read(data, nBytes); 160 decoder->Decode(data, nBytes);169 _decoder->Decode(data, nBytes); 161 170 delete data; 162 for (list<Observation*>::iterator it = decoder->m_lObsList.begin();163 it != decoder->m_lObsList.end(); it++) {171 for (list<Observation*>::iterator it = _decoder->m_lObsList.begin(); 172 it != _decoder->m_lObsList.end(); it++) { 164 173 emit newObs(_staID, *it); 165 174 } 166 decoder->m_lObsList.clear();175 _decoder->m_lObsList.clear(); 167 176 } 168 177 else { 169 emit(newMessage("Data Timeout "));170 return exit(1);178 emit(newMessage("Data Timeout, reconnecting")); 179 tryReconnect(); 171 180 } 172 181 } 173 delete decoder;174 182 } 175 183 … … 183 191 } 184 192 193 // Try Re-Connect 194 //////////////////////////////////////////////////////////////////////////// 195 void bncGetThread::tryReconnect() { 196 197 }
Note:
See TracChangeset
for help on using the changeset viewer.