Index: trunk/BNC/src/PPP/pppClient.cpp
===================================================================
--- trunk/BNC/src/PPP/pppClient.cpp	(revision 8965)
+++ trunk/BNC/src/PPP/pppClient.cpp	(revision 8993)
@@ -74,4 +74,5 @@
   }
   _offGG = 0.0;
+  _offGB = 0.0;
   CLIENTS.setLocalData(this);  // CLIENTS takes ownership over "this"
 }
@@ -382,4 +383,57 @@
 }
 
+// Compute A Priori GPS-BDS Offset
+//////////////////////////////////////////////////////////////////////////////
+double t_pppClient::cmpOffGB(vector<t_pppSatObs*>& obsVector) {
+
+  t_lc::type tLC   = t_lc::dummy;
+  double     offGB = 0.0;
+
+  if (_opt->useSystem('C')) {
+    while (obsVector.size() > 0) {
+      offGB = 0.0;
+      double   maxRes      = 0.0;
+      int      maxResIndex = -1;
+      t_prn    maxResPrn;
+      unsigned nObs        = 0;
+      for (unsigned ii = 0; ii < obsVector.size(); ii++) {
+        const t_pppSatObs* satObs = obsVector.at(ii);
+        if (satObs->prn().system() == 'C') {
+          if (tLC == t_lc::dummy) {
+            tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
+          }
+          if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
+            double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
+            ++nObs;
+            offGB += ll;
+            if (fabs(ll) > fabs(maxRes)) {
+              maxRes      = ll;
+              maxResIndex = ii;
+              maxResPrn   = satObs->prn();
+            }
+          }
+        }
+      }
+
+      if (nObs > 0) {
+        offGB = offGB / nObs;
+      }
+      else {
+        offGB = 0.0;
+      }
+
+      if (fabs(maxRes) > 1000.0) {
+        LOG << "t_pppClient::cmpOffGB outlier " << maxResPrn.toString() << " " << maxRes << endl;
+        delete obsVector.at(maxResIndex);
+        obsVector.erase(obsVector.begin() + maxResIndex);
+      }
+      else {
+        break;
+      }
+    }
+  }
+  return offGB;
+}
+
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -517,4 +571,5 @@
 
       _offGG = cmpOffGG(_obsRover);
+      _offGB = cmpOffGB(_obsRover);
 
       if (_opt->_refSatRequired) {
Index: trunk/BNC/src/PPP/pppClient.h
===================================================================
--- trunk/BNC/src/PPP/pppClient.h	(revision 8965)
+++ trunk/BNC/src/PPP/pppClient.h	(revision 8993)
@@ -38,4 +38,5 @@
   const t_pppStation* staRover() const {return _staRover;}
   double              offGG() const {return _offGG;}
+  double              offGB() const {return _offGB;}
 
   std::ostringstream& log() {return *_log;}
@@ -60,4 +61,5 @@
                     ColumnVector& xyzc, bool print);
   double cmpOffGG(std::vector<t_pppSatObs*>& obsVector);
+  double cmpOffGB(std::vector<t_pppSatObs*>& obsVector);
   void setRefSatellites(std::vector<t_pppSatObs*>& obsVector);
 
@@ -70,4 +72,5 @@
   t_pppFilter*              _filter;
   double                    _offGG;
+  double                    _offGB;
   std::vector<t_pppSatObs*> _obsRover;
   std::ostringstream*       _log;
Index: trunk/BNC/src/PPP/pppFilter.cpp
===================================================================
--- trunk/BNC/src/PPP/pppFilter.cpp	(revision 8965)
+++ trunk/BNC/src/PPP/pppFilter.cpp	(revision 8993)
@@ -361,7 +361,10 @@
       }
       if (preProcessing) {
-        if (par && obs->prn() == refPrn) {
+        if      (par && obs->prn() == refPrn) {
           _obsPool->setRefSatChangeRequired(true);
           break;
+        }
+        else if (par && obs->prn() != refPrn) {
+          par->setAmbResetCandidate();
         }
       }
Index: trunk/BNC/src/PPP/pppParlist.cpp
===================================================================
--- trunk/BNC/src/PPP/pppParlist.cpp	(revision 8965)
+++ trunk/BNC/src/PPP/pppParlist.cpp	(revision 8993)
@@ -78,5 +78,9 @@
              offGG = PPP_CLIENT->offGG();
            }
-           _x0 = floor((obs->obsValue(tLC) - offGG - obs->cmpValue(tLC)) / obs->lambda(tLC) + 0.5);
+           double offGB = 0;
+           if (_prn.system() == 'C' && tLC != t_lc::MW) {
+             offGB = PPP_CLIENT->offGB();
+           }
+           _x0 = floor((obs->obsValue(tLC) - offGG - offGB - obs->cmpValue(tLC)) / obs->lambda(tLC) + 0.5);
            break;
          }
@@ -88,4 +92,9 @@
      _sigma0  = 1000.0;
      _x0      = PPP_CLIENT->offGG();
+     break;
+   case offGB:
+     _epoSpec = true;
+     _sigma0  = 1000.0;
+     _x0      = PPP_CLIENT->offGB();
      break;
    case trp:
@@ -155,4 +164,7 @@
     if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
     return (obs->prn().system() == 'R') ? 1.0 : 0.0;
+  case offGB:
+    if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
+    return (obs->prn().system() == 'C') ? 1.0 : 0.0;
   case amb:
     if      (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
@@ -267,4 +279,7 @@
     ss << "OGG        ";
     break;
+  case offGB:
+    ss << "OGB        ";
+    break;
   case trp:
     ss << "TRP        ";
@@ -388,4 +403,11 @@
     required.push_back(new t_pppParam(t_pppParam::offGG, t_prn(), t_lc::dummy));
   }
+
+  // GPS-BDS Clock Offset
+  // ------------------------
+  if (OPT->useSystem('C')) {
+    required.push_back(new t_pppParam(t_pppParam::offGB, t_prn(), t_lc::dummy));
+  }
+
 
   // Troposphere
Index: trunk/BNC/src/PPP/pppParlist.h
===================================================================
--- trunk/BNC/src/PPP/pppParlist.h	(revision 8965)
+++ trunk/BNC/src/PPP/pppParlist.h	(revision 8993)
@@ -15,5 +15,5 @@
 class t_pppParam {
  public:
-  enum e_type {crdX, crdY, crdZ, clkR, amb, offGG, trp, ion, cBias1, cBias2, pBias1, pBias2};
+  enum e_type {crdX, crdY, crdZ, clkR, amb, offGG, offGB, trp, ion, cBias1, cBias2, pBias1, pBias2};
 
   t_pppParam(e_type type, const t_prn& prn, t_lc::type tLC,
