Changeset 6443 in ntrip


Ignore:
Timestamp:
Dec 26, 2014, 12:47:27 PM (9 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM/RTCM2Decoder.cpp

    r6442 r6443  
    5555//
    5656
    57 RTCM2Decoder::RTCM2Decoder(const std::string& ID) : bncEphUser(true) {
     57RTCM2Decoder::RTCM2Decoder(const std::string& ID) : _ephUser(true) {
    5858  _ID = ID;
    5959}
     
    352352
    353353      // Select corresponding ephemerides
    354       if      (ephLast(prn) && ephLast(prn)->IOD() == IODcorr) {
    355         eph = ephLast(prn);
    356       }
    357       else if (ephPrev(prn) && ephPrev(prn)->IOD() == IODcorr) {
    358         eph = ephPrev(prn);
     354      const t_eph* ephLast = _ephUser.ephLast(prn);
     355      const t_eph* ephPrev = _ephUser.ephPrev(prn);
     356      if      (ephLast && ephLast->IOD() == IODcorr) {
     357        eph = ephLast;
     358      }
     359      else if (ephPrev && ephPrev->IOD() == IODcorr) {
     360        eph = ephPrev;
    359361      }
    360362
  • trunk/BNC/src/RTCM/RTCM2Decoder.h

    r6139 r6443  
    3636#include "bncephuser.h"
    3737
    38 class RTCM2Decoder: public bncEphUser, public GPSDecoder {
     38class RTCM2Decoder: public GPSDecoder {
    3939
    4040  public:
     
    5757    void translateCorr2Obs(std::vector<std::string>& errmsg);
    5858
    59     std::string            _ID;
    60 
    61     std::string            _buffer;
    62     rtcm2::RTCM2packet     _PP;
     59    QMutex             _mutex;
     60    std::string        _ID;
     61    std::string        _buffer;
     62    rtcm2::RTCM2packet _PP;
    6363
    6464    // for messages 18, 19 decoding
    65     rtcm2::RTCM2_Obs       _ObsBlock;
     65    rtcm2::RTCM2_Obs   _ObsBlock;
    6666
    6767    // for messages 20, 21 decoding
    68     rtcm2::RTCM2_03           _msg03;
    69     rtcm2::RTCM2_22           _msg22;
    70     rtcm2::RTCM2_23           _msg23;
    71     rtcm2::RTCM2_24           _msg24;
    72     rtcm2::RTCM2_2021         _msg2021;
     68    rtcm2::RTCM2_03    _msg03;
     69    rtcm2::RTCM2_22    _msg22;
     70    rtcm2::RTCM2_23    _msg23;
     71    rtcm2::RTCM2_24    _msg24;
     72    rtcm2::RTCM2_2021  _msg2021;
     73    bncEphUser         _ephUser;       
    7374};
    7475
  • trunk/BNC/src/bncephuser.cpp

    r6441 r6443  
    6767////////////////////////////////////////////////////////////////////////////
    6868bncEphUser::~bncEphUser() {
    69   QMapIterator<QString, t_ephPair*> it(_eph);
     69  QMapIterator<QString, deque<t_eph*> > it(_eph);
    7070  while (it.hasNext()) {
    7171    it.next();
    72     delete it.value();
     72    const deque<t_eph*>& qq = it.value();
     73    for (unsigned ii = 0; ii < qq.size(); ii++) {
     74      delete qq[ii];
     75    }
    7376  }
    7477}
     
    137140  QString prn(newEph->prn().toString().c_str());
    138141
    139   if (_eph.contains(prn)) {
    140     if (newEph->isNewerThan(_eph.value(prn)->last)) {
    141       delete _eph.value(prn)->prev;
    142       _eph.value(prn)->prev = _eph.value(prn)->last;
    143       _eph.value(prn)->last = newEph;
    144       ephBufferChanged();
    145       return success;
     142  const t_eph* ephOld = ephLast(prn);
     143
     144  if (ephOld == 0 || newEph->isNewerThan(ephOld)) {
     145    deque<t_eph*>& qq = _eph[prn];
     146    qq.push_back(newEph);
     147    if (qq.size() > _maxQueueSize) {
     148      delete qq.front();
     149      qq.pop_front();
    146150    }
    147   }
    148   else {
    149     _eph.insert(prn, new t_ephPair(newEph));
    150151    ephBufferChanged();
    151152    return success;
    152153  }
    153 
    154   return failure;
     154  else {
     155    return failure;
     156  }
    155157}
    156158
  • trunk/BNC/src/bncephuser.h

    r6442 r6443  
    2626#define BNCEPHUSER_H
    2727
     28#include <deque>
    2829#include <QtCore>
    2930#include <newmat.h>
     
    3233#include "bnctime.h"
    3334#include "ephemeris.h"
    34 
    35 extern "C" {
    36 #  include "clock_orbit_rtcm.h"
    37 }
    3835
    3936class bncEphUser : public QObject {
     
    5451  const t_eph* ephLast(const QString& prn) {
    5552    if (_eph.contains(prn)) {
    56       return _eph[prn]->last;
     53      return _eph[prn].back();
    5754    }
    5855    return 0;
     
    6158  const t_eph* ephPrev(const QString& prn) {
    6259    if (_eph.contains(prn)) {
    63       return _eph[prn]->prev;
     60      unsigned nn = _eph[prn].size();
     61      if (nn > 1) {
     62        return _eph[prn].at(nn-2);
     63      }
    6464    }
    6565    return 0;
    6666  }
    6767
     68  const QList<QString> prnList() {return _eph.keys();}
     69
    6870 protected:
    6971  virtual void ephBufferChanged() {}
    7072
    71   class t_ephPair {
    72    public:
    73     t_ephPair(t_eph* lastEph) {
    74       last = lastEph;
    75       prev = 0;
    76     }
    77     ~t_ephPair() {
    78       delete last;
    79       delete prev;
    80     }
    81     t_eph* last;
    82     t_eph* prev;
    83   };
    84 
    85   QMutex                    _mutex;
    86   QMap<QString, t_ephPair*> _eph;
     73 private:
     74  QMutex                             _mutex;
     75  static const unsigned              _maxQueueSize = 5;
     76  QMap<QString, std::deque<t_eph*> > _eph;
    8777};
    8878
  • trunk/BNC/src/combination/bnccomb.cpp

    r6330 r6443  
    127127// Constructor
    128128////////////////////////////////////////////////////////////////////////////
    129 bncComb::bncComb() : bncEphUser(true) {
     129bncComb::bncComb() : _ephUser(true) {
    130130
    131131  bncSettings settings;
     
    382382    // Check the Ephemeris
    383383    //--------------------
    384     if (_eph.find(prn) == _eph.end()) {
     384    const t_eph* ephLast = _ephUser.ephLast(prn);
     385    const t_eph* ephPrev = _ephUser.ephPrev(prn);
     386    if (ephLast == 0) {
    385387      emit newMessage("bncComb: eph not found "  + prn.toAscii(), true);
    386388      delete newCorr;
     
    388390    }
    389391    else {
    390       t_eph* lastEph = _eph[prn]->last;
    391       t_eph* prevEph = _eph[prn]->prev;
    392       if      (lastEph && lastEph->IOD() == newCorr->_iod) {
    393         newCorr->_eph = lastEph;
    394       }
    395       else if (lastEph && prevEph && prevEph->IOD() == newCorr->_iod) {
    396         newCorr->_eph = prevEph;
    397         switchToLastEph(lastEph, newCorr);
     392      if      (ephLast->IOD() == newCorr->_iod) {
     393        newCorr->_eph = ephLast;
     394      }
     395      else if (ephPrev && ephPrev->IOD() == newCorr->_iod) {
     396        newCorr->_eph = ephPrev;
     397        switchToLastEph(ephLast, newCorr);
    398398      }
    399399      else {
     
    10511051    cmbCorr* corr = im.next();
    10521052    QString  prn  = corr->_prn;
    1053     if      (_eph.find(prn) == _eph.end()) {
     1053
     1054    const t_eph* ephLast = _ephUser.ephLast(prn);
     1055    const t_eph* ephPrev = _ephUser.ephPrev(prn);
     1056
     1057    if      (ephLast == 0) {
    10541058      out << "checkOrbit: missing eph (not found) " << corr->_prn << endl;
    10551059      delete corr;
     
    10621066    }
    10631067    else {
    1064       if ( corr->_eph == _eph[prn]->last || corr->_eph == _eph[prn]->prev ) {
    1065         switchToLastEph(_eph[prn]->last, corr);
     1068      if ( corr->_eph == ephLast || corr->_eph == ephPrev ) {
     1069        switchToLastEph(ephLast, corr);
    10661070      }
    10671071      else {
  • trunk/BNC/src/combination/bnccomb.h

    r6160 r6443  
    1212class bncAntex;
    1313
    14 class bncComb : public bncEphUser {
     14class bncComb : public QObject {
    1515 Q_OBJECT
    1616 public:
     
    108108  QVector<cmbCorr*>& corrs() {return _buffer[_resTime].corrs;}
    109109
     110  QMutex                                 _mutex;
    110111  QList<cmbAC*>                          _ACs;
    111112  bncTime                                _resTime;
     
    123124  int                                    _cmbSampl;
    124125  QMap<QString, QMap<t_prn, t_orbCorr> > _orbCorrections;
     126  bncEphUser                             _ephUser;
    125127};
    126128
  • trunk/BNC/src/upload/bncephuploadcaster.cpp

    r6441 r6443  
    6161  if (_ephUploadCaster) {
    6262    QByteArray outBuffer;
    63     QMapIterator<QString, t_ephPair*> it(_eph);
     63
     64    QListIterator<QString> it(prnList());
    6465    while (it.hasNext()) {
    65       it.next();
     66      const t_eph* eph = ephLast(it.next());
    6667
    67       t_eph* eph = it.value()->last;
     68      const t_ephGPS*     ephGPS     = dynamic_cast<const t_ephGPS*>(eph);
     69      const t_ephGlo*     ephGlo     = dynamic_cast<const t_ephGlo*>(eph);
     70      const t_ephGal*     ephGal     = dynamic_cast<const t_ephGal*>(eph);
     71      const t_ephSBAS*    ephSBAS    = dynamic_cast<const t_ephSBAS*>(eph);
     72      const t_ephCompass* ephCompass = dynamic_cast<const t_ephCompass*>(eph);
     73
    6874      unsigned char Array[80];
    6975      int size = 0;
    70       t_ephGPS*     ephGPS     = dynamic_cast<t_ephGPS*>(eph);
    71       t_ephGlo*     ephGlo     = dynamic_cast<t_ephGlo*>(eph);
    72       t_ephGal*     ephGal     = dynamic_cast<t_ephGal*>(eph);
    73       t_ephSBAS*    ephSBAS    = dynamic_cast<t_ephSBAS*>(eph);
    74       t_ephCompass* ephCompass = dynamic_cast<t_ephCompass*>(eph);
     76
    7577      if (ephGPS) {
    7678        size = t_ephEncoder::RTCM3(*ephGPS, Array);
Note: See TracChangeset for help on using the changeset viewer.