Changeset 1170 in ntrip


Ignore:
Timestamp:
Oct 27, 2008, 3:35:54 PM (16 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnccaster.cpp

    r740 r1170  
    4444
    4545#include "bnccaster.h"
     46#include "bncapp.h"
    4647#include "bncgetthread.h"
    4748#include "bncutils.h"
     
    9091  _lastDumpSec   = 0;
    9192
    92   _samplingRate = settings.value("binSampl").toInt();
    93   _waitTime     = settings.value("waitTime").toInt();
    94   if (_waitTime < 1) {
    95     _waitTime = 1;
    96   }
     93  _confTimer = 0;
    9794}
    9895
     
    191188  _staIDs.push_back(getThread->staID());
    192189  _threads.push_back(getThread);
     190
     191  getThread->start();
    193192}
    194193
     
    308307  }
    309308}
     309
     310// Reread configuration
     311////////////////////////////////////////////////////////////////////////////
     312void 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}
  • trunk/BNC/bnccaster.h

    r628 r1170  
    4545 public slots:
    4646   void newObs(QByteArray staID, bool firstObs, p_obs obs);
     47   void slotReadMountpoints();
    4748
    4849 signals:
     
    6970   long                    _waitTime;
    7071   QMutex                  _mutex;
     72   QTimer*                 _confTimer;
     73   int                     _confInterval;
    7174};
    7275
  • trunk/BNC/bncmain.cpp

    r1166 r1170  
    169169    ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
    170170
    171     if (fileInput) {
     171    // Normal case - data from Internet
     172    // --------------------------------
     173    if (!fileInput) {
     174      caster->slotReadMountpoints();
     175      if (caster->numStations() == 0) {
     176        return 0;
     177      }
     178    }
     179
     180    // Special case - data from file
     181    // -----------------------------
     182    else {
    172183      if ( fileName.isEmpty() || format.isEmpty() ||
    173184           dateString.isEmpty() || timeString.isEmpty() ) {
     
    187198     
    188199      caster->addGetThread(getThread);
    189      
    190       getThread->start();
    191     }
    192     else {
    193       int iMount = -1;
    194       QListIterator<QString> it(settings.value("mountPoints").toStringList());
    195       while (it.hasNext()) {
    196         ++iMount;
    197         QStringList hlp = it.next().split(" ");
    198         if (hlp.size() <= 1) continue;
    199         QUrl url(hlp[0]);
    200         QByteArray format = hlp[1].toAscii();
    201         QByteArray latitude = hlp[2].toAscii();
    202         QByteArray longitude = hlp[3].toAscii();
    203         QByteArray nmea = hlp[4].toAscii();
    204      
    205         bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iMount);
    206      
    207         app.connect(getThread, SIGNAL(newMessage(QByteArray)),
    208                     &app, SLOT(slotMessage(const QByteArray)));
    209      
    210         caster->addGetThread(getThread);
    211      
    212         getThread->start();
    213       }
    214       if (caster->numStations() == 0) {
    215         return 0;
    216       }
    217200    }
    218201  }
  • trunk/BNC/bncwindow.cpp

    r1168 r1170  
    145145  if (ii != -1) {
    146146    _rnxIntrComboBox->setCurrentIndex(ii);
     147  }
     148  _onTheFlyComboBox = new QComboBox();
     149  _onTheFlyComboBox->setMaximumWidth(9*ww);
     150  _onTheFlyComboBox->setEditable(false);
     151  _onTheFlyComboBox->addItems(QString("1 min,1 hour,1 day").split(","));
     152  ii = _onTheFlyComboBox->findText(settings.value("onTheFlyInterval").toString());
     153  if (ii != -1) {
     154    _onTheFlyComboBox->setCurrentIndex(ii);
    147155  }
    148156  _ephIntrComboBox    = new QComboBox();
     
    372380  gLayout->addWidget(new QLabel("Append files")    ,1,0 );
    373381  gLayout->addWidget(_rnxAppendCheckBox,     1,1  );
    374   gLayout->addWidget(new QLabel("General settings for logfile and file handling."),2, 0, 1, 2, Qt::AlignLeft);
    375   gLayout->addWidget(new QLabel("    "),3,0);
     382  gLayout->addWidget(new QLabel("Reread Configuration every")    ,2,0 );
     383  gLayout->addWidget(_onTheFlyComboBox,     2,1  );
     384  gLayout->addWidget(new QLabel("General settings for logfile and file handling."),3, 0, 1, 2, Qt::AlignLeft);
    376385  gLayout->addWidget(new QLabel("    "),4,0);
    377386  gLayout->addWidget(new QLabel("    "),5,0);
     387  gLayout->addWidget(new QLabel("    "),6,0);
    378388  ggroup->setLayout(gLayout);
    379389
     
    613623  settings.setValue("rnxScript",   _rnxScrpLineEdit->text());
    614624  settings.setValue("rnxIntr",     _rnxIntrComboBox->currentText());
     625  settings.setValue("onTheFlyInterval", _onTheFlyComboBox->currentText());
    615626  settings.setValue("ephIntr",     _ephIntrComboBox->currentText());
    616627  settings.setValue("corrIntr",    _corrIntrComboBox->currentText());
     
    675686          this, SLOT(slotMessage(QByteArray)));
    676687
    677   slotMessage("============ Start BNC ============");
     688  _caster->slotReadMountpoints();
     689
     690  slotMessage                 ("============ Start BNC ============");
    678691  ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
    679 
    680   for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
    681     QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
    682               "@"  + _mountPointsTable->item(iRow, 1)->text() );
    683 
    684     QByteArray format = _mountPointsTable->item(iRow, 2)->text().toAscii();
    685 
    686     QByteArray latitude = _mountPointsTable->item(iRow, 3)->text().toAscii();
    687     QByteArray longitude = _mountPointsTable->item(iRow, 4)->text().toAscii();
    688     QByteArray nmea = _mountPointsTable->item(iRow, 5)->text().toAscii();
    689 
    690     bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iRow);
    691 
    692     connect(getThread, SIGNAL(newMessage(QByteArray)),
    693             this, SLOT(slotMessage(QByteArray)));
    694     connect(getThread, SIGNAL(newMessage(QByteArray)),
    695             (bncApp*)qApp, SLOT(slotMessage(QByteArray)));
    696 
    697     connect(getThread, SIGNAL(newBytes(QByteArray, double)),
    698             (bncTableItem*) _mountPointsTable->item(iRow, 6),
    699             SLOT(slotNewBytes(QByteArray, double)));
    700 
    701     _caster->addGetThread(getThread);
    702 
    703     getThread->start();
    704   }
    705692}
    706693
  • trunk/BNC/bncwindow.h

    r1095 r1170  
    129129    QLineEdit*   _LonLineEdit;
    130130
     131    QComboBox*  _onTheFlyComboBox;
     132
    131133    QTextEdit*  _log;
    132134
Note: See TracChangeset for help on using the changeset viewer.