Changeset 3184 in ntrip for trunk/BNC/bncoutf.cpp
- Timestamp:
- Mar 29, 2011, 8:19:50 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncoutf.cpp
r3174 r3184 20 20 21 21 #include "bncoutf.h" 22 #include "bncsettings.h" 22 23 23 24 using namespace std; … … 25 26 // Constructor 26 27 //////////////////////////////////////////////////////////////////////////// 27 bncoutf::bncoutf(const QString& prep, const QString& ext, const QString& path, 28 const QString& intr, int sampl) { 28 bncoutf::bncoutf(const QString& sklFileName, const QString& intr, int sampl) { 29 30 bncSettings settings; 29 31 30 32 _headerWritten = false; 31 _prep = prep;32 _ext = ext;33 33 _sampl = sampl; 34 34 _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 36 41 expandEnvVar(_path); 37 if ( _path.length() > 0 && _path[_path.length()-1] != QDir::separator()) {38 _ path += QDir::separator();42 if (!_extension.isEmpty()) { 43 _extension = "." + _extension; 39 44 } 45 46 _append = Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked; 40 47 } 41 48 … … 52 59 } 53 60 54 // Next File Epoch (static)61 // Epoch String 55 62 //////////////////////////////////////////////////////////////////////////// 56 QString bncoutf::nextEpochStr(const QDateTime& datTim, 57 const QString& intStr, QDateTime* nextEpoch) { 63 QString bncoutf::epochStr(const QDateTime& datTim, const QString& intStr) { 58 64 59 65 QString epoStr; 60 61 QTime nextTime;62 QDate nextDate;63 66 64 67 int indHlp = intStr.indexOf("min"); … … 70 73 if (datTim.time().minute() >= 60-step) { 71 74 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 }80 75 } 81 76 else { … … 83 78 if (datTim.time().minute() < limit) { 84 79 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0')); 85 nextTime.setHMS(datTim.time().hour(), limit, 0);86 nextDate = datTim.date();87 80 break; 88 81 } … … 93 86 char ch = 'A' + datTim.time().hour(); 94 87 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 }103 88 } 104 89 else { 105 90 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);112 91 } 113 92 … … 117 96 // File Name according to RINEX Standards 118 97 //////////////////////////////////////////////////////////////////////////// 119 void bncoutf::resolveFileName(int GPSweek, const QDateTime& datTim) { 120 121 QString epoStr = nextEpochStr(datTim, _intr, &_nextCloseEpoch); 98 QString bncoutf::resolveFileName(int GPSweek, const QDateTime& datTim) { 122 99 123 100 int dayOfWeek = datTim.date().dayOfWeek(); … … 125 102 dayOfWeek = 0; 126 103 } 104 QString gpswd = QString().arg(GPSweek).arg(dayOfWeek); 105 QString baseName = _sklBaseName.replace("${GPSWD}", gpswd); 106 QString epoStr = epochStr(datTim, _intr); 127 107 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; 133 109 } 134 110 135 // Write One Epoch111 // Re-Open Output File 136 112 //////////////////////////////////////////////////////////////////////////// 137 t_irc bncoutf::write(int GPSweek, double GPSweeks, const QString&, 138 const ColumnVector&, bool append) { 113 t_irc bncoutf::reopen(int GPSweek, double GPSweeks) { 139 114 140 115 if (_sampl != 0 && fmod(GPSweeks, _sampl) != 0.0) { … … 144 119 QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks); 145 120 121 QString newFileName = resolveFileName(GPSweek, datTim); 122 146 123 // Close the file 147 124 // -------------- 148 if ( _nextCloseEpoch.isValid() && datTim >= _nextCloseEpoch) {125 if (newFileName != _fName) { 149 126 closeFile(); 150 127 _headerWritten = false; 128 _fName = newFileName; 151 129 } 152 130 153 // Write Header154 // ------------ 131 // Re-Open File, Write Header 132 // -------------------------- 155 133 if (!_headerWritten) { 156 resolveFileName(GPSweek, datTim);157 134 _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); 160 137 } 161 138 else { 162 _out.open(_fName. data());139 _out.open(_fName.toAscii().data()); 163 140 writeHeader(datTim); 164 141 } … … 168 145 return success; 169 146 } 147 148 // Write String 149 //////////////////////////////////////////////////////////////////////////// 150 t_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 }
Note:
See TracChangeset
for help on using the changeset viewer.