From 29035e0b0386d7616e92a0b710b5a38c76d213d2 Mon Sep 17 00:00:00 2001
From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date: Fri, 15 Mar 2024 11:45:48 +0000
Subject: [PATCH] Merge restart branch (#132)
* binary store count
Fix issue in binary store object count
* update V10aa/other for testing
* update V10aa/other for testing
* reenable buffer dumping
* update V to 10ac for testing
* Additional diagnostics
Additional output of CPU usage for each module when stopping
* V 2.02.10ad for testing
Fixed issue of finding correct raw data block
---
pom.xml | 2 +-
src/PamController/PamConfiguration.java | 17 +++++++++++++++++
src/PamController/PamController.java | 4 ++--
src/PamController/PamguardVersionInfo.java | 4 ++--
src/PamguardMVC/PamDataBlock.java | 3 +++
src/PamguardMVC/PamProcess.java | 17 +++++++++++++++++
6 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1cc20d52..bbb2fbe6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
org.pamguard
Pamguard
- 2.02.10b
+ 2.02.10ad
Pamguard Java12+
Pamguard for Java 12+, using Maven to control dependcies
www.pamguard.org
diff --git a/src/PamController/PamConfiguration.java b/src/PamController/PamConfiguration.java
index 44866e39..16496901 100644
--- a/src/PamController/PamConfiguration.java
+++ b/src/PamController/PamConfiguration.java
@@ -184,6 +184,23 @@ public class PamConfiguration {
return dataBlock;
}
}
+ return tryShortName(blockType, name);
+ }
+
+ /**
+ * For backwards compatibility, some blocks may still use the short name.
+ * @param blockType
+ * @param name
+ * @return
+ */
+ private PamDataBlock tryShortName(Class blockType, String name) {
+ if (name == null) return null;
+ ArrayList blocks = getDataBlocks(blockType, true);
+ for (PamDataBlock dataBlock:blocks) {
+ if (name.equals(dataBlock.getDataName())) { // check for a long name match first
+ return dataBlock;
+ }
+ }
return null;
}
diff --git a/src/PamController/PamController.java b/src/PamController/PamController.java
index dfa37f56..447c876e 100644
--- a/src/PamController/PamController.java
+++ b/src/PamController/PamController.java
@@ -196,7 +196,7 @@ public class PamController implements PamControllerInterface, PamSettings {
private Timer diagnosticTimer;
- private boolean debugDumpBufferAtRestart = false;
+ private boolean debugDumpBufferAtRestart = true;
private NetworkController networkController;
private int nNetPrepared;
@@ -1434,7 +1434,7 @@ public class PamController implements PamControllerInterface, PamSettings {
pamControlledUnits.get(iU).flushDataBlockBuffers(2000);
}
}
- dumpBufferStatus("In pamStopped, now idle", true);
+ dumpBufferStatus("In pamStopped, now idle", false);
// wait here until the status has changed to Pam_Idle, so that we know
// that we've really finished processing all data
diff --git a/src/PamController/PamguardVersionInfo.java b/src/PamController/PamguardVersionInfo.java
index ddb47056..12814aa5 100644
--- a/src/PamController/PamguardVersionInfo.java
+++ b/src/PamController/PamguardVersionInfo.java
@@ -31,12 +31,12 @@ public class PamguardVersionInfo {
* Version number, major version.minorversion.sub-release.
* Note: can't go higher than sub-release 'f'
*/
- static public final String version = "2.02.10b";
+ static public final String version = "2.02.10ad";
/**
* Release date
*/
- static public final String date = "2 March 2024";
+ static public final String date = "13 March 2024";
// /**
// * Release type - Beta or Core
diff --git a/src/PamguardMVC/PamDataBlock.java b/src/PamguardMVC/PamDataBlock.java
index 3bcce61a..ddc42abe 100644
--- a/src/PamguardMVC/PamDataBlock.java
+++ b/src/PamguardMVC/PamDataBlock.java
@@ -4296,6 +4296,9 @@ public class PamDataBlock extends PamObservable {
* @param sayEmpties dump info even if a buffer is empty (otherwise, only ones that have stuff still)
*/
public void dumpBufferStatus(String message, boolean sayEmpties) {
+ if (sayEmpties || unitsAdded > 0) {
+ System.out.printf("Datablock %s: Added %d data units\n", getLongDataName(), unitsAdded);
+ }
int nObs = countObservers();
for (int i = 0; i < nObs; i++) {
PamObserver obs = getPamObserver(i);
diff --git a/src/PamguardMVC/PamProcess.java b/src/PamguardMVC/PamProcess.java
index e6321207..7aafca1f 100644
--- a/src/PamguardMVC/PamProcess.java
+++ b/src/PamguardMVC/PamProcess.java
@@ -126,6 +126,8 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
private long cpuUsage;
private long lastCPUCheckTime = System.currentTimeMillis();
private double cpuPercent;
+ private double totalCPU, peakCPU;
+ private int nCPU;
/**
* Flag for the process to say whether or not it's primary data connection
@@ -140,6 +142,11 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
* Last received data unit - used for working out timing offsets.
*/
private PamDataUnit lastAcousticDataunit;
+
+ /*
+ * diagnostic count of all data processed
+ */
+ private int nDataProcessed;
// some flags and variables needed to deal with conversion from
// milliseconds to samples and back
// private boolean acousticDataSource = false;
@@ -742,6 +749,7 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
}
// long cpuStart = SystemTiming.getProcessCPUTime();
long threadId = Thread.currentThread().getId();
+ nDataProcessed++;
long cpuStart = tmxb.getThreadCpuTime(threadId);
newData(o, arg);
if (processCheck != null) {
@@ -762,6 +770,12 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
* get percent. Total is -9+3+2 = /!0^4 !
*/
cpuPercent = (double) cpuUsage / (now - lastCPUCheckTime) / 10000.;
+ // these next two allow us to take an average cpu.
+ totalCPU += cpuPercent;
+ nCPU++;
+ // and hte max cpu (may always go to 100 at end ?)
+ peakCPU = Math.max(cpuPercent, peakCPU);
+
lastCPUCheckTime = now;
cpuUsage = 0;
}
@@ -1073,6 +1087,9 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
* @param sayEmpties include info even if a buffer is empty.
*/
public void dumpBufferStatus(String message, boolean sayEmpties) {
+ if (sayEmpties || nDataProcessed > 0) {
+ System.out.printf("Process %s: ran %d datas, peak CPU %3.1f%%, mean CPU %3.1f%%\n", this.getProcessName(), nDataProcessed, peakCPU, totalCPU/nCPU);
+ }
ArrayList outputs = getOutputDataBlocks();
try {
for (PamDataBlock output : outputs) {