[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[35] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[35] | 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncCaster
|
---|
| 30 | *
|
---|
| 31 | * Purpose: buffers and disseminates the data
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Dec-2005
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[222] | 41 | #include <math.h>
|
---|
[636] | 42 | #include <unistd.h>
|
---|
[222] | 43 |
|
---|
[35] | 44 | #include "bnccaster.h"
|
---|
[1170] | 45 | #include "bncapp.h"
|
---|
[35] | 46 | #include "bncgetthread.h"
|
---|
[134] | 47 | #include "bncutils.h"
|
---|
[207] | 48 | #include "RTCM/GPSDecoder.h"
|
---|
[35] | 49 |
|
---|
| 50 | // Constructor
|
---|
| 51 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 52 | bncCaster::bncCaster(const QString& outFileName, int port) {
|
---|
| 53 |
|
---|
[275] | 54 | QSettings settings;
|
---|
| 55 |
|
---|
[1299] | 56 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 57 | (bncApp*) qApp, SLOT(slotMessage(const QByteArray,bool)));
|
---|
[1228] | 58 |
|
---|
[35] | 59 | if ( !outFileName.isEmpty() ) {
|
---|
[134] | 60 | QString lName = outFileName;
|
---|
| 61 | expandEnvVar(lName);
|
---|
| 62 | _outFile = new QFile(lName);
|
---|
[275] | 63 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 64 | _outFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 65 | }
|
---|
| 66 | else {
|
---|
| 67 | _outFile->open(QIODevice::WriteOnly);
|
---|
| 68 | }
|
---|
[35] | 69 | _out = new QTextStream(_outFile);
|
---|
| 70 | _out->setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 71 | }
|
---|
| 72 | else {
|
---|
| 73 | _outFile = 0;
|
---|
| 74 | _out = 0;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | _port = port;
|
---|
| 78 |
|
---|
| 79 | if (_port != 0) {
|
---|
| 80 | _server = new QTcpServer;
|
---|
[1228] | 81 | if ( !_server->listen(QHostAddress::Any, _port) ) {
|
---|
[1450] | 82 | emit newMessage("bncCaster: Cannot listen on sync port", true);
|
---|
[1228] | 83 | }
|
---|
[35] | 84 | connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
|
---|
| 85 | _sockets = new QList<QTcpSocket*>;
|
---|
| 86 | }
|
---|
| 87 | else {
|
---|
| 88 | _server = 0;
|
---|
| 89 | _sockets = 0;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[1222] | 92 | int uPort = settings.value("outUPort").toInt();
|
---|
| 93 | if (uPort != 0) {
|
---|
| 94 | _uServer = new QTcpServer;
|
---|
[1228] | 95 | if ( !_uServer->listen(QHostAddress::Any, uPort) ) {
|
---|
[1450] | 96 | emit newMessage("bncCaster: Cannot listen on usync port", true);
|
---|
[1228] | 97 | }
|
---|
[1222] | 98 | connect(_uServer, SIGNAL(newConnection()), this, SLOT(slotNewUConnection()));
|
---|
| 99 | _uSockets = new QList<QTcpSocket*>;
|
---|
| 100 | }
|
---|
| 101 | else {
|
---|
| 102 | _uServer = 0;
|
---|
| 103 | _uSockets = 0;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[622] | 106 | _epochs = new QMultiMap<long, p_obs>;
|
---|
[35] | 107 |
|
---|
| 108 | _lastDumpSec = 0;
|
---|
[133] | 109 |
|
---|
[1170] | 110 | _confTimer = 0;
|
---|
[35] | 111 | }
|
---|
| 112 |
|
---|
| 113 | // Destructor
|
---|
| 114 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 115 | bncCaster::~bncCaster() {
|
---|
[186] | 116 | QListIterator<bncGetThread*> it(_threads);
|
---|
| 117 | while(it.hasNext()){
|
---|
| 118 | bncGetThread* thread = it.next();
|
---|
| 119 | thread->terminate();
|
---|
[230] | 120 | delete thread;
|
---|
[186] | 121 | }
|
---|
[35] | 122 | delete _out;
|
---|
| 123 | delete _outFile;
|
---|
[187] | 124 | delete _server;
|
---|
[631] | 125 | delete _sockets;
|
---|
[1222] | 126 | delete _uServer;
|
---|
| 127 | delete _uSockets;
|
---|
[603] | 128 | if (_epochs) {
|
---|
[622] | 129 | QListIterator<p_obs> it(_epochs->values());
|
---|
[603] | 130 | while (it.hasNext()) {
|
---|
| 131 | delete it.next();
|
---|
| 132 | }
|
---|
| 133 | delete _epochs;
|
---|
| 134 | }
|
---|
[35] | 135 | }
|
---|
| 136 |
|
---|
| 137 | // New Observations
|
---|
| 138 | ////////////////////////////////////////////////////////////////////////////
|
---|
[622] | 139 | void bncCaster::newObs(const QByteArray staID, bool firstObs, p_obs obs) {
|
---|
[35] | 140 |
|
---|
[243] | 141 | QMutexLocker locker(&_mutex);
|
---|
| 142 |
|
---|
[624] | 143 | obs->_status = t_obs::received;
|
---|
| 144 |
|
---|
[622] | 145 | long iSec = long(floor(obs->_o.GPSWeeks+0.5));
|
---|
| 146 | long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
|
---|
[35] | 147 |
|
---|
[160] | 148 | // Rename the Station
|
---|
| 149 | // ------------------
|
---|
[622] | 150 | strncpy(obs->_o.StatID, staID.constData(),sizeof(obs->_o.StatID));
|
---|
| 151 | obs->_o.StatID[sizeof(obs->_o.StatID)-1] = '\0';
|
---|
[160] | 152 |
|
---|
[1222] | 153 | const char begObs[] = "BEGOBS";
|
---|
| 154 | const int begObsNBytes = sizeof(begObs) - 1;
|
---|
| 155 |
|
---|
| 156 | // Output into the socket
|
---|
| 157 | // ----------------------
|
---|
| 158 | if (_uSockets) {
|
---|
| 159 | QMutableListIterator<QTcpSocket*> is(*_uSockets);
|
---|
| 160 | while (is.hasNext()) {
|
---|
| 161 | QTcpSocket* sock = is.next();
|
---|
| 162 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
| 163 | bool ok = true;
|
---|
| 164 | if (myWrite(sock, begObs, begObsNBytes) != begObsNBytes) {
|
---|
| 165 | ok = false;
|
---|
| 166 | }
|
---|
| 167 | int numBytes = sizeof(obs->_o);
|
---|
| 168 | if (myWrite(sock, (const char*)(&obs->_o), numBytes) != numBytes) {
|
---|
| 169 | ok = false;
|
---|
| 170 | }
|
---|
| 171 | if (!ok) {
|
---|
| 172 | delete sock;
|
---|
| 173 | is.remove();
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 177 | delete sock;
|
---|
| 178 | is.remove();
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 | }
|
---|
| 182 |
|
---|
[35] | 183 | // First time, set the _lastDumpSec immediately
|
---|
| 184 | // --------------------------------------------
|
---|
| 185 | if (_lastDumpSec == 0) {
|
---|
[462] | 186 | _lastDumpSec = newTime - 1;
|
---|
[35] | 187 | }
|
---|
| 188 |
|
---|
| 189 | // An old observation - throw it away
|
---|
| 190 | // ----------------------------------
|
---|
[462] | 191 | if (newTime <= _lastDumpSec) {
|
---|
[257] | 192 | if (firstObs) {
|
---|
| 193 | QSettings settings;
|
---|
| 194 | if ( !settings.value("outFile").toString().isEmpty() ||
|
---|
| 195 | !settings.value("outPort").toString().isEmpty() ) {
|
---|
[1325] | 196 | emit( newMessage(QString("%1: Old epoch %2 thrown away")
|
---|
[1299] | 197 | .arg(staID.data()).arg(iSec).toAscii(), true) );
|
---|
[257] | 198 | }
|
---|
[181] | 199 | }
|
---|
[35] | 200 | delete obs;
|
---|
[350] | 201 | return;
|
---|
[35] | 202 | }
|
---|
| 203 |
|
---|
[160] | 204 | // Save the observation
|
---|
| 205 | // --------------------
|
---|
[462] | 206 | _epochs->insert(newTime, obs);
|
---|
[393] | 207 |
|
---|
[462] | 208 | // Dump Epochs
|
---|
| 209 | // -----------
|
---|
| 210 | if (newTime - _waitTime > _lastDumpSec) {
|
---|
| 211 | dumpEpochs(_lastDumpSec + 1, newTime - _waitTime);
|
---|
| 212 | _lastDumpSec = newTime - _waitTime;
|
---|
[252] | 213 | }
|
---|
[35] | 214 | }
|
---|
| 215 |
|
---|
| 216 | // New Connection
|
---|
| 217 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 218 | void bncCaster::slotNewConnection() {
|
---|
| 219 | _sockets->push_back( _server->nextPendingConnection() );
|
---|
[1450] | 220 | emit( newMessage(QString("New client connection on sync port: # %1")
|
---|
[1299] | 221 | .arg(_sockets->size()).toAscii(), true) );
|
---|
[35] | 222 | }
|
---|
| 223 |
|
---|
[1222] | 224 | void bncCaster::slotNewUConnection() {
|
---|
| 225 | _uSockets->push_back( _uServer->nextPendingConnection() );
|
---|
[1450] | 226 | emit( newMessage(QString("New client connection on usync port: # %1")
|
---|
[1299] | 227 | .arg(_uSockets->size()).toAscii(), true) );
|
---|
[1222] | 228 | }
|
---|
| 229 |
|
---|
[35] | 230 | // Add New Thread
|
---|
| 231 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 232 | void bncCaster::addGetThread(bncGetThread* getThread) {
|
---|
[624] | 233 |
|
---|
| 234 | qRegisterMetaType<p_obs>("p_obs");
|
---|
| 235 |
|
---|
[628] | 236 | connect(getThread, SIGNAL(newObs(QByteArray, bool, p_obs)),
|
---|
| 237 | this, SLOT(newObs(QByteArray, bool, p_obs)));
|
---|
[463] | 238 |
|
---|
[628] | 239 | connect(getThread, SIGNAL(error(QByteArray)),
|
---|
| 240 | this, SLOT(slotGetThreadError(QByteArray)));
|
---|
[35] | 241 |
|
---|
[88] | 242 | _staIDs.push_back(getThread->staID());
|
---|
[186] | 243 | _threads.push_back(getThread);
|
---|
[1170] | 244 |
|
---|
| 245 | getThread->start();
|
---|
[35] | 246 | }
|
---|
| 247 |
|
---|
| 248 | // Error in get thread
|
---|
| 249 | ////////////////////////////////////////////////////////////////////////////
|
---|
[628] | 250 | void bncCaster::slotGetThreadError(QByteArray staID) {
|
---|
[243] | 251 | QMutexLocker locker(&_mutex);
|
---|
[88] | 252 | _staIDs.removeAll(staID);
|
---|
[82] | 253 | emit( newMessage(
|
---|
[1299] | 254 | QString("Mountpoint size %1").arg(_staIDs.size()).toAscii(), true) );
|
---|
[88] | 255 | if (_staIDs.size() == 0) {
|
---|
[1450] | 256 | emit(newMessage("bncCaster: Last get thread terminated", true));
|
---|
[35] | 257 | emit getThreadErrors();
|
---|
| 258 | }
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | // Dump Complete Epochs
|
---|
| 262 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 263 | void bncCaster::dumpEpochs(long minTime, long maxTime) {
|
---|
| 264 |
|
---|
[1182] | 265 | const char begEpoch[] = "BEGEPOCH";
|
---|
| 266 | const char endEpoch[] = "ENDEPOCH";
|
---|
[35] | 267 |
|
---|
[1182] | 268 | const int begEpochNBytes = sizeof(begEpoch) - 1;
|
---|
| 269 | const int endEpochNBytes = sizeof(endEpoch) - 1;
|
---|
| 270 |
|
---|
[35] | 271 | for (long sec = minTime; sec <= maxTime; sec++) {
|
---|
[140] | 272 |
|
---|
[35] | 273 | bool first = true;
|
---|
[622] | 274 | QList<p_obs> allObs = _epochs->values(sec);
|
---|
| 275 | QListIterator<p_obs> it(allObs);
|
---|
[35] | 276 | while (it.hasNext()) {
|
---|
[622] | 277 | p_obs obs = it.next();
|
---|
[35] | 278 |
|
---|
[140] | 279 | if (_samplingRate == 0 || sec % _samplingRate == 0) {
|
---|
| 280 |
|
---|
| 281 | // Output into the file
|
---|
| 282 | // --------------------
|
---|
| 283 | if (_out) {
|
---|
[35] | 284 | if (first) {
|
---|
[341] | 285 | _out->setFieldWidth(1); *_out << begEpoch << endl;;
|
---|
[35] | 286 | }
|
---|
[622] | 287 | _out->setFieldWidth(0); *_out << obs->_o.StatID;
|
---|
| 288 | _out->setFieldWidth(1); *_out << " " << obs->_o.satSys;
|
---|
[344] | 289 | _out->setPadChar('0');
|
---|
[622] | 290 | _out->setFieldWidth(2); *_out << obs->_o.satNum;
|
---|
[344] | 291 | _out->setPadChar(' ');
|
---|
[342] | 292 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 293 | _out->setFieldWidth(4); *_out << obs->_o.GPSWeek;
|
---|
[342] | 294 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 295 | _out->setFieldWidth(14); _out->setRealNumberPrecision(7); *_out << obs->_o.GPSWeeks;
|
---|
[342] | 296 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 297 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.C1;
|
---|
[342] | 298 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 299 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.C2;
|
---|
[366] | 300 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 301 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.P1;
|
---|
[342] | 302 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 303 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.P2;
|
---|
[342] | 304 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 305 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.L1;
|
---|
[342] | 306 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 307 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.L2;
|
---|
[367] | 308 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 309 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.S1;
|
---|
[367] | 310 | _out->setFieldWidth(1); *_out << " ";
|
---|
[622] | 311 | _out->setFieldWidth(14); _out->setRealNumberPrecision(3); *_out << obs->_o.S2;
|
---|
[342] | 312 | _out->setFieldWidth(1);
|
---|
[622] | 313 | *_out << " " << obs->_o.SNR1 << " " << obs->_o.SNR2 << endl;
|
---|
[35] | 314 | if (!it.hasNext()) {
|
---|
[341] | 315 | _out->setFieldWidth(1); *_out << endEpoch << endl;
|
---|
[35] | 316 | }
|
---|
[347] | 317 | _out->flush();
|
---|
[35] | 318 | }
|
---|
[140] | 319 |
|
---|
| 320 | // Output into the socket
|
---|
| 321 | // ----------------------
|
---|
| 322 | if (_sockets) {
|
---|
[637] | 323 | QMutableListIterator<QTcpSocket*> is(*_sockets);
|
---|
[140] | 324 | while (is.hasNext()) {
|
---|
| 325 | QTcpSocket* sock = is.next();
|
---|
[397] | 326 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[637] | 327 | bool ok = true;
|
---|
[397] | 328 | if (first) {
|
---|
[1182] | 329 | if (myWrite(sock, begEpoch, begEpochNBytes) != begEpochNBytes) {
|
---|
[637] | 330 | ok = false;
|
---|
| 331 | }
|
---|
[397] | 332 | }
|
---|
[1182] | 333 | int numBytes = sizeof(obs->_o);
|
---|
| 334 | if (myWrite(sock, (const char*)(&obs->_o), numBytes) != numBytes) {
|
---|
[637] | 335 | ok = false;
|
---|
| 336 | }
|
---|
[397] | 337 | if (!it.hasNext()) {
|
---|
[1182] | 338 | if (myWrite(sock, endEpoch, endEpochNBytes) != endEpochNBytes) {
|
---|
[637] | 339 | ok = false;
|
---|
| 340 | }
|
---|
[397] | 341 | }
|
---|
[637] | 342 | if (!ok) {
|
---|
| 343 | delete sock;
|
---|
| 344 | is.remove();
|
---|
| 345 | }
|
---|
[140] | 346 | }
|
---|
[637] | 347 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 348 | delete sock;
|
---|
| 349 | is.remove();
|
---|
| 350 | }
|
---|
[140] | 351 | }
|
---|
| 352 | }
|
---|
[73] | 353 | }
|
---|
| 354 |
|
---|
[35] | 355 | delete obs;
|
---|
| 356 | _epochs->remove(sec);
|
---|
| 357 | first = false;
|
---|
| 358 | }
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
[1170] | 361 |
|
---|
| 362 | // Reread configuration
|
---|
| 363 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1179] | 364 | void bncCaster::slotReadMountPoints() {
|
---|
[1170] | 365 |
|
---|
| 366 | QSettings settings;
|
---|
| 367 |
|
---|
| 368 | // Reread several options
|
---|
| 369 | // ----------------------
|
---|
| 370 | _samplingRate = settings.value("binSampl").toInt();
|
---|
| 371 | _waitTime = settings.value("waitTime").toInt();
|
---|
| 372 | if (_waitTime < 1) {
|
---|
| 373 | _waitTime = 1;
|
---|
| 374 | }
|
---|
| 375 |
|
---|
| 376 | // Add new mountpoints
|
---|
| 377 | // -------------------
|
---|
| 378 | int iMount = -1;
|
---|
| 379 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 380 | while (it.hasNext()) {
|
---|
| 381 | ++iMount;
|
---|
| 382 | QStringList hlp = it.next().split(" ");
|
---|
| 383 | if (hlp.size() <= 1) continue;
|
---|
| 384 | QUrl url(hlp[0]);
|
---|
| 385 |
|
---|
| 386 | // Does it already exist?
|
---|
| 387 | // ----------------------
|
---|
| 388 | bool existFlg = false;
|
---|
| 389 | QListIterator<bncGetThread*> iTh(_threads);
|
---|
| 390 | while (iTh.hasNext()) {
|
---|
| 391 | bncGetThread* thread = iTh.next();
|
---|
| 392 | if (thread->mountPoint() == url) {
|
---|
| 393 | existFlg = true;
|
---|
| 394 | break;
|
---|
| 395 | }
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | // New bncGetThread
|
---|
| 399 | // ----------------
|
---|
| 400 | if (!existFlg) {
|
---|
| 401 | QByteArray format = hlp[1].toAscii();
|
---|
| 402 | QByteArray latitude = hlp[2].toAscii();
|
---|
| 403 | QByteArray longitude = hlp[3].toAscii();
|
---|
| 404 | QByteArray nmea = hlp[4].toAscii();
|
---|
[1353] | 405 | QByteArray ntripVersion = hlp[5].toAscii();
|
---|
[1170] | 406 |
|
---|
| 407 | bncGetThread* getThread = new bncGetThread(url, format, latitude,
|
---|
[1353] | 408 | longitude, nmea, ntripVersion, iMount);
|
---|
[1170] | 409 | addGetThread(getThread);
|
---|
| 410 | }
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | // Remove mountpoints
|
---|
| 414 | // ------------------
|
---|
| 415 | QListIterator<bncGetThread*> iTh(_threads);
|
---|
| 416 | while (iTh.hasNext()) {
|
---|
| 417 | bncGetThread* thread = iTh.next();
|
---|
| 418 |
|
---|
| 419 | bool existFlg = false;
|
---|
| 420 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 421 | while (it.hasNext()) {
|
---|
| 422 | QStringList hlp = it.next().split(" ");
|
---|
| 423 | if (hlp.size() <= 1) continue;
|
---|
| 424 | QUrl url(hlp[0]);
|
---|
| 425 |
|
---|
| 426 | if (thread->mountPoint() == url) {
|
---|
| 427 | existFlg = true;
|
---|
| 428 | break;
|
---|
| 429 | }
|
---|
| 430 | }
|
---|
| 431 |
|
---|
| 432 | if (!existFlg) {
|
---|
| 433 | disconnect(thread, 0, 0, 0);
|
---|
| 434 | _staIDs.removeAll(thread->staID());
|
---|
| 435 | _threads.removeAll(thread);
|
---|
| 436 | thread->terminate();
|
---|
| 437 | delete thread;
|
---|
| 438 | }
|
---|
| 439 | }
|
---|
| 440 |
|
---|
[1179] | 441 | emit mountPointsRead(_threads);
|
---|
[1246] | 442 | emit( newMessage(QString("Configuration read: %1 stream(s)")
|
---|
[1299] | 443 | .arg(_threads.count()).toAscii(), true) );
|
---|
[1176] | 444 |
|
---|
[1170] | 445 | // (Re-) Start the configuration timer
|
---|
| 446 | // -----------------------------------
|
---|
| 447 | int ms = 0;
|
---|
| 448 |
|
---|
| 449 | if (_confTimer) {
|
---|
| 450 | ms = 1000 * _confInterval;
|
---|
| 451 | }
|
---|
| 452 | else {
|
---|
| 453 | _confTimer = new QTimer();
|
---|
[1179] | 454 | connect(_confTimer, SIGNAL(timeout()), this, SLOT(slotReadMountPoints()));
|
---|
[1170] | 455 |
|
---|
| 456 | QTime currTime = currentDateAndTimeGPS().time();
|
---|
| 457 | QTime nextShotTime;
|
---|
| 458 |
|
---|
| 459 | if (settings.value("onTheFlyInterval").toString() == "1 min") {
|
---|
| 460 | _confInterval = 60;
|
---|
| 461 | nextShotTime = QTime(currTime.hour(), currTime.minute()+1, 0);
|
---|
| 462 | }
|
---|
| 463 | else if (settings.value("onTheFlyInterval").toString() == "1 hour") {
|
---|
| 464 | _confInterval = 3600;
|
---|
| 465 | nextShotTime = QTime(currTime.hour()+1, 0, 0);
|
---|
| 466 | }
|
---|
| 467 | else {
|
---|
| 468 | _confInterval = 86400;
|
---|
| 469 | nextShotTime = QTime(23, 59, 59, 999);
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | ms = currTime.msecsTo(nextShotTime);
|
---|
[1176] | 473 | if (ms < 30000) {
|
---|
| 474 | ms = 30000;
|
---|
| 475 | }
|
---|
[1170] | 476 | }
|
---|
| 477 |
|
---|
| 478 | _confTimer->start(ms);
|
---|
| 479 | }
|
---|
[1182] | 480 |
|
---|
| 481 | //
|
---|
| 482 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 483 | int bncCaster::myWrite(QTcpSocket* sock, const char* buf, int bufLen) {
|
---|
[1229] | 484 | sock->write(buf, bufLen);
|
---|
| 485 | for (int ii = 1; ii <= 10; ii++) {
|
---|
| 486 | if (sock->waitForBytesWritten(10)) { // wait 10 ms
|
---|
| 487 | return bufLen;
|
---|
[1182] | 488 | }
|
---|
| 489 | }
|
---|
[1229] | 490 | return -1;
|
---|
[1182] | 491 | }
|
---|