Changeset 3562 in ntrip for trunk/BNC


Ignore:
Timestamp:
Dec 25, 2011, 3:50:24 PM (12 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC
Files:
5 edited

Legend:

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

    r3257 r3562  
    6565
    6666RTCM2Decoder::~RTCM2Decoder() {
    67   for (t_listMap::iterator ii = _ephList.begin(); ii != _ephList.end(); ii++) {
    68     delete ii->second;
    69   }
    7067}
    7168
     
    222219}
    223220
    224 
    225 
    226 bool RTCM2Decoder::storeEph(const gpsephemeris& gpseph, string& storedPRN, vector<int>& IODs) {
    227   t_ephGPS eph; eph.set(&gpseph);
    228 
    229   return storeEph(eph, storedPRN, IODs);
    230 }
    231 
    232 
    233 bool RTCM2Decoder::storeEph(const t_ephGPS& gpseph, string& storedPRN, vector<int>& IODs) {
    234   t_ephGPS* eph = new t_ephGPS(gpseph);
    235 
    236   string prn = eph->prn().toAscii().data();
    237 
    238   t_listMap::iterator ip = _ephList.find(prn);
    239   if (ip == _ephList.end() ) {
    240     ip = _ephList.insert(pair<string, t_ephList*>(prn, new t_ephList)).first;
    241   }
    242   t_ephList* ephList = ip->second;
    243 
    244   bool stored = ephList->store(eph);
    245 
    246   if ( stored ) {
    247     storedPRN = string(eph->prn().toAscii().data());
    248     ephList->getIODs(IODs);
    249     return true;
    250   }
    251 
    252   delete eph;
    253 
    254   return false;
    255 }
    256  
    257  
    258221void RTCM2Decoder::translateCorr2Obs(vector<string>& errmsg) {
    259222
     
    298261    // end test
    299262
    300 
    301     ostringstream oPRN; oPRN.fill('0');
    302 
    303     oPRN <<            (corr->PRN < 200 ? 'G'       : 'R')
    304          << setw(2) << (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);
    305 
    306     string PRN(oPRN.str());
    307 
    308     t_listMap::const_iterator ieph = _ephList.find(PRN);
     263    QString prn;
     264    if (corr->PRN < 200) {
     265      prn = 'G' + QString("%1").arg(corr->PRN, 2, 10, QChar('0'));
     266    }
     267    else {
     268      prn = 'R' + QString("%1").arg(corr->PRN - 200, 2, 10, QChar('0'));
     269    }
     270
     271    const t_ephPair* ePair = ephPair(prn);
    309272
    310273    double L1 = 0;
     
    356319
    357320      // Select corresponding ephemerides
    358       if ( ieph != _ephList.end() ) {
    359         eph = ieph->second->getEph(IODcorr);
     321      if (ePair) {
     322        if      (ePair->last && ePair->last->IOD() == IODcorr) {
     323          eph = ePair->last;
     324        }
     325        else if (ePair->prev && ePair->prev->IOD() == IODcorr) {
     326          eph = ePair->prev;
     327        }
    360328      }
    361329
     
    431399      copy(missingIOD.begin(), missingIOD.end(), ostream_iterator<string>(missingIODstr, "   "));
    432400
    433       errmsg.push_back("missing eph for " + PRN + " , IODs " + missingIODstr.str());
     401      errmsg.push_back("missing eph for " + string(prn.toAscii().data()) + " , IODs " + missingIODstr.str());
    434402    }
    435403
  • trunk/BNC/RTCM/RTCM2Decoder.h

    r2492 r3562  
    3535#include "rtcm3torinex.h"
    3636#include "ephemeris.h"
     37#include "bncephuser.h"
    3738
    38 class RTCM2Decoder: public GPSDecoder {
     39class RTCM2Decoder: public bncEphUser, public GPSDecoder {
    3940
    4041  public:
     
    4243    virtual ~RTCM2Decoder();
    4344    virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
    44 
    45     bool  storeEph(const gpsephemeris& gpseph, std::string& storedPRN, std::vector<int>& IODs);
    46     bool  storeEph(const t_ephGPS&     gpseph, std::string& storedPRN, std::vector<int>& IODs);
    4745
    4846    t_irc getStaCrd(double& xx, double& yy, double& zz);
     
    5755
    5856  private:
    59 
    60     class t_ephList {
    61     public:
    62       t_ephList() {}
    63      
    64       ~t_ephList() {
    65         for (std::list<t_eph*>::iterator ii = _eph.begin(); ii != _eph.end(); ii++) {
    66           delete  (*ii);
    67         }
    68       }
    69 
    70       bool store(t_eph* eph) {
    71         if ( _eph.size() == 0 ) {
    72           _eph.push_back(eph);
    73           return true;
    74         }
    75          
    76         std::list<t_eph*>::iterator ii = _eph.begin();
    77         while (ii != _eph.end()) {
    78           if ( eph->IOD() == (*ii)->IOD() ) {
    79             return false;
    80           }
    81           if ( ! eph->isNewerThan(*ii) ) {
    82             break;
    83           }
    84           ++ii;
    85         }
    86 
    87         if ( ii == _eph.begin() && _eph.size() == MAXSIZE) {
    88           return false;
    89         }
    90 
    91         _eph.insert(ii, eph);
    92 
    93         while ( _eph.size() > MAXSIZE ) {
    94           delete _eph.front();
    95           _eph.pop_front();
    96         }
    97 
    98         return true;
    99       }
    100      
    101       const t_eph* getEph(int IOD) const {
    102         for (std::list<t_eph*>::const_iterator ii = _eph.begin(); ii != _eph.end(); ii++) {
    103           if ( (*ii)->IOD() == IOD ) {
    104             return (*ii);
    105           }
    106         }
    107         return 0;
    108       }
    109 
    110       void getIODs(std::vector<int>& IODs) const {
    111         IODs.clear();
    112         for (std::list<t_eph*>::const_iterator ii = _eph.begin(); ii != _eph.end(); ii++) {
    113           IODs.push_back((*ii)->IOD());
    114         }
    115       }
    116 
    117       static const unsigned MAXSIZE = 5;
    118 
    119       std::list<t_eph*> _eph;
    120     };
    12157
    12258    void translateCorr2Obs(std::vector<std::string>& errmsg);
     
    13672    rtcm2::RTCM2_24           _msg24;
    13773    rtcm2::RTCM2_2021         _msg2021;
    138     std::map<std::string, t_ephList*> _ephList;
    139 
    140     typedef std::map<std::string, t_ephList*> t_listMap;
    14174};
    14275
  • trunk/BNC/bnccaster.cpp

    r3543 r3562  
    274274          this, SLOT(slotNewNMEAstr(QByteArray)));
    275275
    276   connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
    277           getThread, SLOT(slotNewEphGPS(gpsephemeris)));
    278 
    279276  _staIDs.push_back(getThread->staID());
    280277  _threads.push_back(getThread);
  • trunk/BNC/bncgetthread.cpp

    r3561 r3562  
    771771  }
    772772}
    773 
    774 //
    775 //////////////////////////////////////////////////////////////////////////////
    776 void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
    777   QMutexLocker locker(&_mutex);
    778 
    779   if (!decoder()) {
    780     return;
    781   }
    782 
    783   RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(decoder());
    784   RTCM3Decoder* decoder3 = dynamic_cast<RTCM3Decoder*>(decoder());
    785 
    786   if ( decoder2 ) {
    787     string storedPRN;
    788     vector<int> IODs;
    789    
    790     if ( decoder2->storeEph(gpseph, storedPRN, IODs) ) {
    791 #ifdef DEBUG_RTCM2_2021
    792       QString msg = _staID + QString(": stored eph %1 IODs").arg(storedPRN.c_str());
    793      
    794       for (unsigned ii = 0; ii < IODs.size(); ii++) {
    795         msg += QString(" %1").arg(IODs[ii],4);
    796       }
    797      
    798       emit(newMessage(msg.toAscii()));
    799 #endif
    800     }
    801   }
    802 
    803   if ( decoder3 ) {
    804     if ( decoder3->storeEph(gpseph) ) {
    805 #ifdef DEBUG_RTCM3
    806       QString msg = _staID + QString(": RTCM3Decoder, stored eph for satellite %1").arg(gpseph.satellite);
    807       emit(newMessage(msg.toAscii(),true));
    808 #endif
    809     }
    810   }
    811 }
    812 
  • trunk/BNC/bncgetthread.h

    r3561 r3562  
    8989   virtual void run();
    9090
    91  public slots:
    92    void slotNewEphGPS(gpsephemeris gpseph);
    93 
    9491 private slots:
    9592   void slotSerialReadyRead();
     
    124121   QFile*                     _serialOutFile;
    125122   t_serialNMEA               _serialNMEA;
    126    QMutex                     _mutex;
    127123   bncPPPclient*              _PPPclient;
    128124   bool                       _rawOutput;
Note: See TracChangeset for help on using the changeset viewer.