Changeset 1170 in ntrip for trunk/BNC/bnccaster.cpp
- Timestamp:
- Oct 27, 2008, 3:35:54 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnccaster.cpp
r740 r1170 44 44 45 45 #include "bnccaster.h" 46 #include "bncapp.h" 46 47 #include "bncgetthread.h" 47 48 #include "bncutils.h" … … 90 91 _lastDumpSec = 0; 91 92 92 _samplingRate = settings.value("binSampl").toInt(); 93 _waitTime = settings.value("waitTime").toInt(); 94 if (_waitTime < 1) { 95 _waitTime = 1; 96 } 93 _confTimer = 0; 97 94 } 98 95 … … 191 188 _staIDs.push_back(getThread->staID()); 192 189 _threads.push_back(getThread); 190 191 getThread->start(); 193 192 } 194 193 … … 308 307 } 309 308 } 309 310 // Reread configuration 311 //////////////////////////////////////////////////////////////////////////// 312 void bncCaster::slotReadMountpoints() { 313 314 QSettings settings; 315 316 // Reread several options 317 // ---------------------- 318 _samplingRate = settings.value("binSampl").toInt(); 319 _waitTime = settings.value("waitTime").toInt(); 320 if (_waitTime < 1) { 321 _waitTime = 1; 322 } 323 324 // Add new mountpoints 325 // ------------------- 326 int iMount = -1; 327 QListIterator<QString> it(settings.value("mountPoints").toStringList()); 328 while (it.hasNext()) { 329 ++iMount; 330 QStringList hlp = it.next().split(" "); 331 if (hlp.size() <= 1) continue; 332 QUrl url(hlp[0]); 333 334 // Does it already exist? 335 // ---------------------- 336 bool existFlg = false; 337 QListIterator<bncGetThread*> iTh(_threads); 338 while (iTh.hasNext()) { 339 bncGetThread* thread = iTh.next(); 340 if (thread->mountPoint() == url) { 341 existFlg = true; 342 break; 343 } 344 } 345 346 // New bncGetThread 347 // ---------------- 348 if (!existFlg) { 349 QByteArray format = hlp[1].toAscii(); 350 QByteArray latitude = hlp[2].toAscii(); 351 QByteArray longitude = hlp[3].toAscii(); 352 QByteArray nmea = hlp[4].toAscii(); 353 354 bncGetThread* getThread = new bncGetThread(url, format, latitude, 355 longitude, nmea, iMount); 356 357 bncApp* app = (bncApp*) qApp; 358 app->connect(getThread, SIGNAL(newMessage(QByteArray)), 359 app, SLOT(slotMessage(const QByteArray))); 360 361 std::cout << "newThread " << getThread->staID().data() << std::endl; 362 363 addGetThread(getThread); 364 } 365 } 366 367 // Remove mountpoints 368 // ------------------ 369 QListIterator<bncGetThread*> iTh(_threads); 370 while (iTh.hasNext()) { 371 bncGetThread* thread = iTh.next(); 372 373 bool existFlg = false; 374 QListIterator<QString> it(settings.value("mountPoints").toStringList()); 375 while (it.hasNext()) { 376 QStringList hlp = it.next().split(" "); 377 if (hlp.size() <= 1) continue; 378 QUrl url(hlp[0]); 379 380 if (thread->mountPoint() == url) { 381 existFlg = true; 382 break; 383 } 384 } 385 386 if (!existFlg) { 387 std::cout << "old Thread " << thread->staID().data() << std::endl; 388 disconnect(thread, 0, 0, 0); 389 _staIDs.removeAll(thread->staID()); 390 _threads.removeAll(thread); 391 thread->terminate(); 392 thread->wait(); 393 delete thread; 394 } 395 } 396 397 // (Re-) Start the configuration timer 398 // ----------------------------------- 399 int ms = 0; 400 401 if (_confTimer) { 402 ms = 1000 * _confInterval; 403 } 404 else { 405 _confTimer = new QTimer(); 406 connect(_confTimer, SIGNAL(timeout()), this, SLOT(slotReadMountpoints())); 407 408 QTime currTime = currentDateAndTimeGPS().time(); 409 QTime nextShotTime; 410 411 if (settings.value("onTheFlyInterval").toString() == "1 min") { 412 _confInterval = 60; 413 nextShotTime = QTime(currTime.hour(), currTime.minute()+1, 0); 414 } 415 else if (settings.value("onTheFlyInterval").toString() == "1 hour") { 416 _confInterval = 3600; 417 nextShotTime = QTime(currTime.hour()+1, 0, 0); 418 } 419 else { 420 _confInterval = 86400; 421 nextShotTime = QTime(23, 59, 59, 999); 422 } 423 424 ms = currTime.msecsTo(nextShotTime); 425 } 426 427 _confTimer->start(ms); 428 }
Note:
See TracChangeset
for help on using the changeset viewer.