Index: trunk/BNC/src/bncgetthread.cpp
===================================================================
--- trunk/BNC/src/bncgetthread.cpp	(revision 8270)
+++ trunk/BNC/src/bncgetthread.cpp	(revision 8271)
@@ -103,8 +103,14 @@
   if (!settings.value("rawOutFile").toString().isEmpty()) {
     _rawOutput = true;
-  } else {
+  }
+  else {
     _rawOutput = false;
   }
-
+  if  (!settings.value("miscMount").toString().isEmpty()) {
+    _latencycheck = true;
+  }
+  else {
+    _latencycheck = false;
+  }
   initialize();
   initDecoder();
@@ -284,5 +290,5 @@
   }
 
-  if (!_staID.isEmpty()) {
+  if (!_staID.isEmpty() && _latencycheck) {
     _latencyChecker = new latencyChecker(_staID);
     obs = false;
@@ -509,8 +515,8 @@
       // --------------------------------
       if (_latencyChecker) {
-        _latencyChecker->checkOutage(irc == success);
+        _latencyChecker->checkOutage(irc);
         QListIterator<int> it(decoder()->_typeList);
-        _ssrEpoch = decoder()->corrGPSEpochTime();
-        if (_oldSsrEpoch && _ssrEpoch && _ssrEpoch != _oldSsrEpoch) {
+        _ssrEpoch = static_cast<int>(decoder()->corrGPSEpochTime());
+        if (_oldSsrEpoch != -1  && _ssrEpoch != _oldSsrEpoch) {
           if (ssrOrb) {
             _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1057);
@@ -564,5 +570,5 @@
                 ssrOrbClk = true;
                 break;
-              case 1059: case 1065: case 1242:   case 1248: case 1254: case 1260:
+              case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
                 ssrCbi = true;
                 break;
@@ -585,5 +591,7 @@
           _latencyChecker->checkObsLatency(decoder()->_obsList);
         }
-        _oldSsrEpoch = _ssrEpoch;
+        if (_ssrEpoch != -1) {
+          _oldSsrEpoch = _ssrEpoch;
+        }
         emit newLatency(_staID, _latencyChecker->currentLatency());
       }
Index: trunk/BNC/src/bncgetthread.h
===================================================================
--- trunk/BNC/src/bncgetthread.h	(revision 8270)
+++ trunk/BNC/src/bncgetthread.h	(revision 8271)
@@ -138,4 +138,5 @@
    t_serialNMEA               _serialNMEA;
    bool                       _rawOutput;
+   bool                       _latencycheck;
    QMap<QString, long>        _prnLastEpo;
    QMap<char, QVector<QString> > _rnxTypes;
Index: trunk/BNC/src/latencychecker.cpp
===================================================================
--- trunk/BNC/src/latencychecker.cpp	(revision 8270)
+++ trunk/BNC/src/latencychecker.cpp	(revision 8271)
@@ -321,5 +321,6 @@
 
   if (_miscIntr > 0 ) {
-    t_latency& l = _lObs; l._type =  "Observations";
+    t_latency& l = _lObs;
+    l._type =  "Observations";
     QListIterator<t_satObs> it(obsList);
     while (it.hasNext()) {
@@ -393,7 +394,7 @@
         }
         l._numLat += 1;
-        l._oldSec    = l._newSec;
         l._followSec = true;
       }
+      l._oldSec = l._newSec;
     }
     _lObs = l;
@@ -406,6 +407,7 @@
 void latencyChecker::checkCorrLatency(int corrGPSEpochTime, int type) {
   if (corrGPSEpochTime < 0) {
-    return ;
-  }
+    return;
+  }
+
   t_latency& l = _lOrb; // init
   switch (type) {
@@ -440,16 +442,4 @@
   if (_miscIntr > 0) {
     l._newSec = corrGPSEpochTime;
-    int week;
-    double sec;
-    currentGPSWeeks(week, sec);
-    double dt = fabs(sec - l._newSec);
-    const double secPerWeek = 7.0 * 24.0 * 3600.0;
-    if (dt > 0.5 * secPerWeek) {
-      if (sec > l._newSec) {
-        sec  -= secPerWeek;
-      } else {
-        sec  += secPerWeek;
-      }
-    }
     if (l._newSec > l._oldSec) {
       if (int(l._newSec) % _miscIntr < int(l._oldSec) % _miscIntr) {
@@ -485,5 +475,4 @@
         l.init();
       }
-
       if (l._followSec) {
         l._diffSec += l._newSec - l._oldSec;
@@ -494,4 +483,19 @@
         }
       }
+
+      // Compute the observations latency
+      // --------------------------------
+      int week;
+      double sec;
+      currentGPSWeeks(week, sec);
+      double dt = fabs(sec - l._newSec);
+      const double secPerWeek = 7.0 * 24.0 * 3600.0;
+      if (dt > 0.5 * secPerWeek) {
+        if (sec > l._newSec) {
+          sec  -= secPerWeek;
+        } else {
+          sec  += secPerWeek;
+        }
+      }
       l._curLat   = sec - l._newSec;
       l._sumLat  += l._curLat;
@@ -504,35 +508,36 @@
       }
       l._numLat += 1;
-      l._oldSec = l._newSec;
       l._followSec = true;
       setCurrentLatency(l._curLat);
     }
-    switch (type) {
-       case 1057: case 1063: case 1240: case 1246: case 1252: case 1258:
-         _lOrb = l;
-         break;
-       case 1058: case 1064: case 1241: case 1247: case 1253: case 1259:
-         _lClk = l;
-         break;
-       case 1060: case 1066: case 1243: case 1249: case 1255: case 1261:
-         _lClkOrb = l;
-         break;
-       case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
-         _lCb = l;
-         break;
-       case 1265: case 1266: case 1267: case 1268: case 1269: case 1270:
-         _lPb = l;
-         break;
-       case 1264:
-         _lVtec = l;
-         break;
-       case 1061: case 1067: case 1244: case 1250: case 1256: case 1262:
-         _lUra = l;
-         break;
-       case 1062: case 1068: case 1245: case 1251: case 1257: case 1263:
-         _lHr = l;
-         break;
-     }
-  }
+    l._oldSec = l._newSec;
+  }
+
+  switch (type) {
+     case 1057: case 1063: case 1240: case 1246: case 1252: case 1258:
+       _lOrb = l;
+       break;
+     case 1058: case 1064: case 1241: case 1247: case 1253: case 1259:
+       _lClk = l;
+       break;
+     case 1060: case 1066: case 1243: case 1249: case 1255: case 1261:
+       _lClkOrb = l;
+       break;
+     case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
+       _lCb = l;
+       break;
+     case 1265: case 1266: case 1267: case 1268: case 1269: case 1270:
+       _lPb = l;
+       break;
+     case 1264:
+       _lVtec = l;
+       break;
+     case 1061: case 1067: case 1244: case 1250: case 1256: case 1262:
+       _lUra = l;
+       break;
+     case 1062: case 1068: case 1245: case 1251: case 1257: case 1263:
+       _lHr = l;
+       break;
+   }
 }
 
Index: trunk/BNC/src/latencychecker.h
===================================================================
--- trunk/BNC/src/latencychecker.h	(revision 8270)
+++ trunk/BNC/src/latencychecker.h	(revision 8271)
@@ -45,17 +45,17 @@
    public:
     t_latency() {
-      _oldSec     = 0;
-      _newSec     = 0;
-      _numGaps    = 0;
-      _diffSec    = 0;
-      _numLat     = 0;
-      _sumLat     = 0.0;
-      _sumLatQ    = 0.0;
-      _meanDiff   = 0.0;
+      _oldSec     = -1;
+      _newSec     = -1;
+      _numGaps    =  0;
+      _diffSec    =  0;
+      _numLat     =  0;
+      _sumLat     =  0.0;
+      _sumLatQ    =  0.0;
+      _meanDiff   =  0.0;
       _minLat     =  1000.0;
       _maxLat     = -1000.0;
-      _curLat     = 0.0;
-      _type       = "";
-      _followSec  = false;
+      _curLat     =  0.0;
+      _type       =  "";
+      _followSec  =  false;
     }
     void init() {
