Index: trunk/BNC/bncgetthread.cpp
===================================================================
--- trunk/BNC/bncgetthread.cpp	(revision 3170)
+++ trunk/BNC/bncgetthread.cpp	(revision 3171)
@@ -319,5 +319,5 @@
   else if (_format.indexOf("RTNET") != -1) {
     emit(newMessage(_staID + ": Get data in RTNet format", true));
-    _decoder = new bncRtnetDecoder(_staID);
+    _decoder = new bncRtnetDecoder();
   }
   else {
Index: trunk/BNC/bncutils.cpp
===================================================================
--- trunk/BNC/bncutils.cpp	(revision 3170)
+++ trunk/BNC/bncutils.cpp	(revision 3171)
@@ -309,4 +309,31 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
+double djul(int jj, int mm, double tt) {
+  int    ii, kk;
+  double  djul ;
+  if( mm <= 2 ) {
+    jj = jj - 1;
+    mm = mm + 12;
+  }  
+  ii   = jj/100;
+  kk   = 2 - ii + ii/4;
+  djul = (365.25*jj - fmod( 365.25*jj, 1.0 )) - 679006.0;
+  djul = djul + floor( 30.6001*(mm + 1) ) + tt + kk;
+  return djul;
+} 
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void jdgp(double tjul, double & second, int & nweek) {
+  double      deltat;
+  deltat = tjul - 44244.0 ;
+  // current gps week
+  nweek = (int) floor(deltat/7.0);
+  // seconds past midnight of last weekend
+  second = (deltat - (nweek)*7.0)*86400.0;
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
 void GPSweekFromDateAndTime(const QDateTime& dateTime, 
                             int& GPSWeek, double& GPSWeeks) {
@@ -321,4 +348,15 @@
   GPSWeeks = (weekDay - 1) * 86400.0
              - dateTime.time().msecsTo(QTime()) / 1e3; 
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void GPSweekFromYMDhms(int year, int month, int day, int hour, int min,
+                       double sec, int& GPSWeek, double& GPSWeeks) {
+
+  double mjd = djul(year, month, day);
+
+  jdgp(mjd, GPSWeeks, GPSWeek);
+  GPSWeeks += hour * 3600.0 + min * 60.0 + sec;  
 }
 
Index: trunk/BNC/bncutils.h
===================================================================
--- trunk/BNC/bncutils.h	(revision 3170)
+++ trunk/BNC/bncutils.h	(revision 3171)
@@ -63,4 +63,7 @@
                             int& GPSWeek, double& GPSWeeks);
 
+void GPSweekFromYMDhms(int year, int month, int day, int hour, int min,
+                       double sec, int& GPSWeek, double& GPSWeeks);
+
 void mjdFromDateAndTime(const QDateTime& dateTime, int& mjd, double& dayfrac);
 
Index: trunk/BNC/upload/bncrtnetdecoder.cpp
===================================================================
--- trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3170)
+++ trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3171)
@@ -48,17 +48,7 @@
 // Constructor
 //////////////////////////////////////////////////////////////////////// 
-bncRtnetDecoder::bncRtnetDecoder(const QString& fileName) {
-
+bncRtnetDecoder::bncRtnetDecoder() {
   bncSettings settings;
-  QString path = settings.value("rnxPath").toString();
-  expandEnvVar(path);
-
-  if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
-    path += QDir::separator();
-  }
-
-  _fileName = path + fileName;
-
-  _out = 0;
+  _year = 0;
 }
 
@@ -66,24 +56,13 @@
 //////////////////////////////////////////////////////////////////////// 
 bncRtnetDecoder::~bncRtnetDecoder() {
-  delete _out;
 }
 
-// Reopen Output File
+// Decode Method
 //////////////////////////////////////////////////////////////////////// 
-void bncRtnetDecoder::reopen() {
-  QDate currDate = currentDateAndTimeGPS().date();
-  if (!_out || _fileDate != currDate) {
-    delete _out;
-    QByteArray fileName = 
-           (_fileName + "_" + currDate.toString("yyMMdd")).toAscii();
-    bncSettings settings;
-    if (Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
-      _out = new ofstream(fileName.data(), ios::out | ios::app);
-    }
-    else {
-      _out = new ofstream(fileName.data());
-    }
-    _fileDate = currDate;
-  }
+void bncRtnetDecoder::readEpochTime(const QString& line) {
+  QTextStream in(line.toAscii());
+  QString hlp;
+  in >> hlp >> _year >> _month >> _day >> _hour >> _min >> _sec;
+  GPSweekFromYMDhms(_year, _month, _day, _hour, _min, _sec, _GPSweek, _GPSweeks);
 }
 
@@ -91,8 +70,26 @@
 //////////////////////////////////////////////////////////////////////// 
 t_irc bncRtnetDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
+
   errmsg.clear();
-  reopen();
-  _out->write(buffer, bufLen);
-  _out->flush();
+
+  _buffer.append(QByteArray(buffer, bufLen));
+
+  int iLast = _buffer.lastIndexOf('\n');
+
+  if (iLast != -1) {
+    QStringList lines = _buffer.split('\n', QString::SkipEmptyParts);
+    _buffer = _buffer.mid(iLast+1);
+    cout << "number of lines = " << lines.size() << endl;
+    for (int ii = 0; ii < lines.size(); ii++) {
+      if (lines[ii].indexOf('*') != -1) {
+        readEpochTime(lines[ii]);
+        cout << "epoch: " << lines[ii].toAscii().data() << endl;
+      }
+      else if (_year != 0) {
+        cout << "pos: " << lines[ii].toAscii().data() << endl;
+      }
+    }
+  }
+
   return success;
 }
Index: trunk/BNC/upload/bncrtnetdecoder.h
===================================================================
--- trunk/BNC/upload/bncrtnetdecoder.h	(revision 3170)
+++ trunk/BNC/upload/bncrtnetdecoder.h	(revision 3171)
@@ -23,6 +23,6 @@
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-#ifndef INC_BNCRTNETDECODER_H
-#define INC_BNCRTNETDECODER_H
+#ifndef BNCRTNETDECODER_H
+#define BNCRTNETDECODER_H
 
 #include <fstream>
@@ -33,12 +33,36 @@
 class bncRtnetDecoder: public GPSDecoder, public bncEphUser {
  public:
-  bncRtnetDecoder(const QString& fileName);
+  bncRtnetDecoder();
   ~bncRtnetDecoder();
   virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
  private:
-  void reopen();
-  QString        _fileName;
-  std::ofstream* _out;
-  QDate          _fileDate;
+  void readEpochTime(const QString& line);
+
+  QString _buffer;
+
+  int    _GPSweek;
+  double _GPSweeks;
+  int    _year;
+  int    _month;
+  int    _day;
+  int    _hour;
+  int    _min;
+  double _sec;
+
+  double _dx;
+  double _dy;
+  double _dz;
+  double _dxr;
+  double _dyr;
+  double _dzr;
+  double _ox;
+  double _oy;
+  double _oz;
+  double _oxr;
+  double _oyr;
+  double _ozr;
+  double _sc;
+  double _scr;
+  double _t0;
 };
 
