Changeset 136 in ntrip


Ignore:
Timestamp:
Sep 8, 2006, 9:24:23 AM (18 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnccaster.cpp

    r135 r136  
    5858  QSettings settings;
    5959  _samplingRate = settings.value("rnxSampl").toInt();
     60  _waitTime     = settings.value("waitTime").toInt();
     61  if (_waitTime < 2) {
     62    _waitTime = 2;
     63  }
    6064}
    6165
     
    109113  // Dump older epochs
    110114  // -----------------
    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;
    114117}
    115118
  • trunk/BNC/bnccaster.h

    r134 r136  
    4949   QMap<QString, bncRinex*>       _rinexWriters;
    5050   int                            _samplingRate;
     51   long                           _waitTime;
    5152};
    5253
  • trunk/BNC/bncgetthread.cpp

    r93 r136  
    2828using namespace std;
    2929
    30 const int timeOut = 300*1000;
    31 
    3230// Constructor
    3331////////////////////////////////////////////////////////////////////////////
    3432bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format) {
     33  _decoder    = 0;
    3534  _mountPoint = mountPoint;
    3635  _staID      = mountPoint.path().mid(1).toAscii();
    3736  _format     = format;
    3837  _socket     = 0;
     38  _timeOut    = 10*1000;  // 10 seconds
    3939}
    4040
     
    4343bncGetThread::~bncGetThread() {
    4444  delete _socket;
     45  delete _decoder;
    4546}
    4647
    4748// Connect to Caster, send the Request (static)
    4849////////////////////////////////////////////////////////////////////////////
    49 QTcpSocket* bncGetThread::request(const QUrl& mountPoint, QString& msg) {
     50QTcpSocket* bncGetThread::request(const QUrl& mountPoint, int timeOut,
     51                                  QString& msg) {
    5052
    5153  // Connect the Socket
     
    98100}
    99101
    100 // Run
     102// Init Run
    101103////////////////////////////////////////////////////////////////////////////
    102 void bncGetThread::run() {
     104void bncGetThread::initRun() {
    103105
    104106  // Send the Request
     
    106108  QString msg;
    107109
    108   _socket = bncGetThread::request(_mountPoint, msg);
     110  _socket = bncGetThread::request(_mountPoint, _timeOut, msg);
    109111
    110112  emit(newMessage(msg.toAscii()));
     
    116118  // Read Caster Response
    117119  // --------------------
    118   _socket->waitForReadyRead(timeOut);
     120  _socket->waitForReadyRead(_timeOut);
    119121  if (_socket->canReadLine()) {
    120122    QString line = _socket->readLine();
     
    131133  // Instantiate the filter
    132134  // ----------------------
    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}
    134154
    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////////////////////////////////////////////////////////////////////////////
     157void bncGetThread::run() {
     158
     159  initRun();
    151160
    152161  // Read Incoming Data
    153162  // ------------------
    154163  while (true) {
    155     _socket->waitForReadyRead(timeOut);
     164    _socket->waitForReadyRead(_timeOut);
    156165    qint64 nBytes = _socket->bytesAvailable();
    157166    if (nBytes > 0) {
    158167      char* data = new char[nBytes];
    159168      _socket->read(data, nBytes);
    160       decoder->Decode(data, nBytes);
     169      _decoder->Decode(data, nBytes);
    161170      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++) {
    164173        emit newObs(_staID, *it);
    165174      }
    166       decoder->m_lObsList.clear();
     175      _decoder->m_lObsList.clear();
    167176    }
    168177    else {
    169       emit(newMessage("Data Timeout"));
    170       return exit(1);
     178      emit(newMessage("Data Timeout, reconnecting"));
     179      tryReconnect();
    171180    }
    172181  }
    173   delete decoder;
    174182}
    175183
     
    183191}
    184192
     193// Try Re-Connect
     194////////////////////////////////////////////////////////////////////////////
     195void bncGetThread::tryReconnect() {
     196
     197}
  • trunk/BNC/bncgetthread.h

    r88 r136  
    1616
    1717   static QTcpSocket* bncGetThread::request(const QUrl& mountPoint,
    18                                             QString& msg);
     18                                            int timeOut, QString& msg);
    1919
    2020   QByteArray staID() const {return _staID;}
     
    2828   virtual void run();
    2929 private:
     30   void initRun();
     31   void tryReconnect();
    3032   void message(const QString&);
    3133   void exit(int exitCode = 0);
     34   GPSDecoder* _decoder;
    3235   QTcpSocket* _socket;
    3336   QUrl        _mountPoint;
    3437   QByteArray  _staID;
    3538   QByteArray  _format;
     39   int         _timeOut;
    3640};
    3741
  • trunk/BNC/bnctabledlg.cpp

    r115 r136  
    9494  // Send the Request
    9595  // ----------------
     96  const int timeOut = 10*1000;
    9697  QString msg;
    97   QTcpSocket* socket = bncGetThread::request(url, msg);
     98  QTcpSocket* socket = bncGetThread::request(url, timeOut, msg);
    9899
    99100  if (!socket) {
     
    126127    }
    127128    else {
    128       const int timeOut = 10*1000;
    129129      socket->waitForReadyRead(timeOut);
    130130      if (socket->bytesAvailable() > 0) {
Note: See TracChangeset for help on using the changeset viewer.