Changeset 5646 in ntrip for trunk/BNC/src


Ignore:
Timestamp:
Feb 23, 2014, 10:29:42 AM (10 years ago)
Author:
weber
Message:

Ras stream output through TCP/IP port enabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncgetthread.cpp

    r5524 r5646  
    104104
    105105  bncSettings settings;
     106
    106107  if (!settings.value("rawOutFile").toString().isEmpty()) {
    107108    _rawOutput = true;
     
    131132  _miscMount     = settings.value("miscMount").toString();
    132133  _decoder   = 0;
     134
     135  // Miscellaneous output port  // Georg
     136  // -------------------------
     137  _miscPort = settings.value("miscPort").toInt();
     138  if (_miscPort != 0) {
     139    _miscServer = new QTcpServer;
     140    if ( !_miscServer->listen(QHostAddress::Any, _miscPort) ) {
     141      emit newMessage("bncgetthread: Cannot listen on Miscellaneous Output Port", true);
     142    }
     143    connect(_miscServer, SIGNAL(newConnection()), this, SLOT(slotNewMiscConnection()));
     144    _miscSockets = new QList<QTcpSocket*>;
     145  }
     146  else {
     147    _miscServer  = 0;
     148    _miscSockets = 0;
     149  }
    133150
    134151  // Serial Port
     
    383400  delete _serialPort;
    384401  delete _latencyChecker;
     402  delete _miscServer;
     403  delete _miscSockets;
    385404  emit getThreadFinished(_staID);
    386405}
     
    473492        _serialPort->write(data);
    474493      }
    475      
     494
     495      // Output into the Miscellaneous socket // Georg
     496      // ------------------------------------
     497      if (_miscSockets && _miscMount != "ALL") {
     498        QMutableListIterator<QTcpSocket*> is(*_miscSockets);
     499        while (is.hasNext()) {
     500          QTcpSocket* sock = is.next();
     501          if (sock->state() == QAbstractSocket::ConnectedState) {
     502            if (myMiscWrite(sock, data, nBytes) != nBytes) {
     503              delete sock;
     504              is.remove();
     505            }       
     506          }       
     507          else if (sock->state() != QAbstractSocket::ConnectingState) {
     508            delete sock;
     509            is.remove();
     510          }       
     511        }       
     512      }
     513
    476514      // Decode Data
    477515      // -----------
     
    671709}
    672710
     711// New Connection // Georg
     712////////////////////////////////////////////////////////////////////////////
     713void bncGetThread::slotNewMiscConnection() {
     714  _miscSockets->push_back( _miscServer->nextPendingConnection() );
     715  emit( newMessage(QString("New client connection on Miscellaneous Output Port: # %1")
     716                   .arg(_miscSockets->size()).toAscii(), true) );
     717}
     718
     719// Write buffer // Georg
     720////////////////////////////////////////////////////////////////////////////
     721int bncGetThread::myMiscWrite(QTcpSocket* sock, const char* buf, int bufLen) {
     722  sock->write(buf, bufLen);
     723  for (int ii = 1; ii <= 10; ii++) {
     724    if (sock->waitForBytesWritten(10)) {  // wait 10 ms
     725      return bufLen;
     726    }
     727  }
     728  return -1;
     729}
     730
    673731// RTCM scan output
    674732//////////////////////////////////////////////////////////////////////////////
     
    807865  }
    808866}
     867
Note: See TracChangeset for help on using the changeset viewer.