Index: trunk/BNC/RTCM/RTCM2Decoder.cpp
===================================================================
--- trunk/BNC/RTCM/RTCM2Decoder.cpp	(revision 3561)
+++ trunk/BNC/RTCM/RTCM2Decoder.cpp	(revision 3562)
@@ -65,7 +65,4 @@
 
 RTCM2Decoder::~RTCM2Decoder() {
-  for (t_listMap::iterator ii = _ephList.begin(); ii != _ephList.end(); ii++) {
-    delete ii->second;
-  }
 }
 
@@ -222,38 +219,4 @@
 }
 
-
-
-bool RTCM2Decoder::storeEph(const gpsephemeris& gpseph, string& storedPRN, vector<int>& IODs) {
-  t_ephGPS eph; eph.set(&gpseph);
-
-  return storeEph(eph, storedPRN, IODs);
-}
-
-
-bool RTCM2Decoder::storeEph(const t_ephGPS& gpseph, string& storedPRN, vector<int>& IODs) {
-  t_ephGPS* eph = new t_ephGPS(gpseph);
-
-  string prn = eph->prn().toAscii().data();
-
-  t_listMap::iterator ip = _ephList.find(prn);
-  if (ip == _ephList.end() ) {
-    ip = _ephList.insert(pair<string, t_ephList*>(prn, new t_ephList)).first;
-  }
-  t_ephList* ephList = ip->second;
-
-  bool stored = ephList->store(eph);
-
-  if ( stored ) {
-    storedPRN = string(eph->prn().toAscii().data());
-    ephList->getIODs(IODs);
-    return true;
-  }
-
-  delete eph;
-
-  return false;
-}
-  
-  
 void RTCM2Decoder::translateCorr2Obs(vector<string>& errmsg) {
 
@@ -298,13 +261,13 @@
     // end test
 
-
-    ostringstream oPRN; oPRN.fill('0');
-
-    oPRN <<            (corr->PRN < 200 ? 'G'       : 'R')
-	 << setw(2) << (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);
-
-    string PRN(oPRN.str());
-
-    t_listMap::const_iterator ieph = _ephList.find(PRN);
+    QString prn;
+    if (corr->PRN < 200) {
+      prn = 'G' + QString("%1").arg(corr->PRN, 2, 10, QChar('0'));
+    }
+    else {
+      prn = 'R' + QString("%1").arg(corr->PRN - 200, 2, 10, QChar('0'));
+    }
+
+    const t_ephPair* ePair = ephPair(prn); 
 
     double L1 = 0;
@@ -356,6 +319,11 @@
 
       // Select corresponding ephemerides
-      if ( ieph != _ephList.end() ) {
-	eph = ieph->second->getEph(IODcorr);
+      if (ePair) {
+        if      (ePair->last && ePair->last->IOD() == IODcorr) {
+          eph = ePair->last;
+        }
+        else if (ePair->prev && ePair->prev->IOD() == IODcorr) {
+          eph = ePair->prev;
+        }
       }
 
@@ -431,5 +399,5 @@
       copy(missingIOD.begin(), missingIOD.end(), ostream_iterator<string>(missingIODstr, "   "));
 
-      errmsg.push_back("missing eph for " + PRN + " , IODs " + missingIODstr.str());
+      errmsg.push_back("missing eph for " + string(prn.toAscii().data()) + " , IODs " + missingIODstr.str());
     }
 
Index: trunk/BNC/RTCM/RTCM2Decoder.h
===================================================================
--- trunk/BNC/RTCM/RTCM2Decoder.h	(revision 3561)
+++ trunk/BNC/RTCM/RTCM2Decoder.h	(revision 3562)
@@ -35,6 +35,7 @@
 #include "rtcm3torinex.h"
 #include "ephemeris.h"
+#include "bncephuser.h"
 
-class RTCM2Decoder: public GPSDecoder {
+class RTCM2Decoder: public bncEphUser, public GPSDecoder {
 
   public:
@@ -42,7 +43,4 @@
     virtual ~RTCM2Decoder();
     virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
-
-    bool  storeEph(const gpsephemeris& gpseph, std::string& storedPRN, std::vector<int>& IODs);
-    bool  storeEph(const t_ephGPS&     gpseph, std::string& storedPRN, std::vector<int>& IODs);
 
     t_irc getStaCrd(double& xx, double& yy, double& zz);
@@ -57,66 +55,4 @@
 
   private:
-
-    class t_ephList {
-    public:
-      t_ephList() {}
-      
-      ~t_ephList() {
-        for (std::list<t_eph*>::iterator ii = _eph.begin(); ii != _eph.end(); ii++) {
-          delete  (*ii);
-        }
-      }
-
-      bool store(t_eph* eph) {
-        if ( _eph.size() == 0 ) {
-          _eph.push_back(eph);
-          return true;
-        }
-          
-        std::list<t_eph*>::iterator ii = _eph.begin();
-        while (ii != _eph.end()) {
-          if ( eph->IOD() == (*ii)->IOD() ) {
-            return false;
-          }
-          if ( ! eph->isNewerThan(*ii) ) {
-            break;
-          }
-          ++ii;
-        }
-
-        if ( ii == _eph.begin() && _eph.size() == MAXSIZE) {
-          return false;
-        }
-
-        _eph.insert(ii, eph);
-
-        while ( _eph.size() > MAXSIZE ) {
-          delete _eph.front();
-          _eph.pop_front();
-        }
-
-        return true;
-      }
-      
-      const t_eph* getEph(int IOD) const {
-        for (std::list<t_eph*>::const_iterator ii = _eph.begin(); ii != _eph.end(); ii++) {
-          if ( (*ii)->IOD() == IOD ) {
-            return (*ii);
-          }
-        }
-        return 0;
-      }
-
-      void getIODs(std::vector<int>& IODs) const {
-        IODs.clear();
-        for (std::list<t_eph*>::const_iterator ii = _eph.begin(); ii != _eph.end(); ii++) {
-          IODs.push_back((*ii)->IOD());
-        }
-      }
-
-      static const unsigned MAXSIZE = 5;
-
-      std::list<t_eph*> _eph;
-    };
 
     void translateCorr2Obs(std::vector<std::string>& errmsg);
@@ -136,7 +72,4 @@
     rtcm2::RTCM2_24           _msg24;
     rtcm2::RTCM2_2021         _msg2021;
-    std::map<std::string, t_ephList*> _ephList;
-
-    typedef std::map<std::string, t_ephList*> t_listMap;
 };
 
Index: trunk/BNC/bnccaster.cpp
===================================================================
--- trunk/BNC/bnccaster.cpp	(revision 3561)
+++ trunk/BNC/bnccaster.cpp	(revision 3562)
@@ -274,7 +274,4 @@
           this, SLOT(slotNewNMEAstr(QByteArray)));
 
-  connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
-	  getThread, SLOT(slotNewEphGPS(gpsephemeris)));
-
   _staIDs.push_back(getThread->staID());
   _threads.push_back(getThread);
Index: trunk/BNC/bncgetthread.cpp
===================================================================
--- trunk/BNC/bncgetthread.cpp	(revision 3561)
+++ trunk/BNC/bncgetthread.cpp	(revision 3562)
@@ -771,42 +771,2 @@
   }
 }
-
-//
-//////////////////////////////////////////////////////////////////////////////
-void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
-  QMutexLocker locker(&_mutex);
-
-  if (!decoder()) {
-    return;
-  }
-
-  RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(decoder());
-  RTCM3Decoder* decoder3 = dynamic_cast<RTCM3Decoder*>(decoder());
-
-  if ( decoder2 ) {
-    string storedPRN;
-    vector<int> IODs;
-    
-    if ( decoder2->storeEph(gpseph, storedPRN, IODs) ) {
-#ifdef DEBUG_RTCM2_2021
-      QString msg = _staID + QString(": stored eph %1 IODs").arg(storedPRN.c_str());
-      
-      for (unsigned ii = 0; ii < IODs.size(); ii++) {
-        msg += QString(" %1").arg(IODs[ii],4);
-      }
-      
-      emit(newMessage(msg.toAscii()));
-#endif
-    }
-  }
-
-  if ( decoder3 ) {
-    if ( decoder3->storeEph(gpseph) ) {
-#ifdef DEBUG_RTCM3
-      QString msg = _staID + QString(": RTCM3Decoder, stored eph for satellite %1").arg(gpseph.satellite);
-      emit(newMessage(msg.toAscii(),true));
-#endif
-    }
-  }
-}
-
Index: trunk/BNC/bncgetthread.h
===================================================================
--- trunk/BNC/bncgetthread.h	(revision 3561)
+++ trunk/BNC/bncgetthread.h	(revision 3562)
@@ -89,7 +89,4 @@
    virtual void run();
 
- public slots:
-   void slotNewEphGPS(gpsephemeris gpseph);
-
  private slots:
    void slotSerialReadyRead();
@@ -124,5 +121,4 @@
    QFile*                     _serialOutFile;
    t_serialNMEA               _serialNMEA;
-   QMutex                     _mutex;
    bncPPPclient*              _PPPclient;
    bool                       _rawOutput;
