Index: /trunk/BNC/RTCM/GPSDecoder.h
===================================================================
--- /trunk/BNC/RTCM/GPSDecoder.h	(revision 221)
+++ /trunk/BNC/RTCM/GPSDecoder.h	(revision 222)
@@ -1,130 +1,44 @@
-// -*- C++ -*-
-//
-// $Id: GPSDecoder.h,v 1.2 2006/10/06 10:51:43 mervart Exp $
-// 2005/04/11: include 'int iPCode' into class 'GPSDecoder' (BKG)
-#if !defined(__GPSDecoder_h__)
-#define __GPSDecoder_h__
+
+#ifndef GPSDECODER_H
+#define GPSDECODER_H
 
 #include <list>
-#include <iostream>
 
-using namespace std;
-
-//
-// One Code/Phase - Measurement
-//
-struct Observation {
-    Observation()
-    :SVPRN(0)
-    ,GPSWeek(0)
-    ,GPSWeeks(0)
-    ,sec(0.) 
-    ,C1(0.)
-    ,P2(0.)
-    ,L1(0.)
-    ,L2(0.)
-    ,SNR1(0)
-    ,SNR2(0) 
-    ,pCodeIndicator(0)
-    ,cumuLossOfCont(0)
-    {StatID[0] = '\0';}
-
-    Observation( char _statID
-	        ,char _svprn
-	        ,short _GPSWeek
-	        ,int _GPSWeeks
-		,double _sec
-	        ,double _C1
-		,double _P2
-		,double _L1
-		,double _L2
-		,short _SNR1
-		,short _SNR2
-		,int _pCodeIndicator
-		,unsigned _cumuLossOfCont)
-    :SVPRN(_svprn)
-    ,GPSWeek(_GPSWeek)
-    ,GPSWeeks(_GPSWeeks)
-    ,sec(_sec)
-    ,C1(_C1)
-    ,P2(_P2)
-    ,L1(_L1)
-    ,L2(_L2)
-    ,SNR1(_SNR1)
-    ,SNR2(_SNR2) 
-    ,pCodeIndicator(_pCodeIndicator)
-    ,cumuLossOfCont(_cumuLossOfCont)
-    {StatID[0] = _statID; StatID[1] = '\0';}
-
-    char StatID[5+1];  //< Station ID
-    char SVPRN;    //<  Satellite PRN
-    short GPSWeek; //< Week of GPS-Time
-    int GPSWeeks; //< Second of Week (GPS-Time>
-    double sec;
-    double C1;     //<  CA-code validated raw pseudorange (meters)
-    double P2;     //<  P2-code validated raw pseudorange (meters)
-    double L1;     //<  validated raw carrier phase (meters)
-    double L2;     //<  validated raw carrier phase (meters)
-    short SNR1;    //<  signal-to noise ration (0.1 dB)
-    short SNR2;    //<  signal-to noise ration (0.1 dB)
-    int   pCodeIndicator;  // 0 ... CA Code, 1 ... P Code
-    unsigned cumuLossOfCont;  // 0 to 31
-} ;
-
-//
-// GPS Orbitinformation
-//
-struct Ephemeris {
-    short   svprn;    //< Satellite PRN
-    short   wn;       //< GPS - week number
-    short   aodc;     //< Age of data issue Clock
-    short   aode;     //< Age of data issue Orbit
-    double  tow;      //< Seconds of GPS week
-    double  toc;      //< Reference time, Clock (sec)
-    double  toe;      //< Ref.time for Orbit:(sec)
-    double  tgd;      //< Group delay (sec)
-    double  af2;      //< Clock parameter: (sec/sec^2)
-    double  af1;      //< Clock parameter: (sec/sec)
-    double  af0;      //< Clock parameter: (sec)
-    double  crs;      //< Sin-harmonic correction term, orbit radius:(meters)
-    double  deltan;   //< Mean anomaly correction:(semi-cirl/sec)
-    double  m0;       //< Mean anomaly @ ref.time:(semi-circle)
-    double  cuc;      //< Cos-harmonic correction term, argument of Latitude:(radians)
-    double  e;        //< Eccentricity
-    double  cus;      //< Sin-harmonic correction term, argument of Latitude:(radians)
-    double  roota;    //< Square root of semi-major axis:(m ^1/2)
-    double  cic;      //< Cos-harmonic correction term, angle of inclination:(radians)
-    double  omega0;   //< Lon. of Asc. node at weekly epoch: (semi-circle)
-    double  cis;      //< Sin-harmonic correction term, angle of Inclination:(radians)
-    double  i0;       //< Inclination angle at Ref.time: (semi-circle)
-    double  crc;      //< Cos-harmonic correction term, orbit radius:(meters)
-    double  omega;    //< Argument of Perigee:(semi-circle)
-    double  omegadot; //< Rate of right ascension: (semi-circle/sec)
-    double  idot;     //< Rate of inclination angle: (semi-circle/sec)
-    short   svaccu;   //< SV accuracy (0-15)
-    short   fit;      //< Curve fit interval (0-1)
-    short   cReserved1; //< Not used - yet
-    short   health;     //< 0 if healthy, else unhealthy
-    short   cReserved2; //< Not used - yet
-    short   SVEnable;   //< Not used - yet
-} ;
-
-const double   lambda1 = 0.1902936727984; // [m]
-const double   lambda2 = 0.2442102134241; // [m]
-const unsigned glonass_svid = 45;
+class Observation {
+  public:
+  Observation() {
+    flags     = 0;
+    StatID[0] = '\0';
+    SVPRN     = 0;
+    GPSWeek   = 0;
+    GPSWeeks  = 0.0;
+    C1        = 0.0;
+    P1        = 0.0;
+    P2        = 0.0;
+    L1        = 0.0;
+    L2        = 0.0;
+    SNR1      = 0;
+    SNR2      = 0;
+  }
+  int    flags;
+  char   StatID[5+1]; // Station ID
+  int    SVPRN;       // Satellite PRN
+  int    GPSWeek;     // Week of GPS-Time
+  double GPSWeeks;    // Second of Week (GPS-Time)
+  double C1;          // CA-code pseudorange (meters)
+  double P1;          // P1-code pseudorange (meters)
+  double P2;          // P2-code pseudorange (meters)
+  double L1;          // L1 carrier phase (cycles)
+  double L2;          // L2 carrier phase (cycles)
+  int    SNR1;        // L1 signal-to noise ratio (0.1 dB)
+  int    SNR2;        // L2 signal-to noise ratio (0.1 dB)
+};
 
 class GPSDecoder {
- public:
-  int iPCode;  // pointer for CA or P code on L1
-
-  virtual void Decode(char* _ptrBuffer=NULL, int _nBufLen=0) = 0;
-  virtual ~GPSDecoder() {}
-  typedef list<Observation*> ObsList_t;
-  typedef list<Ephemeris*>   EphList_t;
-
-  ObsList_t m_lObsList;
-  EphList_t m_lEphList;
-
-} ;
+  public:
+    virtual void Decode(char* buffer, int bufLen) = 0;
+    virtual ~GPSDecoder() {}
+    std::list<Observation*> _obsList;
+};
 
 #endif
Index: /trunk/BNC/RTCM/RTCM2.cpp
===================================================================
--- /trunk/BNC/RTCM/RTCM2.cpp	(revision 221)
+++ /trunk/BNC/RTCM/RTCM2.cpp	(revision 222)
@@ -1081,19 +1081,16 @@
           
         for (int iSat=0; iSat < _ObsBlock.nSat; iSat++) {
-          if (_ObsBlock.PRN[iSat] <= 32) {
-            Observation* obs = new Observation();
+          Observation* obs = new Observation();
         
-            obs->SVPRN          = _ObsBlock.PRN[iSat];
-            obs->GPSWeek        = epochWeek;
-            obs->GPSWeeks       = int(epochSecs);
-            obs->sec            = _ObsBlock.secs;
-            obs->pCodeIndicator = 0;
-            obs->C1 = _ObsBlock.rng_C1[iSat];
-            obs->P2 = _ObsBlock.rng_P2[iSat];
-            obs->L1 = _ObsBlock.resolvedPhase_L1(iSat);
-            obs->L2 = _ObsBlock.resolvedPhase_L2(iSat);
+          obs->SVPRN    = _ObsBlock.PRN[iSat];
+          obs->GPSWeek  = epochWeek;
+          obs->GPSWeeks = epochSecs;
+          obs->C1       = _ObsBlock.rng_C1[iSat];
+          obs->P1       = _ObsBlock.rng_P1[iSat];
+          obs->P2       = _ObsBlock.rng_P2[iSat];
+          obs->L1       = _ObsBlock.resolvedPhase_L1(iSat);
+          obs->L2       = _ObsBlock.resolvedPhase_L2(iSat);
         
-            m_lObsList.push_back(obs);
-          }
+          _obsList.push_back(obs);
         }
         _ObsBlock.clear();
Index: /trunk/BNC/RTCM/RTCM2.h
===================================================================
--- /trunk/BNC/RTCM/RTCM2.h	(revision 221)
+++ /trunk/BNC/RTCM/RTCM2.h	(revision 222)
@@ -333,5 +333,5 @@
     void Decode(char* buffer = 0, int bufLen = 0);
   private:
-    string _buffer;
+    std::string        _buffer;
     rtcm2::RTCM2_Obs   _ObsBlock;
     rtcm2::RTCM2packet _PP;
Index: /trunk/BNC/RTCM3/rtcm3.cpp
===================================================================
--- /trunk/BNC/RTCM3/rtcm3.cpp	(revision 221)
+++ /trunk/BNC/RTCM3/rtcm3.cpp	(revision 222)
@@ -16,4 +16,5 @@
  * -----------------------------------------------------------------------*/
 
+#include <iostream>
 #include <math.h>
 
@@ -57,5 +58,5 @@
 
         if (rr == 2) {
-          cerr << "No valid RINEX! All values are modulo 299792.458!\n";
+          std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
           exit(1);
         }
@@ -63,12 +64,7 @@
         for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
           Observation* obs = new Observation();
-          
-////      obs->statID   =
-////      obs->cumuLossOfCont =
-
           obs->SVPRN    = _Parser.Data.satellites[ii];
           obs->GPSWeek  = _Parser.Data.week;
-          obs->GPSWeeks = (int) (_Parser.Data.timeofweek / 1000.0);
-          obs->sec      = fmod(_Parser.Data.timeofweek / 1000.0, 3600.0);
+          obs->GPSWeeks = _Parser.Data.timeofweek / 1000.0;
 
           for (int jj = 0; jj < _Parser.numdatatypes; jj++) {
@@ -82,9 +78,7 @@
             if      (_Parser.dataflag[jj] & GNSSDF_C1DATA) {
               obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
-              obs->pCodeIndicator = 0;
             }
             else if (_Parser.dataflag[jj] & GNSSDF_P1DATA) {
-              obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
-              obs->pCodeIndicator = 1;
+              obs->P1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
             }
             else if (_Parser.dataflag[jj] & GNSSDF_P2DATA) {
@@ -100,5 +94,5 @@
             }
           }
-          m_lObsList.push_back(obs);
+          _obsList.push_back(obs);
         }
       }
Index: /trunk/BNC/RTIGS/rtigs.cpp
===================================================================
--- /trunk/BNC/RTIGS/rtigs.cpp	(revision 221)
+++ /trunk/BNC/RTIGS/rtigs.cpp	(revision 222)
@@ -82,18 +82,16 @@
       Observation* obs = new Observation();
 
-      obs->SVPRN          = _GPSTrans.DecObs.Obs[ii].sat_prn;
-      obs->GPSWeek        = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
-      obs->GPSWeeks       = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
-      obs->sec            = _GPSTrans.DecObs.Obs[ii].GPSTime % 3600;
-      obs->pCodeIndicator = 1;
-      obs->C1             = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
-      obs->P2             = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
-      obs->L1             = _GPSTrans.DecObs.Obs[ii].p1_phase * (C / F1); // ok
-      obs->L2             = _GPSTrans.DecObs.Obs[ii].l1_phase * (C / F1); // strange, probably bug in RTIGS converter
-      obs->SNR1           = (short) _GPSTrans.DecObs.Obs[ii].l1_sn * 10;
-      obs->SNR2           = (short) _GPSTrans.DecObs.Obs[ii].l2_sn * 10;
-      obs->cumuLossOfCont = 0;
+      obs->SVPRN    = _GPSTrans.DecObs.Obs[ii].sat_prn;
+      obs->GPSWeek  = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
+      obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
+      obs->C1       = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
+      obs->P1       = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
+      obs->P2       = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
+      obs->L1       = _GPSTrans.DecObs.Obs[ii].p1_phase;
+      obs->L2       = _GPSTrans.DecObs.Obs[ii].p2_phase;
+      obs->SNR1     = _GPSTrans.DecObs.Obs[ii].l1_sn * 10;
+      obs->SNR2     = _GPSTrans.DecObs.Obs[ii].l2_sn * 10;
 
-      m_lObsList.push_back(obs);
+      _obsList.push_back(obs);
     }
   }
Index: /trunk/BNC/bnccaster.cpp
===================================================================
--- /trunk/BNC/bnccaster.cpp	(revision 221)
+++ /trunk/BNC/bnccaster.cpp	(revision 222)
@@ -15,4 +15,6 @@
  *
  * -----------------------------------------------------------------------*/
+
+#include <math.h>
 
 #include "bnccaster.h"
@@ -91,5 +93,6 @@
 void bncCaster::slotNewObs(const QByteArray& staID, Observation* obs) {
 
-  long newTime = obs->GPSWeek * 7*24*3600 + obs->GPSWeeks;
+  long iSec    = long(floor(obs->GPSWeeks+0.5));
+  long newTime = obs->GPSWeek * 7*24*3600 + iSec;
 
   // Rename the Station
@@ -103,5 +106,5 @@
   }
   bncRinex* rnx = _rinexWriters.find(obs->StatID).value();
-  if (_samplingRate == 0 || obs->GPSWeeks % _samplingRate == 0) {
+  if (_samplingRate == 0 || iSec % _samplingRate == 0) {
     rnx->deepCopy(obs);
   }
@@ -121,5 +124,5 @@
          !settings.value("outPort").toString().isEmpty() ) { 
       emit( newMessage(QString("Station %1: old epoch %2 thrown away")
-                       .arg(staID.data()).arg(obs->GPSWeeks).toAscii()) );
+                       .arg(staID.data()).arg(iSec).toAscii()) );
     }
     delete obs;
@@ -192,15 +195,13 @@
             *_out << begEpoch << endl;;
           }
-          *_out <<       obs->StatID    << " "
-                << (int) obs->SVPRN     << " "
-                << (int) obs->GPSWeek   << " "
-                <<       obs->GPSWeeks  << " "
-                <<       obs->sec       << " "
-                <<       obs->pCodeIndicator << " "
-                <<       obs->cumuLossOfCont << " "
-                <<       obs->C1        << " "
-                <<       obs->P2        << " "
-                <<       obs->L1        << " "
-                <<       obs->L2        << endl;
+          *_out <<  obs->StatID    << " "
+                <<  obs->SVPRN     << " "
+                <<  obs->GPSWeek   << " "
+                <<  obs->GPSWeeks  << " "
+                <<  obs->C1        << " "
+                <<  obs->P1        << " "
+                <<  obs->P2        << " "
+                <<  obs->L1        << " "
+                <<  obs->L2        << endl;
           if (!it.hasNext()) {
             *_out << endEpoch << endl;
Index: /trunk/BNC/bncgetthread.cpp
===================================================================
--- /trunk/BNC/bncgetthread.cpp	(revision 221)
+++ /trunk/BNC/bncgetthread.cpp	(revision 222)
@@ -228,9 +228,9 @@
       _decoder->Decode(data, nBytes);
       delete data;
-      for (list<Observation*>::iterator it = _decoder->m_lObsList.begin(); 
-           it != _decoder->m_lObsList.end(); it++) {
+      for (list<Observation*>::iterator it = _decoder->_obsList.begin(); 
+           it != _decoder->_obsList.end(); it++) {
         emit newObs(_staID, *it);
       }
-      _decoder->m_lObsList.clear();
+      _decoder->_obsList.clear();
     }
     else {
Index: /trunk/BNC/bncrinex.cpp
===================================================================
--- /trunk/BNC/bncrinex.cpp	(revision 221)
+++ /trunk/BNC/bncrinex.cpp	(revision 222)
@@ -298,9 +298,6 @@
   // Time of Epoch
   // -------------
-  Observation* firstObs = *dumpList.begin();
-
-  QDateTime datTim = dateAndTimeFromGPSweek( firstObs->GPSWeek,
-                                             firstObs->GPSWeeks + 
-                                             fmod(firstObs->sec, 1.0) );
+  Observation* fObs = *dumpList.begin();
+  QDateTime datTim = dateAndTimeFromGPSweek(fObs->GPSWeek, fObs->GPSWeeks);
 
   // Close the file
@@ -340,6 +337,6 @@
     _out << setw(14) << setprecision(3) << ob->C1 << lli << snr;
     _out << setw(14) << setprecision(3) << ob->P2 << lli << snr; 
-    _out << setw(14) << setprecision(3) << ob->L1 / t_CST::lambda1 << lli << snr; 
-    _out << setw(14) << setprecision(3) << ob->L2 / t_CST::lambda2 << lli << snr; 
+    _out << setw(14) << setprecision(3) << ob->L1 << lli << snr; 
+    _out << setw(14) << setprecision(3) << ob->L2 << lli << snr; 
     _out << endl;
 
Index: /trunk/BNC/bncrinex.h
===================================================================
--- /trunk/BNC/bncrinex.h	(revision 221)
+++ /trunk/BNC/bncrinex.h	(revision 222)
@@ -28,5 +28,5 @@
    QByteArray          _fName;
    QList<Observation*> _obs;
-   ofstream            _out;
+   std::ofstream       _out;
    QStringList         _headerLines;
    bool                _headerWritten;
