diff --git a/.classpath b/.classpath index a5d40376..26c568d7 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/.gitignore b/.gitignore index 6df976a9..c9419840 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ settings.xml .classpath .classpath .classpath +.classpath diff --git a/src/PamguardMVC/PamObservable.java b/src/PamguardMVC/PamObservable.java index 73897998..da6a540b 100644 --- a/src/PamguardMVC/PamObservable.java +++ b/src/PamguardMVC/PamObservable.java @@ -400,7 +400,7 @@ public class PamObservable {//extends PanelOverlayDraw { } } - private Timer t = new Timer(1000, new ActionListener() { + private Timer t = new Timer(4321, new ActionListener() { public void actionPerformed(ActionEvent evt) { long now = System.currentTimeMillis(); if (cpuUsage == null) return; @@ -412,6 +412,16 @@ public class PamObservable {//extends PanelOverlayDraw { lastCPUCheckTime = now; } }); + + + /** + * Had some issues with the Timer holding a reference to the underlying PamDataBlock + * (RoccaContourDataBlock, in this case) and not releasing it for garbage collection. + * Added in this method to force the timer to stop and release it's hold. + */ + public void stopTimer() { + t.stop(); + } public double getCPUPercent(int objectIndex) { if (objectIndex < 0 || objectIndex >= cpuPercent.length) return -1; diff --git a/src/pamguard/Pamguard.java b/src/pamguard/Pamguard.java index f6865503..4a142c0b 100644 --- a/src/pamguard/Pamguard.java +++ b/src/pamguard/Pamguard.java @@ -23,17 +23,14 @@ package pamguard; import javax.swing.SwingUtilities; import javax.swing.UIManager; -import Acquisition.AcquisitionControl; import Acquisition.FolderInputSystem; import PamController.PamController; import PamController.PamGUIManager; import PamController.PamSettingManager; import PamController.PamguardVersionInfo; import PamController.pamBuoyGlobals; -import PamController.command.TerminalController; import PamModel.SMRUEnable; import PamUtils.FileFunctions; -import PamUtils.PamCalendar; import PamUtils.PamExceptionHandler; import PamUtils.PlatformInfo; import PamUtils.Splash; @@ -45,6 +42,7 @@ import PamguardMVC.debug.Debug; import binaryFileStorage.BinaryStore; import dataPlotsFX.JamieDev; import generalDatabase.DBControl; +import rocca.RoccaDev; import java.io.BufferedReader; import java.io.File; @@ -190,6 +188,10 @@ public class Pamguard { JamieDev.setEnabled(true); System.out.println("Enabling Jamie Macaulay modifications."); } + else if (anArg.equalsIgnoreCase("-rocca")) { + RoccaDev.setEnabled(true); + System.out.println("Enabling Rocca development mode"); + } else if (anArg.equalsIgnoreCase(Debug.flag)) { Debug.setPrintDebug(true); Debug.out.println("Enabling debug terminal output."); diff --git a/src/rocca/RoccaClassifier.java b/src/rocca/RoccaClassifier.java index fe699137..20acb872 100644 --- a/src/rocca/RoccaClassifier.java +++ b/src/rocca/RoccaClassifier.java @@ -408,92 +408,102 @@ public class RoccaClassifier { // load the whistle classifier if (roccaControl.roccaParameters.isClassifyWhistles()) { - String fname = roccaControl.roccaParameters.roccaClassifierModelFilename.getAbsolutePath(); - File f = new File(fname); - if (f.exists() == false) { - WarnOnce.showWarning(roccaControl.getUnitName(), "Rocca whistle classifier file cannot be found at " + fname, WarnOnce.WARNING_MESSAGE); - roccaControl.roccaParameters.setClassifyWhistles(false); - } - else { - try { - BufferedInputStream input = new BufferedInputStream( - (new ProgressMonitorInputStream(null, "Loading Whistle Classifier - Please wait", - new FileInputStream(fname)))); - Object[] modelParams = SerializationHelper.readAll(input); - // separate the classifier model from the training dataset info - // roccaClassifierModel = (AbstractClassifier) modelParams[0]; - // trainedDataset = (Instances) modelParams[1]; - - // there are 2 different styles of model file, the original version and the version - // developed for the 2-stage classifier. Both files contain 2 objects. - // The original version contained the classifier and the training dataset. The newer - // version contains a String description and the classifier. Test the first object; - // if it's a String, then this is the newer version and the String is the description. - // If it's not a String, assume this is the old version and create a RoccaRFModel - // object from the file contents. - if (modelParams[0] instanceof String) { - modelList = (RoccaRFModel) modelParams[1]; - } else { - AbstractClassifier classifier = (AbstractClassifier) modelParams[0]; - Instances dataset = (Instances) modelParams[1]; - RoccaRFModel[] models = new RoccaRFModel[dataset.numClasses()]; - for (int i=0; i 1.5 || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) < 2000. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) > 28000. )) { - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("HIWhist.model") && @@ -402,7 +404,9 @@ public class RoccaProcess extends PamProcess { rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) > 60000. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQRANGE) < 800. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQRANGE) > 14000. )) { - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("NWAtlWhist.model") && @@ -412,7 +416,9 @@ public class RoccaProcess extends PamProcess { rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 2.5 || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) < 9100. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) > 82000. )) { - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; return; } } @@ -431,7 +437,9 @@ public class RoccaProcess extends PamProcess { saveContourPoints(rcdb, rcdb.getChannelMap(), ++numDetections, sNum); saveContourStats(rcdb, rcdb.getChannelMap(), numDetections, sNum); saveContour(rcdb, rcdb.getChannelMap(), numDetections, sNum); - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; /* if this is a click detection (signal, not noise) */ } else if (o==manClickSourceData || o==autoClickSourceData) { @@ -499,18 +507,24 @@ public class RoccaProcess extends PamProcess { (rcdb.getContour().get(RoccaContourStats.ParamIndx.SNR) > 35. || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) < 0.005 || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 0.6 )) { + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("HIClick.model") && (rcdb.getContour().get(RoccaContourStats.ParamIndx.SNR) > 40. || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) < 0.01 || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 0.6 )) { + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("NWAtlClick.model") && (rcdb.getContour().get(RoccaContourStats.ParamIndx.SNR) > 35. || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) < 0.005 || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 0.6 )) { + rcdb.stopTimer(); + rcdb = null; return; } } @@ -529,7 +543,9 @@ public class RoccaProcess extends PamProcess { // add call to update side panel. Set the isClick flag to True updateSidePanel(rcdb, true); saveContourStats(rcdb, rcdb.getChannelMap(), numDetections, sNum); - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; }