- Timestamp:
- Aug 27, 2008, 11:23:17 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNS/bns.cpp
r1059 r1061 73 73 // Socket and file for outputting the results 74 74 // ------------------------------------------- 75 _outSocket = 0; 76 _outSocketOpenTrial = 0; 75 _caster = new t_bnscaster(settings.value("mountpoint").toString()); 77 76 78 77 QIODevice::OpenMode oMode; … … 155 154 delete _clkServer; 156 155 delete _clkSocket; 157 delete _ outSocket;156 delete _caster; 158 157 delete _outStream; 159 158 delete _logStream; … … 209 208 } 210 209 211 // Start the Communication with NTRIP Caster212 ////////////////////////////////////////////////////////////////////////////213 void t_bns::openCaster() {214 215 delete _outSocket; _outSocket = 0;216 217 double minDt = exp2(_outSocketOpenTrial);218 if (++_outSocketOpenTrial > 8) {219 _outSocketOpenTrial = 8;220 }221 if (_outSocketOpenTime.isValid() &&222 _outSocketOpenTime.secsTo(QDateTime::currentDateTime()) < minDt) {223 return;224 }225 else {226 _outSocketOpenTime = QDateTime::currentDateTime();227 }228 229 QSettings settings;230 _outSocket = new QTcpSocket();231 _outSocket->connectToHost(settings.value("outHost").toString(),232 settings.value("outPort").toInt());233 234 const int timeOut = 100; // 0.1 seconds235 if (!_outSocket->waitForConnected(timeOut)) {236 delete _outSocket;237 _outSocket = 0;238 emit(error("bns::openCaster Connect Timeout"));239 return;240 }241 242 QString mountpoint = settings.value("mountpoint").toString();243 QString password = settings.value("password").toString();244 245 QByteArray msg = "SOURCE " + password.toAscii() + " /" +246 mountpoint.toAscii() + "\r\n" +247 "Source-Agent: NTRIP BNS/1.0\r\n\r\n";248 249 _outSocket->write(msg);250 _outSocket->waitForBytesWritten();251 252 _outSocket->waitForReadyRead();253 QByteArray ans = _outSocket->readLine();254 255 if (ans.indexOf("OK") == -1) {256 delete _outSocket;257 _outSocket = 0;258 slotMessage("bns::openCaster socket deleted");259 }260 else {261 slotMessage("bns::openCaster socket OK");262 _outSocketOpenTrial = 0;263 }264 }265 266 210 // 267 211 //////////////////////////////////////////////////////////////////////////// … … 316 260 if (_clkSocket && _clkSocket->state() == QAbstractSocket::ConnectedState) { 317 261 if ( _clkSocket->canReadLine()) { 318 if (_outSocket == 0 || 319 _outSocket->state() != QAbstractSocket::ConnectedState) { 320 openCaster(); 321 } 262 _caster->open(); 322 263 readEpoch(); 323 264 } … … 417 358 } 418 359 419 if ( (_ outSocket|| _outFile) &&360 if ( (_caster->used() || _outFile) && 420 361 (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) ) { 421 362 char obuffer[CLOCKORBIT_BUFFERSIZE]; … … 423 364 if (len > 0) { 424 365 emit(newOutBytes(len)); 425 if (_outSocket) { 426 _outSocket->write(obuffer, len); 427 _outSocket->flush(); 428 } 366 _caster->write(obuffer, len); 429 367 } 430 368 }
Note:
See TracChangeset
for help on using the changeset viewer.