Changeset 4990 in ntrip for trunk


Ignore:
Timestamp:
Mar 20, 2013, 10:31:52 AM (11 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

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

    r4987 r4990  
    338338  for (long sec = minTime; sec <= maxTime; sec++) {
    339339
    340     QList<t_obs> allObs = _epochs->values(sec);
    341 
    342     bool firstEpoLine = true;
    343 
    344     QListIterator<t_obs> it(allObs);
    345     while (it.hasNext()) {
    346       const t_obs& obs = it.next();
    347 
    348       if (_samplingRate == 0 || sec % _samplingRate == 0) {
    349 
    350         if (_out || _sockets) {
    351           ostringstream oStr;
    352           oStr.setf(ios::showpoint | ios::fixed);
    353           if (firstEpoLine) {
    354             firstEpoLine = false;
    355             oStr << "> " << obs.GPSWeek << ' '
    356                  << setprecision(7) << obs.GPSWeeks << endl;;
    357           }
    358           oStr << obs.StatID << ' ' << bncRinex::asciiSatLine(obs) << endl;
    359           if (!it.hasNext()) {
    360             oStr << endl;
    361           }
    362           string hlpStr = oStr.str();
    363 
    364           // Output into the File
    365           // --------------------
    366           if (_out) {
    367             *_out << hlpStr.c_str();
    368             _out->flush();
    369           }
    370 
    371           // Output into the socket
    372           // ----------------------
    373           if (_sockets) {
    374             QMutableListIterator<QTcpSocket*> is(*_sockets);
    375             while (is.hasNext()) {
    376               QTcpSocket* sock = is.next();
    377               if (sock->state() == QAbstractSocket::ConnectedState) {
    378                 int numBytes = hlpStr.length();
    379                 if (myWrite(sock, hlpStr.c_str(), numBytes) != numBytes) {
    380                   delete sock;
    381                   is.remove();
    382                 }
    383               }
    384               else if (sock->state() != QAbstractSocket::ConnectingState) {
     340    if ( (_out || _sockets) &&
     341         (_samplingRate == 0 || sec % _samplingRate == 0) ) {
     342
     343      QList<t_obs> allObs = _epochs->values(sec);
     344     
     345      QListIterator<t_obs> it(allObs);
     346      bool firstObs = true;
     347      while (it.hasNext()) {
     348        const t_obs& obs = it.next();
     349
     350        ostringstream oStr;
     351        oStr.setf(ios::showpoint | ios::fixed);
     352        if (firstObs) {
     353          firstObs = false;
     354          oStr << "> " << obs.GPSWeek << ' '
     355               << setprecision(7) << obs.GPSWeeks << endl;;
     356        }
     357        oStr << obs.StatID << ' ' << bncRinex::asciiSatLine(obs) << endl;
     358        if (!it.hasNext()) {
     359          oStr << endl;
     360        }
     361        string hlpStr = oStr.str();
     362
     363        // Output into the File
     364        // --------------------
     365        if (_out) {
     366          *_out << hlpStr.c_str();
     367          _out->flush();
     368        }
     369
     370        // Output into the socket
     371        // ----------------------
     372        if (_sockets) {
     373          QMutableListIterator<QTcpSocket*> is(*_sockets);
     374          while (is.hasNext()) {
     375            QTcpSocket* sock = is.next();
     376            if (sock->state() == QAbstractSocket::ConnectedState) {
     377              int numBytes = hlpStr.length();
     378              if (myWrite(sock, hlpStr.c_str(), numBytes) != numBytes) {
    385379                delete sock;
    386380                is.remove();
    387381              }
    388382            }
     383            else if (sock->state() != QAbstractSocket::ConnectingState) {
     384              delete sock;
     385              is.remove();
     386            }
    389387          }
    390388        }
    391389      }
    392 
    393       _epochs->remove(sec);
    394     }
     390    }
     391    _epochs->remove(sec);
    395392  }
    396393}
Note: See TracChangeset for help on using the changeset viewer.