Ignore:
Timestamp:
Mar 29, 2011, 4:10:33 PM (13 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.