Index: trunk/BNC/RTCM/GPSDecoder.h
===================================================================
--- trunk/BNC/RTCM/GPSDecoder.h	(revision 1561)
+++ trunk/BNC/RTCM/GPSDecoder.h	(revision 1562)
@@ -136,4 +136,6 @@
   }
 
+  virtual QList<int>* epochList() {return 0;}
+
   struct t_antInfo {
     enum t_type { ARP, APC };
@@ -157,5 +159,4 @@
   QList<p_obs>     _obsList;
   QList<int>       _typeList;  // RTCM   message types
-  QList<int>       _epochList; // Broadcast corrections
   QStringList      _antType;   // RTCM   antenna descriptor
   QList<t_antInfo> _antList;   // RTCM   antenna XYZ
Index: trunk/BNC/RTCM3/RTCM3Decoder.cpp
===================================================================
--- trunk/BNC/RTCM3/RTCM3Decoder.cpp	(revision 1561)
+++ trunk/BNC/RTCM3/RTCM3Decoder.cpp	(revision 1562)
@@ -44,5 +44,4 @@
 
 #include "RTCM3Decoder.h"
-#include "RTCM3coDecoder.h"
 #include "bncconst.h"
 #include "bncapp.h"
@@ -68,26 +67,4 @@
   _checkMountPoint = settings.value("messTypes").toString();
   _staID = staID;
-
-  // Latency
-  _numLat = 0;
-  _minLat = 1000.;
-  _maxLat = -1000.;
-  _sumLat = 0.;
-  _sumLatQ = 0.;
-  _followSec = false;
-  _meanDiff = 0.;
-  _diffSecGPS= 0.;
-  _numGaps = 0;
-  _oldSecGPS = 0.;
-  _newSecGPS = 0.;
-  _curLat = 0.;
-  _perfIntr = 86400;
-  if ( settings.value("perfIntr").toString().isEmpty() ) { _perfIntr = 0; }
-  if ( settings.value("perfIntr").toString().indexOf("1 min") != -1 ) { _perfIntr = 60; }
-  if ( settings.value("perfIntr").toString().indexOf("5 min") != -1 ) { _perfIntr = 300; }
-  if ( settings.value("perfIntr").toString().indexOf("15 min") != -1 ) { _perfIntr = 900; }
-  if ( settings.value("perfIntr").toString().indexOf("1 hour") != -1 ) { _perfIntr = 3600; }
-  if ( settings.value("perfIntr").toString().indexOf("6 hours") != -1 ) { _perfIntr = 21600; }
-  if ( settings.value("perfIntr").toString().indexOf("1 day") != -1 ) { _perfIntr = 86400; }
 
   // Ensure, that the Decoder uses the "old" convention for the data structure for Rinex2. Perlt
@@ -133,80 +110,8 @@
     if ( _coDecoder->Decode(buffer, bufLen, errmsg) == success ) {
       decoded = true;
-
-      // Latency
-      // -------
-      if (_perfIntr>0) {
-        if (0<_coDecoder->_epochList.size()) {
-          for (int ii=0;ii<_coDecoder->_epochList.size();ii++) {
-            int week;
-            double sec;
-            _newSecGPS = _coDecoder->_epochList[ii];
-            currentGPSWeeks(week, sec);
-            double dt = fabs(sec - _newSecGPS);
-            const double secPerWeek = 7.0 * 24.0 * 3600.0;
-            if (dt > 0.5 * secPerWeek) {
-              if (sec > _newSecGPS) {
-                sec  -= secPerWeek;
-              } else {
-                sec  += secPerWeek;
-              }
-            }
-            if (_newSecGPS != _oldSecGPS) {
-              if (int(_newSecGPS) % _perfIntr < int(_oldSecGPS) % _perfIntr) {
-                if (_numLat>0) {
-                  QString late;
-                  if (_meanDiff>0.) {
-                    late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs, %6 gaps")
-                    .arg(int(_sumLat/_numLat*100)/100.)
-                    .arg(int(_minLat*100)/100.)
-                    .arg(int(_maxLat*100)/100.)
-                    .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
-                    .arg(_numLat)
-                    .arg(_numGaps);
-                    emit(newMessage(QString(_staID + late ).toAscii(), true) );
-                  } else {
-                  late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs")
-                    .arg(int(_sumLat/_numLat*100)/100.)
-                    .arg(int(_minLat*100)/100.)
-                    .arg(int(_maxLat*100)/100.)
-                    .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
-                    .arg(_numLat);
-                  emit(newMessage(QString(_staID + late ).toAscii(), true) );
-                  }
-                }
-                _meanDiff = int(_diffSecGPS)/_numLat;
-                _diffSecGPS = 0.;
-                _numGaps = 0;
-                _sumLat = 0.;
-                _sumLatQ = 0.;
-                _numLat = 0;
-                _minLat = 1000.;
-                _maxLat = -1000.;
-              }
-              if (_followSec) {
-                _diffSecGPS += _newSecGPS - _oldSecGPS;
-                if (_meanDiff>0.) {
-                  if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) {
-                    _numGaps += 1;
-                  }
-                }
-              }
-              _curLat = sec - _newSecGPS;
-              _sumLat += _curLat;
-              _sumLatQ += _curLat * _curLat;
-              if (_curLat < _minLat) {_minLat = _curLat;}
-              if (_curLat >= _maxLat) {_maxLat = _curLat;}
-              _numLat += 1;
-              _oldSecGPS = _newSecGPS;
-              _followSec = true;
-            }
-          }
-        }
-      }
       if (_mode == unknown) {
         _mode = corrections;
       }
     }
-    _coDecoder->_epochList.clear();
   }
 
@@ -360,16 +265,4 @@
             decoded = true;
             gpsephemeris* ep = new gpsephemeris(_Parser.ephemerisGPS);
-
-#ifdef DEBUG_RTCM2_2021
-            QString msg = QString("%1: got eph %2 IODC %3 GPSweek %4 TOC %5 TOE %6")
-              .arg(_staID)
-              .arg(ep->satellite, 2)
-              .arg(ep->IODC,      4)
-              .arg(ep->GPSweek,   4)
-              .arg(ep->TOC,       6)
-              .arg(ep->TOE,       6);
-            emit newMessage(msg.toAscii(), false);
-#endif
-
             emit newGPSEph(ep);
           }
Index: trunk/BNC/RTCM3/RTCM3Decoder.h
===================================================================
--- trunk/BNC/RTCM3/RTCM3Decoder.h	(revision 1561)
+++ trunk/BNC/RTCM3/RTCM3Decoder.h	(revision 1562)
@@ -28,10 +28,10 @@
 #include <QtCore>
 #include "../RTCM/GPSDecoder.h"
+#include "../RTCM/GPSDecoder.h"
+#include "RTCM3coDecoder.h"
 
 extern "C" {
 #include "rtcm3torinex.h"
 }
-
-class RTCM3coDecoder;
 
 class RTCM3Decoder : public QObject, public GPSDecoder {
@@ -41,4 +41,7 @@
   virtual ~RTCM3Decoder();
   virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
+  virtual QList<int>* epochList() {
+    return (_coDecoder ? &(_coDecoder->_epochList) : 0);
+  }
  signals:
   void newMessage(QByteArray msg,bool showOnScreen);
@@ -53,18 +56,5 @@
   RTCM3coDecoder*        _coDecoder; 
   t_mode                 _mode;
-  int _perfIntr;
-  int _numLat;
-  int _numGaps;
-  bool _followSec;
-  double _curLat;
-  double _sumLat;
-  double _sumLatQ;
-  double _minLat;
-  double _maxLat;
-  double _newSecGPS;
-  double _oldSecGPS;
-  double _diffSecGPS;
-  double _meanDiff;
-} ;
+};
 
 #endif
Index: trunk/BNC/RTCM3/RTCM3coDecoder.h
===================================================================
--- trunk/BNC/RTCM3/RTCM3coDecoder.h	(revision 1561)
+++ trunk/BNC/RTCM3/RTCM3coDecoder.h	(revision 1562)
@@ -43,4 +43,6 @@
   virtual ~RTCM3coDecoder();
   virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
+  virtual QList<int>* epochList() {return &_epochList;}
+  QList<int>     _epochList;
 
  signals:
@@ -51,12 +53,12 @@
   void printLine(const QString& line, long coTime);
 
-  int                 _port;
-  std::ofstream*      _out;
-  QString             _staID;
-  QString             _fileNameSkl;
-  QString             _fileName;
-  QByteArray          _buffer;
-  ClockOrbit          _co;
-  Bias                _bias;
+  int            _port;
+  std::ofstream* _out;
+  QString        _staID;
+  QString        _fileNameSkl;
+  QString        _fileName;
+  QByteArray     _buffer;
+  ClockOrbit     _co;
+  Bias           _bias;
 };
 
Index: trunk/BNC/bncgetthread.cpp
===================================================================
--- trunk/BNC/bncgetthread.cpp	(revision 1561)
+++ trunk/BNC/bncgetthread.cpp	(revision 1562)
@@ -371,10 +371,12 @@
       // -----------
       vector<string> errmsg;
-      _decoder->Decode(data.data(), data.size(), errmsg);
+      t_irc irc = _decoder->Decode(data.data(), data.size(), errmsg);
 
       // Perform various scans and checks
       // --------------------------------
+      _latencyChecker->checkOutage(irc == success);
+      _latencyChecker->checkObsLatency(_decoder->_obsList);
+      _latencyChecker->checkCorrLatency(_decoder->epochList());
       scanRTCM();            
-      _latencyChecker->check(_decoder->_obsList);
 
       // Loop over all observations (observations output)
Index: trunk/BNC/latencychecker.cpp
===================================================================
--- trunk/BNC/latencychecker.cpp	(revision 1561)
+++ trunk/BNC/latencychecker.cpp	(revision 1562)
@@ -157,14 +157,13 @@
 //////////////////////////////////////////////////////////////////////////////
 latencyChecker::~latencyChecker() {
-
 }
 
-// Perform latency checks
+// Perform check for outages
 //////////////////////////////////////////////////////////////////////////////
-void latencyChecker::check(const QList<p_obs>& obsList) {
+void latencyChecker::checkOutage(bool decoded) {
 
   // Check - once per inspect segment
   // --------------------------------
-  if (obsList.size() > 0) {
+  if (decoded) {
 
     _decodeTime = QDateTime::currentDateTime();
@@ -244,7 +243,10 @@
     }
   }
-      
-  // Latency and completeness
-  // ------------------------
+}      
+
+// Perform latency checks (observations)
+//////////////////////////////////////////////////////////////////////////////
+void latencyChecker::checkObsLatency(const QList<p_obs>& obsList) {
+
   if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
     if (_perfIntr > 0 ) {
@@ -317,8 +319,8 @@
           if (_curLat < _minLat) {
             _minLat = _curLat;
-	  }
+          }
           if (_curLat >= _maxLat) {
             _maxLat = _curLat;
-	  }
+          }
           _numLat += 1;
           _oldSecGPS = _newSecGPS;
@@ -328,4 +330,89 @@
     }
   }
+}
+
+// Perform latency checks (corrections)
+//////////////////////////////////////////////////////////////////////////////
+void latencyChecker::checkCorrLatency(QList<int>* epochList) {
+
+  if (epochList == 0) {
+    return;
+  }
+
+  if (_perfIntr > 0) {
+    if (0 < epochList->size()) {
+      for (int ii = 0; ii < epochList->size(); ii++) {
+        int week;
+        double sec;
+        _newSecGPS = epochList->at(ii);
+        currentGPSWeeks(week, sec);
+        double dt = fabs(sec - _newSecGPS);
+        const double secPerWeek = 7.0 * 24.0 * 3600.0;
+        if (dt > 0.5 * secPerWeek) {
+          if (sec > _newSecGPS) {
+            sec  -= secPerWeek;
+          } else {
+            sec  += secPerWeek;
+          }
+        }
+        if (_newSecGPS != _oldSecGPS) {
+          if (int(_newSecGPS) % _perfIntr < int(_oldSecGPS) % _perfIntr) {
+            if (_numLat>0) {
+              QString late;
+              if (_meanDiff>0.) {
+                late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs, %6 gaps")
+                .arg(int(_sumLat/_numLat*100)/100.)
+                .arg(int(_minLat*100)/100.)
+                .arg(int(_maxLat*100)/100.)
+                .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
+                .arg(_numLat)
+                .arg(_numGaps);
+                emit(newMessage(QString(_staID + late ).toAscii(), true) );
+              } 
+              else {
+                late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs")
+                .arg(int(_sumLat/_numLat*100)/100.)
+                .arg(int(_minLat*100)/100.)
+                .arg(int(_maxLat*100)/100.)
+                .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
+                .arg(_numLat);
+                emit(newMessage(QString(_staID + late ).toAscii(), true) );
+              }
+            }
+            _meanDiff = int(_diffSecGPS)/_numLat;
+            _diffSecGPS = 0;
+            _numGaps    = 0;
+            _sumLat     = 0.0;
+            _sumLatQ    = 0.0;
+            _numLat     = 0;
+            _minLat     = 1000.;
+            _maxLat     = -1000.;
+          }
+          if (_followSec) {
+            _diffSecGPS += _newSecGPS - _oldSecGPS;
+            if (_meanDiff>0.) {
+              if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) {
+                _numGaps += 1;
+              }
+            }
+          }
+          _curLat   = sec - _newSecGPS;
+          _sumLat  += _curLat;
+          _sumLatQ += _curLat * _curLat;
+          if (_curLat < _minLat) {
+            _minLat = _curLat;
+          }
+          if (_curLat >= _maxLat) {
+            _maxLat = _curLat;
+          }
+          _numLat += 1;
+          _oldSecGPS = _newSecGPS;
+          _followSec = true;
+        }
+      }
+    }
+  }
+  
+  epochList->clear();
 }
 
Index: trunk/BNC/latencychecker.h
===================================================================
--- trunk/BNC/latencychecker.h	(revision 1561)
+++ trunk/BNC/latencychecker.h	(revision 1562)
@@ -36,5 +36,7 @@
   latencyChecker(QByteArray staID);
   ~latencyChecker();
-  void check(const QList<p_obs>& obsList);
+  void checkOutage(bool decoded);
+  void checkObsLatency(const QList<p_obs>& obsList);
+  void checkCorrLatency(QList<int>* epochList);
 
  signals:
