Changeset 136 in ntrip
- Timestamp:
- Sep 8, 2006, 9:24:23 AM (18 years ago)
- Location:
- trunk/BNC
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnccaster.cpp
r135 r136 58 58 QSettings settings; 59 59 _samplingRate = settings.value("rnxSampl").toInt(); 60 _waitTime = settings.value("waitTime").toInt(); 61 if (_waitTime < 2) { 62 _waitTime = 2; 63 } 60 64 } 61 65 … … 109 113 // Dump older epochs 110 114 // ----------------- 111 const long waitTime = 2; 112 dumpEpochs(_lastDumpSec + 1, newTime - waitTime); 113 _lastDumpSec = newTime - waitTime; 115 dumpEpochs(_lastDumpSec + 1, newTime - _waitTime); 116 _lastDumpSec = newTime - _waitTime; 114 117 } 115 118 -
trunk/BNC/bnccaster.h
r134 r136 49 49 QMap<QString, bncRinex*> _rinexWriters; 50 50 int _samplingRate; 51 long _waitTime; 51 52 }; 52 53 -
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 } -
trunk/BNC/bncgetthread.h
r88 r136 16 16 17 17 static QTcpSocket* bncGetThread::request(const QUrl& mountPoint, 18 QString& msg);18 int timeOut, QString& msg); 19 19 20 20 QByteArray staID() const {return _staID;} … … 28 28 virtual void run(); 29 29 private: 30 void initRun(); 31 void tryReconnect(); 30 32 void message(const QString&); 31 33 void exit(int exitCode = 0); 34 GPSDecoder* _decoder; 32 35 QTcpSocket* _socket; 33 36 QUrl _mountPoint; 34 37 QByteArray _staID; 35 38 QByteArray _format; 39 int _timeOut; 36 40 }; 37 41 -
trunk/BNC/bnctabledlg.cpp
r115 r136 94 94 // Send the Request 95 95 // ---------------- 96 const int timeOut = 10*1000; 96 97 QString msg; 97 QTcpSocket* socket = bncGetThread::request(url, msg);98 QTcpSocket* socket = bncGetThread::request(url, timeOut, msg); 98 99 99 100 if (!socket) { … … 126 127 } 127 128 else { 128 const int timeOut = 10*1000;129 129 socket->waitForReadyRead(timeOut); 130 130 if (socket->bytesAvailable() > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.