Changeset 3184 in ntrip


Ignore:
Timestamp:
Mar 29, 2011, 8:19:50 PM (14 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncclockrinex.cpp

    r3181 r3184  
    2626// Constructor
    2727////////////////////////////////////////////////////////////////////////////
    28 bncClockRinex::bncClockRinex(const QString& prep, const QString& ext, const QString& path,
    29                              const QString& intr, int sampl)
    30   : bncoutf(prep, ext, path, intr, sampl) {
     28bncClockRinex::bncClockRinex(const QString& sklFileName, const QString& intr,
     29                             int sampl)
     30  : bncoutf(sklFileName, intr, sampl) {
    3131  bncSettings settings;
    32   _append = Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked;
    3332}
    3433
     
    4342                   const ColumnVector& xx) {
    4443
    45   if (bncoutf::write(GPSweek, GPSweeks, prn, xx, _append) == success) {
     44  if (reopen(GPSweek, GPSweeks) == success) {
    4645
    4746      QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks);
  • trunk/BNC/bncclockrinex.h

    r3181 r3184  
    1010class bncClockRinex : public bncoutf {
    1111 public:
    12   bncClockRinex(const QString& prep, const QString& ext, const QString& path,
    13                 const QString& intr, int sampl);
     12  bncClockRinex(const QString& sklFileName, const QString& intr, int sampl);
    1413  virtual ~bncClockRinex();
    1514  virtual t_irc write(int GPSweek, double GPSweeks, const QString& prn,
  • trunk/BNC/bncoutf.cpp

    r3174 r3184  
    2020
    2121#include "bncoutf.h"
     22#include "bncsettings.h"
    2223
    2324using namespace std;
     
    2526// Constructor
    2627////////////////////////////////////////////////////////////////////////////
    27 bncoutf::bncoutf(const QString& prep, const QString& ext, const QString& path,
    28                  const QString& intr, int sampl) {
     28bncoutf::bncoutf(const QString& sklFileName, const QString& intr, int sampl) {
     29
     30  bncSettings settings;
    2931
    3032  _headerWritten = false;
    31   _prep          = prep;
    32   _ext           = ext;
    3333  _sampl         = sampl;
    3434  _intr          = intr;
    35   _path          = path;
     35
     36  QFileInfo fileInfo(sklFileName);
     37  _path        = fileInfo.absolutePath() + QDir::separator();
     38  _sklBaseName = fileInfo.baseName();
     39  _extension   = fileInfo.completeSuffix();
     40
    3641  expandEnvVar(_path);
    37   if ( _path.length() > 0 && _path[_path.length()-1] != QDir::separator() ) {
    38     _path += QDir::separator();
     42  if (!_extension.isEmpty()) {
     43    _extension = "." + _extension;
    3944  }
     45
     46  _append = Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked;
    4047}
    4148
     
    5259}
    5360
    54 // Next File Epoch (static)
     61// Epoch String
    5562////////////////////////////////////////////////////////////////////////////
    56 QString bncoutf::nextEpochStr(const QDateTime& datTim,
    57                              const QString& intStr, QDateTime* nextEpoch) {
     63QString bncoutf::epochStr(const QDateTime& datTim, const QString& intStr) {
    5864
    5965  QString epoStr;
    60 
    61   QTime nextTime;
    62   QDate nextDate;
    6366
    6467  int indHlp = intStr.indexOf("min");
     
    7073    if (datTim.time().minute() >= 60-step) {
    7174      epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
    72       if (datTim.time().hour() < 23) {
    73         nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
    74         nextDate = datTim.date();
    75       }
    76       else {
    77         nextTime.setHMS(0, 0, 0);
    78         nextDate = datTim.date().addDays(1);
    79       }
    8075    }
    8176    else {
     
    8378        if (datTim.time().minute() < limit) {
    8479          epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
    85           nextTime.setHMS(datTim.time().hour(), limit, 0);
    86           nextDate = datTim.date();
    8780          break;
    8881        }
     
    9386    char ch = 'A' + datTim.time().hour();
    9487    epoStr = QString("_") + ch;
    95     if (datTim.time().hour() < 23) {
    96       nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
    97       nextDate = datTim.date();
    98     }
    99     else {
    100       nextTime.setHMS(0, 0, 0);
    101       nextDate = datTim.date().addDays(1);
    102     }
    10388  }
    10489  else {
    10590    epoStr = "";
    106     nextTime.setHMS(0, 0, 0);
    107     nextDate = datTim.date().addDays(1);
    108   }
    109 
    110   if (nextEpoch) {
    111     *nextEpoch = QDateTime(nextDate, nextTime, Qt::UTC);
    11291  }
    11392
     
    11796// File Name according to RINEX Standards
    11897////////////////////////////////////////////////////////////////////////////
    119 void bncoutf::resolveFileName(int GPSweek, const QDateTime& datTim) {
    120 
    121   QString epoStr = nextEpochStr(datTim, _intr, &_nextCloseEpoch);
     98QString bncoutf::resolveFileName(int GPSweek, const QDateTime& datTim) {
    12299
    123100  int dayOfWeek = datTim.date().dayOfWeek();
     
    125102    dayOfWeek = 0;
    126103  }
     104  QString gpswd    = QString().arg(GPSweek).arg(dayOfWeek);
     105  QString baseName = _sklBaseName.replace("${GPSWD}", gpswd);
     106  QString epoStr   = epochStr(datTim, _intr);
    127107
    128   _fName = (_path + _prep
    129             + QString("%1").arg(GPSweek)
    130             + QString("%1").arg(dayOfWeek)
    131             + epoStr
    132             + _ext).toAscii();
     108  return _path + baseName + epoStr + _extension;
    133109}
    134110
    135 // Write One Epoch
     111// Re-Open Output File
    136112////////////////////////////////////////////////////////////////////////////
    137 t_irc bncoutf::write(int GPSweek, double GPSweeks, const QString&,
    138                      const ColumnVector&, bool append) {
     113t_irc bncoutf::reopen(int GPSweek, double GPSweeks) {
    139114
    140115  if (_sampl != 0 && fmod(GPSweeks, _sampl) != 0.0) {
     
    144119  QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks);
    145120
     121  QString newFileName = resolveFileName(GPSweek, datTim);
     122
    146123  // Close the file
    147124  // --------------
    148   if (_nextCloseEpoch.isValid() && datTim >= _nextCloseEpoch) {
     125  if (newFileName != _fName) {
    149126    closeFile();
    150127    _headerWritten = false;
     128    _fName = newFileName;
    151129  }
    152130
    153   // Write Header
    154   // ------------
     131  // Re-Open File, Write Header
     132  // --------------------------
    155133  if (!_headerWritten) {
    156     resolveFileName(GPSweek, datTim);
    157134    _out.setf(ios::showpoint | ios::fixed);
    158     if (append && QFile::exists(_fName)) {
    159       _out.open(_fName.data(), ios::out | ios::app);
     135    if (_append && QFile::exists(_fName)) {
     136      _out.open(_fName.toAscii().data(), ios::out | ios::app);
    160137    }
    161138    else {
    162       _out.open(_fName.data());
     139      _out.open(_fName.toAscii().data());
    163140      writeHeader(datTim);
    164141    }
     
    168145  return success;
    169146}
     147
     148// Write String
     149////////////////////////////////////////////////////////////////////////////
     150t_irc bncoutf::write(int GPSweek, double GPSweeks, const QString& str) {
     151  reopen(GPSweek, GPSweeks);
     152  _out << str.toAscii().data();
     153  _out.flush();
     154  return success;
     155}
  • trunk/BNC/bncoutf.h

    r3183 r3184  
    1010class bncoutf {
    1111 public:
    12   bncoutf(const QString& prep, const QString& ext, const QString& path,
    13           const QString& intr, int sampl);
     12  bncoutf(const QString& sklFileName, const QString& intr, int sampl);
    1413  virtual ~bncoutf();
    15 
    16   virtual t_irc write(int GPSweek, double GPSweeks, const QString& prn,
    17                       const ColumnVector& xx, bool append);
     14  t_irc write(int GPSweek, double GPSweeks, const QString& str);
    1815
    1916 protected:
    20   virtual void writeHeader(const QDateTime& /* datTim */) {}
    21   virtual void closeFile();
     17  virtual t_irc reopen(int GPSweek, double GPSweeks);
     18  virtual void  writeHeader(const QDateTime& /* datTim */) {}
     19  virtual void  closeFile();
    2220  std::ofstream _out;
    2321  int           _sampl;
    2422
    2523 private:
    26   QString nextEpochStr(const QDateTime& datTim,
    27                        const QString& intStr,
    28                        QDateTime* nextEpoch = 0);
    29   void resolveFileName(int GPSweek, const QDateTime& datTim);
     24  QString epochStr(const QDateTime& datTim, const QString& intStr);
     25  QString resolveFileName(int GPSweek, const QDateTime& datTim);
    3026
    31   bool          _headerWritten;
    32   QDateTime     _nextCloseEpoch;
    33   QString       _path;
    34   QString       _intr;
    35   QString       _ext;
    36   QString       _prep;
    37   QByteArray    _fName;
     27  bool    _headerWritten;
     28  QString _path;
     29  QString _sklBaseName;
     30  QString _extension;
     31  QString _intr;
     32  QString _fName;
     33  bool    _append;
    3834};
    3935
  • trunk/BNC/bncsp3.cpp

    r3181 r3184  
    2626// Constructor
    2727////////////////////////////////////////////////////////////////////////////
    28 bncSP3::bncSP3(const QString& prep, const QString& ext, const QString& path,
    29                const QString& intr, int sampl)
    30   : bncoutf(prep, ext, path, intr, sampl) {
     28bncSP3::bncSP3(const QString& sklFileName, const QString& intr, int sampl)
     29  : bncoutf(sklFileName, intr, sampl) {
    3130
    3231  _lastGPSweek  = 0;
     
    4241////////////////////////////////////////////////////////////////////////////
    4342t_irc bncSP3::write(int GPSweek, double GPSweeks, const QString& prn,
    44                     const ColumnVector& xx, bool append) {
     43                    const ColumnVector& xx) {
    4544
    46   if ( bncoutf::write(GPSweek, GPSweeks, prn, xx, append) == success) {
     45  if (reopen(GPSweek, GPSweeks) == success) {
    4746
    4847    if (_lastGPSweek != GPSweek || _lastGPSweeks != GPSweeks) {
  • trunk/BNC/bncsp3.h

    r3181 r3184  
    1010class bncSP3 : public bncoutf {
    1111 public:
    12   bncSP3(const QString& prep, const QString& ext, const QString& path,
    13          const QString& intr, int sampl);
     12  bncSP3(const QString& sklFileName, const QString& intr, int sampl);
    1413  virtual ~bncSP3();
    15   virtual t_irc write(int GPSweek, double GPSweeks, const QString& prn,
    16                       const ColumnVector& xx, bool append);
     14  t_irc write(int GPSweek, double GPSweeks, const QString& prn,
     15              const ColumnVector& xx);
    1716
    1817 private:
  • trunk/BNC/combination/bnccomb.cpp

    r3181 r3184  
    180180  }
    181181  else {
    182     QString prep      = "BNC";
    183     QString ext       = ".sp3";
    184     QString path      = settings.value("cmbSP3Path").toString();
     182    QString sklFileName = settings.value("cmbSP3Path").toString()
     183                        + QDir::separator() + "BNC.sp3";
    185184    QString interval  = "";
    186185    int     sampl     = 0;
    187     _sp3 = new bncSP3(prep, ext, path, interval, sampl);
    188   }
    189 
    190   _append = Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked;
     186    _sp3 = new bncSP3(sklFileName, interval, sampl);
     187  }
    191188
    192189  // ANTEX File
     
    449446        }
    450447      }
    451       _sp3->write(resTime.gpsw(), resTime.gpssec(), corr->prn, xc, _append);
     448      _sp3->write(resTime.gpsw(), resTime.gpssec(), corr->prn, xc);
    452449    }
    453450
  • trunk/BNC/combination/bnccomb.h

    r3181 r3184  
    9090  std::ofstream*        _out;
    9191  bncSP3*               _sp3;
    92   bool                  _append;
    9392  bncAntex*             _antex;
    9493};
  • trunk/BNC/upload/bncuploadcaster.cpp

    r3182 r3184  
    4949  _outSocket  = 0;
    5050  _sOpenTrial = 0;
    51 
    52   _append = Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked;
    5351
    5452  if (outFileName.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.