Index: trunk/BNC/src/PPP/pppClient.cpp
===================================================================
--- trunk/BNC/src/PPP/pppClient.cpp	(revision 5801)
+++ trunk/BNC/src/PPP/pppClient.cpp	(revision 5802)
@@ -55,5 +55,4 @@
 #include "bncutils.h"
 #include "station.h"
-#include "bnctides.h"
 #include "bncantex.h"
 #include "filter.h"
@@ -82,4 +81,5 @@
   _staRover = new t_station();
   _filter   = new t_filter();
+  _tides    = new t_tides();
 
   if (!_opt->_antexFile.empty()) {
@@ -103,4 +103,5 @@
   delete _antex;
   delete _filter;
+  delete _tides;
   clearObs();
 }
@@ -379,7 +380,5 @@
   // Tides
   // -----
-  ColumnVector hlp = station->xyzApr();
-  tides(time, hlp);
-  station->setTideDspl(hlp - station->xyzApr());
+  station->setTideDspl( _tides->displacement(time, station->xyzApr()) );
   
   // Observation model
Index: trunk/BNC/src/PPP/pppClient.h
===================================================================
--- trunk/BNC/src/PPP/pppClient.h	(revision 5801)
+++ trunk/BNC/src/PPP/pppClient.h	(revision 5802)
@@ -7,4 +7,5 @@
 #include "ephemeris.h"
 #include "options.h"
+#include "pppModel.h"
 
 class bncAntex;
@@ -65,4 +66,5 @@
   std::ostringstream*    _log; 
   t_options*             _opt; 
+  t_tides*               _tides;
 };
 
Index: trunk/BNC/src/PPP/pppModel.cpp
===================================================================
--- trunk/BNC/src/PPP/pppModel.cpp	(revision 5801)
+++ trunk/BNC/src/PPP/pppModel.cpp	(revision 5802)
@@ -208,2 +208,88 @@
   return dX;
 }
+
+// Constructor
+///////////////////////////////////////////////////////////////////////////
+t_windUp::t_windUp() {
+  for (unsigned ii = 0; ii <= t_prn::MAXPRN; ii++) {
+    sumWind[ii]   = 0.0;
+    lastEtime[ii] = 0.0;
+  }
+}
+
+// Phase Wind-Up Correction
+///////////////////////////////////////////////////////////////////////////
+double t_windUp::value(const bncTime& etime, const ColumnVector& rRec, 
+                       t_prn prn, const ColumnVector& rSat) {
+
+  if (etime.mjddec() != lastEtime[prn.toInt()]) {
+
+    // Unit Vector GPS Satellite --> Receiver
+    // --------------------------------------
+    ColumnVector rho = rRec - rSat;
+    rho /= rho.norm_Frobenius();
+    
+    // GPS Satellite unit Vectors sz, sy, sx
+    // -------------------------------------
+    ColumnVector sz = -rSat / rSat.norm_Frobenius();
+
+    ColumnVector xSun = Sun(etime.mjddec());
+    xSun /= xSun.norm_Frobenius();
+
+    ColumnVector sy = crossproduct(sz, xSun);
+    ColumnVector sx = crossproduct(sy, sz);
+
+    // Effective Dipole of the GPS Satellite Antenna
+    // ---------------------------------------------
+    ColumnVector dipSat = sx - rho * DotProduct(rho,sx) 
+                                                - crossproduct(rho, sy);
+    
+    // Receiver unit Vectors rx, ry
+    // ----------------------------
+    ColumnVector rx(3);
+    ColumnVector ry(3);
+
+    double recEll[3]; xyz2ell(rRec.data(), recEll) ;
+    double neu[3];
+    
+    neu[0] = 1.0;
+    neu[1] = 0.0;
+    neu[2] = 0.0;
+    neu2xyz(recEll, neu, rx.data());
+    
+    neu[0] =  0.0;
+    neu[1] = -1.0;
+    neu[2] =  0.0;
+    neu2xyz(recEll, neu, ry.data());
+    
+    // Effective Dipole of the Receiver Antenna
+    // ----------------------------------------
+    ColumnVector dipRec = rx - rho * DotProduct(rho,rx) 
+                                                   + crossproduct(rho, ry);
+    
+    // Resulting Effect
+    // ----------------
+    double alpha = DotProduct(dipSat,dipRec) / 
+                      (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
+    
+    if (alpha >  1.0) alpha =  1.0;
+    if (alpha < -1.0) alpha = -1.0;
+    
+    double dphi = acos(alpha) / 2.0 / M_PI;  // in cycles
+    
+    if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
+      dphi = -dphi;
+    }
+
+    if (lastEtime[prn.toInt()] == 0.0) {
+      sumWind[prn.toInt()] = dphi;
+    }
+    else {
+      sumWind[prn.toInt()] = nint(sumWind[prn.toInt()] - dphi) + dphi;
+    }
+
+    lastEtime[prn.toInt()] = etime.mjddec();
+  }
+
+  return sumWind[prn.toInt()];  
+}
Index: trunk/BNC/src/PPP/pppModel.h
===================================================================
--- trunk/BNC/src/PPP/pppModel.h	(revision 5801)
+++ trunk/BNC/src/PPP/pppModel.h	(revision 5802)
@@ -39,3 +39,14 @@
 };
 
+class t_windUp {
+ public:
+  t_windUp();
+  ~t_windUp() {};
+  double value(const bncTime& etime, const ColumnVector& rRec, t_prn prn,
+               const ColumnVector& rSat);
+ private:
+  double lastEtime[t_prn::MAXPRN+1];
+  double sumWind[t_prn::MAXPRN+1];
+};
+
 #endif
Index: trunk/BNC/src/PPP/windup.cpp
===================================================================
--- trunk/BNC/src/PPP/windup.cpp	(revision 5801)
+++ trunk/BNC/src/PPP/windup.cpp	(revision 5802)
@@ -5,5 +5,4 @@
 #include "windup.h"
 #include "bncutils.h"
-#include "bnctides.h"
 
 using namespace std;
Index: trunk/BNC/src/PPP/windup.h
===================================================================
--- trunk/BNC/src/PPP/windup.h	(revision 5801)
+++ 	(revision )
@@ -1,27 +1,0 @@
-
-#ifndef WINDUP_H
-#define WINDUP_H
-
-#include <newmat.h>
-
-#include "ppp.h"
-#include "bnctime.h"
-
-namespace BNC {
-
-class t_windUp {
- public:
-  t_windUp();
-  ~t_windUp() {};
-
-  double value(const bncTime& etime, const ColumnVector& rRec, t_prn prn,
-               const ColumnVector& rSat);
-
- private:
-  double lastEtime[t_prn::MAXPRN+1];
-  double sumWind[t_prn::MAXPRN+1];
-};
-
-}
-
-#endif
