Ignore:
Timestamp:
Oct 5, 2026, 12:35:01 PM (34 hours ago)
Author:
stuerze
Message:

further fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp

    r11058 r11068  
    11391139  }
    11401140
     1141  char epoSys = 0; // system the epoch of this message is taken from
    11411142  if      (epoSecGPS != -1) {
     1143    epoSys = 'G';
    11421144    _lastTime.set(currentWeek, epoSecGPS);
    11431145  }
    11441146  else if (epoSecGlo != -1) {
     1147    epoSys = 'R';
    11451148    QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
    11461149    double leap = gnumleap(date.year(), date.month(), date.day());
    11471150    // IGS-SSR: the SSR Epoch Time (IDF003, 20 bit) is given in one continuous
    11481151    // time scale for all GNSS, i.e. GPS seconds of week also for GLONASS
    1149     // (IGS SSR v1.00) - no conversion. Old encoders (e.g. BNC before
    1150     // 2026-09-30) wrote UTC seconds of day instead: recognised by comparison
    1151     // with the GPS/Galileo epoch of the same stream and converted, with a
    1152     // warning, during a transition period.
     1152    // (IGS SSR v1.00) - no conversion. Old encoders wrote UTC instead, as
     1153    // seconds of day (e.g. BNC before 2026-09-30) or as seconds of week:
     1154    // recognised by comparison with the GPS/Galileo epoch of the same stream
     1155    // and converted, with a warning, during a transition period. The value
     1156    // in GPS time is taken modulo one day around the stream's GPS epoch,
     1157    // which covers both variants.
    11531158    if (_type == IGSssr && _igsRefEpoSec >= 0.0 &&
    11541159        igsLegacyEpoch(epoSecGlo, fmod(_igsRefEpoSec - leap + 7 * 86400.0, 86400.0), 86400.0)) {
    1155       double sow = floor(_igsRefEpoSec / 86400.0) * 86400.0 + epoSecGlo + leap;
    1156       if      (sow - _igsRefEpoSec >  43200.0) sow -= 86400.0;
    1157       else if (_igsRefEpoSec - sow >  43200.0) sow += 86400.0;
    1158       epoSecGlo = sow;
     1160      // seconds of day: outdated convention; seconds of week: erroneous
     1161      bool secOfWeek = (epoSecGlo >= 86400.0);
     1162      double dd = fmod(epoSecGlo + leap - _igsRefEpoSec, 86400.0);
     1163      if      (dd >  43200.0) dd -= 86400.0;
     1164      else if (dd < -43200.0) dd += 86400.0;
     1165      epoSecGlo = _igsRefEpoSec + dd;
    11591166      bncTime& warned = _legacyEpochWarned['R'];
    11601167      if (!warned.valid() || currentTime - warned >= 3600.0) {
    11611168        warned = currentTime;
    1162         emit newMessage(_staID.toLatin1() + ": IGS-SSR GLONASS epoch time in outdated convention "
    1163                         "(UTC seconds of day instead of GPS seconds of week, IGS SSR v1.00 IDF003) "
    1164                         "detected and converted - the SSR encoder should be updated", true);
     1169        if (secOfWeek) {
     1170          emit newMessage(_staID.toLatin1() + ": IGS-SSR GLONASS epoch time erroneously encoded "
     1171                          "(UTC seconds of week instead of GPS seconds of week, IGS SSR v1.00 IDF003) "
     1172                          "detected and converted - the SSR encoder should be corrected", true);
     1173        }
     1174        else {
     1175          emit newMessage(_staID.toLatin1() + ": IGS-SSR GLONASS epoch time in outdated convention "
     1176                          "(UTC seconds of day instead of GPS seconds of week, IGS SSR v1.00 IDF003) "
     1177                          "detected and converted - the SSR encoder should be updated", true);
     1178        }
    11651179      }
    11661180    }
    … …  
    11721186  }
    11731187  else if (epoSecGal != -1) {
     1188    epoSys = 'E';
    11741189    _lastTime.set(currentWeek, epoSecGal);
    11751190  }
    11761191  else if (epoSecQzss != -1) {
     1192    epoSys = 'J';
    11771193    _lastTime.set(currentWeek, epoSecQzss);
    11781194  }
    11791195  else if (epoSecSbas != -1) {
     1196    epoSys = 'S';
    11801197    _lastTime.set(currentWeek, epoSecSbas);
    11811198  }
    11821199  else if (epoSecBds != -1) {
     1200    epoSys = 'C';
    11831201    // RTCM-SSR: BDT; IGS-SSR: GPS time scale for all GNSS (IDF003). Old
    11841202    // IGS-SSR encoders wrote BDT: recognised and converted as for GLONASS.
    … …  
    12181236    while (_lastTime > currentTime + maxDiff) {
    12191237      _lastTime = _lastTime - maxDiff;
     1238    }
     1239  }
     1240
     1241  // Plausibility: the orbit/clock epochs of all systems of a stream,
     1242  // converted to GPS time, refer to the same update cycles as its GPS epochs. A difference
     1243  // of more than MAX_DIFF to the latest GPS epoch (itself not older than
     1244  // MAX_DIFF) indicates an erroneous encoding not covered above; the epoch
     1245  // is used as it is and reported at most once per hour and system.
     1246  // Only orbit/clock messages are checked: code and phase biases may be
     1247  // sent with the (older) epoch of their last update (e.g. Galileo HAS).
     1248  const double MAX_DIFF = 120.0;
     1249  bool clkOrbMsg = false;
     1250  for (unsigned s = 0; s < CLOCKORBIT_SATNUM; s++) {
     1251    if (_clkOrb.NumberOfSat[s] > 0) {
     1252      clkOrbMsg = true;
     1253    }
     1254  }
     1255  if (!clkOrbMsg) {
     1256    return;
     1257  }
     1258  if (_lastTime.valid() && epoSys == 'G') {
     1259    _lastGpsEpoch = _lastTime;
     1260  }
     1261  else if (_lastTime.valid() && epoSys != 0 && _lastGpsEpoch.valid() &&
     1262           fabs(currentTime - _lastGpsEpoch) <= MAX_DIFF &&
     1263           fabs(_lastTime - _lastGpsEpoch) > MAX_DIFF) {
     1264    bncTime& warned = _epochDiffWarned[QChar(epoSys)];
     1265    if (!warned.valid() || currentTime - warned >= 3600.0) {
     1266      warned = currentTime;
     1267      emit newMessage(QString("%1: %2 SSR epoch time %3 %4 differs by %5 s from the GPS SSR epoch time "
     1268                              "of the stream - erroneously encoded?")
     1269                      .arg(_staID).arg(epoSys)
     1270                      .arg(QString::fromStdString(_lastTime.datestr()))
     1271                      .arg(QString::fromStdString(_lastTime.timestr(0)))
     1272                      .arg(_lastTime - _lastGpsEpoch, 0, 'f', 0).toLatin1(), true);
    12201273    }
    12211274  }
Note: See TracChangeset for help on using the changeset viewer.