Changeset 3171 in ntrip


Ignore:
Timestamp:
Mar 29, 2011, 4:10:33 PM (13 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncgetthread.cpp

    r3168 r3171  
    319319  else if (_format.indexOf("RTNET") != -1) {
    320320    emit(newMessage(_staID + ": Get data in RTNet format", true));
    321     _decoder = new bncRtnetDecoder(_staID);
     321    _decoder = new bncRtnetDecoder();
    322322  }
    323323  else {
  • trunk/BNC/bncutils.cpp

    r3044 r3171  
    309309//
    310310////////////////////////////////////////////////////////////////////////////
     311double djul(int jj, int mm, double tt) {
     312  int    ii, kk;
     313  double  djul ;
     314  if( mm <= 2 ) {
     315    jj = jj - 1;
     316    mm = mm + 12;
     317  } 
     318  ii   = jj/100;
     319  kk   = 2 - ii + ii/4;
     320  djul = (365.25*jj - fmod( 365.25*jj, 1.0 )) - 679006.0;
     321  djul = djul + floor( 30.6001*(mm + 1) ) + tt + kk;
     322  return djul;
     323}
     324
     325//
     326////////////////////////////////////////////////////////////////////////////
     327void jdgp(double tjul, double & second, int & nweek) {
     328  double      deltat;
     329  deltat = tjul - 44244.0 ;
     330  // current gps week
     331  nweek = (int) floor(deltat/7.0);
     332  // seconds past midnight of last weekend
     333  second = (deltat - (nweek)*7.0)*86400.0;
     334}
     335
     336//
     337////////////////////////////////////////////////////////////////////////////
    311338void GPSweekFromDateAndTime(const QDateTime& dateTime,
    312339                            int& GPSWeek, double& GPSWeeks) {
     
    321348  GPSWeeks = (weekDay - 1) * 86400.0
    322349             - dateTime.time().msecsTo(QTime()) / 1e3;
     350}
     351
     352//
     353////////////////////////////////////////////////////////////////////////////
     354void GPSweekFromYMDhms(int year, int month, int day, int hour, int min,
     355                       double sec, int& GPSWeek, double& GPSWeeks) {
     356
     357  double mjd = djul(year, month, day);
     358
     359  jdgp(mjd, GPSWeeks, GPSWeek);
     360  GPSWeeks += hour * 3600.0 + min * 60.0 + sec; 
    323361}
    324362
  • trunk/BNC/bncutils.h

    r3044 r3171  
    6363                            int& GPSWeek, double& GPSWeeks);
    6464
     65void GPSweekFromYMDhms(int year, int month, int day, int hour, int min,
     66                       double sec, int& GPSWeek, double& GPSWeeks);
     67
    6568void mjdFromDateAndTime(const QDateTime& dateTime, int& mjd, double& dayfrac);
    6669
  • trunk/BNC/upload/bncrtnetdecoder.cpp

    r3166 r3171  
    4848// Constructor
    4949////////////////////////////////////////////////////////////////////////
    50 bncRtnetDecoder::bncRtnetDecoder(const QString& fileName) {
    51 
     50bncRtnetDecoder::bncRtnetDecoder() {
    5251  bncSettings settings;
    53   QString path = settings.value("rnxPath").toString();
    54   expandEnvVar(path);
    55 
    56   if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
    57     path += QDir::separator();
    58   }
    59 
    60   _fileName = path + fileName;
    61 
    62   _out = 0;
     52  _year = 0;
    6353}
    6454
     
    6656////////////////////////////////////////////////////////////////////////
    6757bncRtnetDecoder::~bncRtnetDecoder() {
    68   delete _out;
    6958}
    7059
    71 // Reopen Output File
     60// Decode Method
    7261////////////////////////////////////////////////////////////////////////
    73 void bncRtnetDecoder::reopen() {
    74   QDate currDate = currentDateAndTimeGPS().date();
    75   if (!_out || _fileDate != currDate) {
    76     delete _out;
    77     QByteArray fileName =
    78            (_fileName + "_" + currDate.toString("yyMMdd")).toAscii();
    79     bncSettings settings;
    80     if (Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
    81       _out = new ofstream(fileName.data(), ios::out | ios::app);
    82     }
    83     else {
    84       _out = new ofstream(fileName.data());
    85     }
    86     _fileDate = currDate;
    87   }
     62void bncRtnetDecoder::readEpochTime(const QString& line) {
     63  QTextStream in(line.toAscii());
     64  QString hlp;
     65  in >> hlp >> _year >> _month >> _day >> _hour >> _min >> _sec;
     66  GPSweekFromYMDhms(_year, _month, _day, _hour, _min, _sec, _GPSweek, _GPSweeks);
    8867}
    8968
     
    9170////////////////////////////////////////////////////////////////////////
    9271t_irc bncRtnetDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
     72
    9373  errmsg.clear();
    94   reopen();
    95   _out->write(buffer, bufLen);
    96   _out->flush();
     74
     75  _buffer.append(QByteArray(buffer, bufLen));
     76
     77  int iLast = _buffer.lastIndexOf('\n');
     78
     79  if (iLast != -1) {
     80    QStringList lines = _buffer.split('\n', QString::SkipEmptyParts);
     81    _buffer = _buffer.mid(iLast+1);
     82    cout << "number of lines = " << lines.size() << endl;
     83    for (int ii = 0; ii < lines.size(); ii++) {
     84      if (lines[ii].indexOf('*') != -1) {
     85        readEpochTime(lines[ii]);
     86        cout << "epoch: " << lines[ii].toAscii().data() << endl;
     87      }
     88      else if (_year != 0) {
     89        cout << "pos: " << lines[ii].toAscii().data() << endl;
     90      }
     91    }
     92  }
     93
    9794  return success;
    9895}
  • trunk/BNC/upload/bncrtnetdecoder.h

    r3167 r3171  
    2323// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    2424
    25 #ifndef INC_BNCRTNETDECODER_H
    26 #define INC_BNCRTNETDECODER_H
     25#ifndef BNCRTNETDECODER_H
     26#define BNCRTNETDECODER_H
    2727
    2828#include <fstream>
     
    3333class bncRtnetDecoder: public GPSDecoder, public bncEphUser {
    3434 public:
    35   bncRtnetDecoder(const QString& fileName);
     35  bncRtnetDecoder();
    3636  ~bncRtnetDecoder();
    3737  virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
    3838 private:
    39   void reopen();
    40   QString        _fileName;
    41   std::ofstream* _out;
    42   QDate          _fileDate;
     39  void readEpochTime(const QString& line);
     40
     41  QString _buffer;
     42
     43  int    _GPSweek;
     44  double _GPSweeks;
     45  int    _year;
     46  int    _month;
     47  int    _day;
     48  int    _hour;
     49  int    _min;
     50  double _sec;
     51
     52  double _dx;
     53  double _dy;
     54  double _dz;
     55  double _dxr;
     56  double _dyr;
     57  double _dzr;
     58  double _ox;
     59  double _oy;
     60  double _oz;
     61  double _oxr;
     62  double _oyr;
     63  double _ozr;
     64  double _sc;
     65  double _scr;
     66  double _t0;
    4367};
    4468
Note: See TracChangeset for help on using the changeset viewer.