Index: trunk/BNC/bncmapview.cpp
===================================================================
--- trunk/BNC/bncmapview.cpp	(revision 3404)
+++ trunk/BNC/bncmapview.cpp	(revision 3405)
@@ -91,5 +91,5 @@
 
 // -------------
-void BncMapView::mouseReleaseEvent(QMouseEvent* /* event */) 
+void BncMapView::mouseReleaseEvent(QMouseEvent* event) 
 {   
    setCursor(Qt::OpenHandCursor);
Index: trunk/BNC/bncmodel.cpp
===================================================================
--- trunk/BNC/bncmodel.cpp	(revision 3404)
+++ trunk/BNC/bncmodel.cpp	(revision 3405)
@@ -52,13 +52,16 @@
 #include "bnctides.h"
 #include "bncantex.h"
-#include "bnccomb.h"
 
 using namespace std;
 
-const unsigned MINOBS                = 5;
-const double   MINELE                = 10.0 * M_PI / 180.0;
-const double   MAXRES_CODE           = 10.0;
-const double   MAXRES_PHASE          = 0.02;
-const double   GLONASS_WEIGHT_FACTOR = 5.0;
+const unsigned MINOBS           =    5;
+const double   MINELE_GPS       = 10.0 * M_PI / 180.0;
+const double   MINELE_GLO       = 10.0 * M_PI / 180.0;
+const double   MINELE_GAL       = 10.0 * M_PI / 180.0;
+const double   MAXRES_CODE_GPS  = 10.0;
+const double   MAXRES_PHASE_GPS = 0.05;
+const double   MAXRES_PHASE_GLO = 0.05;
+const double   MAXRES_CODE_GAL  = 10.0;
+const double   MAXRES_PHASE_GAL = 0.05;
 
 // Constructor
@@ -254,8 +257,4 @@
   _xcBanc.ReSize(4);  _xcBanc  = 0.0;
   _ellBanc.ReSize(3); _ellBanc = 0.0;
-
-  // Save copy of data (used in outlier detection)
-  // ---------------------------------------------
-  _epoData_sav = new t_epoData();
 }
 
@@ -272,5 +271,4 @@
     delete _params[iPar-1];
   }
-  delete _epoData_sav;
 }
 
@@ -324,24 +322,22 @@
   Tracer tracer("bncModel::cmpBancroft");
 
-  if (epoData->sizeSys('G') < MINOBS) {
+  if (epoData->sizeGPS() < MINOBS) {
     _log += "bncModel::cmpBancroft: not enough data\n";
     return failure;
   }
 
-  Matrix BB(epoData->sizeSys('G'), 4);
-
-  QMapIterator<QString, t_satData*> it(epoData->satData);
+  Matrix BB(epoData->sizeGPS(), 4);
+
+  QMapIterator<QString, t_satData*> it(epoData->satDataGPS);
   int iObsBanc = 0;
   while (it.hasNext()) {
+    ++iObsBanc;
     it.next();
+    QString    prn     = it.key();
     t_satData* satData = it.value();
-    if (satData->system() == 'G') {
-      ++iObsBanc;
-      QString    prn     = it.key();
-      BB(iObsBanc, 1) = satData->xx(1);
-      BB(iObsBanc, 2) = satData->xx(2);
-      BB(iObsBanc, 3) = satData->xx(3);
-      BB(iObsBanc, 4) = satData->P3 + satData->clk;
-    }
+    BB(iObsBanc, 1) = satData->xx(1);
+    BB(iObsBanc, 2) = satData->xx(2);
+    BB(iObsBanc, 3) = satData->xx(3);
+    BB(iObsBanc, 4) = satData->P3 + satData->clk;
   }
 
@@ -354,12 +350,34 @@
   // Compute Satellite Elevations
   // ----------------------------
-  QMutableMapIterator<QString, t_satData*> im(epoData->satData);
-  while (im.hasNext()) {
-    im.next();
-    t_satData* satData = im.value();
+  QMutableMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
+  while (iGPS.hasNext()) {
+    iGPS.next();
+    t_satData* satData = iGPS.value();
     cmpEle(satData);
-    if (satData->eleSat < MINELE) {
+    if (satData->eleSat < MINELE_GPS) {
       delete satData;
-      im.remove();
+      iGPS.remove();
+    }
+  }
+
+  QMutableMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
+  while (iGlo.hasNext()) {
+    iGlo.next();
+    t_satData* satData = iGlo.value();
+    cmpEle(satData);
+    if (satData->eleSat < MINELE_GLO) {
+      delete satData;
+      iGlo.remove();
+    }
+  }
+
+  QMutableMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
+  while (iGal.hasNext()) {
+    iGal.next();
+    t_satData* satData = iGal.value();
+    cmpEle(satData);
+    if (satData->eleSat < MINELE_GAL) {
+      delete satData;
+      iGal.remove();
     }
   }
@@ -582,13 +600,15 @@
     // ------------------------------------------------
     int iPar = 0;
-    QMutableVectorIterator<bncParam*> im(_params);
-    while (im.hasNext()) {
-      bncParam* par = im.next();
+    QMutableVectorIterator<bncParam*> it(_params);
+    while (it.hasNext()) {
+      bncParam* par = it.next();
       bool removed = false;
       if (par->type == bncParam::AMB_L3) {
-        if (epoData->satData.find(par->prn) == epoData->satData.end()) {
+        if (epoData->satDataGPS.find(par->prn) == epoData->satDataGPS.end() &&
+            epoData->satDataGlo.find(par->prn) == epoData->satDataGlo.end() && 
+            epoData->satDataGal.find(par->prn) == epoData->satDataGal.end() ) {
           removed = true;
           delete par;
-          im.remove();
+          it.remove();
         }
       }
@@ -601,8 +621,22 @@
     // Add new ambiguity parameters
     // ----------------------------
-    QMapIterator<QString, t_satData*> it(epoData->satData);
-    while (it.hasNext()) {
-      it.next();
-      t_satData* satData = it.value();
+    QMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
+    while (iGPS.hasNext()) {
+      iGPS.next();
+      t_satData* satData = iGPS.value();
+      addAmb(satData);
+    }
+
+    QMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
+    while (iGlo.hasNext()) {
+      iGlo.next();
+      t_satData* satData = iGlo.value();
+      addAmb(satData);
+    }
+
+    QMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
+    while (iGal.hasNext()) {
+      iGal.next();
+      t_satData* satData = iGal.value();
       addAmb(satData);
     }
@@ -657,5 +691,4 @@
   // ----------------------
   if (update_p(epoData) != success) {
-    emit newMessage(_log, false);
     return failure;
   }
@@ -903,26 +936,102 @@
 // Outlier Detection
 ////////////////////////////////////////////////////////////////////////////
-bool bncModel::outlierDetection(int iPhase, const ColumnVector& vv,
-                                QMap<QString, t_satData*>& satData) {
+int bncModel::outlierDetection(int iPhase, const SymmetricMatrix& QQsav, 
+                               const ColumnVector& vv,
+                               QMap<QString, t_satData*>& satDataGPS,
+                               QMap<QString, t_satData*>& satDataGlo,
+                               QMap<QString, t_satData*>& satDataGal) {
 
   Tracer tracer("bncModel::outlierDetection");
 
-  QString prn;
-  double  maxRes  = 0.0;
-  findMaxRes(vv, satData, prn, maxRes);
-
-  if      (iPhase == 1 && maxRes > MAXRES_PHASE) {
-    _log += "Outlier Phase " + prn + " " 
+  QString prnCode;
+  QString prnPhase;
+  double  maxResCode  = 0.0;
+  double  maxResPhase = 0.0;
+
+  QString prnRemoved;
+  double  maxRes;
+
+  int irc = 0;
+
+  if (iPhase == 0) {
+
+    // Check GPS Code
+    // --------------
+    if (irc == 0) {
+      findMaxRes(iPhase, vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
+      if (maxResCode > MAXRES_CODE_GPS) {
+        satDataGPS.remove(prnCode);
+        prnRemoved = prnCode;
+        maxRes     = maxResCode;
+        irc        = 1;
+      }
+    }
+    
+    // Check Galileo Code
+    // ------------------
+    if (irc == 0) {
+      findMaxRes(iPhase, vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
+      if (maxResCode > MAXRES_CODE_GAL) {
+        satDataGal.remove(prnCode);
+        prnRemoved = prnCode;
+        maxRes     = maxResCode;
+        irc        = 1;
+      }
+    }
+  }
+
+  else {
+
+    // Check Glonass Phase
+    // -------------------
+    if (irc == 0) {
+      findMaxRes(iPhase, vv,satDataGlo, prnCode, maxResCode, prnPhase, maxResPhase);
+      if (maxResPhase > MAXRES_PHASE_GLO) {
+        satDataGlo.remove(prnPhase);
+        prnRemoved = prnPhase;
+        maxRes     = maxResPhase;
+        irc        = 1;
+      }
+    }
+    
+    // Check Galileo Phase
+    // -------------------
+    if (irc == 0) {
+      findMaxRes(iPhase, vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
+      if      (maxResPhase > MAXRES_PHASE_GAL) {
+        satDataGal.remove(prnPhase);
+        prnRemoved = prnPhase;
+        maxRes     = maxResPhase;
+        irc        = 1;
+      }
+    }
+    
+    // Check GPS Phase
+    // ---------------
+    if (irc == 0) {
+      findMaxRes(iPhase, vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
+      if      (maxResPhase > MAXRES_PHASE_GPS) {
+        satDataGPS.remove(prnPhase);
+        prnRemoved = prnPhase;
+        maxRes     = maxResPhase;
+        irc        = 1;
+      }
+    }
+  }
+ 
+  if (irc != 0) {
+    _log += "Outlier " + prnRemoved.toAscii() + " " 
           + QByteArray::number(maxRes, 'f', 3) + "\n"; 
-    return true;
-  }
-  else if (iPhase == 0 && maxRes > MAXRES_CODE) {
-    _log += "Outlier Code  " + prn + " " 
-          + QByteArray::number(maxRes, 'f', 3) + "\n"; 
-    return true;
-  }
-  else {
-    return false;
-  }
+    _QQ = QQsav;
+    QVectorIterator<bncParam*> itPar(_params);
+    while (itPar.hasNext()) {
+      bncParam* par = itPar.next();
+      if (par->type == bncParam::AMB_L3 && par->prn == prnRemoved) {
+        par->numEpo = 0;
+      }
+    }
+  }
+
+  return irc;
 }
 
@@ -949,5 +1058,5 @@
 }
 
-//
+//// 
 //////////////////////////////////////////////////////////////////////////////
 void bncModel::kalman(const Matrix& AA, const ColumnVector& ll, 
@@ -1121,18 +1230,13 @@
   }
 
-  // Remember Observation Index
-  // --------------------------
-  ++iObs;
-  satData->obsIndex = iObs;
-
   // Phase Observations
   // ------------------
   if (iPhase == 1) {
+    ++iObs;
     ll(iObs)      = satData->L3 - cmpValue(satData, true);
-    double sigL3 = _sigL3;
+    PP(iObs,iObs) = 1.0 / (_sigL3 * _sigL3) / (ellWgtCoef * ellWgtCoef);
     if (satData->system() == 'R') {
-      sigL3 *= GLONASS_WEIGHT_FACTOR;
-    }
-    PP(iObs,iObs) = 1.0 / (sigL3 * sigL3) / (ellWgtCoef * ellWgtCoef);
+      PP(iObs,iObs) /= 25.0;
+    }
     for (int iPar = 1; iPar <= _params.size(); iPar++) {
       if (_params[iPar-1]->type == bncParam::AMB_L3 &&
@@ -1142,4 +1246,5 @@
       AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
     }
+    satData->indexPhase = iObs;
   }
 
@@ -1147,4 +1252,5 @@
   // -----------------
   else {
+    ++iObs;
     ll(iObs)      = satData->P3 - cmpValue(satData, false);
     PP(iObs,iObs) = 1.0 / (_sigP3 * _sigP3) / (ellWgtCoef * ellWgtCoef);
@@ -1152,4 +1258,5 @@
       AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
     }
+    satData->indexCode = iObs;
   }
 }
@@ -1157,36 +1264,28 @@
 // 
 ///////////////////////////////////////////////////////////////////////////
-QByteArray bncModel::printRes(int iPhase, const ColumnVector& vv, 
-                              const QMap<QString, t_satData*>& satDataMap) {
-
+void bncModel::printRes(int iPhase, const ColumnVector& vv, 
+                        ostringstream& str, t_satData* satData) {
   Tracer tracer("bncModel::printRes");
-
-  ostringstream str;
-  str.setf(ios::fixed);
-        
-  QMapIterator<QString, t_satData*> it(satDataMap);
-  while (it.hasNext()) {
-    it.next();
-    t_satData* satData = it.value();
-    if (satData->obsIndex != 0) {
-      str << _time.timestr(1)
-          << " RES " << satData->prn.toAscii().data() 
-          << (iPhase ? "   L3 " : "   P3 ")
-          << setw(9) << setprecision(4) << vv(satData->obsIndex) << endl;
-    }
-  }
-
-  return QByteArray(str.str().c_str());
+  if (iPhase == 1) {
+    str << _time.timestr(1)
+        << " RES " << satData->prn.toAscii().data() << "   L3 "
+        << setw(9) << setprecision(4) << vv(satData->indexPhase) << endl;
+  }
+  else {
+    str << _time.timestr(1)
+        << " RES " << satData->prn.toAscii().data() << "   P3 "
+        << setw(9) << setprecision(4) << vv(satData->indexCode) << endl;
+  }
 }
 
 // 
 ///////////////////////////////////////////////////////////////////////////
-void bncModel::findMaxRes(const ColumnVector& vv,
+void bncModel::findMaxRes(int iPhase, const ColumnVector& vv,
                           const QMap<QString, t_satData*>& satData,
-                          QString& prn,  double& maxRes) { 
-
+                          QString& prnCode,  double& maxResCode, 
+                          QString& prnPhase, double& maxResPhase) {
   Tracer tracer("bncModel::findMaxRes");
-
-  maxRes  = 0.0;
+  maxResCode  = 0.0;
+  maxResPhase = 0.0;
 
   QMapIterator<QString, t_satData*> it(satData);
@@ -1194,7 +1293,19 @@
     it.next();
     t_satData* satData = it.value();
-    if (satData->obsIndex != 0 && fabs(vv(satData->obsIndex)) > maxRes) {
-      maxRes = fabs(vv(satData->obsIndex));
-      prn    = satData->prn;
+    if (iPhase == 0) {
+      if (satData->indexCode) {
+        if (fabs(vv(satData->indexCode)) > maxResCode) {
+          maxResCode = fabs(vv(satData->indexCode));
+          prnCode    = satData->prn;
+        }
+      }
+    }
+    else {
+      if (satData->indexPhase) {
+        if (fabs(vv(satData->indexPhase)) > maxResPhase) {
+          maxResPhase = fabs(vv(satData->indexPhase));
+          prnPhase    = satData->prn;
+        }
+      }
     }
   }
@@ -1207,147 +1318,153 @@
   Tracer tracer("bncModel::update_p");
 
-  // Save Variance-Covariance Matrix, and Status Vector
-  // --------------------------------------------------
-  rememberState(epoData);
-
-  ColumnVector dx;
-
-  std::vector<QString> allPrns; 
-  QMapIterator<QString, t_satData*> it(epoData->satData);
-  while (it.hasNext()) {
-    it.next();
-    t_satData* satData = it.value();
-    allPrns.push_back(satData->prn);
-  }
-  std::vector<QString> usedPrns;
-
-  // Try with all satellites, then with all minus one, etc.
-  // ------------------------------------------------------
-  const unsigned MAX_NEGLECT = 1;
-  for (unsigned nNeglected = 0; nNeglected <= MAX_NEGLECT; nNeglected++) {
-    usedPrns = allPrns;
-
-    for (unsigned ii = 0; ii < nNeglected && usedPrns.size() > 0; ii++) {
-      usedPrns.pop_back();
-    }
-
-    // Loop over all Combinations of used Satellites
-    // ---------------------------------------------
+  rememberState();
+
+  for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++) {
+
+    SymmetricMatrix QQsav;
+    ColumnVector    vv;
+    ColumnVector    dx;
+
     do {
-
-      QByteArray strResCode;
-      QByteArray strResPhase;
-      QString    strNeglected;
-
-      // Remove Neglected Satellites from epoData
-      // ----------------------------------------
-      for (unsigned ip = 0; ip < allPrns.size(); ip++) {
-        QString prn = allPrns[ip];
-        if ( !findInVector(usedPrns, prn) ) {
-          epoData->satData.remove(prn);
-          strNeglected += prn + " ";
-        }
-      }
-      if (epoData->sizeSys('G') < MINOBS) {
-        continue;
-      }
 
       // Bancroft Solution
       // -----------------
-      if (cmpBancroft(epoData) != success) {
-        continue;
-      }
-
-      // First update using code observations, then phase observations
-      // -------------------------------------------------------------      
-      for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++) {
+      if (iPhase == 0) {      
+        if (cmpBancroft(epoData) != success) {
+          restoreState();
+          emit newMessage(_log, false);
+          return failure;
+        }
+      }
+      else {
+        if (epoData->sizeGPS() < MINOBS) {
+          restoreState();
+          _log += "bncModel::update_p: not enough data\n";
+          emit newMessage(_log, false);
+          return failure;
+        }
+        unsigned numSatNoSlip = 0;
+        QVectorIterator<bncParam*> itPar(_params);
+        while (itPar.hasNext()) {
+          bncParam* par = itPar.next();
+          if (par->type == bncParam::AMB_L3 && par->prn[0] == 'G') {
+            if (par->numEpo >= 1) {
+              ++numSatNoSlip;
+            }
+          }
+        }
+        if (numSatNoSlip > 0 && numSatNoSlip < MINOBS) {
+          restoreState();
+          _log += "bncModel::update_p: not enough GPS satellites without cycle-slips\n";
+          emit newMessage(_log, false);
+          return failure;
+        }
+      }
       
-        // Status Prediction
-        // -----------------
-        predict(iPhase, epoData);
-        
-        // Create First-Design Matrix
-        // --------------------------
-        unsigned nPar = _params.size();
-        unsigned nObs = 0;
-        if (iPhase == 0) {
-          nObs = epoData->sizeAll() - epoData->sizeSys('R'); // Glonass code not used
-        }
-        else {
-          nObs = epoData->sizeAll();
-        }
-        
-        // Prepare first-design Matrix, vector observed-computed
-        // -----------------------------------------------------
-        Matrix          AA(nObs, nPar);  // first design matrix
-        ColumnVector    ll(nObs);        // tems observed-computed
-        DiagonalMatrix  PP(nObs); PP = 0.0;
-        
-        unsigned iObs = 0;
-        QMapIterator<QString, t_satData*> it(epoData->satData);
-        while (it.hasNext()) {
-          it.next();
-          t_satData* satData = it.value();
-          if (iPhase == 1 || satData->system() != 'R') {
-            QString prn = satData->prn;
-            addObs(iPhase, iObs, satData, AA, ll, PP);
+      // Status Prediction
+      // -----------------
+      predict(iPhase, epoData);
+      
+      // Create First-Design Matrix
+      // --------------------------
+      unsigned nPar = _params.size();
+      unsigned nObs = 0;
+      if (iPhase == 0) {
+        nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used
+      }
+      else {
+        nObs = epoData->sizeGPS() + epoData->sizeGal() + epoData->sizeGlo();
+      }
+    
+      Matrix          AA(nObs, nPar);  // first design matrix
+      ColumnVector    ll(nObs);        // tems observed-computed
+      DiagonalMatrix  PP(nObs); PP = 0.0;
+      
+      unsigned iObs = 0;
+    
+      // GPS
+      // ---
+      QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
+      while (itGPS.hasNext()) {
+        itGPS.next();
+        t_satData* satData = itGPS.value();
+        addObs(iPhase, iObs, satData, AA, ll, PP);
+      }
+    
+      // Glonass
+      // -------
+      if (iPhase == 1) {
+        QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
+        while (itGlo.hasNext()) {
+          itGlo.next();
+          t_satData* satData = itGlo.value();
+          addObs(iPhase, iObs, satData, AA, ll, PP);
+        }
+      }
+
+      // Galileo
+      // -------
+      QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
+      while (itGal.hasNext()) {
+        itGal.next();
+        t_satData* satData = itGal.value();
+        addObs(iPhase, iObs, satData, AA, ll, PP);
+      }
+    
+      // Compute Filter Update
+      // ---------------------
+      QQsav = _QQ;
+    
+      kalman(AA, ll, PP, _QQ, dx);
+    
+      vv = ll - AA * dx;
+
+      // Print Residuals
+      // ---------------
+      if (true) {
+        ostringstream str;
+        str.setf(ios::fixed);
+    
+        QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
+        while (itGPS.hasNext()) {
+          itGPS.next();
+          t_satData* satData = itGPS.value();
+          printRes(iPhase, vv, str, satData);
+        }
+        if (iPhase == 1) {
+          QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
+          while (itGlo.hasNext()) {
+            itGlo.next();
+            t_satData* satData = itGlo.value();
+            printRes(iPhase, vv, str, satData);
           }
         }
-
-        // Compute Filter Update
-        // ---------------------
-        kalman(AA, ll, PP, _QQ, dx);
-        
-        ColumnVector vv = ll - AA * dx;
-        
-        // Print Residuals
-        // ---------------
-        if (iPhase == 0) {
-          strResCode  = printRes(iPhase, vv, epoData->satData);
-        }
-        else {
-          strResPhase = printRes(iPhase, vv, epoData->satData);
-        }
-
-        // Check the residuals
-        // -------------------
-        if ( outlierDetection(iPhase, vv, epoData->satData) ) {
-          restoreState(epoData);
-          break;
-        }
-
-        // Set estimated values
-        // --------------------
-        else if (!_usePhase || iPhase == 1) {
-          QVectorIterator<bncParam*> itPar(_params);
-          while (itPar.hasNext()) {
-            bncParam* par = itPar.next();
-            par->xx += dx(par->index);
-          }
-
-          // Print Neglected PRNs
-          // --------------------
-          if (nNeglected > 0) {
-            _log += "Neglected PRNs: " + strNeglected + '\n';
-          }
-
-          _log += strResCode + strResPhase;
-        
-          return success;
-        }
-
-      } // for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++)
-
-    } while ( next_combination(allPrns.begin(), allPrns.end(),
-                               usedPrns.begin(), usedPrns.end()) );
-
-  } // for (unsigned nNeglected
-
-  return failure;
+        QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
+        while (itGal.hasNext()) {
+          itGal.next();
+          t_satData* satData = itGal.value();
+          printRes(iPhase, vv, str, satData);
+        }
+        _log += str.str().c_str();
+      }
+    
+    } while (outlierDetection(iPhase, QQsav, vv, epoData->satDataGPS, 
+                              epoData->satDataGlo, epoData->satDataGal) != 0);
+
+    // Update Parameters
+    // -----------------
+    QVectorIterator<bncParam*> itPar(_params);
+    while (itPar.hasNext()) {
+      bncParam* par = itPar.next();
+      par->xx += dx(par->index);
+    }
+  }
+
+  return success;
 }
 
 // Remeber Original State Vector and Variance-Covariance Matrix
 ////////////////////////////////////////////////////////////////////////////
-void bncModel::rememberState(t_epoData* epoData) {
+void bncModel::rememberState() {
 
   _QQ_sav = _QQ;
@@ -1365,11 +1482,9 @@
     _params_sav.push_back(new bncParam(*par));
   }
-
-  _epoData_sav->deepCopy(epoData);
 }
 
 // Restore Original State Vector and Variance-Covariance Matrix
 ////////////////////////////////////////////////////////////////////////////
-void bncModel::restoreState(t_epoData* epoData) {
+void bncModel::restoreState() {
 
   _QQ = _QQ_sav;
@@ -1387,5 +1502,4 @@
     _params.push_back(new bncParam(*par));
   }
-
-  epoData->deepCopy(_epoData_sav);
-}
+}
+
Index: trunk/BNC/bncmodel.h
===================================================================
--- trunk/BNC/bncmodel.h	(revision 3404)
+++ trunk/BNC/bncmodel.h	(revision 3405)
@@ -29,5 +29,4 @@
 #include <QtNetwork>
 #include <newmat.h>
-#include <vector>
 
 #include "bncconst.h"
@@ -60,4 +59,5 @@
   bncModel(QByteArray staID);
   ~bncModel();
+  t_irc cmpBancroft(t_epoData* epoData);
   t_irc update(t_epoData* epoData);
   bncTime time()  const {return _time;}
@@ -94,5 +94,4 @@
 
  private:
-  t_irc cmpBancroft(t_epoData* epoData);
   void   reset();
   void   cmpEle(t_satData* satData);
@@ -100,15 +99,19 @@
   void   addObs(int iPhase, unsigned& iObs, t_satData* satData,
                 Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP);
-  QByteArray printRes(int iPhase, const ColumnVector& vv, 
-                      const QMap<QString, t_satData*>& satDataMap);
-  void   findMaxRes(const ColumnVector& vv,
+  void   printRes(int iPhase, const ColumnVector& vv, 
+                  std::ostringstream& str, t_satData* satData);
+  void   findMaxRes(int iPhase, const ColumnVector& vv,
                     const QMap<QString, t_satData*>& satData,
-                    QString& prn,  double& maxRes); 
+                    QString& prnCode,  double& maxResCode, 
+                    QString& prnPhase, double& maxResPhase);
   double cmpValue(t_satData* satData, bool phase);
   double delay_saast(double Ele);
   void   predict(int iPhase, t_epoData* epoData);
   t_irc  update_p(t_epoData* epoData);
-  bool   outlierDetection(int iPhase, const ColumnVector& vv,
-                          QMap<QString, t_satData*>& satData);
+  int    outlierDetection(int iPhase, const SymmetricMatrix& QQsav, 
+                          const ColumnVector& vv,
+                          QMap<QString, t_satData*>& satDataGPS,
+                          QMap<QString, t_satData*>& satDataGlo,
+                          QMap<QString, t_satData*>& satDataGal);
   void writeNMEAstr(const QString& nmStr);
 
@@ -118,6 +121,6 @@
   bncTime  _startTime;
 
-  void rememberState(t_epoData* epoData);
-  void restoreState(t_epoData* epoData);
+  void rememberState();
+  void restoreState();
 
   class pppPos {
@@ -139,5 +142,4 @@
   QVector<bncParam*>    _params_sav;
   SymmetricMatrix       _QQ_sav;
-  t_epoData*            _epoData_sav;
   ColumnVector          _xcBanc;
   ColumnVector          _ellBanc;
Index: trunk/BNC/bncpppclient.cpp
===================================================================
--- trunk/BNC/bncpppclient.cpp	(revision 3404)
+++ trunk/BNC/bncpppclient.cpp	(revision 3405)
@@ -194,5 +194,5 @@
       satData->lambda3 = c1 * t_CST::c / f1 + c2 * t_CST::c / f2;
 
-      _epoData.back()->satData[satData->prn] = satData;
+      _epoData.back()->satDataGPS[satData->prn] = satData;
     }
     else {
@@ -227,5 +227,5 @@
       satData->lambda3 = c1 * t_CST::c / f1 + c2 * t_CST::c / f2;
 
-      _epoData.back()->satData[satData->prn] = satData;
+      _epoData.back()->satDataGlo[satData->prn] = satData;
     }
     else {
@@ -250,5 +250,5 @@
       satData->L3      = c1 * satData->L1 + c5 * satData->L5;
       satData->lambda3 = c1 * t_CST::c / f1 + c5 * t_CST::c / f5;
-      _epoData.back()->satData[satData->prn] = satData;
+      _epoData.back()->satDataGal[satData->prn] = satData;
     }
     else {
@@ -459,13 +459,39 @@
   // Data Pre-Processing
   // -------------------
-  QMutableMapIterator<QString, t_satData*> it(_epoData.front()->satData);
-  while (it.hasNext()) {
-    it.next();
-    QString    prn     = it.key();
-    t_satData* satData = it.value();
+  QMutableMapIterator<QString, t_satData*> iGPS(_epoData.front()->satDataGPS);
+  while (iGPS.hasNext()) {
+    iGPS.next();
+    QString    prn     = iGPS.key();
+    t_satData* satData = iGPS.value();
 
     if (cmpToT(satData) != success) {
       delete satData;
-      it.remove();
+      iGPS.remove();
+      continue;
+    }
+  }
+
+  QMutableMapIterator<QString, t_satData*> iGlo(_epoData.front()->satDataGlo);
+  while (iGlo.hasNext()) {
+    iGlo.next();
+    QString    prn     = iGlo.key();
+    t_satData* satData = iGlo.value();
+
+    if (cmpToT(satData) != success) {
+      delete satData;
+      iGlo.remove();
+      continue;
+    }
+  }
+
+  QMutableMapIterator<QString, t_satData*> iGal(_epoData.front()->satDataGal);
+  while (iGal.hasNext()) {
+    iGal.next();
+    QString    prn     = iGal.key();
+    t_satData* satData = iGal.value();
+
+    if (cmpToT(satData) != success) {
+      delete satData;
+      iGal.remove();
       continue;
     }
Index: trunk/BNC/bncpppclient.h
===================================================================
--- trunk/BNC/bncpppclient.h	(revision 3404)
+++ trunk/BNC/bncpppclient.h	(revision 3405)
@@ -35,5 +35,6 @@
  public:
   t_satData() {
-    obsIndex = 0;
+    indexCode  = 0;
+    indexPhase = 0;
   }
   ~t_satData() {}
@@ -56,5 +57,6 @@
   bool         slipFlag;
   double       lambda3;
-  unsigned     obsIndex;
+  unsigned     indexCode;
+  unsigned     indexPhase;
   char system() const {return prn.toAscii()[0];}
 };
@@ -63,43 +65,30 @@
  public:
   t_epoData() {}
-
   ~t_epoData() {
-    clear();
-  }
-
-  void clear() {
-    QMapIterator<QString, t_satData*> it(satData);
-    while (it.hasNext()) {
-      it.next();
-      delete it.value();
+    QMapIterator<QString, t_satData*> itGPS(satDataGPS);
+    while (itGPS.hasNext()) {
+      itGPS.next();
+      delete itGPS.value();
     }
-    satData.clear();
-  }
-
-  void deepCopy(const t_epoData* from) {
-    clear();
-    tt = from->tt;
-    QMapIterator<QString, t_satData*> it(from->satData);
-    while (it.hasNext()) {
-      it.next();
-      satData[it.key()] = new t_satData(*it.value());
+    QMapIterator<QString, t_satData*> itGlo(satDataGlo);
+    while (itGlo.hasNext()) {
+      itGlo.next();
+      delete itGlo.value();
+    }
+    QMapIterator<QString, t_satData*> itGal(satDataGal);
+    while (itGal.hasNext()) {
+      itGal.next();
+      delete itGal.value();
     }
   }
-
-  unsigned sizeSys(char system) const {
-    unsigned ans = 0;
-    QMapIterator<QString, t_satData*> it(satData);
-    while (it.hasNext()) {
-      it.next();
-      if (it.value()->system() == system) {
-        ++ans;
-      }
-    }
-    return ans;
-  }
-  unsigned sizeAll() const {return satData.size();}
-
-  bncTime                   tt;
-  QMap<QString, t_satData*> satData;
+  unsigned sizeGPS() const {return satDataGPS.size();}
+  unsigned sizeGlo() const {return satDataGlo.size();}
+  unsigned sizeGal() const {return satDataGal.size();}
+  unsigned sizeAll() const {return satDataGPS.size() + satDataGlo.size() +
+                                   satDataGal.size();}
+  bncTime                    tt;
+  QMap<QString, t_satData*> satDataGPS;
+  QMap<QString, t_satData*> satDataGlo;
+  QMap<QString, t_satData*> satDataGal;
 };
 
Index: trunk/BNC/bncutils.cpp
===================================================================
--- trunk/BNC/bncutils.cpp	(revision 3404)
+++ trunk/BNC/bncutils.cpp	(revision 3405)
@@ -374,15 +374,2 @@
                dateTime.time().msec() / 1000.0) / 60.0) / 60.0) / 24.0;
 }
-
-// 
-////////////////////////////////////////////////////////////////////////////
-bool findInVector(const vector<QString>& vv, const QString& str) {
-  std::vector<QString>::const_iterator it;
-  for (it = vv.begin(); it != vv.end(); ++it) {
-    if ( (*it) == str) {
-      return true;
-    }
-  }
-  return false;
-}
-
Index: trunk/BNC/bncutils.h
===================================================================
--- trunk/BNC/bncutils.h	(revision 3404)
+++ trunk/BNC/bncutils.h	(revision 3405)
@@ -25,6 +25,4 @@
 #ifndef BNCUTILS_H
 #define BNCUTILS_H
-
-#include <vector>
 
 #include <QString>
@@ -70,5 +68,3 @@
 void mjdFromDateAndTime(const QDateTime& dateTime, int& mjd, double& dayfrac);
 
-bool findInVector(const std::vector<QString>& vv, const QString& str);
-
 #endif
