From 6e162af1161a06a5f03ab4229e55811fbfbd323b Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Mon, 4 Mar 2019 14:59:12 +0000
Subject: [PATCH] COB-4: Skip spurious first log line of received packet rate.

---
 .../InputProc/src/Station/PacketReader.cc     | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc b/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc
index 84d5975274b..4eec3bb3ea0 100644
--- a/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc
+++ b/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc
@@ -203,20 +203,22 @@ namespace LOFAR
 
       const double interval = now - lastLogTime;
 
-      // Emit log line
-      LOG_INFO_STR( logPrefix << (nrReceived / interval) << " pps: received " <<
-                    nrReceived << " packets: " << nrBadTime << " bad timestamps, " <<
-                    nrBadMode << " bad clock/bitmode, " << nrBadData << " payload errors, " <<
-                    nrBadOther << " otherwise bad packets" );
-
-      // Emit data points for monitoring (PVSS)
-      // Reproduce PN_CSI_STREAM0_BLOCKS_IN or PN_CSI_STREAM0_REJECTED, but with the right nr.
-      string streamStr = str(boost::format("stream%u") % boardNr);
-      mdLogger.log(mdKeyPrefix + streamStr + ".blocksIn",
-                   (int)round(nrReceived / interval));
-      size_t nrBad = nrBadTime + nrBadMode + nrBadData + nrBadOther;
-      mdLogger.log(mdKeyPrefix + streamStr + ".rejected",
-                   (int)round(nrBad / interval));
+      // Emit log line, but only once we are producing increments
+      if (lastLogTime > 0.0) {
+        LOG_INFO_STR( logPrefix << (nrReceived / interval) << " pps: received " <<
+                      nrReceived << " packets: " << nrBadTime << " bad timestamps, " <<
+                      nrBadMode << " bad clock/bitmode, " << nrBadData << " payload errors, " <<
+                      nrBadOther << " otherwise bad packets" );
+
+        // Emit data points for monitoring (PVSS)
+        // Reproduce PN_CSI_STREAM0_BLOCKS_IN or PN_CSI_STREAM0_REJECTED, but with the right nr.
+        string streamStr = str(boost::format("stream%u") % boardNr);
+        mdLogger.log(mdKeyPrefix + streamStr + ".blocksIn",
+                     (int)round(nrReceived / interval));
+        size_t nrBad = nrBadTime + nrBadMode + nrBadData + nrBadOther;
+        mdLogger.log(mdKeyPrefix + streamStr + ".rejected",
+                     (int)round(nrBad / interval));
+      }
 
       // Update totals
       totalNrReceived += nrReceived;
-- 
GitLab