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


Ignore:
Timestamp:
Nov 6, 2026, 4:05:20 PM (30 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/bncsp3.cpp

    r10613 r11179  
    5858////////////////////////////////////////////////////////////////////////////
    5959bncSP3::~bncSP3() {
     60  if (_inpOut == output && _lastEpoTime.valid()) {
     61    writeEpoch(_lastEpoTime, _oStr.str()); // last epoch, otherwise printed with the next one
     62    closeFile();
     63  }
    6064  delete _currEpoch;
    6165  delete _prevEpoch;
    … …  
    7074  _oStr.setf(ios::fixed);
    7175
    72   if (reopen(GPSweek, GPSweeks) == success) {
    73 
    74     bncTime epoTime(GPSweek, GPSweeks);
    75 
    76     if (epoTime != _lastEpoTime) {
    77 
    78       // print out epoch before
    79       if (_lastEpoTime.valid()) {
    80         _out << _oStr.str();
    81         if (_lastEpoTime.daysec() != 0.0) {
    82           _oStr.str(std::string());
    83         }
    84         // Check the sampling interval (print empty epochs)
    85         // ------------------------------------------------
    86         if (_sampl > 0) {
    87           for (bncTime ep = _lastEpoTime +_sampl; ep < epoTime; ep = ep +_sampl) {
    88             _oStr << "\n*  " << ep.datestr(' ') << ' ' << ep.timestr(8, ' ');
    89           }
     76  if (_sampl != 0 && fmod(GPSweeks, _sampl) != 0.0) {
     77    return failure;
     78  }
     79
     80  bncTime epoTime(GPSweek, GPSweeks);
     81
     82  if (epoTime != _lastEpoTime) {
     83
     84    // print out epoch before (complete now)
     85    if (_lastEpoTime.valid()) {
     86      writeEpoch(_lastEpoTime, _oStr.str());
     87      _oStr.str(std::string());
     88      // Check the sampling interval (print empty epochs)
     89      // ------------------------------------------------
     90      if (_sampl > 0) {
     91        for (bncTime ep = _lastEpoTime +_sampl; ep < epoTime; ep = ep +_sampl) {
     92          _oStr << "\n*  " << ep.datestr(' ') << ' ' << ep.timestr(8, ' ');
    9093        }
    9194      }
    92 
    93       // Print the new epoch
    94       // -------------------
    95       _oStr << "\n*  " << epoTime.datestr(' ') << ' ' << epoTime.timestr(8, ' ');
    96 
    97       _lastEpoTime = epoTime;
    98     }
    99 
    100     _oStr << "\nP" << prn.toLatin1().data()
    101          << setw(14) << setprecision(6) << xCoM(1) / 1000.0 // [km]
    102          << setw(14) << setprecision(6) << xCoM(2) / 1000.0 // [km]
    103          << setw(14) << setprecision(6) << xCoM(3) / 1000.0 // [km]
    104          << setw(14) << setprecision(6) << sp3Clk * 1e6;     // microseconds
    105 
    106     if (sp3ClkRate) {
    107       _oStr << "\nV" << prn.toLatin1().data()
    108            << setw(14) << setprecision(6) << v(1) * 10.0      // [dm/s]
    109            << setw(14) << setprecision(6) << v(2) * 10.0      // [dm/s]
    110            << setw(14) << setprecision(6) << v(3) * 10.0      // [dm/s]
    111            << setw(14) << setprecision(6) << sp3ClkRate * 1e2; // 10^⁻4 microseconds/sec
    112     }
    113     return success;
    114   }
    115   else {
    116     return failure;
    117   }
     95    }
     96
     97    // Print the new epoch
     98    // -------------------
     99    _oStr << "\n*  " << epoTime.datestr(' ') << ' ' << epoTime.timestr(8, ' ');
     100
     101    _lastEpoTime = epoTime;
     102  }
     103
     104  _oStr << "\nP" << prn.toLatin1().data()
     105       << setw(14) << setprecision(6) << xCoM(1) / 1000.0 // [km]
     106       << setw(14) << setprecision(6) << xCoM(2) / 1000.0 // [km]
     107       << setw(14) << setprecision(6) << xCoM(3) / 1000.0 // [km]
     108       << setw(14) << setprecision(6) << sp3Clk * 1e6;     // microseconds
     109
     110  if (sp3ClkRate) {
     111    _oStr << "\nV" << prn.toLatin1().data()
     112         << setw(14) << setprecision(6) << v(1) * 10.0      // [dm/s]
     113         << setw(14) << setprecision(6) << v(2) * 10.0      // [dm/s]
     114         << setw(14) << setprecision(6) << v(3) * 10.0      // [dm/s]
     115         << setw(14) << setprecision(6) << sp3ClkRate * 1e2; // 10^-4 microseconds/sec
     116  }
     117  return success;
    118118}
    119119
    … …  
    121121////////////////////////////////////////////////////////////////////////////
    122122void bncSP3::closeFile() {
    123   _out << "\nEOF" << endl;
     123  if (_out.is_open()) {
     124    _out << "\nEOF" << endl;
     125  }
    124126  bncoutf::closeFile();
    125127}
Note: See TracChangeset for help on using the changeset viewer.