Changeset 5524 in ntrip


Ignore:
Timestamp:
Nov 6, 2013, 2:01:59 PM (10 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/src
Files:
4 edited

Legend:

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

    r5070 r5524  
    175175// New Observations
    176176////////////////////////////////////////////////////////////////////////////
    177 void bncCaster::newObs(const QByteArray staID, bool firstObs, t_obs obs) {
     177void bncCaster::slotNewObs(const QByteArray staID, QList<t_obs> obsList) {
    178178
    179179  QMutexLocker locker(&_mutex);
    180180
    181   long iSec    = long(floor(obs.GPSWeeks+0.5));
    182   long newTime = obs.GPSWeek * 7*24*3600 + iSec;
    183 
    184   // Rename the Station
    185   // ------------------
    186   strncpy(obs.StatID, staID.constData(),sizeof(obs.StatID));
    187   obs.StatID[sizeof(obs.StatID)-1] = '\0';
    188 
    189   // Output into the socket
    190   // ----------------------
    191   if (_uSockets) {
    192 
    193     ostringstream oStr;
    194     oStr.setf(ios::showpoint | ios::fixed);
    195     oStr << obs.StatID                                        << " "
    196          << obs.GPSWeek                                       << " "
    197          << setprecision(7) << obs.GPSWeeks                   << " "
    198          << bncRinex::asciiSatLine(obs) << endl;
    199 
    200     string hlpStr = oStr.str();
    201 
    202     QMutableListIterator<QTcpSocket*> is(*_uSockets);
    203     while (is.hasNext()) {
    204       QTcpSocket* sock = is.next();
    205       if (sock->state() == QAbstractSocket::ConnectedState) {
    206         int numBytes = hlpStr.length();
    207         if (myWrite(sock, hlpStr.c_str(), numBytes) != numBytes) {
     181  long newTime = 0;
     182  QMutableListIterator<t_obs> it(obsList);
     183  while (it.hasNext()) {
     184
     185    t_obs& obs = it.next();
     186
     187    long iSec    = long(floor(obs.GPSWeeks+0.5));
     188    newTime = obs.GPSWeek * 7*24*3600 + iSec;
     189   
     190    // Rename the Station
     191    // ------------------
     192    strncpy(obs.StatID, staID.constData(),sizeof(obs.StatID));
     193    obs.StatID[sizeof(obs.StatID)-1] = '\0';
     194   
     195    // Output into the socket
     196    // ----------------------
     197    if (_uSockets) {
     198   
     199      ostringstream oStr;
     200      oStr.setf(ios::showpoint | ios::fixed);
     201      oStr << obs.StatID                                        << " "
     202           << obs.GPSWeek                                       << " "
     203           << setprecision(7) << obs.GPSWeeks                   << " "
     204           << bncRinex::asciiSatLine(obs) << endl;
     205   
     206      string hlpStr = oStr.str();
     207   
     208      QMutableListIterator<QTcpSocket*> is(*_uSockets);
     209      while (is.hasNext()) {
     210        QTcpSocket* sock = is.next();
     211        if (sock->state() == QAbstractSocket::ConnectedState) {
     212          int numBytes = hlpStr.length();
     213          if (myWrite(sock, hlpStr.c_str(), numBytes) != numBytes) {
     214            delete sock;
     215            is.remove();
     216          }
     217        }
     218        else if (sock->state() != QAbstractSocket::ConnectingState) {
    208219          delete sock;
    209220          is.remove();
    210221        }
    211222      }
    212       else if (sock->state() != QAbstractSocket::ConnectingState) {
    213         delete sock;
    214         is.remove();
    215       }
    216     }
    217   }
    218 
    219   // First time, set the _lastDumpSec immediately
    220   // --------------------------------------------
    221   if (_lastDumpSec == 0) {
    222     _lastDumpSec = newTime - 1;
    223   }
    224 
    225   // An old observation - throw it away
    226   // ----------------------------------
    227   if (newTime <= _lastDumpSec) {
    228     if (firstObs) {
     223    }
     224   
     225    // First time, set the _lastDumpSec immediately
     226    // --------------------------------------------
     227    if (_lastDumpSec == 0) {
     228      _lastDumpSec = newTime - 1;
     229    }
     230   
     231    // An old observation - throw it away
     232    // ----------------------------------
     233    if (newTime <= _lastDumpSec) {
    229234      bncSettings settings;
    230235      if ( !settings.value("outFile").toString().isEmpty() ||
    231236           !settings.value("outPort").toString().isEmpty() ) {
    232 
    233         QTime enomtime = QTime(0,0,0).addSecs(iSec);
    234 
     237   
     238        QTime enomtime = QTime(0,0,0).addSecs(iSec);
     239   
    235240        emit( newMessage(QString("%1: Old epoch %2 (%3) thrown away")
    236                          .arg(staID.data()).arg(iSec)
    237                          .arg(enomtime.toString("HH:mm:ss"))
    238                          .toAscii(), true) );
    239       }
    240     }
    241     return;
    242   }
    243 
    244   // Save the observation
    245   // --------------------
    246   _epochs->insert(newTime, obs);
     241                         .arg(staID.data()).arg(iSec)
     242                         .arg(enomtime.toString("HH:mm:ss"))
     243                         .toAscii(), true) );
     244      }
     245      return;
     246    }
     247   
     248    // Save the observation
     249    // --------------------
     250    _epochs->insert(newTime, obs);
     251  }
    247252
    248253  // Dump Epochs
     
    279284
    280285  qRegisterMetaType<t_obs>("t_obs");
     286  qRegisterMetaType< QList<t_obs> >("QList<t_obs>");
    281287  qRegisterMetaType<gpsephemeris>("gpsephemeris");
    282288  qRegisterMetaType<glonassephemeris>("glonassephemeris");
    283289  qRegisterMetaType<galileoephemeris>("galileoephemeris");
    284290
    285   connect(getThread, SIGNAL(newObs(QByteArray, bool, t_obs)),
    286           this,      SLOT(newObs(QByteArray, bool, t_obs)));
     291  connect(getThread, SIGNAL(newObs(QByteArray, QList<t_obs>)),
     292          this,      SLOT(slotNewObs(QByteArray, QList<t_obs>)));
    287293
    288294#ifdef RTROVER_INTERFACE
    289295  if (_bncRtrover) {
    290     connect(getThread, SIGNAL(newObs(QByteArray, bool, t_obs)),
    291             _bncRtrover, SLOT(slotNewObs(QByteArray, bool, t_obs)));
     296    connect(getThread, SIGNAL(newObs(QByteArray, QList<t_obs>)),
     297            _bncRtrover, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
    292298  }
    293299#endif
  • trunk/BNC/src/bnccaster.h

    r4763 r5524  
    4848
    4949 public slots:
    50    void newObs(QByteArray staID, bool firstObs, t_obs obs);
     50   void slotNewObs(QByteArray staID, QList<t_obs> obsList);
    5151   void slotNewNMEAstr(QByteArray str);
    5252
  • trunk/BNC/src/bncgetthread.cpp

    r5364 r5524  
    4545#include <QFile>
    4646#include <QTextStream>
     47#include <QMutex>
    4748#include <QtNetwork>
    4849#include <QTime>
     
    498499      // ------------------------------------------------
    499500      QListIterator<t_obs> it(decoder()->_obsList);
    500       bool firstObs = true;
     501
     502      QList<t_obs> obsListHlp;
     503
    501504      while (it.hasNext()) {
    502505        const t_obs& obs = it.next();
     
    550553        }
    551554#endif
    552 
    553         // Emit new observation signal
    554         // ---------------------------
    555         if (!_isToBeDeleted) {
    556           emit newObs(_staID, firstObs, obs);
    557         }
    558         firstObs = false;
    559       }
     555        // Save observations
     556        // -----------------
     557        obsListHlp.append(obs);
     558      }
     559
     560      // Emit signal
     561      // -----------
     562      if (!_isToBeDeleted && obsListHlp.size() > 0) {
     563        emit newObs(_staID, obsListHlp);
     564      }
     565
    560566      decoder()->_obsList.clear();
    561567    }
  • trunk/BNC/src/bncgetthread.h

    r4763 r5524  
    7878   void newBytes(QByteArray staID, double nbyte);
    7979   void newLatency(QByteArray staID, double clate);
    80    void newObs(QByteArray staID, bool firstObs, t_obs obs);
     80   void newObs(QByteArray staID, QList<t_obs> obsList);
    8181   void newAntCrd(QByteArray staID, double xx, double yy, double zz,
    8282                  double hh, QByteArray antType);
Note: See TracChangeset for help on using the changeset viewer.