Index: trunk/BNC/bnc.pro
===================================================================
--- trunk/BNC/bnc.pro	(revision 2518)
+++ trunk/BNC/bnc.pro	(revision 2519)
@@ -40,5 +40,5 @@
           bncserialport.h bncnetquerys.h bncfigure.h                  \ 
           bncfigurelate.h bncpppclient.h bncversion.h                 \ 
-          bancroft.h bncmodel.h bncfigureppp.h                        \ 
+          bancroft.h bncmodel.h bncfigureppp.h bncrawfile.h           \ 
           RTCM/GPSDecoder.h RTCM/RTCM2.h RTCM/RTCM2Decoder.h          \
           RTCM/RTCM2_2021.h RTCM/rtcm_utils.h                         \
@@ -69,5 +69,5 @@
           bncserialport.cpp bncnetquerys.cpp bncfigure.cpp            \
           bncfigurelate.cpp bncpppclient.cpp bnctime.cpp              \
-          bancroft.cpp bncmodel.cpp bncfigureppp.cpp                  \
+          bancroft.cpp bncmodel.cpp bncfigureppp.cpp bncrawfile.cpp   \
           RTCM/RTCM2.cpp RTCM/RTCM2Decoder.cpp                        \
           RTCM/RTCM2_2021.cpp RTCM/rtcm_utils.cpp                     \
Index: trunk/BNC/bncapp.cpp
===================================================================
--- trunk/BNC/bncapp.cpp	(revision 2518)
+++ trunk/BNC/bncapp.cpp	(revision 2519)
@@ -60,5 +60,5 @@
   _logStream   = 0;
   _caster      = 0;
-  _rawOutFile  = 0;
+  _rawFile     = 0;
 
   // Lists of Ephemeris
@@ -129,5 +129,5 @@
   delete _currentDateAndTimeGPS;
 
-  delete _rawOutFile;
+  delete _rawFile;
 }
 
@@ -713,25 +713,14 @@
   QMutexLocker locker(&_mutex);
 
-  if (!_rawOutFile) {
+  if (!_rawFile) {
     bncSettings settings;
-    QString rawOutFileName = settings.value("rawOutFile").toString();
-    if (!rawOutFileName.isEmpty()) {
-      _rawOutFile = new QFile(rawOutFileName);
-      _rawOutFile->open(QIODevice::WriteOnly);
-
-      QByteArray header = 
-        "1 Version of BNC raw file\n" +
-	currentDateAndTimeGPS().toString(Qt::ISODate).toAscii();
-
-      _rawOutFile->write(header);
-    }
-  }
-
-  if (_rawOutFile) {
-    QString chunkHeader = 
-      QString("\n%1 %2 %3\n").arg(QString(staID)).arg(QString(format)).arg(data.size());
-    _rawOutFile->write(chunkHeader.toAscii());
-    _rawOutFile->write(data);
-    _rawOutFile->flush();
-  }
-}
+    QByteArray fileName = settings.value("rawOutFile").toByteArray();
+    if (!fileName.isEmpty()) {
+      _rawFile = new bncRawFile(fileName, format, bncRawFile::output);
+    }
+  }
+
+  if (_rawFile) {
+    _rawFile->writeRawData(data, staID, format);
+  }
+}
Index: trunk/BNC/bncapp.h
===================================================================
--- trunk/BNC/bncapp.h	(revision 2518)
+++ trunk/BNC/bncapp.h	(revision 2519)
@@ -31,4 +31,5 @@
 
 #include "bnccaster.h"
+#include "bncrawfile.h"
 #include "RTCM3/RTCM3Decoder.h"
 
@@ -75,5 +76,4 @@
 
     QFile*            _logFile;
-    QFile*            _rawOutFile;
     QTextStream*      _logStream;
     int               _logFileFlag;
@@ -105,5 +105,6 @@
     QMultiMap<long, QString>* _corrs;
     QString             _confFileName;
-    QDate          _fileDate;
+    QDate               _fileDate;
+    bncRawFile*         _rawFile;
 };
 #endif
Index: trunk/BNC/bncgetthread.cpp
===================================================================
--- trunk/BNC/bncgetthread.cpp	(revision 2518)
+++ trunk/BNC/bncgetthread.cpp	(revision 2519)
@@ -75,15 +75,10 @@
 // Constructor 1
 ////////////////////////////////////////////////////////////////////////////
-bncGetThread::bncGetThread(const QByteArray& rawInpFileName, 
-                           const QByteArray& format) {
-
-  _rawInpFile = new QFile(rawInpFileName);
-  _rawInpFile->open(QIODevice::ReadOnly);
-  _format     = format;
-  _staID      = rawInpFileName.mid(
-                       rawInpFileName.lastIndexOf(QDir::separator())+1,5);  
-
-  _rawOutput = false;
-
+bncGetThread::bncGetThread(bncRawFile* rawFile) {
+
+  _rawFile      = rawFile;
+  _format       = rawFile->format();
+  _staID        = rawFile->staID();
+  _rawOutput    = false;
   _ntripVersion = "N";
 
@@ -99,5 +94,5 @@
                            const QByteArray& nmea, 
                            const QByteArray& ntripVersion, const QByteArray& extraStaID) {
-  _rawInpFile   = 0;
+  _rawFile      = 0;
   _mountPoint   = mountPoint;
   _staID        = (extraStaID.size() == 0 ? mountPoint.path().mid(1).toAscii() : extraStaID);
@@ -305,9 +300,5 @@
            _format.indexOf("RTCM 3") != -1 ) {
     emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
-    bool inputFromFile = false;
-    if (_rawInpFile != 0) {
-      inputFromFile = true;
-    }
-    _decoder = new RTCM3Decoder(_staID, inputFromFile);
+    _decoder = new RTCM3Decoder(_staID, bool(_rawFile != 0));
     connect((RTCM3Decoder*) _decoder, SIGNAL(newMessage(QByteArray,bool)), 
             this, SIGNAL(newMessage(QByteArray,bool)));
@@ -348,5 +339,5 @@
   delete _decoder;
   delete _rnx;
-  delete _rawInpFile;
+  delete _rawFile;
   delete _serialOutFile;
   delete _serialPort;
@@ -395,11 +386,6 @@
         _query->waitForReadyRead(data);
       }
-      else if (_rawInpFile) {
-        const qint64 maxBytes = 1024;
-        data = _rawInpFile->read(maxBytes);
-
-        //// beg test
-        msleep(10);
-        //// end test
+      else if (_rawFile) {
+        data = _rawFile->read();
 
         if (data.isEmpty()) {
@@ -457,5 +443,5 @@
         // Check observation epoch
         // -----------------------
-        if (!_rawInpFile && !dynamic_cast<gpssDecoder*>(_decoder)) {
+        if (!_rawFile && !dynamic_cast<gpssDecoder*>(_decoder)) {
           int week;
           double sec;
@@ -525,5 +511,5 @@
   // Start a new query
   // -----------------
-  if (!_rawInpFile) {
+  if (!_rawFile) {
 
     sleep(_nextSleep);
Index: trunk/BNC/bncgetthread.h
===================================================================
--- trunk/BNC/bncgetthread.h	(revision 2518)
+++ trunk/BNC/bncgetthread.h	(revision 2519)
@@ -36,4 +36,5 @@
 #include "bncnetquery.h"
 #include "bnctime.h"
+#include "bncrawfile.h"
 
 class bncRinex;
@@ -46,5 +47,5 @@
 
  public:
-   bncGetThread(const QByteArray&  rawInpFileName, const QByteArray& format);
+   bncGetThread(bncRawFile* rawFile);
    bncGetThread(const QUrl& mountPoint, 
                 const QByteArray& format,
@@ -117,5 +118,5 @@
    int             _samplingRate;
    bncRinex*       _rnx;
-   QFile*          _rawInpFile;
+   bncRawFile*     _rawFile;
    QextSerialPort* _serialPort;
    bool            _isToBeDeleted;
Index: trunk/BNC/bncmain.cpp
===================================================================
--- trunk/BNC/bncmain.cpp	(revision 2518)
+++ trunk/BNC/bncmain.cpp	(revision 2519)
@@ -64,6 +64,4 @@
   QByteArray rawFileName;
   QByteArray format; 
-  QString    dateString;
-  QString    timeString;
   QString    confFileName;
 
@@ -82,10 +80,4 @@
       if (QByteArray(argv[ii]).indexOf("-format") != -1) {
         format = QByteArray(argv[ii+1]);
-      }
-      if (QByteArray(argv[ii]).indexOf("-date")   != -1) {
-        dateString = QString(argv[ii+1]);
-      }
-      if (QByteArray(argv[ii]).indexOf("-time")   != -1) {
-        timeString = QString(argv[ii+1]);
       }
     }
@@ -158,14 +150,13 @@
     // -----------------------------
     else {
-      if ( format.isEmpty() || dateString.isEmpty() || timeString.isEmpty() ) {
+      if ( format.isEmpty() ) {
         cout << printHelp.toAscii().data() << endl;
         exit(0);
       }
 
-      app._currentDateAndTimeGPS = 
-        new QDateTime(QDate::fromString(dateString, Qt::ISODate), 
-                      QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
+      bncRawFile* rawFile = new bncRawFile(rawFileName, format, 
+                                           bncRawFile::input);
 
-      bncGetThread* getThread = new bncGetThread(rawFileName, format);
+      bncGetThread* getThread = new bncGetThread(rawFile);
       caster->addGetThread(getThread);
     }
