Index: /branches/BNC_LM/GPSS/hassDecoder.cpp
===================================================================
--- /branches/BNC_LM/GPSS/hassDecoder.cpp	(revision 3570)
+++ /branches/BNC_LM/GPSS/hassDecoder.cpp	(revision 3571)
@@ -16,6 +16,8 @@
  * -----------------------------------------------------------------------*/
 
+#include <iostream>
 #include "hassDecoder.h"
 #include "bnctime.h"
+#include "bncutils.h"
 
 using namespace std;
@@ -44,7 +46,7 @@
   while ( (indexEOL = _buffer.indexOf('\n')) != -1) {
     QByteArray line = _buffer.left(indexEOL-1);
-    _buffer = _buffer.mid(indexEOL);
+    _buffer = _buffer.mid(indexEOL+1);
 
-    if (QString(line).split(QRegExp("\\s+")).count() != 11) {
+    if (QString(line).split(QRegExp("\\s+"), QString::SkipEmptyParts).count() != 11) {
       continue;
     }
@@ -56,11 +58,15 @@
     int     mjd, IOD;
     double  daySec;
-    double  deltaX, deltaY, deltaZ, deltaClk;
-    double  rateDeltaX, rateDeltaY, rateDeltaZ;
+    ColumnVector dx(3);
+    ColumnVector dxRate(3);
+    double clkFull;
+
     QString prn;
     
-    in >> mjd >> daySec >> prn >> IOD >> deltaX >> deltaY >> deltaZ
-       >> deltaClk >> rateDeltaX >> rateDeltaY >> rateDeltaZ;
+    in >> mjd >> daySec >> prn >> IOD >> dx[0] >> dx[1] >> dx[2] >> clkFull
+       >> dxRate[0] >> dxRate[1] >> dxRate[2];
 
+    // Correction Time
+    // ---------------
     bncTime tt; 
     tt.setmjd(daySec, mjd);
@@ -69,13 +75,48 @@
     long coTime = tt.gpsw() * 7*24*3600 + long(floor(_GPSweeks+0.5));
 
+    // Transform Correction
+    // --------------------
+    dx     = -dx;
+    dxRate = -dxRate;
+
+    //// beg test
+    continue;
+    //// end test
+    ////  t_eph* eph = 0;
+    ////  if (_eph.contains(prn)) {
+    ////    if      (_eph.value(prn)->last && _eph.value(prn)->last->IOD() == IOD) {
+    ////      eph = _eph.value(prn)->last;
+    ////    }
+    ////    else if (_eph.value(prn)->prev && _eph.value(prn)->prev->IOD() == IOD) {
+    ////      eph = _eph.value(prn)->prev;
+    ////    }
+    ////  }
+    ////  if (!eph) {
+    ////    continue;
+    ////  }
+
+    ColumnVector xc(4);
+    ColumnVector vv(3);
+    ////  eph->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
+
+    ColumnVector rao(3);
+    XYZ_to_RSW(xc.Rows(1,3), vv, dx,     rao);
+
+    ColumnVector dotRao(3);
+    XYZ_to_RSW(xc.Rows(1,3), vv, dxRate, dotRao);
+
+    double dClk = clkFull - xc[3] * t_CST::c;
+
+    // Print Correction Line
+    // ---------------------
     QString corrLine;
 
-    int updateInterval =  0;
-    int messageType = 0;
+    int updateInterval = 0;
+    int messageType    = 0;
     if      (prn[0] == 'G') {
-      messageType = -COTYPE_GPSCOMBINED;
+      messageType = COTYPE_GPSCOMBINED;
     }
     else if (prn[0] == 'R') {
-      messageType = -COTYPE_GLONASSCOMBINED;
+      messageType = COTYPE_GLONASSCOMBINED;
     }
 
@@ -87,7 +128,8 @@
                      messageType, updateInterval, tt.gpsw(), _GPSweeks,
                      prn.toAscii().data(), IOD, 
-                     deltaClk, deltaX, deltaY, deltaZ, 
-                     0.0, rateDeltaX, rateDeltaY, rateDeltaZ, 0.0);
-    
+                     dClk, rao[0], rao[1], rao[2],
+                     0.0, dotRao[0], dotRao[1], dotRao[2], 0.0);
+
+    reopen(_fileNameSkl, _fileName, _out);    
     printLine(corrLine, coTime);
   }
Index: /branches/BNC_LM/RTCM3/ephemeris.cpp
===================================================================
--- /branches/BNC_LM/RTCM3/ephemeris.cpp	(revision 3570)
+++ /branches/BNC_LM/RTCM3/ephemeris.cpp	(revision 3571)
@@ -395,24 +395,7 @@
 ////////////////////////////////////////////////////////////////////////////
 int t_ephGlo::IOD() const {
-
-  bool old = false;
-
-  if (old) { // 5 LSBs of iod are equal to 5 LSBs of tb
-    unsigned int tb  = int(fmod(_GPSweeks,86400.0)); //sec of day
-    const int shift = sizeof(tb) * 8 - 5;
-    unsigned int iod = tb << shift;
-    return (iod >> shift);
-  }
-  else     {  
-    bncTime tGPS(_GPSweek, _GPSweeks);
-    int hlpWeek = _GPSweek;
-    int hlpSec  = int(_GPSweeks);
-    int hlpMsec = int(_GPSweeks * 1000);
-    updatetime(&hlpWeek, &hlpSec, hlpMsec, 0);
-    bncTime tHlp(hlpWeek, hlpSec);
-    double diffSec = tGPS - tHlp;
-    bncTime tMoscow = tGPS + diffSec;
-    return int(tMoscow.daysec() / 900);
-  }
+  bncTime tGPS(_GPSweek, _GPSweeks);
+  bncTime tMoscow = tGPS - _gps_utc + 3 * 3600.0;
+  return int(tMoscow.daysec() / 900);
 }
 
Index: /branches/BNC_LM/bncantex.cpp
===================================================================
--- /branches/BNC_LM/bncantex.cpp	(revision 3570)
+++ /branches/BNC_LM/bncantex.cpp	(revision 3571)
@@ -119,4 +119,7 @@
     else if (line.indexOf("END OF ANTENNA") == 60) {
       if (newAntMap) {
+        if (_maps.contains(newAntMap->antName)) {
+          delete _maps[newAntMap->antName];
+        }
         _maps[newAntMap->antName] = newAntMap;
         newAntMap = 0;
@@ -163,7 +166,9 @@
         if (newFrqMap) {
           if      (line.indexOf("G01") == 3 || line.indexOf("R01") == 3) {
+            delete newAntMap->frqMapL1;
             newAntMap->frqMapL1 = newFrqMap;
           }
           else if (line.indexOf("G02") == 3 || line.indexOf("R02") == 3) {
+            delete newAntMap->frqMapL2;
             newAntMap->frqMapL2 = newFrqMap;
           }
Index: /branches/BNC_LM/bncapp.cpp
===================================================================
--- /branches/BNC_LM/bncapp.cpp	(revision 3570)
+++ /branches/BNC_LM/bncapp.cpp	(revision 3571)
@@ -867,5 +867,5 @@
     QByteArray fileName = settings.value("rawOutFile").toByteArray();
     if (!fileName.isEmpty()) {
-      _rawFile = new bncRawFile(fileName, staID, format, bncRawFile::output);
+      _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
     }
   }
Index: /branches/BNC_LM/bnccaster.cpp
===================================================================
--- /branches/BNC_LM/bnccaster.cpp	(revision 3570)
+++ /branches/BNC_LM/bnccaster.cpp	(revision 3571)
@@ -127,6 +127,7 @@
   _epochs = new QMultiMap<long, t_obs>;
 
+  _samplingRate = settings.value("binSampl").toInt();
+  _waitTime     = settings.value("waitTime").toInt();
   _lastDumpSec  = 0; 
-  _waitTime     = 0;
   _confInterval = -1;
 }
@@ -262,4 +263,5 @@
   qRegisterMetaType<gpsephemeris>("gpsephemeris");
   qRegisterMetaType<glonassephemeris>("glonassephemeris");
+  qRegisterMetaType<galileoephemeris>("galileoephemeris");
 
   connect(getThread, SIGNAL(newObs(QByteArray, bool, t_obs)),
@@ -271,7 +273,4 @@
   connect(getThread, SIGNAL(newNMEAstr(QByteArray)), 
           this, SLOT(slotNewNMEAstr(QByteArray)));
-
-  connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
-	  getThread, SLOT(slotNewEphGPS(gpsephemeris)));
 
   _staIDs.push_back(getThread->staID());
@@ -314,5 +313,4 @@
   for (long sec = minTime; sec <= maxTime; sec++) {
 
-    bool first = true;
     QList<t_obs> allObs = _epochs->values(sec);
 
@@ -365,5 +363,4 @@
 
       _epochs->remove(sec);
-      first = false;
     }
   }
Index: /branches/BNC_LM/bncephuser.cpp
===================================================================
--- /branches/BNC_LM/bncephuser.cpp	(revision 3570)
+++ /branches/BNC_LM/bncephuser.cpp	(revision 3571)
@@ -165,8 +165,4 @@
   if (!relevantMessageType(messageType)) {
     return failure;
-  }
-
-  if (messageType < 0) {
-    xyzCorr = true;  // correction in xyz instead of rao
   }
 
Index: /branches/BNC_LM/bncephuser.h
===================================================================
--- /branches/BNC_LM/bncephuser.h	(revision 3570)
+++ /branches/BNC_LM/bncephuser.h	(revision 3571)
@@ -44,12 +44,8 @@
     eph     = 0;
     hrClk   = 0.0;
-    xyzCorr = false;
   }
   bool ready() {return raoSet && dClkSet;}
 
   static bool relevantMessageType(int msgType) {
-    if (msgType < 0) {
-      msgType = -msgType;
-    }
     return ( msgType == COTYPE_GPSCOMBINED     || 
              msgType == COTYPE_GLONASSCOMBINED ||
@@ -76,5 +72,4 @@
   bool         raoSet;
   bool         dClkSet;
-  bool         xyzCorr;
   const t_eph* eph;
 };
Index: /branches/BNC_LM/bncgetthread.cpp
===================================================================
--- /branches/BNC_LM/bncgetthread.cpp	(revision 3570)
+++ /branches/BNC_LM/bncgetthread.cpp	(revision 3571)
@@ -141,5 +141,5 @@
   }
   else {
-    _rnx = new bncRinex(_staID, _mountPoint, _format, _latitude, 
+    _rnx = new bncRinex(_staID, _mountPoint, _latitude, 
                         _longitude, _nmea, _ntripVersion);
   }
@@ -491,5 +491,5 @@
             _rnx->deepCopy(obs);
           }
-          _rnx->dumpEpoch(obsTime);
+          _rnx->dumpEpoch(_format, obsTime);
         }
       
Index: /branches/BNC_LM/bncmain.cpp
===================================================================
--- /branches/BNC_LM/bncmain.cpp	(revision 3570)
+++ /branches/BNC_LM/bncmain.cpp	(revision 3571)
@@ -64,6 +64,4 @@
   bool       GUIenabled  = true;
   QByteArray rawFileName;
-  QByteArray format; 
-  QByteArray staID; 
   QString    confFileName;
 
@@ -80,10 +78,4 @@
         rawFileName = QByteArray(argv[ii+1]);
       }
-      if (QByteArray(argv[ii]).indexOf("-format") != -1) {
-        format = QByteArray(argv[ii+1]);
-      }
-      if (QByteArray(argv[ii]).indexOf("-mountpoint") != -1) {
-        staID = QByteArray(argv[ii+1]);
-      }
     }
   }
@@ -95,7 +87,5 @@
   QString printHelp = "Usage: bnc --nw\n" 
                       "           --conf       <confFileName>\n" 
-                      "           --file       <rawFileName>\n"
-                      "           --mountpoint <station>\n"
-                      "           --format     <RTCM_2 | RTCM_3>\n";
+                      "           --file       <rawFileName>\n";
 
   bncApp app(argc, argv, GUIenabled);
@@ -162,13 +152,6 @@
     else {
       app.setMode(bncApp::batchPostProcessing);
-
-      if ( format.isEmpty() || staID.isEmpty() ) {
-        cout << printHelp.toAscii().data() << endl;
-        exit(0);
-      }
-
-      bncRawFile* rawFile = new bncRawFile(rawFileName, staID, format, 
-                                           bncRawFile::input);
-
+      bncRawFile*   rawFile   = new bncRawFile(rawFileName, "", 
+                                               bncRawFile::input);
       bncGetThread* getThread = new bncGetThread(rawFile);
       caster->addGetThread(getThread, true);
Index: /branches/BNC_LM/bncmodel.cpp
===================================================================
--- /branches/BNC_LM/bncmodel.cpp	(revision 3570)
+++ /branches/BNC_LM/bncmodel.cpp	(revision 3571)
@@ -272,4 +272,7 @@
     delete _params[iPar-1];
   }
+  for (int iPar = 1; iPar <= _params_sav.size(); iPar++) {
+    delete _params_sav[iPar-1];
+  }
   delete _epoData_sav;
 }
@@ -477,6 +480,4 @@
     bncSettings settings;
     
-    _time = epoData->tt; // current epoch time
-    
     _maxSolGap = settings.value("pppMaxSolGap").toDouble();
     
@@ -642,4 +643,6 @@
 
   _log.clear();  
+
+  _time = epoData->tt; // current epoch time
 
   if (settings.value("pppSPP").toString() == "PPP") {
Index: /branches/BNC_LM/bncnetqueryv0.cpp
===================================================================
--- /branches/BNC_LM/bncnetqueryv0.cpp	(revision 3570)
+++ /branches/BNC_LM/bncnetqueryv0.cpp	(revision 3571)
@@ -28,5 +28,5 @@
 bncNetQueryV0::bncNetQueryV0() {
   _socket  = 0;
-  _timeOut = 20000;
+  _timeOut = 120000;
 }
 
Index: /branches/BNC_LM/bncpppclient.cpp
===================================================================
--- /branches/BNC_LM/bncpppclient.cpp	(revision 3570)
+++ /branches/BNC_LM/bncpppclient.cpp	(revision 3571)
@@ -399,6 +399,5 @@
 ////////////////////////////////////////////////////////////////////////////
 t_irc bncPPPclient::applyCorr(const bncTime& tt, const t_corr* cc, 
-                             ColumnVector& xc, ColumnVector& vv) {
-  ColumnVector dx(3);
+                              ColumnVector& xc, ColumnVector& vv) {
 
   double dt = tt - cc->tt;
@@ -409,11 +408,6 @@
   }
 
-  if (cc->xyzCorr) {
-    dx = raoHlp;
-  }
-  else {
-    RSW_to_XYZ(xc.Rows(1,3), vv, raoHlp, dx);
-  }
-
+  ColumnVector dx(3);
+  RSW_to_XYZ(xc.Rows(1,3), vv, raoHlp, dx);
   xc[0] -= dx[0];
   xc[1] -= dx[1];
Index: /branches/BNC_LM/bncpppclient.h
===================================================================
--- /branches/BNC_LM/bncpppclient.h	(revision 3570)
+++ /branches/BNC_LM/bncpppclient.h	(revision 3571)
@@ -126,4 +126,5 @@
   static t_irc applyCorr(const bncTime& tt, const t_corr* cc, ColumnVector& xc, 
                          ColumnVector& vv);
+  QByteArray staID() const {return _staID;}
 
  public slots:
Index: /branches/BNC_LM/bncrawfile.cpp
===================================================================
--- /branches/BNC_LM/bncrawfile.cpp	(revision 3570)
+++ /branches/BNC_LM/bncrawfile.cpp	(revision 3571)
@@ -51,9 +51,9 @@
 ////////////////////////////////////////////////////////////////////////////
 bncRawFile::bncRawFile(const QByteArray& fileName, const QByteArray& staID,
-                       const QByteArray& format, inpOutFlag ioFlg) {
+                       inpOutFlag ioFlg) {
 
   _fileName   = fileName; expandEnvVar(_fileName);
+  _format     = "unset";
   _staID      = staID;
-  _format     = format;
   _inpFile    = 0;
   _outFile    = 0;
Index: /branches/BNC_LM/bncrawfile.h
===================================================================
--- /branches/BNC_LM/bncrawfile.h	(revision 3570)
+++ /branches/BNC_LM/bncrawfile.h	(revision 3571)
@@ -37,5 +37,5 @@
 
   bncRawFile(const QByteArray& fileName, const QByteArray& staID,
-             const QByteArray& format, inpOutFlag ioflg);
+             inpOutFlag ioflg);
 
   ~bncRawFile();  
Index: /branches/BNC_LM/bncrinex.cpp
===================================================================
--- /branches/BNC_LM/bncrinex.cpp	(revision 3570)
+++ /branches/BNC_LM/bncrinex.cpp	(revision 3571)
@@ -66,11 +66,9 @@
 ////////////////////////////////////////////////////////////////////////////
 bncRinex::bncRinex(const QByteArray& statID, const QUrl& mountPoint, 
-                   const QByteArray& format, const QByteArray& latitude,
-                   const QByteArray& longitude, const QByteArray& nmea,
-                   const QByteArray& ntripVersion) {
+                   const QByteArray& latitude, const QByteArray& longitude, 
+                   const QByteArray& nmea, const QByteArray& ntripVersion) {
 
   _statID        = statID;
   _mountPoint    = mountPoint;
-  _format        = format.left(6);
   _latitude      = latitude;
   _longitude     = longitude;
@@ -103,4 +101,6 @@
 
   _approxPos[0] = _approxPos[1] = _approxPos[2] = 0.0;
+
+  _samplingRate = settings.value("rnxSampl").toInt();
 }
 
@@ -377,5 +377,5 @@
 // Write RINEX Header
 ////////////////////////////////////////////////////////////////////////////
-void bncRinex::writeHeader(const QDateTime& datTim, 
+void bncRinex::writeHeader(const QByteArray& format, const QDateTime& datTim, 
                            const QDateTime& datTimNom) {
 
@@ -439,5 +439,5 @@
                                 "    hh    mm   ss.zzz0000").toAscii().data();
         _out << "     GPS         TIME OF FIRST OBS"    << endl;
-        QString hlp = (_format + QString(" %1").arg(_mountPoint.host() + 
+        QString hlp = (format.left(6) + QString(" %1").arg(_mountPoint.host() + 
                       _mountPoint.path())).leftJustified(60, ' ', true);
         _out << hlp.toAscii().data() << "COMMENT" << endl;
@@ -511,5 +511,5 @@
                                 "    hh    mm   ss.zzz0000").toAscii().data();
     _out << "     GPS         TIME OF FIRST OBS"    << endl;
-    QString hlp = (_format + QString(" %1").arg(_mountPoint.host() + 
+    QString hlp = (format.left(6) + QString(" %1").arg(_mountPoint.host() + 
           _mountPoint.path())).leftJustified(60, ' ', true);
     _out << hlp.toAscii().data() << "COMMENT" << endl;
@@ -533,5 +533,5 @@
 // Write One Epoch into the RINEX File
 ////////////////////////////////////////////////////////////////////////////
-void bncRinex::dumpEpoch(long maxTime) {
+void bncRinex::dumpEpoch(const QByteArray& format, long maxTime) {
 
   // Select observations older than maxTime
@@ -570,5 +570,5 @@
   // ------------------
   if (!_headerWritten) {
-    writeHeader(datTim, datTimNom);
+    writeHeader(format, datTim, datTimNom);
   }
 
Index: /branches/BNC_LM/bncrinex.h
===================================================================
--- /branches/BNC_LM/bncrinex.h	(revision 3570)
+++ /branches/BNC_LM/bncrinex.h	(revision 3571)
@@ -26,26 +26,25 @@
 #define BNCRINEX_H
 
-#include <QByteArray>
-#include <QDateTime>
-#include <QList>
-
+#include <QtCore>
 #include <fstream>
 
 #include "bncconst.h"
-#include "RTCM/GPSDecoder.h"
+
+class t_obs;
 
 class bncRinex {
  public:
    bncRinex(const QByteArray& statID, const QUrl& mountPoint, 
-            const QByteArray& format, const QByteArray& latitude,
-            const QByteArray& longitude, const QByteArray& nmea,
-            const QByteArray& ntripVersion); 
+            const QByteArray& latitude, const QByteArray& longitude,
+            const QByteArray& nmea, const QByteArray& ntripVersion); 
    ~bncRinex();
    void deepCopy(t_obs obs);
-   void dumpEpoch(long maxTime);
+   void dumpEpoch(const QByteArray& format, long maxTime);
    void setReconnectFlag(bool flag){_reconnectFlag = flag;}
    static QString nextEpochStr(const QDateTime& datTim,
                                const QString& intStr, 
                                QDateTime* nextEpoch = 0);
+
+   int samplingRate() const {return _samplingRate;}
 
    void setApproxPos(double stax, double stay, double staz) {
@@ -64,5 +63,6 @@
    void resolveFileName(const QDateTime& datTim);
    void readSkeleton();
-   void writeHeader(const QDateTime& datTim, const QDateTime& datTimNom);
+   void writeHeader(const QByteArray& format, const QDateTime& datTim, 
+                    const QDateTime& datTimNom);
    void closeFile();
    t_irc downloadSkeleton();
@@ -80,5 +80,4 @@
    QString       _userName;
    QString       _sklName;
-   QByteArray    _format;
    QByteArray    _latitude;
    QByteArray    _longitude;
@@ -91,4 +90,5 @@
    bool          _reloadDone;
    double        _approxPos[3];
+   int           _samplingRate;
 
    QMap<QString, int>  _slip_cnt_L1;
Index: /branches/BNC_LM/combination/bnccomb.cpp
===================================================================
--- /branches/BNC_LM/combination/bnccomb.cpp	(revision 3570)
+++ /branches/BNC_LM/combination/bnccomb.cpp	(revision 3571)
@@ -257,7 +257,8 @@
     delete _params[iPar-1];
   }
-  QVectorIterator<cmbCorr*> itCorr(corrs());
-  while (itCorr.hasNext()) {
-    delete itCorr.next();
+  QListIterator<bncTime> itTime(_buffer.keys());
+  while (itTime.hasNext()) {
+    bncTime epoTime = itTime.next();
+    _buffer.remove(epoTime);
   }
 }
@@ -355,5 +356,5 @@
   while (itCorr.hasNext()) {
     cmbCorr* hlp = itCorr.next();
-    if (hlp->prn == newCorr->prn && hlp->acName == newCorr->prn) {
+    if (hlp->prn == newCorr->prn && hlp->acName == newCorr->acName) {
       existingCorr = hlp;
       break;
@@ -875,4 +876,5 @@
       }
       if (!foundMaster) {
+        delete corr;
         it.remove();
       }
@@ -973,4 +975,5 @@
     if (maxRes > _MAXRES) {
       out << "  Outlier" << endl;
+      delete corrs()[maxResIndex-1];
       corrs().remove(maxResIndex-1);
     }
@@ -1010,8 +1013,10 @@
     if      (_eph.find(prn) == _eph.end()) {
       out << "checkOrbit: missing eph (not found) " << corr->prn << endl;
+      delete corr;
       im.remove();
     }
     else if (corr->eph == 0) {
       out << "checkOrbit: missing eph (zero) " << corr->prn << endl;
+      delete corr;
       im.remove();
     }
@@ -1022,4 +1027,5 @@
       else {
         out << "checkOrbit: missing eph (deleted) " << corr->prn << endl;
+        delete corr;
         im.remove();
       }
@@ -1086,4 +1092,5 @@
       QString  prn  = corr->prn;
       if      (numCorr[prn] < 2) {
+        delete corr;
         im.remove();
       }
@@ -1098,4 +1105,5 @@
               << corr->iod                     << " " 
               << norm                          << endl;
+          delete corr;
           im.remove();
           removed = true;
