Merge pull request #79 from PAMGuard/main

merge from main
This commit is contained in:
Douglas Gillespie 2024-06-20 09:48:51 +01:00 committed by GitHub
commit 69cb9dccb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 59 additions and 20 deletions

View File

@ -197,7 +197,7 @@ public class PamController implements PamControllerInterface, PamSettings {
private Timer diagnosticTimer;
private boolean debugDumpBufferAtRestart = false;
private boolean debugDumpBufferAtRestart = true;
private NetworkController networkController;
private int nNetPrepared;
@ -1457,7 +1457,6 @@ public class PamController implements PamControllerInterface, PamSettings {
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pamControlledUnits.get(iU).pamHasStopped();
}
long stopTime = PamCalendar.getTimeInMillis();
saveEndSettings(stopTime);

View File

@ -58,17 +58,23 @@ public class JPanelWithPamKey extends PamPanel implements ColorManaged {
}
private void replaceKeyPanel(KeyPanel newPanel) {
if (keyPanel != null) {
// synchronized (keyPanel) {
try {
if (keyPanel != null) {
// synchronized (keyPanel) {
remove(keyPanel.getPanel());
// }
// }
}
if (newPanel != null) {
// synchronized (newPanel) {
add(newPanel.getPanel(), gc);
// }
}
}
catch (Exception e) {
}
keyPanel = newPanel;
if (keyPanel != null) {
// synchronized (newPanel) {
add(keyPanel.getPanel(), gc);
// }
}
this.invalidate();
this.repaint(10);
drawKeyOnTop();

View File

@ -4,9 +4,11 @@ import java.util.ArrayList;
import PamController.DataIntegrityChecker;
import PamController.PamController;
import PamUtils.PamCalendar;
import PamView.dialog.warn.WarnOnce;
import PamguardMVC.PamDataBlock;
import binaryFileStorage.BinaryStore;
import dataMap.MapOverlap;
import dataMap.OfflineDataMap;
public class BinaryIntegrityChecker implements DataIntegrityChecker {
@ -38,16 +40,16 @@ public class BinaryIntegrityChecker implements DataIntegrityChecker {
if (dataMap == null) {
return true;
}
long overlaps = dataMap.checkOverlaps();
if (overlaps <= 0) {
ArrayList<MapOverlap> overlaps = dataMap.checkOverlaps();
if (overlaps == null || overlaps.size() == 0) {
return true;
}
String warn = String.format("<html>Binary data %s has overlapping data files, with a maximum overlap of %3.1fs<br>"
String warn = String.format("<html>Binary data %s has %d overlapping data files, the first one at %s to %s<br>"
+ "This can occur when data have been reprocessed multiple times offline into "
+ "the same folders.<br>Since files sometimes get slightly different names, old files are"
+ "not always overwritten. <br>"
+ "You should determine which files are 'old' by looking at file creation dates and delete them.",
aBlock.getLongDataName(), (double) overlaps / 1000.);
aBlock.getLongDataName(), overlaps.size(), PamCalendar.formatDBDateTime(overlaps.get(0).getFile1End()), PamCalendar.formatDBDateTime(overlaps.get(0).getFile2Start()));
WarnOnce.showNamedWarning("BINOVERLAPWARNING", PamController.getMainFrame(), "Data Integrity Warning", warn, WarnOnce.WARNING_MESSAGE);
return false;
}

View File

@ -0,0 +1,30 @@
package dataMap;
public class MapOverlap {
private long file2Start;
private long file1End;
public MapOverlap(long file1End, long file2Start) {
super();
this.file1End = file1End;
this.file2Start = file2Start;
}
/**
* @return the file2Start
*/
public long getFile2Start() {
return file2Start;
}
/**
* @return the file1End
*/
public long getFile1End() {
return file1End;
}
}

View File

@ -847,20 +847,22 @@ abstract public class OfflineDataMap<TmapPoint extends OfflineDataMapPoint> {
/**
* Check to see if any data maps overlap in time.
* @return largest overlap between maps. 0 or -ve means no overlap.
* @return list of overlaps.
*/
public long checkOverlaps() {
public ArrayList<MapOverlap> checkOverlaps() {
long bigLap = Long.MIN_VALUE;
TmapPoint prevPoint = null;
ArrayList<MapOverlap> overlaps = new ArrayList<>();
for (TmapPoint mapPoint : mapPoints) {
if (prevPoint != null) {
long olap = prevPoint.getEndTime() - mapPoint.getStartTime();
// if (mapPoint.getStartTime() < prevPoint.getEndTime()) {
if (mapPoint.getStartTime() < prevPoint.getEndTime()) {
bigLap = Math.max(olap, bigLap);
// }
overlaps.add(new MapOverlap(prevPoint.getEndTime(), mapPoint.getStartTime()));
}
}
prevPoint = mapPoint;
}
return bigLap;
return overlaps;
}
}

View File

@ -124,7 +124,7 @@ public class PamFFTProcess extends PamProcess {
public synchronized void setupFFT() {
System.out.println("In call to setupFFT in " + getProcessName());
// System.out.println("In call to setupFFT in " + getProcessName());
// need to find the existing source data block and remove from observing it.
// then find the new one and subscribe to that instead.
channelCounts = new int[PamConstants.MAX_CHANNELS];