Changeset 11179 in ntrip for trunk/BNC/src/bncoutf.cpp


Ignore:
Timestamp:
Nov 6, 2026, 4:05:20 PM (7 hours ago)
Author:
stuerze
Message:

structuered logging is added and bug is fixed in SP3 file writing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncoutf.cpp

    r10608 r11179  
    187187  QString newFileName = resolveFileName(GPSweek, datTim);
    188188
    189   bool wait = false;
    190   if (isProductFile() &&
    191       datTim.time().hour()   == 0 &&
    192       datTim.time().minute() == 0 &&
    193       (datTim.time().second() == 0.0 ||  datTim.time().second() == _sampl)) {
    194     wait = true;
    195   }
    196 
    197189  // Close the file
    198190  // --------------
    199   if (newFileName != _fName && !wait) {
     191  if (newFileName != _fName) {
    200192    closeFile();
    201193    _headerWritten = false;
    … …  
    206198  // --------------------------
    207199  if (!_headerWritten) {
     200    _out.clear();
     201    _out.width(0);
    208202    _out.setf(ios::showpoint | ios::fixed);
    209     if (_append && QFile::exists(_fName)) {
    210       _out.open(_fName.toLatin1().data(), ios::out | ios::app);
    211     }
    212     else {
    213       _out.open(_fName.toLatin1().data());
     203    bool appended = _append && QFile::exists(_fName);
     204    _out.open(_fName.toLatin1().data(), appended ? ios::out | ios::app : ios::out);
     205    if (!_out.is_open()) {
     206      return failure;
     207    }
     208    if (!appended) {
    214209      writeHeader(datTim);
    215210    }
    216     if (_out.is_open()) {
    217       _headerWritten = true;
    218     }
    219   }
    220 
     211    _headerWritten = true;
     212  }
     213
     214  return success;
     215}
     216
     217// Write a complete epoch (product files): an epoch at the start of a file
     218// period (e.g. 00:00:00 for daily files) is written as last epoch into the
     219// file of the period before, too
     220////////////////////////////////////////////////////////////////////////////
     221t_irc bncoutf::writeEpoch(const bncTime& epoTime, const std::string& str) {
     222  if (_out.is_open() && isProductFile()) {
     223    bncTime   before   = epoTime - 1.0;
     224    QDateTime datTim   = dateAndTimeFromGPSweek(epoTime.gpsw(), epoTime.gpssec());
     225    QDateTime datTimBf = dateAndTimeFromGPSweek(before.gpsw(), before.gpssec());
     226    if (resolveFileName(epoTime.gpsw(), datTim) != _fName &&
     227        resolveFileName(before.gpsw(), datTimBf) == _fName) {
     228      _out << str;
     229    }
     230  }
     231  if (reopen(epoTime.gpsw(), epoTime.gpssec()) != success) {
     232    return failure;
     233  }
     234  _out << str;
    221235  return success;
    222236}
Note: See TracChangeset for help on using the changeset viewer.