Changeset 784 in ntrip for trunk/BNS/bns.cpp


Ignore:
Timestamp:
Apr 8, 2008, 11:25:10 AM (16 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNS/bns.cpp

    r781 r784  
    116116}
    117117
     118//
     119////////////////////////////////////////////////////////////////////////////
     120void t_bns::slotNewEph(gpsEph* ep) {
     121
     122  QMutexLocker locker(&_mutex);
     123
     124  t_ephPair* pair;
     125  if ( !_ephList.contains(ep->prn) ) {
     126    pair = new t_ephPair();
     127    _ephList.insert(ep->prn, pair);
     128  }
     129  else {
     130    pair = _ephList[ep->prn];
     131  }
     132
     133  if (pair->eph == 0) {
     134    pair->eph = ep;
     135  }
     136  else {
     137    if (ep->GPSweek >  pair->eph->GPSweek ||
     138        (ep->GPSweek == pair->eph->GPSweek && ep->TOC > pair->eph->TOC)) {
     139      delete pair->oldEph;
     140      pair->oldEph = pair->eph;
     141      pair->eph    = ep;
     142    }
     143    else {
     144      delete ep;
     145    }
     146  }
     147}
     148
    118149// Start
    119150////////////////////////////////////////////////////////////////////////////
     
    141172  while (true) {
    142173    if (_clkSocket) {
    143 
     174      if (_clkSocket->state() != QAbstractSocket::ConnectedState) {
     175        delete _clkSocket;
     176        _clkSocket = 0;
     177        continue;
     178      }
     179      if (!_clkSocket->canReadLine()) {
     180        _clkSocket->waitForReadyRead();
     181      }
     182      else {
     183        readEpoch();
     184      }
    144185    }
    145186    else {
     
    151192//
    152193////////////////////////////////////////////////////////////////////////////
    153 void t_bns::slotNewEph(gpsEph* ep) {
    154 
    155   QMutexLocker locker(&_mutex);
    156 
    157   t_ephPair* pair;
    158   if ( !_ephList.contains(ep->prn) ) {
    159     pair = new t_ephPair();
    160     _ephList.insert(ep->prn, pair);
    161   }
    162   else {
    163     pair = _ephList[ep->prn];
    164   }
    165 
    166   if (pair->eph == 0) {
    167     pair->eph = ep;
    168       cout << "A: new eph: " << ep->prn.toAscii().data() << " "
    169            << ep->GPSweek << " " << ep->TOC << endl;
    170   }
    171   else {
    172     if (ep->GPSweek >  pair->eph->GPSweek ||
    173         (ep->GPSweek == pair->eph->GPSweek && ep->TOC > pair->eph->TOC)) {
    174       cout << "B: new eph: " << ep->prn.toAscii().data() << " "
    175            << ep->GPSweek << " " << ep->TOC << endl;
    176       delete pair->oldEph;
    177       pair->oldEph = pair->eph;
    178       pair->eph    = ep;
    179     }
    180     else {
    181       delete ep;
    182     }
    183   }
    184 }
     194void t_bns::readEpoch() {
     195
     196  QByteArray line = _clkSocket->readLine();
     197  if (line.indexOf('*') == -1) {
     198    return;
     199  }
     200
     201  QTextStream in(line);
     202
     203  QString hlp;
     204  int     mjd, numSat;
     205  double  sec;
     206
     207  in >> hlp >> mjd >> sec >> numSat;
     208
     209  for (int ii = 1; ii <= numSat; ii++) {
     210    if (!_clkSocket->canReadLine()) {
     211      _clkSocket->waitForReadyRead();
     212    }
     213    line = _clkSocket->readLine();
     214    QTextStream in(line);
     215
     216    QString      prn;
     217    ColumnVector xx(4);
     218
     219    in >> prn >> xx(1) >> xx(2) >> xx(3) >> xx(4);
     220
     221    processSatellite(mjd, sec, prn, xx);
     222  }
     223}
     224
     225//
     226////////////////////////////////////////////////////////////////////////////
     227void t_bns::processSatellite(int mjd, double sec, const QString& prn,
     228                             const ColumnVector& xx) {
     229
     230}
Note: See TracChangeset for help on using the changeset viewer.