Index: trunk/BNC/latencychecker.cpp
===================================================================
--- trunk/BNC/latencychecker.cpp	(revision 1977)
+++ trunk/BNC/latencychecker.cpp	(revision 1978)
@@ -309,16 +309,16 @@
 void latencyChecker::checkObsLatency(const QList<p_obs>& obsList) {
 
-  if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
-    if (_perfIntr > 0 ) {
-
-      QListIterator<p_obs> it(obsList);
-      while (it.hasNext()) {
-        p_obs obs = it.next();
+  if (_perfIntr > 0 ) {
+
+    QListIterator<p_obs> it(obsList);
+    while (it.hasNext()) {
+      p_obs obs = it.next();
       
-        _newSecGPS = static_cast<int>(obs->_o.GPSWeeks);
-        if (_newSecGPS != _oldSecGPS) {
-          if (_newSecGPS % _perfIntr < _oldSecGPS % _perfIntr) {
-            if (_numLat > 0) {
-              if (_meanDiff > 0.0) {
+      _newSecGPS = static_cast<int>(obs->_o.GPSWeeks);
+      if (_newSecGPS != _oldSecGPS) {
+        if (_newSecGPS % _perfIntr < _oldSecGPS % _perfIntr) {
+          if (_numLat > 0) {
+            if (_meanDiff > 0.0) {
+              if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
                 emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps")
                   .arg(_staID.data())
@@ -330,5 +330,7 @@
                   .arg(_numGaps)
                   .toAscii(), true) );
-              } else {
+              }
+            } else {
+              if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
                 emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs")
                   .arg(_staID.data())
@@ -341,105 +343,6 @@
               }
             }
-            _meanDiff  = _diffSecGPS / _numLat;
-            _diffSecGPS = 0;
-            _numGaps    = 0;
-            _sumLat     = 0.0;
-            _sumLatQ    = 0.0;
-            _numLat     = 0;
-            _minLat     = _maxDt;
-            _maxLat     = -_maxDt;
           }
-          if (_followSec) {
-            _diffSecGPS += _newSecGPS - _oldSecGPS;
-            if (_meanDiff>0.) {
-              if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) {
-                _numGaps += 1;
-              }
-            }
-          }
-
-          // Compute the observations latency
-          // --------------------------------
-          int week;
-          double sec;
-          currentGPSWeeks(week, sec);
-          const double secPerWeek = 7.0 * 24.0 * 3600.0;
-          if (week < obs->_o.GPSWeek) {
-            week += 1;
-            sec  -= secPerWeek;
-          }
-          if (week > obs->_o.GPSWeek) {
-            week -= 1;
-            sec  += secPerWeek;
-          }
-
-          _curLat   = sec - obs->_o.GPSWeeks;
-          _sumLat  += _curLat;
-          _sumLatQ += _curLat * _curLat;
-          if (_curLat < _minLat) {
-            _minLat = _curLat;
-          }
-          if (_curLat >= _maxLat) {
-            _maxLat = _curLat;
-          }
-          _numLat += 1;
-          _oldSecGPS = _newSecGPS;
-          _followSec = true;
-        }
-      }
-    }
-  }
-}
-
-// Perform latency checks (corrections)
-//////////////////////////////////////////////////////////////////////////////
-void latencyChecker::checkCorrLatency(int corrGPSEpochTime) {
-
-  if (corrGPSEpochTime < 0) {
-    return;
-  }
-
-  if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
-    if (_perfIntr > 0) {
-
-      _newSecGPS = corrGPSEpochTime;
-
-      int week;
-      double sec;
-      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;
+          _meanDiff  = _diffSecGPS / _numLat;
           _diffSecGPS = 0;
           _numGaps    = 0;
@@ -447,6 +350,6 @@
           _sumLatQ    = 0.0;
           _numLat     = 0;
-          _minLat     = 1000.;
-          _maxLat     = -1000.;
+          _minLat     = _maxDt;
+          _maxLat     = -_maxDt;
         }
         if (_followSec) {
@@ -458,5 +361,20 @@
           }
         }
-        _curLat   = sec - _newSecGPS;
+
+        // Compute the observations latency
+        // --------------------------------
+        int week;
+        double sec;
+        currentGPSWeeks(week, sec);
+        const double secPerWeek = 7.0 * 24.0 * 3600.0;
+        if (week < obs->_o.GPSWeek) {
+          week += 1;
+          sec  -= secPerWeek;
+        }
+        if (week > obs->_o.GPSWeek) {
+          week -= 1;
+          sec  += secPerWeek;
+        }
+         _curLat   = sec - obs->_o.GPSWeeks;
         _sumLat  += _curLat;
         _sumLatQ += _curLat * _curLat;
@@ -471,4 +389,89 @@
         _followSec = true;
       }
+    }
+  }
+}
+
+// Perform latency checks (corrections)
+//////////////////////////////////////////////////////////////////////////////
+void latencyChecker::checkCorrLatency(int corrGPSEpochTime) {
+
+  if (corrGPSEpochTime < 0) {
+    return;
+  }
+
+  if (_perfIntr > 0) {
+
+    _newSecGPS = corrGPSEpochTime;
+
+    int week;
+    double sec;
+    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);
+            if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
+              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);
+            if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
+            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;
     }
   }
