Map key exception

Fix bug in map key that was getting null pointers.
This commit is contained in:
Douglas Gillespie 2024-05-01 19:21:48 +01:00
parent 6db451699f
commit 3e71a0f3d9
8 changed files with 70 additions and 30 deletions

View File

@ -1456,13 +1456,13 @@ public class PamController implements PamControllerInterface, PamSettings {
for (int iU = 0; iU < pamControlledUnits.size(); iU++) { for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pamControlledUnits.get(iU).pamHasStopped(); pamControlledUnits.get(iU).pamHasStopped();
} }
guiFrameManager.pamEnded();
long stopTime = PamCalendar.getTimeInMillis(); long stopTime = PamCalendar.getTimeInMillis();
saveEndSettings(stopTime); saveEndSettings(stopTime);
setPamStatus(PAM_IDLE); setPamStatus(PAM_IDLE);
guiFrameManager.pamEnded();
// no good having this here since it get's called at the end of every file. // no good having this here since it get's called at the end of every file.
// if (GlobalArguments.getParam(PamController.AUTOEXIT) != null) { // if (GlobalArguments.getParam(PamController.AUTOEXIT) != null) {
//// can exit here, since we've auto started, can auto exit. //// can exit here, since we've auto started, can auto exit.

View File

@ -36,7 +36,7 @@ public class PamguardVersionInfo {
/** /**
* Release date * Release date
*/ */
static public final String date = "23 April 2024"; static public final String date = "1 May 2024";
// /** // /**
// * Release type - Beta or Core // * Release type - Beta or Core

View File

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

View File

@ -4,9 +4,11 @@ import java.util.ArrayList;
import PamController.DataIntegrityChecker; import PamController.DataIntegrityChecker;
import PamController.PamController; import PamController.PamController;
import PamUtils.PamCalendar;
import PamView.dialog.warn.WarnOnce; import PamView.dialog.warn.WarnOnce;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import binaryFileStorage.BinaryStore; import binaryFileStorage.BinaryStore;
import dataMap.MapOverlap;
import dataMap.OfflineDataMap; import dataMap.OfflineDataMap;
public class BinaryIntegrityChecker implements DataIntegrityChecker { public class BinaryIntegrityChecker implements DataIntegrityChecker {
@ -38,16 +40,16 @@ public class BinaryIntegrityChecker implements DataIntegrityChecker {
if (dataMap == null) { if (dataMap == null) {
return true; return true;
} }
long overlaps = dataMap.checkOverlaps(); ArrayList<MapOverlap> overlaps = dataMap.checkOverlaps();
if (overlaps <= 0) { if (overlaps == null || overlaps.size() == 0) {
return true; 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 " + "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" + "the same folders.<br>Since files sometimes get slightly different names, old files are"
+ "not always overwritten. <br>" + "not always overwritten. <br>"
+ "You should determine which files are 'old' by looking at file creation dates and delete them.", + "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); WarnOnce.showNamedWarning("BINOVERLAPWARNING", PamController.getMainFrame(), "Data Integrity Warning", warn, WarnOnce.WARNING_MESSAGE);
return false; 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. * 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; long bigLap = Long.MIN_VALUE;
TmapPoint prevPoint = null; TmapPoint prevPoint = null;
ArrayList<MapOverlap> overlaps = new ArrayList<>();
for (TmapPoint mapPoint : mapPoints) { for (TmapPoint mapPoint : mapPoints) {
if (prevPoint != null) { if (prevPoint != null) {
long olap = prevPoint.getEndTime() - mapPoint.getStartTime(); long olap = prevPoint.getEndTime() - mapPoint.getStartTime();
// if (mapPoint.getStartTime() < prevPoint.getEndTime()) { if (mapPoint.getStartTime() < prevPoint.getEndTime()) {
bigLap = Math.max(olap, bigLap); bigLap = Math.max(olap, bigLap);
// } overlaps.add(new MapOverlap(prevPoint.getEndTime(), mapPoint.getStartTime()));
}
} }
prevPoint = mapPoint; prevPoint = mapPoint;
} }
return bigLap; return overlaps;
} }
} }

View File

@ -124,7 +124,7 @@ public class PamFFTProcess extends PamProcess {
public synchronized void setupFFT() { 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. // need to find the existing source data block and remove from observing it.
// then find the new one and subscribe to that instead. // then find the new one and subscribe to that instead.
channelCounts = new int[PamConstants.MAX_CHANNELS]; channelCounts = new int[PamConstants.MAX_CHANNELS];

View File

@ -197,15 +197,15 @@ public class DBXMLConnect {
marshal.marshal(nilusObject, tempFile.toString()); marshal.marshal(nilusObject, tempFile.toString());
// above lines have made a file. Are now going to gzip it before sending to Tethys // above lines have made a file. Are now going to gzip it before sending to Tethys
File zipFile = null; File zipFile = null;
try { // try {
zipFile = zipOutputFile(tempFile); // zipFile = zipOutputFile(tempFile);
} // }
catch (FileNotFoundException e1){ // catch (FileNotFoundException e1){
System.out.println(e1.getMessage()); // System.out.println(e1.getMessage());
} // }
catch (IOException e2) { // catch (IOException e2) {
System.out.println(e2.getMessage()); // System.out.println(e2.getMessage());
} // }
String finalName; String finalName;
if (zipFile == null) { if (zipFile == null) {
finalName = bodgeName; finalName = bodgeName;