Index: trunk/BNC/RTCM3/ephemeris.h
===================================================================
--- trunk/BNC/RTCM3/ephemeris.h	(revision 3173)
+++ trunk/BNC/RTCM3/ephemeris.h	(revision 3174)
@@ -3,5 +3,5 @@
 
 #include <newmat.h>
-
+#include <QtCore>
 #include <stdio.h>
 #include <string>
@@ -16,4 +16,8 @@
   bool        isNewerThan(const t_eph* eph) const;
   std::string prn() const {return _prn;}
+  void    setReceptDateTime(const QDateTime& dateTime) {
+    _receptDateTime = dateTime;
+  }
+  const QDateTime& receptDateTime() const {return _receptDateTime;}
 
   int    GPSweek()  const { return _GPSweek; }
@@ -42,4 +46,5 @@
   int         _GPSweek;
   double      _GPSweeks;
+  QDateTime   _receptDateTime;
 };
 
Index: trunk/BNC/bnc.pro
===================================================================
--- trunk/BNC/bnc.pro	(revision 3173)
+++ trunk/BNC/bnc.pro	(revision 3174)
@@ -42,6 +42,7 @@
           bancroft.h bncmodel.h bncfigureppp.h bncrawfile.h           \ 
           bnctides.h bncmap.h bncmapview.h bncantex.h                 \
-          bncephuser.h                                                \
+          bncephuser.h bncoutf.h                                      \
           upload/bncrtnetdecoder.h upload/bncuploadcaster.h           \
+          upload/bncclockrinex.h                                      \
           RTCM/GPSDecoder.h RTCM/RTCM2.h RTCM/RTCM2Decoder.h          \
           RTCM/RTCM2_2021.h RTCM/rtcm_utils.h                         \
@@ -74,6 +75,7 @@
           bancroft.cpp bncmodel.cpp bncfigureppp.cpp bncrawfile.cpp   \
           bnctides.cpp bncmap.cpp bncmapview.cpp bncantex.cpp         \
-          bncephuser.cpp                                              \
+          bncephuser.cpp bncoutf.cpp                                  \
           upload/bncrtnetdecoder.cpp upload/bncuploadcaster.cpp       \
+          upload/bncclockrinex.cpp                                    \
           RTCM/RTCM2.cpp RTCM/RTCM2Decoder.cpp                        \
           RTCM/RTCM2_2021.cpp RTCM/rtcm_utils.cpp                     \
Index: trunk/BNC/bncephuser.h
===================================================================
--- trunk/BNC/bncephuser.h	(revision 3173)
+++ trunk/BNC/bncephuser.h	(revision 3174)
@@ -95,4 +95,5 @@
       delete prev;
     }
+    ColumnVector xx;
     t_eph* last;
     t_eph* prev;
Index: trunk/BNC/bncoutf.cpp
===================================================================
--- trunk/BNC/bncoutf.cpp	(revision 3174)
+++ trunk/BNC/bncoutf.cpp	(revision 3174)
@@ -0,0 +1,169 @@
+
+/* -------------------------------------------------------------------------
+ * BKG NTRIP Server
+ * -------------------------------------------------------------------------
+ *
+ * Class:      bncoutf
+ *
+ * Purpose:    Basis Class for File-Writers
+ *
+ * Author:     L. Mervart
+ *
+ * Created:    25-Apr-2008
+ *
+ * Changes:    
+ *
+ * -----------------------------------------------------------------------*/
+
+#include <math.h>
+#include <iomanip>
+
+#include "bncoutf.h"
+
+using namespace std;
+
+// Constructor
+////////////////////////////////////////////////////////////////////////////
+bncoutf::bncoutf(const QString& prep, const QString& ext, const QString& path,
+                 const QString& intr, int sampl) {
+
+  _headerWritten = false;
+  _prep          = prep;
+  _ext           = ext;
+  _sampl         = sampl;
+  _intr          = intr;
+  _path          = path;
+  expandEnvVar(_path);
+  if ( _path.length() > 0 && _path[_path.length()-1] != QDir::separator() ) {
+    _path += QDir::separator();
+  }
+}
+
+// Destructor
+////////////////////////////////////////////////////////////////////////////
+bncoutf::~bncoutf() {
+  closeFile();
+}
+
+// Close the Old RINEX File
+////////////////////////////////////////////////////////////////////////////
+void bncoutf::closeFile() {
+  _out.close();
+}
+
+// Next File Epoch (static)
+////////////////////////////////////////////////////////////////////////////
+QString bncoutf::nextEpochStr(const QDateTime& datTim, 
+                             const QString& intStr, QDateTime* nextEpoch) {
+
+  QString epoStr;
+
+  QTime nextTime;
+  QDate nextDate;
+
+  int indHlp = intStr.indexOf("min");
+
+  if ( indHlp != -1) {
+    int step = intStr.left(indHlp-1).toInt();
+    char ch = 'A' + datTim.time().hour();
+    epoStr = QString("_") + ch;
+    if (datTim.time().minute() >= 60-step) {
+      epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
+      if (datTim.time().hour() < 23) {
+        nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
+        nextDate = datTim.date();
+      }
+      else {
+        nextTime.setHMS(0, 0, 0);
+        nextDate = datTim.date().addDays(1);
+      }
+    }
+    else {
+      for (int limit = step; limit <= 60-step; limit += step) {
+        if (datTim.time().minute() < limit) {
+          epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
+          nextTime.setHMS(datTim.time().hour(), limit, 0);
+          nextDate = datTim.date();
+          break;
+        }
+      }
+    }
+  }
+  else if (intStr == "1 hour") {
+    char ch = 'A' + datTim.time().hour();
+    epoStr = QString("_") + ch;
+    if (datTim.time().hour() < 23) {
+      nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
+      nextDate = datTim.date();
+    }
+    else {
+      nextTime.setHMS(0, 0, 0);
+      nextDate = datTim.date().addDays(1);
+    }
+  }
+  else {
+    epoStr = "";
+    nextTime.setHMS(0, 0, 0);
+    nextDate = datTim.date().addDays(1);
+  }
+
+  if (nextEpoch) {
+    *nextEpoch = QDateTime(nextDate, nextTime, Qt::UTC);
+  }
+
+  return epoStr;
+}
+
+// File Name according to RINEX Standards
+////////////////////////////////////////////////////////////////////////////
+void bncoutf::resolveFileName(int GPSweek, const QDateTime& datTim) {
+
+  QString epoStr = nextEpochStr(datTim, _intr, &_nextCloseEpoch);
+
+  int dayOfWeek = datTim.date().dayOfWeek();
+  if (dayOfWeek == 7) {
+    dayOfWeek = 0;
+  }
+
+  _fName = (_path + _prep
+            + QString("%1").arg(GPSweek)
+            + QString("%1").arg(dayOfWeek)
+            + epoStr 
+            + _ext).toAscii();
+}
+
+// Write One Epoch
+////////////////////////////////////////////////////////////////////////////
+t_irc bncoutf::write(int GPSweek, double GPSweeks, const QString&, 
+                     const ColumnVector&, bool append) {
+
+  if (_sampl != 0 && fmod(GPSweeks, _sampl) != 0.0) {
+    return failure;
+  }
+
+  QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks);
+
+  // Close the file
+  // --------------
+  if (_nextCloseEpoch.isValid() && datTim >= _nextCloseEpoch) {
+    closeFile();
+    _headerWritten = false;
+  }
+
+  // Write Header
+  // ------------
+  if (!_headerWritten) {
+    resolveFileName(GPSweek, datTim);
+    _out.setf(ios::showpoint | ios::fixed);
+    if (append && QFile::exists(_fName)) {
+      _out.open(_fName.data(), ios::out | ios::app);
+    }
+    else {
+      _out.open(_fName.data());
+      writeHeader(datTim);
+    }
+    _headerWritten = true;
+  }
+
+  return success;
+}
Index: trunk/BNC/bncoutf.h
===================================================================
--- trunk/BNC/bncoutf.h	(revision 3174)
+++ trunk/BNC/bncoutf.h	(revision 3174)
@@ -0,0 +1,40 @@
+#ifndef BNCOUTF_H
+#define BNCOUTF_H
+
+#include <fstream>
+#include <newmat.h>
+#include <QtCore>
+
+#include "bncutils.h"
+
+class bncoutf {
+ public:
+  bncoutf(const QString& prep, const QString& ext, const QString& path,
+          const QString& intr, int sampl);
+  virtual ~bncoutf();
+
+  virtual t_irc write(int GPSweek, double GPSweeks, const QString& prn, 
+                      const ColumnVector& xx, bool append);
+
+ protected:
+  virtual void writeHeader(const QDateTime& datTim) = 0;
+  virtual void closeFile();
+  std::ofstream _out;
+  int           _sampl;
+
+ private:
+  QString nextEpochStr(const QDateTime& datTim,
+                       const QString& intStr, 
+                       QDateTime* nextEpoch = 0);
+  void resolveFileName(int GPSweek, const QDateTime& datTim);
+
+  bool          _headerWritten;
+  QDateTime     _nextCloseEpoch;
+  QString       _path;
+  QString       _intr;
+  QString       _ext;
+  QString       _prep;
+  QByteArray    _fName;
+};
+
+#endif
Index: trunk/BNC/upload/bncrtnetdecoder.cpp
===================================================================
--- trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3173)
+++ trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3174)
@@ -125,5 +125,5 @@
           in >> prn;
           prns << prn;
-          if ( _ephList.contains(prn) ) {
+          if ( _eph.contains(prn) ) {
             in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5) 
                >> xx(6) >> xx(7) >> xx(8) >> xx(9) >> xx(10)
@@ -142,5 +142,5 @@
             xx(14) *= 1e3;         // z-crd at time + dT
 
-            pair     = _ephList[prn];
+            pair     = _eph[prn];
             pair->xx = xx;
           }
@@ -148,6 +148,6 @@
         else {
           prn = prns[ii];
-          if ( _ephList.contains(prn) ) {
-            pair = _ephList[prn];
+          if ( _eph.contains(prn) ) {
+            pair = _eph[prn];
             xx   = pair->xx;
           }
@@ -158,8 +158,8 @@
         t_eph* ep = 0;
         if (pair) {
-          ep = pair->eph;
-          if (pair->oldEph && ep && 
+          ep = pair->last;
+          if (pair->prev && ep && 
               ep->receptDateTime().secsTo(QDateTime::currentDateTime()) < 60) {
-            ep = pair->oldEph;
+            ep = pair->prev;
           }
         }
@@ -229,14 +229,4 @@
         int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
         if (len > 0) {
-          if (_caster.at(ic)->ic() == 1)  { emit(newOutBytes1(len));}
-          if (_caster.at(ic)->ic() == 2)  { emit(newOutBytes2(len));}
-          if (_caster.at(ic)->ic() == 3)  { emit(newOutBytes3(len));}
-          if (_caster.at(ic)->ic() == 4)  { emit(newOutBytes4(len));}
-          if (_caster.at(ic)->ic() == 5)  { emit(newOutBytes5(len));}
-          if (_caster.at(ic)->ic() == 6)  { emit(newOutBytes6(len));}
-          if (_caster.at(ic)->ic() == 7)  { emit(newOutBytes7(len));}
-          if (_caster.at(ic)->ic() == 8)  { emit(newOutBytes8(len));}
-          if (_caster.at(ic)->ic() == 9)  { emit(newOutBytes9(len));}
-          if (_caster.at(ic)->ic() == 10) { emit(newOutBytes10(len));}
           _caster.at(ic)->write(obuffer, len);
         }
@@ -287,5 +277,5 @@
     ColumnVector vv(3);
 
-    ep->position(GPSweek12, GPSweeks12, xB, vv);
+    ep->position(GPSweek12, GPSweeks12, xB.data(), vv.data());
     
     ColumnVector xyz;
@@ -333,5 +323,5 @@
 
   outLine.sprintf("%d %.1f %s  %3d  %10.3f  %8.3f %8.3f %8.3f\n", 
-                  GPSweek, GPSweeks, ep->prn().toAscii().data(),
+                  GPSweek, GPSweeks, ep->prn().c_str(),
                   ep->IOD(), dClk, rsw(1), rsw(2), rsw(3));
 
@@ -351,5 +341,5 @@
                                const QString& trafo) {
 
-  bnsSettings settings;
+  bncSettings settings;
 
   if (trafo == "ETRF2000") {
Index: trunk/BNC/upload/bncrtnetdecoder.h
===================================================================
--- trunk/BNC/upload/bncrtnetdecoder.h	(revision 3173)
+++ trunk/BNC/upload/bncrtnetdecoder.h	(revision 3174)
@@ -29,4 +29,5 @@
 #include <QtCore>
 #include "bncephuser.h"
+#include "bncuploadcaster.h"
 #include "RTCM/GPSDecoder.h"
 
@@ -48,5 +49,5 @@
 
   QString _buffer;
-
+  QList<bncUploadCaster*> _caster;
   int    _GPSweek;
   double _GPSweeks;
Index: trunk/BNC/upload/bncuploadcaster.cpp
===================================================================
--- trunk/BNC/upload/bncuploadcaster.cpp	(revision 3173)
+++ trunk/BNC/upload/bncuploadcaster.cpp	(revision 3174)
@@ -27,5 +27,6 @@
 bncUploadCaster::bncUploadCaster(const QString& mountpoint,
                                  const QString& outHost, int outPort,
-                                 const QString& password,  
+                                 const QString& password, 
+                                 const QString& crdTrafo, bool  CoM, 
                                  const QString& outFileName) {
 
@@ -36,4 +37,6 @@
   _outPort    = outPort;
   _password   = password;
+  _crdTrafo   = crdTrafo;
+  _CoM        = CoM;
 
   _outSocket  = 0;
Index: trunk/BNC/upload/bncuploadcaster.h
===================================================================
--- trunk/BNC/upload/bncuploadcaster.h	(revision 3173)
+++ trunk/BNC/upload/bncuploadcaster.h	(revision 3174)
@@ -9,5 +9,6 @@
   bncUploadCaster(const QString& mountpoint,
                   const QString& outHost, int outPort,
-                  const QString& password,  
+                  const QString& password, 
+                  const QString& crdTrafo, bool  CoM, 
                   const QString& outFileName);
   virtual ~bncUploadCaster();
@@ -16,4 +17,6 @@
   void printAscii(const QString& line);
   bool usedSocket() const {return _outSocket;}
+  QString crdTrafo() const {return _crdTrafo;}
+  bool CoM() const {return _CoM;}
 
  signals:
@@ -26,4 +29,6 @@
   int          _outPort;
   QString      _password;
+  QString      _crdTrafo;
+  bool         _CoM;
   QTcpSocket*  _outSocket;
   int          _sOpenTrial;
