diff --git a/pom.xml b/pom.xml
index 33727661..ac0eedd4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
org.pamguard
Pamguard
- 2.02.09b
+ 2.02.09d
Pamguard Java12+
Pamguard for Java 12+, using Maven to control dependcies
www.pamguard.org
@@ -807,7 +807,7 @@ C:\Users\*yourusername*\.m2\repository\pamguard\org\x3\2.2.2-->
pamguard.org
x3
- 2.2.3
+ 2.2.6
diff --git a/repo/pamguard/org/x3/2.2.6/_remote.repositories b/repo/pamguard/org/x3/2.2.6/_remote.repositories
new file mode 100644
index 00000000..dea4c4db
--- /dev/null
+++ b/repo/pamguard/org/x3/2.2.6/_remote.repositories
@@ -0,0 +1,4 @@
+#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
+#Wed Nov 15 12:43:42 GMT 2023
+x3-2.2.6.jar>=
+x3-2.2.6.pom>=
diff --git a/repo/pamguard/org/x3/2.2.6/x3-2.2.6.jar b/repo/pamguard/org/x3/2.2.6/x3-2.2.6.jar
new file mode 100644
index 00000000..91b60886
Binary files /dev/null and b/repo/pamguard/org/x3/2.2.6/x3-2.2.6.jar differ
diff --git a/repo/pamguard/org/x3/2.2.6/x3-2.2.6.pom b/repo/pamguard/org/x3/2.2.6/x3-2.2.6.pom
new file mode 100644
index 00000000..609bc1d5
--- /dev/null
+++ b/repo/pamguard/org/x3/2.2.6/x3-2.2.6.pom
@@ -0,0 +1,9 @@
+
+
+ 4.0.0
+ pamguard.org
+ x3
+ 2.2.6
+ POM was created from install:install-file
+
diff --git a/src/Acquisition/AcquisitionControl.java b/src/Acquisition/AcquisitionControl.java
index 354cefb5..b9410172 100644
--- a/src/Acquisition/AcquisitionControl.java
+++ b/src/Acquisition/AcquisitionControl.java
@@ -398,7 +398,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
message += "\n\nFailure to do so may result in PAMGUARD crashing or features not working correctly";
int ans = JOptionPane.showConfirmDialog(parentFrame, message, getArrayErrorMessage(error), JOptionPane.YES_NO_OPTION);
if (ans == JOptionPane.YES_OPTION) {
- ArrayManager.getArrayManager().showArrayDialog(getPamView().getGuiFrame());
+ ArrayManager.getArrayManager().showArrayDialog(getGuiFrame());
return checkArrayChannels(parentFrame);
}
diff --git a/src/Acquisition/pamAudio/SudAudioFile.java b/src/Acquisition/pamAudio/SudAudioFile.java
index 70c3eb46..acde6db9 100644
--- a/src/Acquisition/pamAudio/SudAudioFile.java
+++ b/src/Acquisition/pamAudio/SudAudioFile.java
@@ -7,57 +7,214 @@ import java.util.Arrays;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.swing.SwingUtilities;
+
+import org.pamguard.x3.sud.ChunkHeader;
+import org.pamguard.x3.sud.SudMapListener;
+
+import PamController.PamController;
+import PamUtils.worker.PamWorkProgressMessage;
+import PamUtils.worker.PamWorkWrapper;
+import PamUtils.worker.PamWorker;
/**
* Opens a .sud audio file.
*
- * Sud files contain X3 compressed audio data. The sud
- * file reader opens files, creating a map of the file and saving
- * the map as a.sudx file so it can be read more rapidly when the file
- * is next accessed.
+ * Sud files contain X3 compressed audio data. The sud file reader opens files,
+ * creating a map of the file and saving the map as a.sudx file so it can be
+ * read more rapidly when the file is next accessed.
*
- * The SudioAudioInput stream fully implements AudioInputStream and so
- * sud files can be accessed using much of the same code as .wav files.
- *
+ * The SudioAudioInput stream fully implements AudioInputStream and so sud files
+ * can be accessed using much of the same code as .wav files.
+ *
* @author Jamie Macaulay
*
*/
public class SudAudioFile extends WavAudioFile {
-
-
+
+ private Object conditionSync = new Object();
+
+ private volatile PamWorker worker;
+ private volatile SudMapWorker sudMapWorker;
+
public SudAudioFile() {
- super();
- fileExtensions = new ArrayList(Arrays.asList(new String[]{".sud"}));
+ super();
+ fileExtensions = new ArrayList(Arrays.asList(new String[] { ".sud" }));
}
@Override
public String getName() {
return "SUD";
}
-
-
+
@Override
public AudioInputStream getAudioStream(File soundFile) {
- if (soundFile.exists() == false) {
- System.err.println("The sud file does not exist: " + soundFile);
- return null;
- }
- if (soundFile != null) {
- try {
- return new SudAudioFileReader().getAudioInputStream(soundFile);
- }
- // don't do anything and it will try the built in Audiosystem
- catch (UnsupportedAudioFileException e) {
- System.err.println("UnsupportedAudioFileException: Could not open sud file: not a supported file " + soundFile.getName());
- System.err.println(e.getMessage());
-// e.printStackTrace();
- } catch (IOException e) {
- System.err.println("Could not open sud file: IO Exception: " + soundFile.getName());
- e.printStackTrace();
+ synchronized (conditionSync) {
+
+ // System.out.println("Get SUD getAudioStream : " + soundFile.getName());
+
+ if (soundFile.exists() == false) {
+ System.err.println("The sud file does not exist: " + soundFile);
+ return null;
+ }
+ if (soundFile != null) {
+
+ if (new File(soundFile.getAbsolutePath() + "x").exists()) {
+// System.out.println("----NO NEED TO MAP SUD FILE-----" + soundFile);
+ try {
+ return new SudAudioFileReader().getAudioInputStream(soundFile);
+ } catch (UnsupportedAudioFileException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else {
+
+// System.out.println("----MAP SUD FILE ON OTHER THREAD-----" + soundFile);
+
+ /**
+ * We need to map the sud file. But we don't want this o just freeze the current
+ * GUI thread. Therefore add a listener to the mapping process and show a
+ * blocking dialog to indicate that something is happening. The mapping is put
+ * on a separate thread and blocks stuff from happening until the mapping
+ * process has completed.
+ */
+ if (sudMapWorker == null || !sudMapWorker.getSudFile().equals(soundFile)) {
+
+ sudMapWorker = new SudMapWorker(soundFile);
+ worker = new PamWorker(sudMapWorker,
+ PamController.getInstance().getMainFrame(), 1,
+ "Mapping sud file: " + soundFile.getName());
+// System.out.println("Sud Audio Stream STARTED: " + soundFile.getName());
+
+ SwingUtilities.invokeLater(() -> {
+ worker.start();
+ });
+ // this should block AWT thread but won't block if called on another thread..
+ }
+
+ // this is only ever called if this function is called on another thread other
+ // than the event dispatch thread.
+ while (sudMapWorker == null || !sudMapWorker.isDone()) {
+ // do nothing
+// System.out.println("Waiting for the SUD file map: " + soundFile.getName() + " worker: " + worker);
+ try {
+// Thread.sleep(100);
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ AudioInputStream stream = sudMapWorker.getSudAudioStream();
+
+// sudMapWorker= null;
+// worker = null;
+
+// System.out.println("----RETURN SUD FILE ON OTHER THREAD-----" + stream);
+
+ return stream;
+
+ }
}
}
+
return null;
}
-}
+ public class SudMapProgress implements SudMapListener {
+
+ PamWorker sudMapWorker;
+
+ public SudMapProgress(PamWorker sudMapWorker) {
+ this.sudMapWorker = sudMapWorker;
+ }
+
+ @Override
+ public void chunkProcessed(ChunkHeader chunkHeader, int count) {
+ // System.out.println("Sud Map Progress: " + count);
+ if (count % 500 == 0) {
+ // don't update too often or everything just freezes
+ sudMapWorker.update(new PamWorkProgressMessage(-1, ("Mapped " + count + " sud file chunks")));
+ }
+ if (count == -1) {
+ sudMapWorker.update(new PamWorkProgressMessage(-1, ("Mapping sud file finished")));
+ }
+ }
+
+ }
+
+ /**
+ * Opens an sud file on a different thread and adds a listener for a mapping.
+ * This allows a callback to show map progress.
+ *
+ * @author Jamie Macaulay
+ *
+ */
+ public class SudMapWorker implements PamWorkWrapper {
+
+ private File soundFile;
+
+ private SudMapProgress sudMapListener;
+
+ private volatile boolean done = false;
+
+ private AudioInputStream result;
+
+ public SudMapWorker(File soundFile) {
+ this.soundFile = soundFile;
+ }
+
+ public File getSudFile() {
+ return soundFile;
+ }
+
+ public AudioInputStream getSudAudioStream() {
+ return result;
+ }
+
+ @Override
+ public AudioInputStream runBackgroundTask(PamWorker pamWorker) {
+ AudioInputStream stream;
+ try {
+// System.out.println("START OPEN SUD FILE:");
+
+ this.sudMapListener = new SudMapProgress(pamWorker);
+ stream = new SudAudioFileReader().getAudioInputStream(soundFile, sudMapListener);
+
+// System.out.println("END SUD FILE:");
+
+ // for some reason - task finished may not be called on other
+ // thread so put this here.
+ this.result = stream;
+ this.done = true;
+
+ return stream;
+ } catch (UnsupportedAudioFileException e) {
+ System.err.println("UnsupportedAudioFileException: Could not open sud file: not a supported file "
+ + soundFile.getName());
+ System.err.println(e.getMessage());
+ // e.printStackTrace();
+ } catch (IOException e) {
+ System.err.println("Could not open sud file: IO Exception: " + soundFile.getName());
+
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public void taskFinished(AudioInputStream result) {
+// System.out.println("TASK FINSIHED:");
+ this.result = result;
+ this.done = true;
+ }
+
+ public boolean isDone() {
+ return done;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/Acquisition/pamAudio/SudAudioFileReader.java b/src/Acquisition/pamAudio/SudAudioFileReader.java
index 07de8053..b38ea34e 100644
--- a/src/Acquisition/pamAudio/SudAudioFileReader.java
+++ b/src/Acquisition/pamAudio/SudAudioFileReader.java
@@ -27,13 +27,14 @@ public class SudAudioFileReader {
public SudAudioFileReader() {
- sudParams = new SudParams();
- //set up the sud params for default. i.e. just read files and
- //don't save any decompressed or meta data.
- sudParams.saveWav = false;
- sudParams.saveMeta = false;
- sudParams.zeroPad = true;
- }
+ sudParams = new SudParams();
+ //set up the sud params for default. i.e. just read files and
+ //don't save any decompressed or meta data.
+// sudParams.saveWav = false;
+// sudParams.saveMeta = false;
+ sudParams.setFileSave(false, false, false, false);
+ sudParams.zeroPad = true;
+ }
/**
* Get the audio input streamn.
@@ -51,5 +52,25 @@ public class SudAudioFileReader {
}
return sudAudioInputStream;
}
+ /**
+ * Get the audio input stream for a sud file.
+ * @param file - the .sud file to open.
+ * @param mapListener- a listener for the sud file maps - can be null.
+ * @return the sud AudioStream.
+ * @throws UnsupportedAudioFileException
+ * @throws IOException
+ */
+ public AudioInputStream getAudioInputStream(File file, SudMapListener mapListener) throws UnsupportedAudioFileException, IOException {
+
+// System.out.println("Get SUD getAudioInputStream");
+
+ try {
+ sudAudioInputStream = SudAudioInputStream.openInputStream(file, sudParams, mapListener, false);
+ } catch (Exception e) {
+ String msg = String.format("Corrupt sud file %s: %s", file.getName(), e.getMessage());
+ throw new UnsupportedAudioFileException(msg);
+ }
+ return sudAudioInputStream;
+ }
}
diff --git a/src/Acquisition/sud/SUDFileTime.java b/src/Acquisition/sud/SUDFileTime.java
index 1cc3ef52..92ac94ca 100644
--- a/src/Acquisition/sud/SUDFileTime.java
+++ b/src/Acquisition/sud/SUDFileTime.java
@@ -1,18 +1,12 @@
package Acquisition.sud;
-
+
import java.io.File;
-
-import org.pamguard.x3.sud.ChunkHeader;
+
import org.pamguard.x3.sud.SudAudioInputStream;
-import org.pamguard.x3.sud.SudFileMap;
-import org.pamguard.x3.sud.SudParams;
-
-import PamUtils.PamCalendar;
-
+
public class SUDFileTime {
-
+
private static long sudTime;
-
private static String lastFilePath = "";
/**
* Temp measure to get the time from the first available sud record.
@@ -20,6 +14,7 @@ public class SUDFileTime {
* @return
*/
public static long getSUDFileTime(File file) {
+ //System.out.println("Get sud file time: " + file.getName());
if (file == null || file.exists() == false) {
return Long.MIN_VALUE;
}
@@ -36,22 +31,26 @@ public class SUDFileTime {
*/
// long t1 = System.currentTimeMillis();
sudTime = Long.MIN_VALUE;
- SudParams sudParams = new SudParams();
- sudParams.saveMeta = false;
- sudParams.saveWav = false;
+// SudParams sudParams = new SudParams();
+// sudParams.saveMeta = false;
+// sudParams.saveWav = false;
try {
- SudAudioInputStream sudAudioInputStream = SudAudioInputStream.openInputStream(file, sudParams, false);
- if (sudAudioInputStream == null) {
- return Long.MIN_VALUE;
- }
- SudFileMap sudMap = sudAudioInputStream.getSudMap();
- if (sudMap == null) {
- return Long.MIN_VALUE;
- }
- long t = sudMap.getFirstChunkTimeMillis();
+//
+// SudAudioInputStream sudAudioInputStream = SudAudioInputStream.openInputStream(file, sudParams, false);
+// if (sudAudioInputStream == null) {
+// return Long.MIN_VALUE;
+// }
+// SudFileMap sudMap = sudAudioInputStream.getSudMap();
+// if (sudMap == null) {
+// return Long.MIN_VALUE;
+// }
+// long t = sudMap.getFirstChunkTimeMillis();
+ long t = SudAudioInputStream.quickFileTime(file);
+ t=t/1000; //turn to milliseconds.
if (t != 0) {
sudTime = t;
}
+
// sudAudioInputStream.addSudFileListener((chunkID, sudChunk)->{
// ChunkHeader chunkHead = sudChunk.chunkHeader;
// if (chunkHead == null || sudTime != Long.MIN_VALUE) {
@@ -70,17 +69,16 @@ public class SUDFileTime {
// sudAudioInputStream.read();
// }
//
- sudAudioInputStream.close();
+// sudAudioInputStream.close();
// long t2 = System.currentTimeMillis();
// System.out.printf("SUD file time %s extracted in %d milliseconds\n", PamCalendar.formatDBDateTime(sudTime), t2-t1);
-
} catch (Exception e) {
- System.err.println("Error getting time from SUD file: " + e.getMessage());
+ System.err.println("Error getting time from SUD file: " + file + " " + e.getMessage());
+ e.printStackTrace();
}
-
return sudTime;
}
-
+
-
-}
+
+}
\ No newline at end of file
diff --git a/src/IMU/IMUControl.java b/src/IMU/IMUControl.java
index d0b75103..1c82cec3 100644
--- a/src/IMU/IMUControl.java
+++ b/src/IMU/IMUControl.java
@@ -73,7 +73,7 @@ public class IMUControl extends PamControlledUnit implements PamSettings {
}
public void actionPerformed(ActionEvent e) {
- IMUSettingsDialog.showDialog(getPamView().getGuiFrame(),THIS);
+ IMUSettingsDialog.showDialog(getGuiFrame(),THIS);
}
}
@@ -89,7 +89,7 @@ public class IMUControl extends PamControlledUnit implements PamSettings {
}
public void actionPerformed(ActionEvent e) {
- IMUParams newIMUParams=IMUImportDialog.showDialog(getPamView().getGuiFrame(),THIS, importCSV);
+ IMUParams newIMUParams=IMUImportDialog.showDialog(getGuiFrame(),THIS, importCSV);
//if params are not null try and load data
if (newIMUParams!=null){
imuParams=newIMUParams;
@@ -115,7 +115,7 @@ public class IMUControl extends PamControlledUnit implements PamSettings {
}
public void actionPerformed(ActionEvent e) {
- IMUParams newIMUParams=IMUCalibrationDialog.showDialog(getPamView().getGuiFrame(),imuParams);
+ IMUParams newIMUParams=IMUCalibrationDialog.showDialog(getGuiFrame(),imuParams);
if (newIMUParams!=null) imuParams=newIMUParams;
updateProcesses(CAL_VALUES_CHANGED);
}
diff --git a/src/IMU/IMUImportDialog.java b/src/IMU/IMUImportDialog.java
index 61427052..f2e5323b 100644
--- a/src/IMU/IMUImportDialog.java
+++ b/src/IMU/IMUImportDialog.java
@@ -91,7 +91,7 @@ public class IMUImportDialog extends PamDialog{
}
else dir=null;
- String newFile=PamFileBrowser.csvFileBrowser(imuControl.getPamView().getGuiFrame(),dir,PamFileBrowser.OPEN_FILE);
+ String newFile=PamFileBrowser.csvFileBrowser(imuControl.getGuiFrame(),dir,PamFileBrowser.OPEN_FILE);
addNewFileToList( newFile);
diff --git a/src/Map/MapPanel.java b/src/Map/MapPanel.java
index 2fc57630..e3122141 100644
--- a/src/Map/MapPanel.java
+++ b/src/Map/MapPanel.java
@@ -23,6 +23,7 @@ package Map;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Cursor;
+import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
@@ -1636,9 +1637,9 @@ public class MapPanel extends JPanelWithPamKey implements PamObserver, ColorMana
class OverlayOptions implements ActionListener {
public void actionPerformed(ActionEvent e) {
- JFrame frame = (JFrame) PamController.getMainFrame();
+ Frame frame = (JFrame) PamController.getMainFrame();
if (mapController.getPamView() != null) {
- frame = mapController.getPamView().getGuiFrame();
+ frame = mapController.getGuiFrame();
}
MapDetectionsParameters newParams = MapDetectionsDialog.showDialog(frame,
diff --git a/src/PamController/PamConfiguration.java b/src/PamController/PamConfiguration.java
new file mode 100644
index 00000000..dd9daf1e
--- /dev/null
+++ b/src/PamController/PamConfiguration.java
@@ -0,0 +1,549 @@
+package PamController;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import Array.ArrayManager;
+import PamController.settings.output.xml.PamguardXMLWriter;
+import PamDetection.PamDetection;
+import PamDetection.RawDataUnit;
+import PamView.GeneralProjector;
+import PamView.PanelOverlayDraw;
+import PamguardMVC.PamDataBlock;
+import PamguardMVC.PamDataUnit;
+import PamguardMVC.PamProcess;
+import PamguardMVC.PamRawDataBlock;
+import binaryFileStorage.BinaryStore;
+import fftManager.FFTDataBlock;
+import fftManager.FFTDataUnit;
+import offlineProcessing.OfflineTask;
+import offlineProcessing.OfflineTaskGroup;
+
+/**
+ * Class to take all of the configuration information out of PamController. This
+ * is because PamController is a singleton class, so there can only every be one of
+ * them, but for some of the batch processing control, we need to be able to load and
+ * manipulate a second set of modules, which do nothing within the running
+ * configuration, but are there to allow us to set up a configuration to send to
+ * other batch processes in viewer mode.
+ * @author dg50
+ *
+ */
+public class PamConfiguration {
+
+ /**
+ * List of the current controlled units (PAMGuard modules)
+ */
+ private ArrayList pamControlledUnits;
+
+ public PamConfiguration() {
+ super();
+
+ // create the array list to hold multiple views
+ pamControlledUnits = new ArrayList();
+ }
+
+ /**
+ * Call setupControlledUnit() on all modules.
+ */
+ public void setupProcesses() {
+ for (int i = 0; i < pamControlledUnits.size(); i++) {
+ pamControlledUnits.get(i).setupControlledUnit();
+ }
+ }
+
+ /**
+ * Can PAMGUARD shut down. This question is asked in turn to
+ * every module. Each module should attempt to make sure it can
+ * answer true, e.g. by closing files, but if any module
+ * returns false, then canClose() will return false;
+ * @return whether it's possible to close PAMGUARD
+ * without corrupting or losing data.
+ */
+ public boolean canClose() {
+ for (int i = 0; i < pamControlledUnits.size(); i++) {
+ if (pamControlledUnits.get(i).canClose() == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Called after canClose has returned true to finally tell
+ * all modules that PAMGUARD is definitely closing down.so they
+ * can free any resources, etc.
+ */
+ public void pamClose() {
+
+
+ for (int i = 0; i < pamControlledUnits.size(); i++) {
+ pamControlledUnits.get(i).pamClose();
+ }
+ }
+
+ /**
+ * @return the pamControlledUnits
+ */
+ public ArrayList getPamControlledUnits() {
+ return pamControlledUnits;
+ }
+
+ /**
+ * Add a PamControlledUnit to the main list.
+ * @param controlledUnit
+ */
+ public void addControlledUnit(PamControlledUnit controlledUnit) {
+ pamControlledUnits.add(controlledUnit);
+ }
+
+ public boolean removeControlledUnt(PamControlledUnit controlledUnit) {
+
+ boolean removed = false;
+ while (pamControlledUnits.contains(controlledUnit)) {
+ pamControlledUnits.remove(controlledUnit);
+ removed = true;
+ }
+ return removed;
+ // getMainFrame().revalidate(); //handled inside the GUIFrameManager by notify model changed. The controller should have
+ //as few direct GUI calls as possible.
+ }
+
+ /**
+ * re-order the modules according to the given list.
+ * @param newOrder
+ * @return
+ */
+ public boolean reOrderModules(int[] newOrder) {
+
+ if (pamControlledUnits.size() != newOrder.length) return false;
+
+ ArrayList newList = new ArrayList();
+
+ for (int i = 0; i < newOrder.length; i++) {
+
+ newList.add(pamControlledUnits.get(newOrder[i]));
+
+ }
+
+ pamControlledUnits = newList;
+
+ return true;
+ }
+
+ public PamControlledUnit getControlledUnit(int iUnit) {
+ if (iUnit < getNumControlledUnits()) {
+ return pamControlledUnits.get(iUnit);
+ }
+ return null;
+ }
+
+ public PamControlledUnit findControlledUnit(String unitType) {
+ for (int i = 0; i < getNumControlledUnits(); i++) {
+ if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType)) {
+ return pamControlledUnits.get(i);
+ }
+ }
+ return null;
+ }
+
+ public int getNumControlledUnits() {
+ return pamControlledUnits.size();
+ }
+
+ public PamRawDataBlock getRawDataBlock(int id) {
+ return (PamRawDataBlock) getDataBlock(RawDataUnit.class, id);
+ }
+
+ public PamRawDataBlock getRawDataBlock(String name) {
+ return (PamRawDataBlock) getDataBlock(RawDataUnit.class, name);
+ }
+
+ /**
+ * Find a block of a given type with the given name, or null if it
+ * doesn't exist.
+ * @param blockType -- RAW, FFT, DETECTOR, null, etc.
+ * @param name -- the block name
+ * @return block, which you may want to cast to a subtype
+ */
+ public PamDataBlock getDataBlock(Class blockType, String name) {
+ if (name == null) return null;
+ ArrayList blocks = getDataBlocks(blockType, true);
+ for (PamDataBlock dataBlock:blocks) {
+ if (name.equals(dataBlock.getLongDataName())) { // check for a long name match first
+ return dataBlock;
+ }
+ if (dataBlock instanceof FFTDataBlock) {
+ FFTDataBlock fb = (FFTDataBlock) dataBlock;
+ if (name.equals(fb.getOldLongDataName())) {
+ return dataBlock;
+ }
+ }
+ if (name.equals(dataBlock.toString())) {
+ return dataBlock;
+ }
+ }
+ return null;
+ }
+
+ public ArrayList getDataBlocks(Class blockType, boolean includeSubClasses) {
+ return makeDataBlockList(blockType, includeSubClasses);
+ }
+
+ public ArrayList getDetectorDataBlocks() {
+ return makeDataBlockList(PamDetection.class, true);
+ }
+
+ public ArrayList getFFTDataBlocks() {
+ return makeDataBlockList(FFTDataUnit.class, true);
+ }
+
+ public PamDataBlock getFFTDataBlock(int id) {
+ return getDataBlock(FFTDataUnit.class, id);
+ }
+
+ public PamDataBlock getFFTDataBlock(String name) {
+ return getDataBlock(FFTDataUnit.class, name);
+ }
+
+ /**
+ * Find a block of a given type with the id number, or null if the number
+ * is out of range.
+ *
+ * @param blockType
+ * @param id -- the block id number
+ * @return block, which you may want to cast to a subtype
+ */
+ public PamDataBlock getDataBlock(Class blockType, int id) {
+
+ ArrayList blocks = getDataBlocks(blockType, true);
+ if (id >= 0 && id < blocks.size()) return blocks.get(id);
+ return null;
+ }
+ public ArrayList getRawDataBlocks() {
+ return makeDataBlockList(RawDataUnit.class, true);
+ }
+ /**
+ * Find a block with the given long name, or null if it doesn't exist.
+ * @param longName the long name of the PamDataBlock
+ * @return block
+ */
+ public PamDataBlock getDataBlockByLongName(String longName) {
+ if (longName == null) return null;
+ ArrayList allBlocks = getDataBlocks();
+ for (PamDataBlock dataBlock:allBlocks) {
+ if (longName.equals(dataBlock.getLongDataName())) {
+ return dataBlock;
+ }
+ if (dataBlock instanceof FFTDataBlock) {
+ FFTDataBlock fb = (FFTDataBlock) dataBlock;
+ if (longName.equals(fb.getOldLongDataName())) {
+ return dataBlock;
+ }
+ }
+ }
+ return null;
+ }
+
+ public ArrayList getDataBlocks() {
+ return makeDataBlockList(PamDataUnit.class, true);
+ }
+
+ /**
+ * Get a list of PamControlledUnit units of a given type
+ * @param unitType Controlled unit type
+ * @return list of units.
+ */
+ public ArrayList findControlledUnits(String unitType) {
+ ArrayList l = new ArrayList();
+ int n = getNumControlledUnits();
+ PamControlledUnit pcu;
+ for (int i = 0; i < n; i++) {
+ pcu = getControlledUnit(i);
+ if (pcu.getUnitType().equals(unitType)) {
+ l.add(pcu);
+ }
+ }
+
+ return l;
+ }
+
+ /**
+ * Get a list of PamControlledUnit units of a given type and name, allowing for nulls.
+ * @param unitType Controlled unit type, can be null for all units of name
+ * @param unitName Controlled unit name, can be null for all units of type
+ * @return list of units.
+ */
+ public ArrayList findControlledUnits(String unitType, String unitName) {
+ ArrayList l = new ArrayList();
+ int n = getNumControlledUnits();
+ PamControlledUnit pcu;
+ for (int i = 0; i < n; i++) {
+ pcu = getControlledUnit(i);
+ if (unitType != null && !unitType.equals(pcu.getUnitType())) {
+ continue;
+ }
+ if (unitName != null && !unitName.equals(pcu.getUnitName())) {
+ continue;
+ }
+ l.add(pcu);
+ }
+
+ return l;
+ }
+
+ /**
+ * find the first controlled unit with the given type and name.
+ * @param unitType
+ * @param unitName
+ * @return
+ */
+ public PamControlledUnit findControlledUnit(String unitType, String unitName) {
+ for (int i = 0; i < getNumControlledUnits(); i++) {
+ if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType) &&
+ pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName)) {
+ return pamControlledUnits.get(i);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find the first instance of a module with a given class type and name.
+ * Name can be null in which case the first module with the correct class
+ * will be returned
+ * @param unitClass Module class (sub class of PamControlledUnit)
+ * @param unitName Module Name
+ * @return Existing module with that class and name.
+ */
+ public PamControlledUnit findControlledUnit(Class unitClass, String unitName) {
+ for (int i = 0; i < getNumControlledUnits(); i++) {
+ if (pamControlledUnits.get(i).getClass() == unitClass && (unitName == null ||
+ pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName))) {
+ return pamControlledUnits.get(i);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get an Array list of PamControlledUnits of a particular class (exact matches only).
+ * @param unitClass PamControlledUnit class
+ * @return List of current instances of this class.
+ */
+ public ArrayList findControlledUnits(Class unitClass) {
+ ArrayList foundUnits = new ArrayList<>();
+ for (int i = 0; i < getNumControlledUnits(); i++) {
+ if (pamControlledUnits.get(i).getClass() == unitClass) {
+ foundUnits.add(pamControlledUnits.get(i));
+ }
+ }
+ return foundUnits;
+ }
+
+ /**
+ * Get an Array list of PamControlledUnits of a particular class (exact matches only).
+ * @param unitClass PamControlledUnit class
+ * @return List of current instances of this class.
+ */
+ public ArrayList findControlledUnits(Class unitClass, boolean includeSubClasses) {
+ if (includeSubClasses == false) {
+ return findControlledUnits(unitClass);
+ }
+ ArrayList foundUnits = new ArrayList<>();
+ for (int i = 0; i < getNumControlledUnits(); i++) {
+ if (unitClass.isAssignableFrom(pamControlledUnits.get(i).getClass())) {
+ foundUnits.add(pamControlledUnits.get(i));
+ }
+ }
+ return foundUnits;
+ }
+ /**
+ * Check whether a controlled unit exists based on it's name.
+ * @param the controlled unit name e.g. "my crazy click detector", not the default name.
+ */
+ public boolean isControlledUnit(String controlName) {
+ for (int i = 0; i < getNumControlledUnits(); i++) {
+ if (pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(controlName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Gets called in pamStart and may / will attempt to store all
+ * PAMGUARD settings via the database and binary storage modules.
+ */
+ public void saveSettings(long timeNow) {
+ PamControlledUnit pcu;
+ PamSettingsSource settingsSource;
+ for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
+ pcu = pamControlledUnits.get(iU);
+ if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
+ settingsSource = (PamSettingsSource) pcu;
+ settingsSource.saveStartSettings(timeNow);
+ }
+ }
+ PamguardXMLWriter.getXMLWriter().writeStartSettings(timeNow);
+ }
+
+ /**
+ *
+ * @return a list of PamControlledUnits which implements the
+ * PamSettingsSource interface
+ * @see PamSettingsSource
+ */
+ public ArrayList findSettingsSources() {
+ ArrayList settingsSources = new ArrayList();
+ PamControlledUnit pcu;
+ for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
+ pcu = pamControlledUnits.get(iU);
+ if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
+ settingsSources.add((PamSettingsSource) pcu);
+ }
+ }
+ return settingsSources;
+ }
+
+ public ArrayList getPlottableDataBlocks(GeneralProjector generalProjector) {
+
+ ArrayList blockList = new ArrayList();
+ PamProcess pP;
+ Class unitClass;
+ PanelOverlayDraw panelOverlayDraw;
+
+ for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
+ for (int iP = 0; iP < pamControlledUnits.get(iU)
+ .getNumPamProcesses(); iP++) {
+ pP = pamControlledUnits.get(iU).getPamProcess(iP);
+ for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
+ if(pP.getOutputDataBlock(j).canDraw(generalProjector)) {
+ blockList.add(pP.getOutputDataBlock(j));
+ }
+ }
+ }
+ }
+ return blockList;
+ }
+
+ public ArrayList makeDataBlockList(Class classType, boolean includSubClasses) {
+
+ ArrayList blockList = new ArrayList();
+ PamProcess pP;
+ Class unitClass;
+
+ for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
+ for (int iP = 0; iP < pamControlledUnits.get(iU)
+ .getNumPamProcesses(); iP++) {
+ pP = pamControlledUnits.get(iU).getPamProcess(iP);
+ for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
+ //System.out.println("Comparing "+pP.getOutputDataBlock(j).getUnitClass().getCanonicalName()+" to "+classType.getCanonicalName());
+ if ((unitClass = pP.getOutputDataBlock(j).getUnitClass()) == classType) {
+ blockList.add(pP.getOutputDataBlock(j));
+ }
+ else if (includSubClasses) {
+ if (classType != null && classType.isAssignableFrom(unitClass)) {
+ blockList.add(pP.getOutputDataBlock(j));
+ }
+ // while ((unitClass = unitClass.getSuperclass()) != null) {
+ // if (unitClass == classType) {
+ // blockList.add(pP.getOutputDataBlock(j));
+ // break;
+ // }
+ // }
+ }
+ }
+ }
+ }
+
+ return blockList;
+ }
+
+ public void notifyModelChanged(int changeType) {
+ // also tell all PamControlledUnits since they may want to find their data source
+ // it that was created after they were - i.e. dependencies have got all muddled
+ for (int i = 0; i < pamControlledUnits.size(); i++) {
+ pamControlledUnits.get(i).notifyModelChanged(changeType);
+ }
+ }
+
+ public Serializable getSettingsReference() {
+ ArrayList usedModules = new ArrayList();
+ for (int i = 0; i < pamControlledUnits.size(); i++) {
+ usedModules.add(new UsedModuleInfo(pamControlledUnits.get(i).getClass().getName(),
+ pamControlledUnits.get(i).getUnitType(),
+ pamControlledUnits.get(i).getUnitName()));
+ }
+ return usedModules;
+ }
+
+ public void destroyModel() {
+
+ for (int i = 0; i < pamControlledUnits.size(); i++) {
+ pamControlledUnits.get(i).notifyModelChanged(PamController.DESTROY_EVERYTHING);
+ }
+ pamControlledUnits.clear();
+ }
+
+ /**
+ * Get the index of a PamControlledUnit
+ * @param unit
+ * @return
+ */
+ public int getControlledUnitIndex(PamControlledUnit unit) {
+ return pamControlledUnits.indexOf(unit);
+ }
+
+ /**
+ * Find the path to the binary store ....
+ * @return path to the binary store.
+ */
+ public String findBinaryStorePath() {
+ BinaryStore binaryStore = (BinaryStore) findControlledUnit(BinaryStore.getBinaryUnitType());
+ if (binaryStore == null) {
+ return null;
+ }
+ String storeLoc = binaryStore.getBinaryStoreSettings().getStoreLocation();
+ if (storeLoc == null) {
+ return "";
+ }
+ if (storeLoc.endsWith(File.separator) == false) {
+ storeLoc += File.separator;
+ }
+ return storeLoc;
+ }
+
+ /**
+ * Get a list of all offline task groups in this configuration
+ * @return task group list
+ */
+ public ArrayList getAllOfflineTaskGroups() {
+ ArrayList tgs = new ArrayList();
+ for (PamControlledUnit unit : pamControlledUnits){
+ int numGroups = unit.getNumOfflineTaskGroups();
+ for (int iGp=0;iGp getAllOfflineTasks() {
+ ArrayList ots = new ArrayList();
+ ArrayList groups = getAllOfflineTaskGroups();
+ for (OfflineTaskGroup group : groups) {
+ int nTasks = group.getNTasks();
+ for (int i = 0; i < nTasks; i++) {
+ ots.add(group.getTask(i));
+ }
+ }
+ return ots;
+ }
+}
diff --git a/src/PamController/PamControlledUnit.java b/src/PamController/PamControlledUnit.java
index 1f9e9d42..9b9eae63 100644
--- a/src/PamController/PamControlledUnit.java
+++ b/src/PamController/PamControlledUnit.java
@@ -144,6 +144,8 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
private ModuleStatusManager moduleStatusManager;
+ private PamConfiguration pamConfiguration;
+
// private ArrayList offlineTasks = new ArrayList<>();
/**
@@ -158,8 +160,17 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
* name of unit
*/
public PamControlledUnit(String unitType, String unitName) {
+ this(null, unitType, unitName);
+ }
+
+ public PamControlledUnit(PamConfiguration pamConfiguration, String unitType, String unitName) {
this.unitType = unitType;
this.unitName = unitName;
+ this.pamConfiguration = pamConfiguration;
+ if (this.pamConfiguration == null) {
+ this.pamConfiguration = PamController.getInstance().getPamConfiguration();
+ }
+
pamProcesses = new ArrayList();
isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW;
@@ -500,6 +511,12 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
return true;
}
+ /**
+ * Get the GUI associated with this module. However, this may return null, so if you want a frame
+ * to use for a dialog, better to use PamController.getGuiFrame() which handles null automatically.
+ * @return
+ */
+ @Deprecated
public PamView getPamView() {
return pamView;
}
@@ -677,11 +694,11 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
* @param offlineTaskGroup
*/
public void addOfflineTaskGroup(OfflineTaskGroup offlineTaskGroup) {
- if (isViewer){
+// if (isViewer){
offlineTaskGroups.add(offlineTaskGroup);
- }else{
- System.out.println("OfflineTaskGroup cannot be added as is not viewer mode");
- }
+// }else{
+// System.out.println("OfflineTaskGroup cannot be added as is not viewer mode");
+// }
}
@@ -884,4 +901,34 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
return null;
}
+ /**
+ * The PamConfiguration holds the master list of modules which form part of a
+ * configuration. It should be accessed to find list of datablocks, etc. rather than
+ * doing everything through PAMController whenever possible.
+ * @return the pamConfiguration
+ */
+ public PamConfiguration getPamConfiguration() {
+ if (pamConfiguration == null) {
+ pamConfiguration = PamController.getInstance().getPamConfiguration();
+ }
+ return pamConfiguration;
+ }
+
+ /**
+ * Is this module in the main configuration. If it isn't then it's probably a dummy config
+ * used in the batch processor or for importing / exporting configs, so it should be stopped from
+ * doing too much !
+ * @return
+ */
+ public boolean isInMainConfiguration() {
+ return pamConfiguration == PamController.getInstance().getPamConfiguration();
+ }
+
+ /**
+ * @param pamConfiguration the pamConfiguration to set
+ */
+ public void setPamConfiguration(PamConfiguration pamConfiguration) {
+ this.pamConfiguration = pamConfiguration;
+ }
+
}
diff --git a/src/PamController/PamController.java b/src/PamController/PamController.java
index 160ae7f4..56d4f6a9 100644
--- a/src/PamController/PamController.java
+++ b/src/PamController/PamController.java
@@ -34,6 +34,9 @@ import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.ToolTipManager;
+import com.jcraft.jsch.ConfigRepository.Config;
+import com.sun.xml.bind.v2.TODO;
+
import Acquisition.AcquisitionProcess;
//import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
@@ -68,7 +71,6 @@ import PamController.soundMedium.GlobalMediumManager;
import PamDetection.PamDetection;
import PamDetection.RawDataUnit;
import PamModel.PamModel;
-import PamModel.PamModelInterface;
import PamModel.PamModelSettings;
import PamModel.PamModuleInfo;
import PamModel.SMRUEnable;
@@ -145,11 +147,7 @@ public class PamController implements PamControllerInterface, PamSettings {
*/
private PamModel pamModelInterface;
- /**
- * List of the current controlled units (PAMGuard modules)
- */
- private ArrayList pamControlledUnits;
-
+ private PamConfiguration pamConfiguration;
/**
* The current PAM status
*/
@@ -236,6 +234,8 @@ public class PamController implements PamControllerInterface, PamSettings {
private PamController(int runMode, Object object) {
uniqueController = this;
+
+ pamConfiguration = new PamConfiguration();
this.runMode = runMode;
@@ -354,10 +354,6 @@ public class PamController implements PamControllerInterface, PamSettings {
*/
public void setupPamguard() {
-
- // create the array list to hold multiple views
- pamControlledUnits = new ArrayList();
-
/**
* Set Locale to English so that formated writes to text fields
* in dialogs use . and not , for the decimal.
@@ -663,9 +659,10 @@ public class PamController implements PamControllerInterface, PamSettings {
// }
void setupProcesses() {
- for (int i = 0; i < pamControlledUnits.size(); i++) {
- pamControlledUnits.get(i).setupControlledUnit();
- }
+// for (int i = 0; i < pamControlledUnits.size(); i++) {
+// pamControlledUnits.get(i).setupControlledUnit();
+// }
+ pamConfiguration.setupProcesses();
}
/**
@@ -677,12 +674,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* without corrupting or losing data.
*/
public boolean canClose() {
- for (int i = 0; i < pamControlledUnits.size(); i++) {
- if (pamControlledUnits.get(i).canClose() == false) {
- return false;
- }
- }
- return true;
+ return pamConfiguration.canClose();
}
@@ -696,9 +688,7 @@ public class PamController implements PamControllerInterface, PamSettings {
getUidManager().runShutDownOps();
- for (int i = 0; i < pamControlledUnits.size(); i++) {
- pamControlledUnits.get(i).pamClose();
- }
+ pamConfiguration.pamClose();
}
/**
@@ -718,6 +708,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* it to be easy to override this for specific modules / processes / data blocks.
*/
public void saveViewerData() {
+ ArrayList pamControlledUnits = pamConfiguration.getPamControlledUnits();
for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).saveViewerData();
}
@@ -730,7 +721,8 @@ public class PamController implements PamControllerInterface, PamSettings {
@Override
public void addControlledUnit(PamControlledUnit controlledUnit) {
- pamControlledUnits.add(controlledUnit);
+
+ pamConfiguration.addControlledUnit(controlledUnit);
guiFrameManager.addControlledUnit(controlledUnit);
@@ -856,8 +848,8 @@ public class PamController implements PamControllerInterface, PamSettings {
guiFrameManager.removeControlledUnit(controlledUnit);
- while (pamControlledUnits.contains(controlledUnit)) {
- pamControlledUnits.remove(controlledUnit);
+ boolean removed = pamConfiguration.removeControlledUnt(controlledUnit);
+ if (removed) {
notifyModelChanged(PamControllerInterface.REMOVE_CONTROLLEDUNIT);
}
// getMainFrame().revalidate(); //handled inside the GUIFrameManager by notify model changed. The controller should have
@@ -873,7 +865,7 @@ public class PamController implements PamControllerInterface, PamSettings {
int[] newOrder = ModuleOrderDialog.showDialog(this, parentFrame);
if (newOrder != null) {
// re-order the modules according the new list.
- reOrderModules(newOrder);
+ pamConfiguration.reOrderModules(newOrder);
notifyModelChanged(PamControllerInterface.REORDER_CONTROLLEDUNITS);
@@ -883,22 +875,22 @@ public class PamController implements PamControllerInterface, PamSettings {
return false;
}
- private boolean reOrderModules(int[] newOrder) {
-
- if (pamControlledUnits.size() != newOrder.length) return false;
-
- ArrayList newList = new ArrayList();
-
- for (int i = 0; i < newOrder.length; i++) {
-
- newList.add(pamControlledUnits.get(newOrder[i]));
-
- }
-
- pamControlledUnits = newList;
-
- return true;
- }
+// private boolean reOrderModules(int[] newOrder) {
+//
+// if (pamControlledUnits.size() != newOrder.length) return false;
+//
+// ArrayList newList = new ArrayList();
+//
+// for (int i = 0; i < newOrder.length; i++) {
+//
+// newList.add(pamControlledUnits.get(newOrder[i]));
+//
+// }
+//
+// pamControlledUnits = newList;
+//
+// return true;
+// }
/**
* Swaps the positions of two modules in the main list of modules and
@@ -924,20 +916,12 @@ public class PamController implements PamControllerInterface, PamSettings {
@Override
public PamControlledUnit getControlledUnit(int iUnit) {
- if (iUnit < getNumControlledUnits()) {
- return pamControlledUnits.get(iUnit);
- }
- return null;
+ return pamConfiguration.getControlledUnit(iUnit);
}
@Override
public PamControlledUnit findControlledUnit(String unitType) {
- for (int i = 0; i < getNumControlledUnits(); i++) {
- if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType)) {
- return pamControlledUnits.get(i);
- }
- }
- return null;
+ return pamConfiguration.findControlledUnit(unitType);
}
/**
@@ -946,17 +930,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return list of units.
*/
public ArrayList findControlledUnits(String unitType) {
- ArrayList l = new ArrayList();
- int n = getNumControlledUnits();
- PamControlledUnit pcu;
- for (int i = 0; i < n; i++) {
- pcu = getControlledUnit(i);
- if (pcu.getUnitType().equals(unitType)) {
- l.add(pcu);
- }
- }
-
- return l;
+ return pamConfiguration.findControlledUnits(unitType);
}
/**
* Get a list of PamControlledUnit units of a given type and name, allowing for nulls.
@@ -965,32 +939,12 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return list of units.
*/
public ArrayList findControlledUnits(String unitType, String unitName) {
- ArrayList l = new ArrayList();
- int n = getNumControlledUnits();
- PamControlledUnit pcu;
- for (int i = 0; i < n; i++) {
- pcu = getControlledUnit(i);
- if (unitType != null && !unitType.equals(pcu.getUnitType())) {
- continue;
- }
- if (unitName != null && !unitName.equals(pcu.getUnitName())) {
- continue;
- }
- l.add(pcu);
- }
-
- return l;
+ return pamConfiguration.findControlledUnits(unitType, unitName);
}
@Override
public PamControlledUnit findControlledUnit(String unitType, String unitName) {
- for (int i = 0; i < getNumControlledUnits(); i++) {
- if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType) &&
- pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName)) {
- return pamControlledUnits.get(i);
- }
- }
- return null;
+ return pamConfiguration.findControlledUnit(unitType, unitName);
}
/**
@@ -1002,13 +956,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return Existing module with that class and name.
*/
public PamControlledUnit findControlledUnit(Class unitClass, String unitName) {
- for (int i = 0; i < getNumControlledUnits(); i++) {
- if (pamControlledUnits.get(i).getClass() == unitClass && (unitName == null ||
- pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName))) {
- return pamControlledUnits.get(i);
- }
- }
- return null;
+ return pamConfiguration.findControlledUnit(unitClass, unitName);
}
/**
@@ -1017,13 +965,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return List of current instances of this class.
*/
public ArrayList findControlledUnits(Class unitClass) {
- ArrayList foundUnits = new ArrayList<>();
- for (int i = 0; i < getNumControlledUnits(); i++) {
- if (pamControlledUnits.get(i).getClass() == unitClass) {
- foundUnits.add(pamControlledUnits.get(i));
- }
- }
- return foundUnits;
+ return pamConfiguration.findControlledUnits(unitClass);
}
/**
@@ -1032,16 +974,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return List of current instances of this class.
*/
public ArrayList findControlledUnits(Class unitClass, boolean includeSubClasses) {
- if (includeSubClasses == false) {
- return findControlledUnits(unitClass);
- }
- ArrayList foundUnits = new ArrayList<>();
- for (int i = 0; i < getNumControlledUnits(); i++) {
- if (unitClass.isAssignableFrom(pamControlledUnits.get(i).getClass())) {
- foundUnits.add(pamControlledUnits.get(i));
- }
- }
- return foundUnits;
+ return pamConfiguration.findControlledUnits(unitClass, includeSubClasses);
}
/**
@@ -1049,28 +982,19 @@ public class PamController implements PamControllerInterface, PamSettings {
* @param the controlled unit name e.g. "my crazy click detector", not the default name.
*/
public boolean isControlledUnit(String controlName) {
- for (int i = 0; i < getNumControlledUnits(); i++) {
- if (pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(controlName)) {
- return true;
- }
- }
- return false;
+ return pamConfiguration.isControlledUnit(controlName);
}
@Override
public int getNumControlledUnits() {
- if (pamControlledUnits == null) {
- return 0;
- }
- return pamControlledUnits.size();
+ return pamConfiguration.getNumControlledUnits();
}
static public PamController getInstance() {
return uniqueController;
}
- @Override
- public PamModelInterface getModelInterface() {
+ public PamModel getModelInterface() {
return pamModelInterface;
}
@@ -1187,6 +1111,8 @@ public class PamController implements PamControllerInterface, PamSettings {
globalTimeManager.getGlobalTimeParameters().getStartupDelay());
manualStop = false;
+
+ ArrayList pamControlledUnits = pamConfiguration.getPamControlledUnits();
PamCalendar.setSessionStartTime(startTime);
setPamStatus(PAM_RUNNING);
@@ -1287,6 +1213,7 @@ public class PamController implements PamControllerInterface, PamSettings {
// actually stopped
// statusCheckThread = new Thread(new StatusTimer());
// statusCheckThread.start();
+ ArrayList pamControlledUnits = pamConfiguration.getPamControlledUnits();
// tell all controlled units to stop
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
@@ -1362,6 +1289,8 @@ public class PamController implements PamControllerInterface, PamSettings {
* it is necessary to make sure that all internal datablock
* buffers have had time to empty.
*/
+ ArrayList pamControlledUnits = pamConfiguration.getPamControlledUnits();
+
if (PamModel.getPamModel().isMultiThread()) {
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pamControlledUnits.get(iU).flushDataBlockBuffers(2000);
@@ -1482,6 +1411,8 @@ public class PamController implements PamControllerInterface, PamSettings {
// }
// Debug.out.println(" Are we finished? " + areWeFinished);
// return areWeFinished;
+ ArrayList pamControlledUnits = pamConfiguration.getPamControlledUnits();
+
boolean running = false;
for (PamControlledUnit aUnit : pamControlledUnits) {
int numProcesses = aUnit.getNumPamProcesses();
@@ -1504,16 +1435,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* PAMGUARD settings via the database and binary storage modules.
*/
private void saveSettings(long timeNow) {
- PamControlledUnit pcu;
- PamSettingsSource settingsSource;
- for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
- pcu = pamControlledUnits.get(iU);
- if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
- settingsSource = (PamSettingsSource) pcu;
- settingsSource.saveStartSettings(timeNow);
- }
- }
- PamguardXMLWriter.getXMLWriter().writeStartSettings(timeNow);
+ pamConfiguration.saveSettings(timeNow);
}
/**
@@ -1549,18 +1471,20 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return path to the binary store.
*/
public String findBinaryStorePath() {
- BinaryStore binaryControl = BinaryStore.findBinaryStoreControl();
- if (binaryControl == null) {
- return null;
- }
- String storeLoc = binaryControl.getBinaryStoreSettings().getStoreLocation();
- if (storeLoc == null) {
- return "";
- }
- if (storeLoc.endsWith(File.separator) == false) {
- storeLoc += File.separator;
- }
- return storeLoc;
+// TODO get rid of the singleton binary store control and do from the Config.class
+// BinaryStore binaryControl = BinaryStore.findBinaryStoreControl();
+// if (binaryControl == null) {
+// return null;
+// }
+// String storeLoc = binaryControl.getBinaryStoreSettings().getStoreLocation();
+// if (storeLoc == null) {
+// return "";
+// }
+// if (storeLoc.endsWith(File.separator) == false) {
+// storeLoc += File.separator;
+// }
+// return storeLoc;
+ return pamConfiguration.findBinaryStorePath();
}
/**
@@ -1570,15 +1494,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* @see PamSettingsSource
*/
public ArrayList findSettingsSources() {
- ArrayList settingsSources = new ArrayList();
- PamControlledUnit pcu;
- for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
- pcu = pamControlledUnits.get(iU);
- if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
- settingsSources.add((PamSettingsSource) pcu);
- }
- }
- return settingsSources;
+ return pamConfiguration.findSettingsSources();
}
@Override
@@ -1607,37 +1523,37 @@ public class PamController implements PamControllerInterface, PamSettings {
*/
@Override
public ArrayList getFFTDataBlocks() {
- return makeDataBlockList(FFTDataUnit.class, true);
+ return pamConfiguration.getFFTDataBlocks();
}
@Override
public PamDataBlock getFFTDataBlock(int id) {
- return getDataBlock(FFTDataUnit.class, id);
+ return pamConfiguration.getDataBlock(FFTDataUnit.class, id);
}
@Override
public PamDataBlock getFFTDataBlock(String name) {
- return getDataBlock(FFTDataUnit.class, name);
+ return pamConfiguration.getDataBlock(FFTDataUnit.class, name);
}
@Override
public ArrayList getRawDataBlocks() {
- return makeDataBlockList(RawDataUnit.class, true);
+ return pamConfiguration.makeDataBlockList(RawDataUnit.class, true);
}
@Override
public PamRawDataBlock getRawDataBlock(int id) {
- return (PamRawDataBlock) getDataBlock(RawDataUnit.class, id);
+ return (PamRawDataBlock) pamConfiguration.getDataBlock(RawDataUnit.class, id);
}
@Override
public PamRawDataBlock getRawDataBlock(String name) {
- return (PamRawDataBlock) getDataBlock(RawDataUnit.class, name);
+ return pamConfiguration.getRawDataBlock(name);
}
@Override
public ArrayList getDetectorDataBlocks() {
- return makeDataBlockList(PamDetection.class, true);
+ return pamConfiguration.getDetectorDataBlocks();
}
@Override
@@ -1675,33 +1591,16 @@ public class PamController implements PamControllerInterface, PamSettings {
* true.
*/
public ArrayList getDataBlocks(Class blockType, boolean includeSubClasses) {
- return makeDataBlockList(blockType, includeSubClasses);
+ return pamConfiguration.getDataBlocks(blockType, includeSubClasses);
}
@Override
public ArrayList getDataBlocks() {
- return makeDataBlockList(PamDataUnit.class, true);
+ return pamConfiguration.getDataBlocks();
}
public ArrayList getPlottableDataBlocks(GeneralProjector generalProjector) {
-
- ArrayList blockList = new ArrayList();
- PamProcess pP;
- Class unitClass;
- PanelOverlayDraw panelOverlayDraw;
-
- for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
- for (int iP = 0; iP < pamControlledUnits.get(iU)
- .getNumPamProcesses(); iP++) {
- pP = pamControlledUnits.get(iU).getPamProcess(iP);
- for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
- if(pP.getOutputDataBlock(j).canDraw(generalProjector)) {
- blockList.add(pP.getOutputDataBlock(j));
- }
- }
- }
- }
- return blockList;
+ return pamConfiguration.getPlottableDataBlocks(generalProjector);
}
/**
@@ -1728,38 +1627,9 @@ public class PamController implements PamControllerInterface, PamSettings {
// }
// }
// }
- private ArrayList makeDataBlockList(Class classType, boolean includSubClasses) {
-
- ArrayList blockList = new ArrayList();
- PamProcess pP;
- Class unitClass;
-
- for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
- for (int iP = 0; iP < pamControlledUnits.get(iU)
- .getNumPamProcesses(); iP++) {
- pP = pamControlledUnits.get(iU).getPamProcess(iP);
- for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
- //System.out.println("Comparing "+pP.getOutputDataBlock(j).getUnitClass().getCanonicalName()+" to "+classType.getCanonicalName());
- if ((unitClass = pP.getOutputDataBlock(j).getUnitClass()) == classType) {
- blockList.add(pP.getOutputDataBlock(j));
- }
- else if (includSubClasses) {
- if (classType != null && classType.isAssignableFrom(unitClass)) {
- blockList.add(pP.getOutputDataBlock(j));
- }
- // while ((unitClass = unitClass.getSuperclass()) != null) {
- // if (unitClass == classType) {
- // blockList.add(pP.getOutputDataBlock(j));
- // break;
- // }
- // }
- }
- }
- }
- }
-
- return blockList;
- }
+// private ArrayList makeDataBlockList(Class classType, boolean includSubClasses) {
+// return pamConfiguration.makeDataBlockList(classType, includSubClasses);
+// }
/**
* Find a block of a given type with the id number, or null if the number
@@ -1771,10 +1641,7 @@ public class PamController implements PamControllerInterface, PamSettings {
*/
@Override
public PamDataBlock getDataBlock(Class blockType, int id) {
-
- ArrayList blocks = getDataBlocks(blockType, true);
- if (id >= 0 && id < blocks.size()) return blocks.get(id);
- return null;
+ return pamConfiguration.getDataBlock(blockType, id);
}
/**
@@ -1786,23 +1653,7 @@ public class PamController implements PamControllerInterface, PamSettings {
*/
@Override
public PamDataBlock getDataBlock(Class blockType, String name) {
- if (name == null) return null;
- ArrayList blocks = getDataBlocks(blockType, true);
- for (PamDataBlock dataBlock:blocks) {
- if (name.equals(dataBlock.getLongDataName())) { // check for a long name match first
- return dataBlock;
- }
- if (dataBlock instanceof FFTDataBlock) {
- FFTDataBlock fb = (FFTDataBlock) dataBlock;
- if (name.equals(fb.getOldLongDataName())) {
- return dataBlock;
- }
- }
- if (name.equals(dataBlock.toString())) {
- return dataBlock;
- }
- }
- return null;
+ return pamConfiguration.getDataBlock(blockType, name);
}
/**
@@ -1811,20 +1662,7 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return block
*/
public PamDataBlock getDataBlockByLongName(String longName) {
- if (longName == null) return null;
- ArrayList allBlocks = getDataBlocks();
- for (PamDataBlock dataBlock:allBlocks) {
- if (longName.equals(dataBlock.getLongDataName())) {
- return dataBlock;
- }
- if (dataBlock instanceof FFTDataBlock) {
- FFTDataBlock fb = (FFTDataBlock) dataBlock;
- if (longName.equals(fb.getOldLongDataName())) {
- return dataBlock;
- }
- }
- }
- return null;
+ return pamConfiguration.getDataBlockByLongName(longName);
}
/**
@@ -1911,11 +1749,7 @@ public class PamController implements PamControllerInterface, PamSettings {
MasterReferencePoint.notifyModelChanged(changeType);
- // also tell all PamControlledUnits since they may want to find their data source
- // it that was created after they were - i.e. dependencies have got all muddled
- for (int i = 0; i < pamControlledUnits.size(); i++) {
- pamControlledUnits.get(i).notifyModelChanged(changeType);
- }
+ pamConfiguration.notifyModelChanged(changeType);
PamSettingManager.getInstance().notifyModelChanged(changeType);
@@ -1986,6 +1820,7 @@ public class PamController implements PamControllerInterface, PamSettings {
private void changedThreading() {
PamProcess pamProcess;
int nP;
+ ArrayList pamControlledUnits = pamConfiguration.getPamControlledUnits();
for (int i = 0; i < pamControlledUnits.size(); i++) {
nP = pamControlledUnits.get(i).getNumPamProcesses();
for (int iP = 0; iP < nP; iP++) {
@@ -2019,13 +1854,7 @@ public class PamController implements PamControllerInterface, PamSettings {
@Override
public Serializable getSettingsReference() {
- ArrayList usedModules = new ArrayList();
- for (int i = 0; i < pamControlledUnits.size(); i++) {
- usedModules.add(new UsedModuleInfo(pamControlledUnits.get(i).getClass().getName(),
- pamControlledUnits.get(i).getUnitType(),
- pamControlledUnits.get(i).getUnitName()));
- }
- return usedModules;
+ return pamConfiguration.getSettingsReference();
}
@Override
@@ -2067,10 +1896,7 @@ public class PamController implements PamControllerInterface, PamSettings {
// also tell all PamControlledUnits since they may want to find their data source
// it that was created after they were - i.e. dependencies have got all muddled
- for (int i = 0; i < pamControlledUnits.size(); i++) {
- pamControlledUnits.get(i).notifyModelChanged(DESTROY_EVERYTHING);
- }
- pamControlledUnits = null;
+ pamConfiguration.destroyModel();
PamSettingManager.getInstance().reset();
@@ -2395,6 +2221,7 @@ public class PamController implements PamControllerInterface, PamSettings {
public void loadOldSettings(PamSettingsGroup settingsGroup) {
loadOldSettings(settingsGroup, true);
}
+
/**
* Called to load a specific set of PAMGUARD settings in
* viewer mode, which were previously loaded in from a
@@ -2499,7 +2326,7 @@ public class PamController implements PamControllerInterface, PamSettings {
continue;
}
aUnit = findControlledUnit(moduleClass, aModuleInfo.unitName);
- currentPos = pamControlledUnits.indexOf(aUnit);
+ currentPos = pamConfiguration.getControlledUnitIndex(aUnit);
if (currentPos >= 0) {
temp = orderLUT[nFound];
orderLUT[nFound] = currentPos;
@@ -2865,4 +2692,12 @@ public class PamController implements PamControllerInterface, PamSettings {
return this.globalMediumManager;
}
+ /**
+ * Gt the main PAMGuard configuration (list of connected modules).
+ * @return the pamConfiguration
+ */
+ public PamConfiguration getPamConfiguration() {
+ return pamConfiguration;
+ }
+
}
diff --git a/src/PamController/PamControllerInterface.java b/src/PamController/PamControllerInterface.java
index 3f6dd192..d363f958 100644
--- a/src/PamController/PamControllerInterface.java
+++ b/src/PamController/PamControllerInterface.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
import javax.swing.JFrame;
-import PamModel.PamModelInterface;
+import PamModel.PamModel;
import PamModel.PamModuleInfo;
import PamView.GuiFrameManager;
import PamView.PamViewInterface;
@@ -102,7 +102,7 @@ public interface PamControllerInterface {
*
* @return Reference to the PamGuard model
*/
- public PamModelInterface getModelInterface();
+ public PamModel getModelInterface();
/**
* Instruction to the controller (probably from a menu command inthe view)
diff --git a/src/PamController/PamSettingManager.java b/src/PamController/PamSettingManager.java
index d101fad7..ddd15740 100644
--- a/src/PamController/PamSettingManager.java
+++ b/src/PamController/PamSettingManager.java
@@ -293,7 +293,7 @@ public class PamSettingManager {
* call this for at least one set of settings. Often the PamSettings
* is implemented by the class that extends PamControlledunit, but
* it's also possible to have multiple sub modules, processes or displays
- * implemnt PamSettings so that different settings for different bits of
+ * implement PamSettings so that different settings for different bits of
* a PamControlledUnit are stored separately.
* @see PamSettings
* @see PamControlledUnit
diff --git a/src/PamController/PamguardVersionInfo.java b/src/PamController/PamguardVersionInfo.java
index a5d16d78..7172293c 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.09b";
+ static public final String version = "2.02.09c";
/**
* Release date
*/
- static public final String date = "29 June 2023";
+ static public final String date = "10 November 2023";
// /**
// * Release type - Beta or Core
diff --git a/src/PamModel/PamModel.java b/src/PamModel/PamModel.java
index f793aa58..ff425f38 100644
--- a/src/PamModel/PamModel.java
+++ b/src/PamModel/PamModel.java
@@ -79,7 +79,7 @@ import PamUtils.FileFinder;
* PamController.
*
*/
-final public class PamModel implements PamModelInterface, PamSettings {
+final public class PamModel implements PamSettings {
private PamController pamController;
@@ -1000,7 +1000,6 @@ final public class PamModel implements PamModelInterface, PamSettings {
}
- @Override
public boolean modelSettings(JFrame frame) {
PamModelSettings newSettings = ThreadingDialog.showDialog(frame, pamModelSettings);
if (newSettings != null) {
diff --git a/src/PamModel/PamModelInterface.java b/src/PamModel/PamModelInterface.java
index 2ad342e0..9875e25a 100644
--- a/src/PamModel/PamModelInterface.java
+++ b/src/PamModel/PamModelInterface.java
@@ -29,6 +29,7 @@ import javax.swing.JFrame;
* order that the PamController and the PamView can interface with the
* model.
*/
+@Deprecated
public interface PamModelInterface {
/**
diff --git a/src/PamModel/PamModuleInfo.java b/src/PamModel/PamModuleInfo.java
index 8284e145..e7ba3945 100644
--- a/src/PamModel/PamModuleInfo.java
+++ b/src/PamModel/PamModuleInfo.java
@@ -10,6 +10,7 @@ import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamController;
import PamController.PamControllerInterface;
@@ -34,6 +35,9 @@ public class PamModuleInfo implements PamDependent{
private Class moduleClass;
private String toolTipText;
+ private static final Class[] constrParams1 = {PamConfiguration.class, String.class};
+ private static final Class[] constrParams2 = {String.class};
+
/**
* A list of possible GUI types the module can have. These are received from flags in PAMGuiManager();
*/
@@ -209,7 +213,7 @@ public class PamModuleInfo implements PamDependent{
dependencyManager.checkDependency(parentFrame, moduleInfo, true);
}
// create a new PamControlledUnit and add it to PamGuard ...
- PamControllerInterface pamController = PamController.getInstance();
+ PamController pamController = PamController.getInstance();
pamController.addModule(parentFrame, moduleInfo);
}
@@ -219,38 +223,63 @@ public class PamModuleInfo implements PamDependent{
public AddModuleMenuAction getMenuAction(Frame parentFrame) {
return new AddModuleMenuAction(parentFrame, this);
}
-
+
public PamControlledUnit create(String unitName) {
+ return create(null, unitName);
+ }
+
+ public PamControlledUnit create(PamConfiguration pamConfiguration, String unitName) {
PamControlledUnit newUnit = null;
- Class[] paramList = new Class[1];
- paramList[0] = unitName.getClass();
+// Class[] paramList = new Class[1];
+// paramList[0] = unitName.getClass();
+ boolean error = false;
try {
- Constructor constructor = moduleClass.getConstructor(paramList);
-// Debug.out.println("unitName:"+ unitName);
- newUnit = (PamControlledUnit) constructor.newInstance(unitName);
+ Constructor constructor = moduleClass.getConstructor(constrParams1);
+ newUnit = (PamControlledUnit) constructor.newInstance(pamConfiguration, unitName);
newUnit.setPamModuleInfo(this);
}
catch (Exception Ex) {
- String title = "Error loading module";
- String msg = "There was an error trying to load " + unitName + "." +
- "If this is a core Pamguard module, please copy the error message text and email to " +
- "support@pamguard.org.
" +
- "If this is a plug-in, the error may have been caused by an incompatibility between " +
- "it and this version of PAMGuard, or a problem with the code. Please check the developer's website for help.
" +
- "This module will not be loaded.";
- String help = null;
- int ans = WarnOnce.showWarning(title, msg, WarnOnce.WARNING_MESSAGE, help, Ex);
- System.err.println("Exception while loading " + Ex.getMessage());
- Ex.printStackTrace();
- return null;
}
-
+ if (newUnit == null) {
+ try {
+ Constructor constructor = moduleClass.getConstructor(constrParams2);
+ newUnit = (PamControlledUnit) constructor.newInstance(unitName);
+ newUnit.setPamModuleInfo(this);
+ }
+ catch (Exception Ex) {
+ String title = "Error loading module";
+ String msg = "There was an error trying to load " + unitName + ".
" +
+ "If this is a core Pamguard module, please copy the error message text and email to " +
+ "support@pamguard.org.
" +
+ "If this is a plug-in, the error may have been caused by an incompatibility between " +
+ "it and this version of PAMGuard, or a problem with the code. Please check the developer's website for help.
" +
+ "This module will not be loaded.";
+ String help = null;
+ int ans = WarnOnce.showWarning(title, msg, WarnOnce.WARNING_MESSAGE, help, Ex);
+ System.err.println("Exception while loading " + Ex.getMessage());
+ Ex.printStackTrace();
+ return null;
+ }
+ }
+
setNInstances(nInstances + 1);
return newUnit;
}
+ private Constructor findConstructor() throws NoSuchMethodException, SecurityException {
+ Constructor constructor = null;
+ try {
+ constructor = moduleClass.getConstructor(constrParams1);
+ return constructor;
+ } catch (NoSuchMethodException | SecurityException e1) {
+ }
+
+ constructor = moduleClass.getConstructor(constrParams2);
+ return constructor;
+ }
+
private void moduleRemoved(PamControlledUnit controlledUnit) {
setNInstances(nInstances - 1);
@@ -376,7 +405,7 @@ public class PamModuleInfo implements PamDependent{
}
public void actionPerformed(ActionEvent e) {
- int ans = JOptionPane.showConfirmDialog(pamControlledUnit.getPamView().getGuiFrame(),
+ int ans = JOptionPane.showConfirmDialog(pamControlledUnit.getGuiFrame(),
"Do you really want to remove the module "
+ pamControlledUnit.getUnitName());
if (ans == JOptionPane.YES_OPTION) {
diff --git a/src/PamUtils/TxtFileUtils.java b/src/PamUtils/TxtFileUtils.java
index 58d8c72b..72bab5fc 100644
--- a/src/PamUtils/TxtFileUtils.java
+++ b/src/PamUtils/TxtFileUtils.java
@@ -89,7 +89,8 @@ public class TxtFileUtils {
//5/08/2022 - there was a bug here where there is some sort of invisible character that does not appear on the
//print screen - the only way you can tell is the char array is greater than the number of digits - removed all non numeric
//characters.
- String number = new String(recordsOnLine[i].strip().replaceAll("[^\\d.]", ""));
+ // updated again on 15/11/23 to include - signs, or you end up with the abs(of every number!)
+ String number = new String(recordsOnLine[i].strip().replaceAll("[^\\d.-]", ""));
dat = Double.valueOf(number);
//dat = DecimalFormat.getNumberInstance().parse(new String(recordsOnLine[i].strip().toCharArray())).doubleValue();
}
diff --git a/src/PamView/PamGui.java b/src/PamView/PamGui.java
index fed07f88..ed596c5d 100644
--- a/src/PamView/PamGui.java
+++ b/src/PamView/PamGui.java
@@ -89,7 +89,6 @@ import PamController.PamguardVersionInfo;
import PamController.settings.SettingsImport;
import PamModel.CommonPluginInterface;
import PamModel.PamModel;
-import PamModel.PamModelInterface;
import PamModel.PamModuleInfo;
import PamModel.PamPluginInterface;
import PamModel.AboutPluginDisplay;
@@ -135,11 +134,14 @@ public class PamGui extends PamView implements WindowListener, PamSettings {
* Outer layered pane which allows things to be added the GUI.
*/
private JLayeredPane layeredPane;
+ private PamController pamController;
- public PamGui(PamControllerInterface pamControllerInterface,
- PamModelInterface pamModelInterface, int frameNumber)
+ public PamGui(PamController pamControllerInterface,
+ PamModel pamModelInterface, int frameNumber)
{
super(pamControllerInterface, pamModelInterface, frameNumber);
+
+ this.pamController = pamControllerInterface;
startMenuEnabler = new MenuItemEnabler();
stopMenuEnabler = new MenuItemEnabler();
@@ -1201,7 +1203,7 @@ public class PamGui extends PamView implements WindowListener, PamSettings {
class menuShowObjectDiagram implements ActionListener {
public void actionPerformed(ActionEvent ev){
- PamObjectViewer.Show(getGuiFrame());
+ PamObjectViewer.Show(getGuiFrame(), pamController.getPamConfiguration());
}
}
diff --git a/src/PamView/PamMenu.java b/src/PamView/PamMenu.java
index 836c7c0d..62ef9280 100644
--- a/src/PamView/PamMenu.java
+++ b/src/PamView/PamMenu.java
@@ -26,7 +26,7 @@ import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
-import PamModel.PamModelInterface;
+import PamModel.PamModel;
/**
* @author dgillespie
@@ -39,7 +39,7 @@ import PamModel.PamModelInterface;
*
*/
public class PamMenu {
- static public JMenuBar createBasicMenu(PamModelInterface pamModelInterface,
+ static public JMenuBar createBasicMenu(PamModel pamModelInterface,
ActionListener actionListener) {
JMenuBar menuBar = new JMenuBar();
@@ -52,7 +52,7 @@ public class PamMenu {
return menuBar;
}
- static public JMenu fileMenu(PamModelInterface pamModelInterface,
+ static public JMenu fileMenu(PamModel pamModelInterface,
ActionListener actionListener) {
JMenuItem menuItem;
JMenu menu = new JMenu("File");
@@ -64,7 +64,7 @@ public class PamMenu {
return menu;
}
- static public JMenu loggingMenu(PamModelInterface pamModelInterface,
+ static public JMenu loggingMenu(PamModel pamModelInterface,
ActionListener actionListener) {
JMenuItem menuItem;
JMenu menu = new JMenu("Logging");
@@ -76,7 +76,7 @@ public class PamMenu {
return menu;
}
- static public JMenu detectionMenu(PamModelInterface pamModelInterface,
+ static public JMenu detectionMenu(PamModel pamModelInterface,
ActionListener actionListener) {
JMenu menu = new JMenu("Detection");
JMenuItem menuItem;
@@ -108,7 +108,7 @@ public class PamMenu {
return menu;
}
- static public JMenu displayMenu(PamModelInterface pamModelInterface,
+ static public JMenu displayMenu(PamModel pamModelInterface,
ActionListener actionListener) {
JMenu menu = new JMenu("Display");
JMenuItem menuItem;
diff --git a/src/PamView/PamObjectViewer.java b/src/PamView/PamObjectViewer.java
index 2801162b..17525076 100644
--- a/src/PamView/PamObjectViewer.java
+++ b/src/PamView/PamObjectViewer.java
@@ -42,6 +42,7 @@ import javax.swing.Timer;
import javax.swing.WindowConstants;
import PamController.NewModuleDialog;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings;
import PamController.PamController;
@@ -114,9 +115,11 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
private Stroke arrowStroke, instantArrowStroke;
+ private PamConfiguration pamConfiguration;
+
// Font controllerFont, processFont, datablockFont;
- private PamObjectViewer(JFrame frame) {
+ private PamObjectViewer(Frame frame) {
arrowStroke = new BasicStroke(1.5f);
instantArrowStroke = new BasicStroke(1.5f);
@@ -125,23 +128,27 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
objectFrame = new ObjectFrame(frame);
- MakeDiagram();
+// MakeDiagram();
PamController.getInstance().addView(this);
PamSettingManager.getInstance().registerSettings(this);
}
- static public PamObjectViewer getObjectViewer(JFrame frame) {
+ static public PamObjectViewer getObjectViewer(Frame frame) {
if (singleInstance == null) {
singleInstance = new PamObjectViewer(frame);
}
return singleInstance;
}
- static public void Show(JFrame frame) {
+ static public void Show(Frame frame, PamConfiguration pamConfiguration) {
+
+ getObjectViewer(frame).setConfiguration(pamConfiguration);
getObjectViewer(frame).objectFrame.setVisible(true);
+ singleInstance.MakeDiagram();
+
// Go through all of the processes/datablocks in every view and update button/tooltip text.
// Mostly done for the FFT Engine process because it includes the FFT size in the
// process name, and without this code the name would get set the first time you open
@@ -164,6 +171,10 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
}
}
+ private void setConfiguration(PamConfiguration pamConfiguration) {
+ this.pamConfiguration = pamConfiguration;
+ }
+
void MakeDiagram() {
if (pamObjectViewerSettings.viewStyle == PamObjectViewerSettings.VIEWBYPROCESS) {
@@ -180,12 +191,16 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
private void makeControllerDiagram() {
clearDiagram();
- PamControllerInterface pamController = PamController.getInstance();
+
+ if (pamConfiguration == null) {
+ return;
+ }
+
PamControlledUnit pamControlledUnit;
PamControllerView pamControllerView;
controllerList = new ArrayList();
- for (int iUnit = 0; iUnit < pamController.getNumControlledUnits(); iUnit++) {
- pamControlledUnit = pamController.getControlledUnit(iUnit);
+ for (int iUnit = 0; iUnit < pamConfiguration.getNumControlledUnits(); iUnit++) {
+ pamControlledUnit = pamConfiguration.getControlledUnit(iUnit);
if (pamControlledUnit.getNumPamProcesses() == 0
&& pamObjectViewerSettings.showProcesslessModules == false) {
continue;
@@ -198,25 +213,6 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
}
- // private void makeProcesslessModules() {
- // PamControllerInterface pamController = PamController.getInstance();
- // PamControlledUnit pamControlledUnit;
- // PamControllerView pamControllerView;
- // if (controllerList == null)
- // controllerList = new ArrayList();
- // for (int iUnit = 0; iUnit < pamController.getNumControlledUnits();
- // iUnit++) {
- // pamControlledUnit = pamController.getControlledUnit(iUnit);
- // if (pamControlledUnit.getNumPamProcesses() > 0) {
- // continue;
- // }
- // pamControllerView = new PamControllerView(pamControlledUnit);
- // controllerList.add(pamControllerView);
- // layoutPanel.add(pamControllerView);
- // pamControllerView.addComponentListener(this);
- // }
- //
- // }
private void layoutControllerDiagram() {
if (controllerList == null) {
return;
@@ -285,11 +281,10 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
int x = xStart;
int y = yStart;
- PamControllerInterface pamController = PamController.getInstance();
PamControlledUnit pamControlledUnit;
PamProcess pamProcess;
- for (int iUnit = 0; iUnit < pamController.getNumControlledUnits(); iUnit++) {
- pamControlledUnit = pamController.getControlledUnit(iUnit);
+ for (int iUnit = 0; iUnit < pamConfiguration.getNumControlledUnits(); iUnit++) {
+ pamControlledUnit = pamConfiguration.getControlledUnit(iUnit);
for (int iP = 0; iP < pamControlledUnit.getNumPamProcesses(); iP++) {
pamProcess = pamControlledUnit.getPamProcess(iP);
pamProcessView = new PamProcessView(pamControlledUnit,
@@ -417,7 +412,7 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
class ObjectFrame extends JFrame implements ActionListener {
- ObjectFrame(JFrame frame) {
+ ObjectFrame(Frame frame) {
setTitle("Pamguard Data Model");
// fixed case of Resources 17/8/08 DG.
@@ -599,6 +594,9 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
int bestYGap;
Rectangle sourceBounds, destBounds;
hasInstant = false;
+ if (controllerList == null) {
+ return;
+ }
for (int i = 0; i < controllerList.size(); i++) {
pamControllerView = controllerList.get(i);
pamControlledUnit = pamControllerView.pamControlledUnit;
diff --git a/src/PamView/PamView.java b/src/PamView/PamView.java
index f742de52..bcd6e259 100644
--- a/src/PamView/PamView.java
+++ b/src/PamView/PamView.java
@@ -24,7 +24,7 @@ import javax.swing.JFrame;
import PamController.PamControlledUnit;
import PamController.PamControllerInterface;
-import PamModel.PamModelInterface;
+import PamModel.PamModel;
import javafx.application.Platform;
/**
@@ -36,7 +36,7 @@ abstract public class PamView implements PamViewInterface {
protected PamControllerInterface pamControllerInterface;
- protected PamModelInterface pamModelInterface;
+ protected PamModel pamModelInterface;
/**
* Frame for main window associated with this view (i.e a PamGUI).
@@ -47,7 +47,7 @@ abstract public class PamView implements PamViewInterface {
public PamView(PamControllerInterface pamControllerInterface,
- PamModelInterface pamModelInterface, int frameNumber) {
+ PamModel pamModelInterface, int frameNumber) {
this.pamControllerInterface = pamControllerInterface;
this.pamModelInterface = pamModelInterface;
this.frameNumber = frameNumber;
diff --git a/src/PamView/component/DataBlockTableView.java b/src/PamView/component/DataBlockTableView.java
index f8ae214f..af5918cf 100644
--- a/src/PamView/component/DataBlockTableView.java
+++ b/src/PamView/component/DataBlockTableView.java
@@ -11,6 +11,7 @@ import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
+import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
@@ -128,6 +129,14 @@ public abstract class DataBlockTableView {
}
}
+ /**
+ * Get table. Allows adding of more menu handlers, etc.
+ * @return the table object.
+ */
+ public JTable getTable() {
+ return testTable;
+ }
+
/**
* Set allowing of multiple row selection.
* @param allow
@@ -228,7 +237,7 @@ public abstract class DataBlockTableView {
* @param tableRow
* @return data unit for the table row.
*/
- private final T getDataUnit(int tableRow) {
+ protected final T getDataUnit(int tableRow) {
synchronized (copySynch) {
int rowIndex = getDataIndexForRow(tableRow);
if (rowIndex < 0) return null;
@@ -377,7 +386,7 @@ public abstract class DataBlockTableView {
* so consider changing the row selection
* @param e
*/
- private void checkRowSelection(MouseEvent e) {
+ protected void checkRowSelection(MouseEvent e) {
int tableRow = testTable.rowAtPoint(e.getPoint());
int currentRow = testTable.getSelectedRow();
if (tableRow != currentRow) {
@@ -389,6 +398,16 @@ public abstract class DataBlockTableView {
}
}
+ /**
+ * Put the getColumnName function out here, so that subclasses can
+ * more easily override it than if it's buried in the table model
+ * @param column
+ * @return colum name
+ */
+ public String getColumnName(int column) {
+ return getColumnNames()[column];
+ }
+
private class ViewScrollObserver implements PamScrollObserver {
@Override
@@ -448,7 +467,7 @@ public abstract class DataBlockTableView {
*/
@Override
public String getColumnName(int column) {
- return getColumnNames()[column];
+ return DataBlockTableView.this.getColumnName(column);
}
/* (non-Javadoc)
diff --git a/src/PamView/dialog/GroupedSourcePanel.java b/src/PamView/dialog/GroupedSourcePanel.java
index c4914ca5..3906dc45 100644
--- a/src/PamView/dialog/GroupedSourcePanel.java
+++ b/src/PamView/dialog/GroupedSourcePanel.java
@@ -154,9 +154,13 @@ public class GroupedSourcePanel extends SourcePanel {
public void setChannelGroups(int[] channelGroups) {
if (channelGroups == null) return;
- for (int i = 0; i < Math.min(channelGroups.length, PamConstants.MAX_CHANNELS); i++) {
+ for (int i = 0; i < Math.min(channelGroups.length, PamConstants.MAX_CHANNELS); i++) { try {
groupList[i].setSelectedIndex(channelGroups[i]);
}
+ catch (Exception e) {
+
+ }
+ }
}
public static void addComponent(JPanel panel, Component p, GridBagConstraints constraints){
diff --git a/src/SoundRecorder/RecorderTabPanel.java b/src/SoundRecorder/RecorderTabPanel.java
index 67dd07fd..799684aa 100644
--- a/src/SoundRecorder/RecorderTabPanel.java
+++ b/src/SoundRecorder/RecorderTabPanel.java
@@ -343,7 +343,7 @@ public class RecorderTabPanel implements PamTabPanel, RecorderView {
class SettingsButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
- recorderControl.recordSettingsDialog(recorderControl.getPamView().getGuiFrame());
+ recorderControl.recordSettingsDialog(recorderControl.getGuiFrame());
}
}
diff --git a/src/Spectrogram/SpectrogramDisplay.java b/src/Spectrogram/SpectrogramDisplay.java
index bc1726cf..0f90919d 100644
--- a/src/Spectrogram/SpectrogramDisplay.java
+++ b/src/Spectrogram/SpectrogramDisplay.java
@@ -107,6 +107,7 @@ import PamView.GeneralProjector;
import PamView.ColourArray.ColourArrayType;
import PamView.dialog.PamLabel;
import PamView.PamColors;
+import PamView.PamView;
import PamView.hidingpanel.HidingDialogPanel;
import PamView.panel.CornerLayout;
import PamView.panel.CornerLayoutContraint;
@@ -275,11 +276,13 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
// }
if (spectrogramParameters == null) {
this.spectrogramParameters = new SpectrogramParameters();
- // setSettings(); // force up the dialog.
- SpectrogramParameters newParams = SpectrogramParamsDialog
- .showDialog(userDisplayControl.getPamView().getGuiFrame(), spectrogramPanels, spectrogramParameters);
- if (newParams != null) {
- this.spectrogramParameters = newParams;
+ PamView view = userDisplayControl.getPamView();
+ if (view != null) {
+ SpectrogramParameters newParams = SpectrogramParamsDialog
+ .showDialog(userDisplayControl.getGuiFrame(), spectrogramPanels, spectrogramParameters);
+ if (newParams != null) {
+ this.spectrogramParameters = newParams;
+ }
}
}
@@ -1184,7 +1187,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
// SpectrogramParameters newParams = SpectrogramParamsDialog
// .showDialog(userDisplayControl.getPamView().getGuiFrame(), this.getOverlayMarker(), spectrogramParameters);
SpectrogramParameters newParams = SpectrogramParamsDialog
- .showDialog(userDisplayControl.getPamView().getGuiFrame(), spectrogramPanels, spectrogramParameters);
+ .showDialog(userDisplayControl.getGuiFrame(), spectrogramPanels, spectrogramParameters);
if (newParams == null) return;
diff --git a/src/alarm/AlarmOfflineTask.java b/src/alarm/AlarmOfflineTask.java
index c1e40c33..47aa8c06 100644
--- a/src/alarm/AlarmOfflineTask.java
+++ b/src/alarm/AlarmOfflineTask.java
@@ -62,7 +62,7 @@ public class AlarmOfflineTask extends OfflineTask {
@Override
public boolean callSettings() {
- Frame frame = alarmControl.getPamView().getGuiFrame();
+ Frame frame = alarmControl.getGuiFrame();
boolean ok = alarmControl.showAlarmDialog(frame);
if (ok) {
setParentDataBlock(alarmProcess.getSourceDataBlock());
diff --git a/src/analogarraysensor/ArraySensorParams.java b/src/analogarraysensor/ArraySensorParams.java
index bd63bbaa..b84081a6 100644
--- a/src/analogarraysensor/ArraySensorParams.java
+++ b/src/analogarraysensor/ArraySensorParams.java
@@ -11,7 +11,7 @@ public class ArraySensorParams implements Serializable, Cloneable, ManagedParame
public static final long serialVersionUID = 1L;
- public int readIntervalMillis = 1000;
+ public volatile int readIntervalMillis = 1000;
private ArrayDisplayParameters arrayDisplayParameters;
diff --git a/src/analogarraysensor/ArraySensorProcess.java b/src/analogarraysensor/ArraySensorProcess.java
index 7b656146..df909217 100644
--- a/src/analogarraysensor/ArraySensorProcess.java
+++ b/src/analogarraysensor/ArraySensorProcess.java
@@ -45,7 +45,8 @@ public class ArraySensorProcess extends PamProcess {
while(true) {
readData();
try {
- Thread.sleep(analogSensorControl.getAnalogSensorParams().readIntervalMillis);
+ int slptime = analogSensorControl.getAnalogSensorParams().readIntervalMillis;
+ Thread.sleep(slptime);
} catch (InterruptedException e) {
e.printStackTrace();
}
diff --git a/src/analoginput/brainboxes/BrainBoxDevices.java b/src/analoginput/brainboxes/BrainBoxDevices.java
index 6b16b3b2..2d4ae91a 100644
--- a/src/analoginput/brainboxes/BrainBoxDevices.java
+++ b/src/analoginput/brainboxes/BrainBoxDevices.java
@@ -139,7 +139,7 @@ public class BrainBoxDevices implements AnalogDeviceType, PamSettings{
double sensData = BBED549.hexToEngineering(bbRanges[item], sensInts);
double paramValue = calibration.rawToValue(sensData, calibrationData[item]);
analogDevicesManager.notifyData(new ItemAllData(item, sensInts, sensData, paramValue));
-// System.out.printf("Read item %d, chan %d, int %d, real %3.5f, param %3.5f\n", iChan, chan, sensInts, sensData, paramValue);
+// System.out.printf("Read item %d, chan %d, int %d, real %3.5f, param %3.5f\n", 0, chan, sensInts, sensData, paramValue);
sayError(null);
return new AnalogSensorData(sensData, paramValue);
diff --git a/src/analoginput/swing/AnalogDiagnosticsDisplay.java b/src/analoginput/swing/AnalogDiagnosticsDisplay.java
index d4a19d5a..2dac0c96 100644
--- a/src/analoginput/swing/AnalogDiagnosticsDisplay.java
+++ b/src/analoginput/swing/AnalogDiagnosticsDisplay.java
@@ -221,7 +221,7 @@ public class AnalogDiagnosticsDisplay extends UserDisplayComponentAdapter implem
break;
case 3:
if (lastUpdate[rowIndex] > 0) {
- return PamCalendar.formatTime(lastUpdate[rowIndex]);
+ return PamCalendar.formatTime(lastUpdate[rowIndex], true);
}
break;
case 4:
diff --git a/src/autecPhones/AutecPhonesControl.java b/src/autecPhones/AutecPhonesControl.java
index 3051d1f8..09bced27 100644
--- a/src/autecPhones/AutecPhonesControl.java
+++ b/src/autecPhones/AutecPhonesControl.java
@@ -22,7 +22,7 @@ public class AutecPhonesControl extends PamControlledUnit {
}
public Frame getGuiFrame() {
- return super.getPamView().getGuiFrame();
+ return super.getGuiFrame();
}
class AutecProcess extends PamProcess {
diff --git a/src/bearinglocaliser/offline/BLOfflineTask.java b/src/bearinglocaliser/offline/BLOfflineTask.java
index 3f98c031..3fcde7c1 100644
--- a/src/bearinglocaliser/offline/BLOfflineTask.java
+++ b/src/bearinglocaliser/offline/BLOfflineTask.java
@@ -22,6 +22,7 @@ public class BLOfflineTask extends OfflineTask {
this.bearingLocaliserControl = bearingLocaliserControl;
bearingProcess = bearingLocaliserControl.getBearingProcess();
this.addRequiredDataBlock(rawOrFFTBlock = bearingProcess.getParentDataBlock());
+ addAffectedDataBlock(detectionBlock);
// PamDataBlock detectionSource = bearingLocaliserControl.getDetectionMonitor().getParentDataBlock();
// this.setParentDataBlock(detectionSource);
// setParentDataBlock(bearingProcess.getParentDataBlock());
diff --git a/src/binaryFileStorage/BinaryStore.java b/src/binaryFileStorage/BinaryStore.java
index 97e85358..39dbb8b4 100644
--- a/src/binaryFileStorage/BinaryStore.java
+++ b/src/binaryFileStorage/BinaryStore.java
@@ -929,7 +929,7 @@ PamSettingsSource, DataOutputStore {
protected void process(List chunks) {
if (PamGUIManager.isSwing()) {
if (binaryMapDialog == null) {
- binaryMapDialog = BinaryMapMakingDialog.showDialog(getPamView().getGuiFrame());
+ binaryMapDialog = BinaryMapMakingDialog.showDialog(PamController.getMainFrame());
}
super.process(chunks);
for (int i = 0; i < chunks.size(); i++) {
@@ -2376,7 +2376,7 @@ PamSettingsSource, DataOutputStore {
* Get the unit type for the binary store.
* @return the binary store unit type.
*/
- private static String getBinaryUnitType() {
+ public static String getBinaryUnitType() {
return defUnitType;
}
diff --git a/src/clickDetector/ClickBTDisplay.java b/src/clickDetector/ClickBTDisplay.java
index 40c1bd1e..f91c3ebd 100644
--- a/src/clickDetector/ClickBTDisplay.java
+++ b/src/clickDetector/ClickBTDisplay.java
@@ -2771,7 +2771,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
BTDisplayParameters newParameters =
ClickDisplayDialog.showDialog(clickControl,
- clickControl.getPamView().getGuiFrame(), btDisplayParameters);
+ clickControl.getGuiFrame(), btDisplayParameters);
if (newParameters != null){
btDisplayParameters = newParameters.clone();
if (getVScaleManager() != null) {
diff --git a/src/clickDetector/ClickControl.java b/src/clickDetector/ClickControl.java
index 5bd48dd9..e03b73a7 100644
--- a/src/clickDetector/ClickControl.java
+++ b/src/clickDetector/ClickControl.java
@@ -44,6 +44,7 @@ import binaryFileStorage.BinaryStore;
import Filters.FilterDialog;
import Filters.FilterParams;
import Localiser.detectionGroupLocaliser.GroupDetection;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings;
@@ -97,6 +98,7 @@ import dataPlotsFX.data.TDDataProviderRegisterFX;
import detectionPlotFX.data.DDPlotRegister;
import detectionPlotFX.rawDDPlot.ClickDDPlotProvider;
import fftManager.fftorganiser.FFTDataOrganiser;
+import offlineProcessing.OfflineTaskGroup;
/**
* Main Controller for click detection.
@@ -207,9 +209,22 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
public static final String UNITTYPE = "Click Detector";
+ /**
+ * Old style constructor which only gets a name
+ * @param name
+ */
public ClickControl(String name) {
+ this(null, name);
+ }
+
+ /**
+ * New style constructor which get a configuraiton and a name.
+ * @param pamConfiguration
+ * @param name
+ */
+ public ClickControl(PamConfiguration pamConfiguration, String name) {
- super(UNITTYPE, name);
+ super(pamConfiguration, UNITTYPE, name);
sortDataBlockPrefix();
@@ -220,7 +235,6 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
// }
clickControl = this;
-
angleVetoes = new AngleVetoes(this);
offlineToolbar = new OfflineToolbar(this);
@@ -288,6 +302,9 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
roccaControl = (RoccaControl) PamController.getInstance().findControlledUnit(RoccaControl.unitType);
}
+ else {
+ ClicksOffline.getOfflineTaskGroup(this);
+ }
if (PamGUIManager.isSwing()) {
@@ -988,6 +1005,19 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
return clicksOffline;
}
+// /**
+// * @return the number of offlineTaskGroups
+// */
+// public int getNumOfflineTaskGroups() {
+// return 1;
+// }
+//
+// /**
+// * @return the iTH offlineTaskGroup
+// */
+// public OfflineTaskGroup getOfflineTaskGroup(int i) {
+// return offlineTaskGroups.get(i);
+// }
/**
* @return the latestOfflineEvent
@@ -1187,7 +1217,8 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
* @return
*/
public PamRawDataBlock findRawDataBlock() {
- return (PamController.getInstance().getRawDataBlock(clickParameters.getRawDataSource()));
+ return getPamConfiguration().getRawDataBlock(clickParameters.getRawDataSource());
+// return (PamController.getInstance().getRawDataBlock(clickParameters.getRawDataSource()));
}
diff --git a/src/clickDetector/ClickDetector.java b/src/clickDetector/ClickDetector.java
index d7330047..56b9481e 100644
--- a/src/clickDetector/ClickDetector.java
+++ b/src/clickDetector/ClickDetector.java
@@ -403,7 +403,7 @@ public class ClickDetector extends PamProcess {
// try to connect automatically to the acquisition module ...
// ArrayList rawBlocks =
// PamController.getInstance().getDataBlocks(RawDataUnit.class, false);
- AcquisitionControl daq = (AcquisitionControl) PamController.getInstance()
+ AcquisitionControl daq = (AcquisitionControl) clickControl.getPamConfiguration()
.findControlledUnit(AcquisitionControl.unitType);
if (daq != null) {
rawDataSource = daq.getRawDataBlock();
diff --git a/src/clickDetector/ClickSpectrum.java b/src/clickDetector/ClickSpectrum.java
index e0af7e1e..11c5c2ff 100644
--- a/src/clickDetector/ClickSpectrum.java
+++ b/src/clickDetector/ClickSpectrum.java
@@ -841,7 +841,7 @@ public class ClickSpectrum extends ClickDisplay implements PamObserver , PamSett
pt.x += 10;
pt.y += 20;
ClickSpectrumParams newParams = ClickSpectrumDialog.showDialog(
- clickControl.getPamView().getGuiFrame(), pt, this, clickSpectrumParams);
+ clickControl.getGuiFrame(), pt, this, clickSpectrumParams);
if (newParams != null) {
if (newParams.plotCepstrum) {
newParams.logScale = false;
@@ -859,7 +859,7 @@ public class ClickSpectrum extends ClickDisplay implements PamObserver , PamSett
pt.x += 10;
pt.y += 20;
ClickSpectrumTemplateParams newTempParams = ClickSpectrumTemplateEditDialog.showDialog(
- clickControl.getPamView().getGuiFrame(), pt, this, clickTemplateParams,clickControl);
+ clickControl.getGuiFrame(), pt, this, clickTemplateParams,clickControl);
if (newTempParams!=null){
clickTemplateParams = newTempParams.clone();
sortWestAxis();
@@ -873,7 +873,7 @@ public class ClickSpectrum extends ClickDisplay implements PamObserver , PamSett
pt.x += 10;
pt.y += 20;
ClickSpectrumTemplateParams newTempParams = ClickSpectrumTemplateDialog.showDialog(
- clickControl.getPamView().getGuiFrame(), pt, this, clickTemplateParams);
+ clickControl.getGuiFrame(), pt, this, clickTemplateParams);
if (newTempParams!=null){
clickTemplateParams = newTempParams.clone();
sortWestAxis();
diff --git a/src/clickDetector/ClickWaveform.java b/src/clickDetector/ClickWaveform.java
index aefc7bb1..95706258 100644
--- a/src/clickDetector/ClickWaveform.java
+++ b/src/clickDetector/ClickWaveform.java
@@ -765,7 +765,7 @@ public class ClickWaveform extends ClickDisplay implements PamObserver {
@Override
public void actionPerformed(ActionEvent arg0) {
- ClickParameters newParams = WaveDisplayDialog.showDialog(clickControl.getPamView().getGuiFrame(),
+ ClickParameters newParams = WaveDisplayDialog.showDialog(clickControl.getGuiFrame(),
clickWaveform, clickControl.clickParameters);
if (newParams != null) {
clickControl.clickParameters = newParams.clone();
diff --git a/src/clickDetector/IDI_Display.java b/src/clickDetector/IDI_Display.java
index e000d7fd..383fdf42 100644
--- a/src/clickDetector/IDI_Display.java
+++ b/src/clickDetector/IDI_Display.java
@@ -975,7 +975,7 @@ public class IDI_Display extends ClickDisplay implements PamObserver, PamSetting
pt.y -= 10;
pt.x += 10;
IDI_DisplayParams newParams = IDI_DisplayDialog.showDialog(
- clickControl.getPamView().getGuiFrame(), pt, idiParams);
+ clickControl.getGuiFrame(), pt, idiParams);
if (newParams != null) {
idiParams = newParams.clone();
setParameters();
diff --git a/src/clickDetector/WignerPlot.java b/src/clickDetector/WignerPlot.java
index 2398cd78..eb6c0375 100644
--- a/src/clickDetector/WignerPlot.java
+++ b/src/clickDetector/WignerPlot.java
@@ -248,7 +248,7 @@ public class WignerPlot extends ClickDisplay implements PamSettings {
pt.y -= 10;
pt.x += 10;
WignerPlotOptions newoptions = WignerPlotdialog.showDialog(
- clickControl.getPamView().getGuiFrame(), pt, wignerPlotOptions);
+ clickControl.getGuiFrame(), pt, wignerPlotOptions);
if (newoptions != null) {
wignerPlotOptions = newoptions.clone();
clickedOnClick(lastClick);
diff --git a/src/clickDetector/offlineFuncs/ClickDelayTask.java b/src/clickDetector/offlineFuncs/ClickDelayTask.java
index bb029b4b..0fb08d14 100644
--- a/src/clickDetector/offlineFuncs/ClickDelayTask.java
+++ b/src/clickDetector/offlineFuncs/ClickDelayTask.java
@@ -123,7 +123,7 @@ public class ClickDelayTask extends OfflineTask {
// clickControl.getClickParameters().setDelayMeasurementParams(0, newParams.clone());
// return true;
// }
- ClickParameters newParams = ClickDelayDialog.showDialog(clickControl.getPamView().getGuiFrame(), clickControl);
+ ClickParameters newParams = ClickDelayDialog.showDialog(clickControl.getGuiFrame(), clickControl);
if (newParams != null) {
clickControl.setClickParameters(newParams);
return true;
diff --git a/src/clickDetector/offlineFuncs/ClickReClassifyTask.java b/src/clickDetector/offlineFuncs/ClickReClassifyTask.java
index 911ea1b8..3758e4c7 100644
--- a/src/clickDetector/offlineFuncs/ClickReClassifyTask.java
+++ b/src/clickDetector/offlineFuncs/ClickReClassifyTask.java
@@ -75,7 +75,7 @@ public class ClickReClassifyTask extends OfflineTask {
@Override
public boolean callSettings() {
- return clickControl.classificationDialog(clickControl.getPamView().getGuiFrame());
+ return clickControl.classificationDialog(clickControl.getGuiFrame());
}
diff --git a/src/clickDetector/offlineFuncs/ClicksOffline.java b/src/clickDetector/offlineFuncs/ClicksOffline.java
index 4ee5ad25..4423c721 100644
--- a/src/clickDetector/offlineFuncs/ClicksOffline.java
+++ b/src/clickDetector/offlineFuncs/ClicksOffline.java
@@ -61,8 +61,6 @@ public class ClicksOffline {
private OfflineParameters offlineParameters = new OfflineParameters();
private OLProcessDialog clickOfflineDialog;
-
- private OfflineTaskGroup offlineTaskGroup;
public static final String ClickTypeLookupName = "OfflineRCEvents";
@@ -545,8 +543,8 @@ public class ClicksOffline {
*/
public void reAnalyseClicks() {
if (clickOfflineDialog == null) {
- clickOfflineDialog = new OLProcessDialog(clickControl.getPamView().getGuiFrame(),
- getOfflineTaskGroup(), "Click Reprocessing");
+ clickOfflineDialog = new OLProcessDialog(clickControl.getGuiFrame(),
+ getOfflineTaskGroup(clickControl), "Click Reprocessing");
}
clickOfflineDialog.setVisible(true);
}
@@ -576,8 +574,9 @@ public class ClicksOffline {
* Get / Create an offline task group for click re-processing.
* @return offline task group. Create if necessary
*/
- private OfflineTaskGroup getOfflineTaskGroup() {
- offlineTaskGroup = new OfflineTaskGroup(clickControl, "Click Reprocessing");
+ public static OfflineTaskGroup getOfflineTaskGroup(ClickControl clickControl) {
+
+ OfflineTaskGroup offlineTaskGroup = new OfflineTaskGroup(clickControl, "Click Reprocessing");
/**
* These tasks are not registered - gets too complicated since some of them
@@ -607,7 +606,7 @@ public class ClicksOffline {
}
public void labelClicks(OverlayMark overlayMark, List dataList) {
- Window win = clickControl.getPamView().getGuiFrame();
+ Window win = clickControl.getGuiFrame();
OfflineEventDataUnit event = LabelClicksDialog.showDialog(win, clickControl, overlayMark, dataList);
if (event != null) {
notifyEventChanges(event);
@@ -625,7 +624,7 @@ public class ClicksOffline {
}
public void newEvent(OverlayMark overlayMark, List markedClicks) {
- Window win = clickControl.getPamView().getGuiFrame();
+ Window win = clickControl.getGuiFrame();
OfflineEventDataBlock offlineEventDataBlock = clickControl.getClickDetector().getOfflineEventDataBlock();
if (markedClicks == null) {
return;
@@ -692,7 +691,7 @@ public class ClicksOffline {
}
public void labelClick(OverlayMark overlayMark, PamDataUnit singleClick) {
- Window win = clickControl.getPamView().getGuiFrame();
+ Window win = clickControl.getGuiFrame();
OfflineEventDataUnit event = LabelClicksDialog.showDialog(win, clickControl, overlayMark, singleClick);
if (event != null) {
notifyEventChanges(event);
diff --git a/src/clickDetector/offlineFuncs/EchoDetectionTask.java b/src/clickDetector/offlineFuncs/EchoDetectionTask.java
index f7db4913..1b16b482 100644
--- a/src/clickDetector/offlineFuncs/EchoDetectionTask.java
+++ b/src/clickDetector/offlineFuncs/EchoDetectionTask.java
@@ -90,7 +90,7 @@ public class EchoDetectionTask extends OfflineTask {
if (echoDetectionSystem == null) {
return false;
}
- return EchoDialog.showDialog(clickControl.getPamView().getGuiFrame(), echoDetectionSystem);
+ return EchoDialog.showDialog(clickControl.getGuiFrame(), echoDetectionSystem);
}
/* (non-Javadoc)
diff --git a/src/clickTrainDetector/offline/ClickTrainOfflineProcess.java b/src/clickTrainDetector/offline/ClickTrainOfflineProcess.java
index cef170cb..067d60b4 100644
--- a/src/clickTrainDetector/offline/ClickTrainOfflineProcess.java
+++ b/src/clickTrainDetector/offline/ClickTrainOfflineProcess.java
@@ -84,7 +84,7 @@ public class ClickTrainOfflineProcess {
//if null open the dialog- also create a new offlineTask group if the datablock has changed.
if (clickTrainDialog == null) {
- clickTrainDialog = new CTProcessDialog(this.clickTrainControl.getPamView().getGuiFrame(),
+ clickTrainDialog = new CTProcessDialog(this.clickTrainControl.getGuiFrame(),
clickTrainOfflineGroup, "Click Train Detection");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
}
diff --git a/src/dbht/DbHtControl.java b/src/dbht/DbHtControl.java
index cd561034..4774e2f9 100644
--- a/src/dbht/DbHtControl.java
+++ b/src/dbht/DbHtControl.java
@@ -122,7 +122,7 @@ public class DbHtControl extends PamControlledUnit implements PamSettings {
offlineTaskGroup.addTask(task);
}
if (olProcessDialog == null) {
- olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup, "dBHt Data Export");
+ olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup, "dBHt Data Export");
}
olProcessDialog.setVisible(true);
}
diff --git a/src/difar/DifarControl.java b/src/difar/DifarControl.java
index cb92d3d7..1e1baf49 100644
--- a/src/difar/DifarControl.java
+++ b/src/difar/DifarControl.java
@@ -455,7 +455,7 @@ public class DifarControl extends PamControlledUnit implements PamSettings {
// offlineTaskGroup.addTask(task);
}
OLProcessDialog olProcessDialog;
- olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup, "DIFAR Data Export");
+ olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup, "DIFAR Data Export");
olProcessDialog.setVisible(true);
}
diff --git a/src/fftManager/PamFFTControl.java b/src/fftManager/PamFFTControl.java
index 62d747a8..ef73f913 100644
--- a/src/fftManager/PamFFTControl.java
+++ b/src/fftManager/PamFFTControl.java
@@ -37,6 +37,7 @@ import fftManager.layoutFX.FFTGuiFX;
//import fftManager.layoutFX.FFTGuiFX;
import fftManager.newSpectrogram.SpectrogramPlotProvider;
import spectrogramNoiseReduction.SpectrogramNoiseProcess;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings;
@@ -70,7 +71,11 @@ public class PamFFTControl extends PamControlledUnit implements PamSettings {
private PamControlledGUISwing fftGUISwing;
public PamFFTControl(String unitName) {
- super("FFT Engine", unitName);
+ this(null, unitName);
+ }
+
+ public PamFFTControl(PamConfiguration pamConfiguration, String unitName) {
+ super(pamConfiguration, "FFT Engine", unitName);
PamRawDataBlock rawDataBlock = PamController.getInstance().
getRawDataBlock(fftParameters.dataSource);
diff --git a/src/fftManager/PamFFTProcess.java b/src/fftManager/PamFFTProcess.java
index b7dde70f..34b45371 100644
--- a/src/fftManager/PamFFTProcess.java
+++ b/src/fftManager/PamFFTProcess.java
@@ -144,10 +144,10 @@ public class PamFFTProcess extends PamProcess {
* name has not been set, so if there isn't a name, use the number !
*/
if (fftParameters.dataSourceName != null) {
- rawDataBlock = (PamRawDataBlock) PamController.getInstance().getDataBlock(RawDataUnit.class, fftParameters.dataSourceName);
+ rawDataBlock = (PamRawDataBlock) fftControl.getPamConfiguration().getDataBlock(RawDataUnit.class, fftParameters.dataSourceName);
}
else {
- rawDataBlock = PamController.getInstance().getRawDataBlock(fftParameters.dataSource);
+ rawDataBlock = fftControl.getPamConfiguration().getRawDataBlock(fftParameters.dataSource);
if (rawDataBlock != null) {
fftParameters.dataSourceName = rawDataBlock.getDataName();
}
diff --git a/src/generalDatabase/DBControl.java b/src/generalDatabase/DBControl.java
index ed22b885..788366c4 100644
--- a/src/generalDatabase/DBControl.java
+++ b/src/generalDatabase/DBControl.java
@@ -32,6 +32,7 @@ import offlineProcessing.OLProcessDialog;
import offlineProcessing.OfflineTaskGroup;
import warnings.PamWarning;
import warnings.WarningSystem;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings;
@@ -109,8 +110,8 @@ PamSettingsSource {
private int lastErrorCount;
- public DBControl(String unitName, int settingsStore, boolean openImmediately) {
- super(dbUnitType, unitName);
+ public DBControl(PamConfiguration pamconfiguration, String unitName, int settingsStore, boolean openImmediately) {
+ super(pamconfiguration, dbUnitType, unitName);
THIS = this;
databaseWarning = new PamWarning(getUnitName(), "Database error", 2);
@@ -157,6 +158,9 @@ PamSettingsSource {
// selectDatabase(null);
+ if (isInMainConfiguration() == false) {
+ openImmediately = false;
+ }
if (databaseSystem == null){
selectSystem(dbParameters.getDatabaseSystem(), openImmediately);
}
@@ -529,7 +533,7 @@ PamSettingsSource {
// offlineTaskGroup.addTask(task);
}
if (olProcessDialog == null) {
- olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup,
+ olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup,
dataBlock.getDataName() + " Export");
}
olProcessDialog.setVisible(true);
diff --git a/src/generalDatabase/DBControlSettings.java b/src/generalDatabase/DBControlSettings.java
index 6647f7c3..3d9c6fb5 100644
--- a/src/generalDatabase/DBControlSettings.java
+++ b/src/generalDatabase/DBControlSettings.java
@@ -18,7 +18,7 @@ public class DBControlSettings extends DBControl {
public DBControlSettings(String unitName) {
- super(unitName, PamSettingManager.LIST_DATABASESTUFF, false);
+ super(null, unitName, PamSettingManager.LIST_DATABASESTUFF, false);
// logSettings = new LogSettings(this);
diff --git a/src/generalDatabase/DBControlUnit.java b/src/generalDatabase/DBControlUnit.java
index 74073ba9..e2c129c9 100644
--- a/src/generalDatabase/DBControlUnit.java
+++ b/src/generalDatabase/DBControlUnit.java
@@ -20,6 +20,7 @@ import pamViewFX.pamTask.PamTaskUpdate;
import PamController.AWTScheduler;
import PamController.DataOutputStore;
import PamController.OfflineDataStore;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamController;
import PamController.PamControllerInterface;
@@ -51,7 +52,10 @@ public class DBControlUnit extends DBControl implements DataOutputStore {
private BackupInformation backupInformation;
public DBControlUnit(String unitName) {
- super(unitName, whichStore(), true);
+ this(null, unitName);
+ }
+ public DBControlUnit(PamConfiguration pamConfiguration, String unitName) {
+ super(pamConfiguration, unitName, whichStore(), true);
THIS = this;
setFullTablesCheck(true);
// int runMode = PamController.getInstance().getRunMode();
diff --git a/src/generalDatabase/SQLLogging.java b/src/generalDatabase/SQLLogging.java
index 74aa9066..8f8b9f84 100644
--- a/src/generalDatabase/SQLLogging.java
+++ b/src/generalDatabase/SQLLogging.java
@@ -1111,6 +1111,9 @@ public abstract class SQLLogging {
* @return a result set
*/
protected ResultSet createViewResultSet(PamConnection con, PamViewParameters pamViewParameters) {
+ if (con == null) {
+ return null;
+ }
String viewerClause = getViewerLoadClause(con.getSqlTypes(), pamViewParameters);
return createViewResultSet(con, viewerClause);
}
diff --git a/src/group3dlocaliser/offline/Group3DOfflineTask.java b/src/group3dlocaliser/offline/Group3DOfflineTask.java
index 0a9a8e94..000f022f 100644
--- a/src/group3dlocaliser/offline/Group3DOfflineTask.java
+++ b/src/group3dlocaliser/offline/Group3DOfflineTask.java
@@ -26,6 +26,10 @@ public class Group3DOfflineTask extends OfflineTask{
this.group3DControl = group3DControl;
group3DProcess = group3DControl.getGroup3dProcess();
addAffectedDataBlock(group3DProcess.getGroup3dDataBlock());
+ PamDataBlock parentData = group3DProcess.getParentDataBlock();
+ if (parentData != null) {
+ this.addRequiredDataBlock(parentData);
+ }
}
@Override
diff --git a/src/help/localisation/difar/difarAzigram/docs/azigram.html b/src/help/localisation/difar/difarAzigram/docs/azigram.html
index f1ec9541..6b576e4a 100644
--- a/src/help/localisation/difar/difarAzigram/docs/azigram.html
+++ b/src/help/localisation/difar/difarAzigram/docs/azigram.html
@@ -36,11 +36,11 @@ The Azigram plugin is version 0.0.1 and has been tested on Pamguard version 2.01
The sample rate of the Azigram output can be chosen from the Output panel of the settings. The plugin uses frequency domain downsampling in order to acheive the selected sample rate. When selecting the output sample rate, the output FFT length and FFT hop will be altered in order to maintain the same time and frequency resolution as the upstream FFT module.
-
+
The Azigram can be viewed on a Spectrogram Display. The HSV colour model is recommended for viewing Azigrams. This colour model is circular so will better illustrate the circular nature of the angular data (e.g. sounds from 359 degrees will be similar in colour to sounds from 1 degree). The limits of the Amplitude Range on the "Scales" tab of the "Spectrogram Parameters" should be manually set to Min 0 and Max 360. While this tab suggests that the Min and Max are in dB, the Azigram module will treat these values as degrees if an Azigram is being displayed.
-
+
@@ -48,7 +48,7 @@ The Azigram plugin is version 0.0.1 and has been tested on Pamguard version 2.01
The screenshot below shows the DIFAR Azigram Module displaying the Azigram output (top graph) and regular spectrogram ouput (middle panel) of a synthetic test signal. The test signal is a simulated DIFAR source with 8 short FM downsweeps arriving from 0-315 degrees in 45 degree increments. The bottom panel shows the PAMGuard Data Model.
-
+
diff --git a/src/matchedTemplateClassifer/offline/MTOfflineProcess.java b/src/matchedTemplateClassifer/offline/MTOfflineProcess.java
index 69ae30a0..0fee2df7 100644
--- a/src/matchedTemplateClassifer/offline/MTOfflineProcess.java
+++ b/src/matchedTemplateClassifer/offline/MTOfflineProcess.java
@@ -70,7 +70,7 @@ public class MTOfflineProcess {
//if null open the dialog- also create a new offlineTask group if the datablock has changed.
if (mtOfflineDialog == null) {
- mtOfflineDialog = new OLProcessDialog(this.mtContorl.getPamView().getGuiFrame(),
+ mtOfflineDialog = new OLProcessDialog(this.mtContorl.getGuiFrame(),
mtOfflineGroup, "Match Template Classifier");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
}
diff --git a/src/noiseBandMonitor/NoiseBandProcess.java b/src/noiseBandMonitor/NoiseBandProcess.java
index 9adad329..744f71b1 100644
--- a/src/noiseBandMonitor/NoiseBandProcess.java
+++ b/src/noiseBandMonitor/NoiseBandProcess.java
@@ -62,7 +62,7 @@ public class NoiseBandProcess extends PamProcess {
public void setupProcess() {
super.setupProcess();
- PamDataBlock sourceData = PamController.getInstance().getDataBlock(RawDataUnit.class, noiseBandControl.noiseBandSettings.rawDataSource);
+ PamDataBlock sourceData = noiseBandControl.getPamConfiguration().getDataBlock(RawDataUnit.class, noiseBandControl.noiseBandSettings.rawDataSource);
if (sourceData == null) {
return;
}
diff --git a/src/noiseMonitor/NoiseProcess.java b/src/noiseMonitor/NoiseProcess.java
index 8b3022c4..a984030d 100644
--- a/src/noiseMonitor/NoiseProcess.java
+++ b/src/noiseMonitor/NoiseProcess.java
@@ -129,7 +129,7 @@ public class NoiseProcess extends PamProcess {
}
private void findDataSource() {
- PamDataBlock source = PamController.getInstance().getDataBlock(FFTDataUnit.class,
+ PamDataBlock source = noiseControl.getPamConfiguration().getDataBlock(FFTDataUnit.class,
noiseControl.noiseSettings.dataSource);
daqProcess = null;
diff --git a/src/noiseMonitor/NoiseTabPanel.java b/src/noiseMonitor/NoiseTabPanel.java
index f6df1896..460b36ec 100644
--- a/src/noiseMonitor/NoiseTabPanel.java
+++ b/src/noiseMonitor/NoiseTabPanel.java
@@ -1189,7 +1189,7 @@ private void setAxisLabels() {
if (mouseMenu == null) {
mouseMenu = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Display Options ...");
- menuItem.addActionListener(new DisplayOptions(pamControlledUnit.getPamView().getGuiFrame()));
+ menuItem.addActionListener(new DisplayOptions(pamControlledUnit.getGuiFrame()));
mouseMenu.add(menuItem);
}
diff --git a/src/noiseOneBand/OneBandControl.java b/src/noiseOneBand/OneBandControl.java
index bf011340..c14fae48 100644
--- a/src/noiseOneBand/OneBandControl.java
+++ b/src/noiseOneBand/OneBandControl.java
@@ -126,7 +126,7 @@ public class OneBandControl extends PamControlledUnit implements PamSettings {
offlineTaskGroup.addTask(task);
}
if (olProcessDialog == null) {
- olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup, "Noise Data Export");
+ olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup, "Noise Data Export");
}
olProcessDialog.setVisible(true);
}
diff --git a/src/radardisplay/RadarDisplay.java b/src/radardisplay/RadarDisplay.java
index d919e3d4..879ff75b 100644
--- a/src/radardisplay/RadarDisplay.java
+++ b/src/radardisplay/RadarDisplay.java
@@ -123,7 +123,7 @@ public class RadarDisplay extends UserFramePlots implements PamObserver, PamSett
if (this.radarParameters == null) {
this.radarParameters = new RadarParameters();
RadarParameters newParams = RadarParametersDialog.showDialog(RadarDisplay.this,
- userDisplayControl.getPamView().getGuiFrame(), this.radarParameters, radarProjector);
+ userDisplayControl.getGuiFrame(), this.radarParameters, radarProjector);
if (newParams != null) {
this.radarParameters = newParams.clone();
}
@@ -697,7 +697,7 @@ public class RadarDisplay extends UserFramePlots implements PamObserver, PamSett
public void actionPerformed(ActionEvent e) {
RadarParameters newParams = RadarParametersDialog.showDialog(RadarDisplay.this,
- userDisplayControl.getPamView().getGuiFrame(), radarParameters, radarProjector);
+ userDisplayControl.getGuiFrame(), radarParameters, radarProjector);
if (newParams != null) {
radarParameters = newParams.clone();
newSettings();
diff --git a/src/rawDeepLearningClassifier/offline/DLOfflineProcess.java b/src/rawDeepLearningClassifier/offline/DLOfflineProcess.java
index 52cfa004..07270632 100644
--- a/src/rawDeepLearningClassifier/offline/DLOfflineProcess.java
+++ b/src/rawDeepLearningClassifier/offline/DLOfflineProcess.java
@@ -56,7 +56,7 @@ public class DLOfflineProcess {
//if null open the dialog- also create a new offlineTask group if the datablock has changed.
if (mtOfflineDialog == null) {
- mtOfflineDialog = new OLProcessDialog(this.dlControl.getPamView().getGuiFrame(),
+ mtOfflineDialog = new OLProcessDialog(this.dlControl.getGuiFrame(),
dlOfflineGroup, "Deep Learning Classifier");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
}
diff --git a/src/rocca/RoccaClassifyThis.java b/src/rocca/RoccaClassifyThis.java
index 1a2d56b2..87987247 100644
--- a/src/rocca/RoccaClassifyThis.java
+++ b/src/rocca/RoccaClassifyThis.java
@@ -32,6 +32,7 @@ import java.io.IOException;
import java.util.EnumMap;
import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileNameExtensionFilter;
import PamUtils.PamCalendar;
@@ -126,31 +127,34 @@ public class RoccaClassifyThis {
/** the field in the RoccaContourStats object which contains all the stats measures */
private EnumMap contourStats;
- private String dirIn;
-
- /** the input filename */
- private String csvIn;
-
- /** the input file */
- private File statsFileIn;
-
- /** the output filename */
- private String csvOut;
-
- /** the output file */
- private File statsFileOut;
-
- /** Constructor */
+ /**
+ * Constructor used when allowing user to select training dataset
+ * */
public RoccaClassifyThis(RoccaProcess roccaProcess) {
-
- // initialize the BufferedReader
- BufferedReader inputFile = null;
-
+ File statsFileIn = getTheFile();
+ if (statsFileIn!=null) {
+ runTheClassifier(statsFileIn, roccaProcess);
+ }
+ }
+
+ /**
+ * Constructor when we pass in the training dataset
+ */
+ public RoccaClassifyThis() {
+ }
+
+
+ /**
+ * Ask the user to select the file containing the testing dataset
+ *
+ * @return File the csv file containing the testing dataset
+ */
+ public File getTheFile() {
// set the directory
// this.dirIn = new String("C:\\Users\\Mike\\Documents\\Work\\Java\\EclipseWorkspace\\testing\\RoccaClassifyThis_testing");
// this.dirIn = new String("C:\\Users\\Mike\\Documents\\Work\\Tom\\Atlantic Classifier\\manual 2-stage data");
// this.dirIn = new String("C:\\Users\\Mike\\Documents\\Work\\Tom\\Hawaii dataset problems");
- this.dirIn = new String("C:\\Users\\SCANS\\Documents\\Work\\Biowaves\\ONR classifier");
+// this.dirIn = new String("C:\\Users\\SCANS\\Documents\\Work\\Biowaves\\ONR classifier");
// Define the input and output filenames
// Hard-coded for now. To Do: query the user for the filename
@@ -158,35 +162,54 @@ public class RoccaClassifyThis {
// this.csvIn = new String("Manual_5sp_April 9 2013.csv");
// this.csvIn = new String("CombinedContourStats-fixed.csv");
// this.csvOut = new String("RoccaContourStatsReclassified.csv");
- this.csvIn = new String("Atl_TestDFNoTrain_Call_W_160831.csv");
- statsFileIn = new File(dirIn, csvIn);
- this.csvOut = new String("Atl_TestDFNoTrain_Call_W_160829-classified.csv");
- statsFileOut = new File(dirIn, csvOut);
+// this.csvIn = new String("Atl_TestDFNoTrain_Call_W_160831.csv");
+// statsFileIn = new File(dirIn, csvIn);
+// this.csvOut = new String("Atl_TestDFNoTrain_Call_W_160829-classified.csv");
+// statsFileOut = new File(dirIn, csvOut);
+ // let the user select the arff file
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setDialogTitle("Select spreadsheet to recalculate...");
+ fileChooser.setFileHidingEnabled(true);
+ fileChooser.setApproveButtonText("Select");
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ FileNameExtensionFilter restrict = new FileNameExtensionFilter("Only .csv files", "csv");
+ fileChooser.addChoosableFileFilter(restrict);
+
+ int state = fileChooser.showOpenDialog(null);
+ File statsFileIn = null;
+ if (state == JFileChooser.APPROVE_OPTION) {
+
+ // load the file
+ statsFileIn = fileChooser.getSelectedFile();
+ return statsFileIn;
+
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Run the classifier
+ * @param statsFileIn the File containing the testing dataset
+ * @param roccaProcess the RoccaProcess instance
+ */
+ public void runTheClassifier(File statsFileIn, RoccaProcess roccaProcess) {
-// JFileChooser fileChooser = new JFileChooser();
-// fileChooser.setDialogTitle("Select spreadsheet to recalculate...");
-// fileChooser.setFileHidingEnabled(true);
-// fileChooser.setApproveButtonText("Select");
-// fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
-//
-// int state = fileChooser.showOpenDialog(this.dirIn);
-// if (state == JFileChooser.APPROVE_OPTION) {
-
-
-
-
-
-
-
-
-
+ int index = statsFileIn.getAbsolutePath().lastIndexOf(".");
+ String csvOut = statsFileIn.getAbsolutePath().substring(0,index) + "-classified.csv";
+ File statsFileOut = new File(csvOut);
+
// load the classifier
System.out.println("Loading classifier...");
roccaProcess.setClassifierLoaded
(roccaProcess.roccaClassifier.setUpClassifier());
+ // initialize the BufferedReader
+ BufferedReader inputFile = null;
+
// open the input file
try {
System.out.println("Opening input file "+statsFileIn);
@@ -263,12 +286,45 @@ public class RoccaClassifyThis {
contourStats.put(RoccaContourStats.ParamIndx.FREQPOSSLOPEMEAN, Double.parseDouble(dataArray[34]));
contourStats.put(RoccaContourStats.ParamIndx.FREQNEGSLOPEMEAN, Double.parseDouble(dataArray[35]));
contourStats.put(RoccaContourStats.ParamIndx.FREQSLOPERATIO, Double.parseDouble(dataArray[36]));
- contourStats.put(RoccaContourStats.ParamIndx.FREQBEGSWEEP, Double.parseDouble(dataArray[37]));
- //contourStats.put(RoccaContourStats.ParamIndx.FREQBEGUP, Double.parseDouble(dataArray[38]));
- //contourStats.put(RoccaContourStats.ParamIndx.FREQBEGDWN, Double.parseDouble(dataArray[39]));
- contourStats.put(RoccaContourStats.ParamIndx.FREQENDSWEEP, Double.parseDouble(dataArray[40]));
- //contourStats.put(RoccaContourStats.ParamIndx.FREQENDUP, Double.parseDouble(dataArray[41]));
- //contourStats.put(RoccaContourStats.ParamIndx.FREQENDDWN, Double.parseDouble(dataArray[42]));
+
+ // Note that we have to modify the FREQBEGSWEEP value. Weka is trained with the FREQBEGSWEEP param
+ // as -1=down, 0=flat and 1=up, and that would be how the test data comes through as well. HOWEVER,
+ // Weka assumes that for nominal parameters, the value is the index location (0,1 or 2) and NOT the actual trained
+ // value (-1,0 or 1). So if the whistle has a down sweep, Weka needs the FREQBEGSWEEP value to be 0 indicating the
+ // first location in the array (which was 'down'). If it was up, the value would need to be 2 indicating the third
+ // location in the array (which was 'up').
+ // Ideally we would map the values in the test data to the positions in the training array, but as a quick and
+ // dirty hack we'll simply add 1 to the value since the difference between the nominal values (-1,0,1) and the
+ /// index positions (0,1,2) is an offset of 1
+ // Note also that we don't have to do the same thing for FREQBEGUP and FREQBEGDWN since, by coincidence, the training
+ // values of 0 and 1 happen to match the index locations of 0 and 1
+ //contourStats.put(RoccaContourStats.ParamIndx.FREQBEGSWEEP, Double.parseDouble(dataArray[37]));
+ double tempVal = Double.parseDouble(dataArray[37]);
+ tempVal++;
+ contourStats.put(RoccaContourStats.ParamIndx.FREQBEGSWEEP, tempVal);
+ contourStats.put(RoccaContourStats.ParamIndx.FREQBEGUP, Double.parseDouble(dataArray[38]));
+ contourStats.put(RoccaContourStats.ParamIndx.FREQBEGDWN, Double.parseDouble(dataArray[39]));
+
+ // Note that we have to modify the FREQENDSWEEP value. Weka is trained with the FREQENDSWEEP param
+ // as -1=down, 0=flat and 1=up, and that would be how the test data comes through as well. HOWEVER,
+ // Weka assumes that for nominal parameters, the value is the index location (0,1 or 2) and NOT the actual trained
+ // value (-1,0 or 1). So if the whistle has a down sweep, Weka needs the FREQENDSWEEP value to be 0 indicating the
+ // first location in the array (which was 'down'). If it was up, the value would need to be 2 indicating the third
+ // location in the array (which was 'up').
+ // Ideally we would map the values in the test data to the positions in the training array, but as a quick and
+ // dirty hack we'll simply add 1 to the value since the difference between the nominal values (-1,0,1) and the
+ /// index positions (0,1,2) is an offset of 1
+ // Note also that we don't have to do the same thing for FREQENDUP and FREQENDDWN since, by coincidence, the training
+ // values of 0 and 1 happen to match the index locations of 0 and 1
+ //contourStats.put(RoccaContourStats.ParamIndx.FREQENDSWEEP, Double.parseDouble(dataArray[40]));
+ tempVal = Double.parseDouble(dataArray[40]);
+ tempVal++;
+ contourStats.put(RoccaContourStats.ParamIndx.FREQENDSWEEP, tempVal);
+ contourStats.put(RoccaContourStats.ParamIndx.FREQENDUP, Double.parseDouble(dataArray[41]));
+ contourStats.put(RoccaContourStats.ParamIndx.FREQENDDWN, Double.parseDouble(dataArray[42]));
+ // end of hack
+
+
contourStats.put(RoccaContourStats.ParamIndx.NUMSWEEPSUPDWN, Double.parseDouble(dataArray[43]));
contourStats.put(RoccaContourStats.ParamIndx.NUMSWEEPSDWNUP, Double.parseDouble(dataArray[44]));
contourStats.put(RoccaContourStats.ParamIndx.NUMSWEEPSUPFLAT, Double.parseDouble(dataArray[45]));
@@ -285,8 +341,8 @@ public class RoccaClassifyThis {
contourStats.put(RoccaContourStats.ParamIndx.INFLMEANDELTA, Double.parseDouble(dataArray[56]));
contourStats.put(RoccaContourStats.ParamIndx.INFLSTDDEVDELTA, Double.parseDouble(dataArray[57]));
contourStats.put(RoccaContourStats.ParamIndx.INFLMEDIANDELTA, Double.parseDouble(dataArray[58]));
- contourStats.put(RoccaContourStats.ParamIndx.INFLDUR, Double.parseDouble(dataArray[59]));
- contourStats.put(RoccaContourStats.ParamIndx.STEPDUR, Double.parseDouble(dataArray[60]));
+ //contourStats.put(RoccaContourStats.ParamIndx.INFLDUR, Double.parseDouble(dataArray[59]));
+ //contourStats.put(RoccaContourStats.ParamIndx.STEPDUR, Double.parseDouble(dataArray[60]));
// Run the classifier
roccaProcess.roccaClassifier.classifyContour2(rcdb);
diff --git a/src/rocca/RoccaParametersDialog.java b/src/rocca/RoccaParametersDialog.java
index 2fd1f136..fb74da29 100644
--- a/src/rocca/RoccaParametersDialog.java
+++ b/src/rocca/RoccaParametersDialog.java
@@ -169,6 +169,7 @@ public class RoccaParametersDialog extends PamDialog implements ActionListener,
JButton classifier2Button;
JButton recalcButton;
JButton reclassifyButton;
+ JButton trainThenTestButton;
JButton clearClassifier;
JComboBox>> stage1Classes;
DefaultComboBoxModel> stage1ClassModel;
@@ -513,6 +514,10 @@ public class RoccaParametersDialog extends PamDialog implements ActionListener,
reclassifyButton.addActionListener(this);
reclassifyButton.setToolTipText("Load the whistle data from the contour stats output file, and run it through the current Classifier");
reclassifyButton.setVisible(true);
+ trainThenTestButton = new JButton("Train then Test");
+ trainThenTestButton.addActionListener(this);
+ trainThenTestButton.setToolTipText("Train a classifier on a set of training data, then test it with a set of testing data");
+ trainThenTestButton.setVisible(true);
// ******** THIS LINES CONTROLS THE VISIBILITY ********
if (RoccaDev.isEnabled()) {
@@ -528,13 +533,15 @@ public class RoccaParametersDialog extends PamDialog implements ActionListener,
extraPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(extraPanelLayout.createSequentialGroup()
.addComponent(recalcButton)
- .addComponent(reclassifyButton))
+ .addComponent(reclassifyButton)
+ .addComponent(trainThenTestButton))
);
extraPanelLayout.setVerticalGroup(
extraPanelLayout.createSequentialGroup()
.addGroup(extraPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(recalcButton)
- .addComponent(reclassifyButton))
+ .addComponent(reclassifyButton)
+ .addComponent(trainThenTestButton))
);
classifierPanel.add(extraButtonsSubPanel);
@@ -892,7 +899,9 @@ public class RoccaParametersDialog extends PamDialog implements ActionListener,
} else if (e.getSource() == recalcButton) {
RoccaFixParams recalc = new RoccaFixParams(roccaControl.roccaProcess);
} else if (e.getSource() == reclassifyButton) {
- RoccaClassifyThisEvent reclassify = new RoccaClassifyThisEvent(roccaControl.roccaProcess);
+ RoccaClassifyThis reclassify = new RoccaClassifyThis(roccaControl.roccaProcess);
+ } else if (e.getSource() == trainThenTestButton) {
+ RoccaTrainThenTest trainThenTest = new RoccaTrainThenTest(roccaControl.roccaProcess);
} else if (e.getSource() == fftButton) {
roccaParameters.setUseFFT(true);
this.enableTheCorrectSource();
diff --git a/src/rocca/RoccaRFModel.java b/src/rocca/RoccaRFModel.java
index bcf74f4d..e7c9b208 100644
--- a/src/rocca/RoccaRFModel.java
+++ b/src/rocca/RoccaRFModel.java
@@ -145,6 +145,7 @@ public class RoccaRFModel implements java.io.Serializable {
} catch (Exception ex) {
System.err.println("1st Classification failed: " + ex.getMessage());
+ ex.printStackTrace();
rcdb.setClassifiedAs("Err");
}
}
diff --git a/src/rocca/RoccaTrainClassifier.java b/src/rocca/RoccaTrainClassifier.java
index 09b2c6c7..70acc07d 100644
--- a/src/rocca/RoccaTrainClassifier.java
+++ b/src/rocca/RoccaTrainClassifier.java
@@ -24,10 +24,14 @@
package rocca;
import java.io.BufferedReader;
+import java.io.File;
import java.io.FileReader;
import java.util.Date;
import java.util.Enumeration;
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
import weka.classifiers.trees.RandomForest;
import weka.core.Instances;
import weka.core.SerializationHelper;
@@ -42,13 +46,64 @@ import weka.core.SerializationHelper;
*/
public class RoccaTrainClassifier {
+
+ /**
+ * Standalone implementation
+ *
+ * @param args
+ */
public static void main(String[] args) {
+
+ RoccaTrainClassifier rtc = new RoccaTrainClassifier();
+ File arffFile = rtc.getArff();
+ if (arffFile!=null) {
+ String modelName = rtc.trainClassifier(arffFile);
+ }
+ }
+
+
+ /**
+ * Let user choose arff file training dataset
+ *
+ * @return File the arff file containing the training dataset
+ */
+ public File getArff() {
+// String arffFile = "C:\\Users\\SCANS\\Documents\\Work\\Biowaves\\ONR classifier\\TP_TrainEvtDF_170408";
+
+ // let the user select the arff file
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setDialogTitle("Select arff file containing training data");
+ fileChooser.setFileHidingEnabled(true);
+ fileChooser.setApproveButtonText("Select");
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ FileNameExtensionFilter restrict = new FileNameExtensionFilter("Only .arff files", "arff");
+ fileChooser.addChoosableFileFilter(restrict);
+ File arffFile;
+
+ int state = fileChooser.showOpenDialog(null);
+ if (state == JFileChooser.APPROVE_OPTION) {
+
+ // load the file
+ arffFile = fileChooser.getSelectedFile();
+ return arffFile;
+
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Actual code to train the classifier
+ *
+ */
+ public String trainClassifier(File arffFile) {
+
RandomForest model = new RandomForest ();
Instances trainData = null;
- String arffFile = "C:\\Users\\SCANS\\Documents\\Work\\Biowaves\\ONR classifier\\TP_TrainEvtDF_170408";
// load the ARFF file containing the training set
- System.out.println("Loading data...");
+ System.out.println("Loading data..." + arffFile.getAbsolutePath());
try {
trainData = new Instances
(new BufferedReader
@@ -56,10 +111,13 @@ public class RoccaTrainClassifier {
// ("C:\\Users\\Mike\\Documents\\Work\\Java\\WEKA\\allwhists 12 vars 8sp update 1-28-10.arff")));
// ("C:\\Users\\Mike\\Documents\\Work\\Java\\WEKA\\weka vs R\\ETP_orcawale_whists2 modified-subset110perspecies-no_harm_ratios.arff")));
// ("C:\\Users\\SCANS\\Documents\\Work\\Biowaves\\ONR classifier\\Atl_TrainDF_Event_160829.arff")));
- (arffFile + ".arff")));
+// (arffFile + ".arff")));
+ (arffFile)));
trainData.setClassIndex(trainData.numAttributes()-1);
} catch (Exception ex) {
System.out.println("Error Loading...");
+ ex.printStackTrace();
+ return null;
}
// set the classifier parameters
@@ -78,6 +136,8 @@ public class RoccaTrainClassifier {
model.setOptions(options);
} catch (Exception ex) {
System.out.println("Error setting options...");
+ ex.printStackTrace();
+ return null;
}
// train the classifier
@@ -90,23 +150,29 @@ public class RoccaTrainClassifier {
new Date());
} catch (Exception ex) {
System.out.println("Error training classifier...");
+ ex.printStackTrace();
+ return null;
}
// save the classifier
- String[] curOptions = model.getOptions();
- Enumeration test = model.listOptions();
- System.out.println("Saving Classifier...");
+// String[] curOptions = model.getOptions();
+// Enumeration test = model.listOptions();
Instances header = new Instances(trainData,0);
+ int index = arffFile.getAbsolutePath().lastIndexOf(".");
+ String modelName = arffFile.getAbsolutePath().substring(0,index) + ".model";
+ System.out.println("Saving Classifier..." + modelName);
try {
SerializationHelper.writeAll
// ("C:\\Users\\Mike\\Documents\\Work\\Java\\WEKA\\weka vs R\\RF_8sp_54att_110whistle-subset.model",
- (arffFile + ".model",
+// (arffFile + ".model",
+ (modelName,
new Object[]{model,header});
+ System.out.println("Finished!");
+ return modelName;
} catch (Exception ex) {
System.out.println("Error saving classifier...");
+ ex.printStackTrace();
}
-
- System.out.println("Finished!");
+ return null;
}
-
}
diff --git a/src/rocca/RoccaTrainThenTest.java b/src/rocca/RoccaTrainThenTest.java
new file mode 100644
index 00000000..7af2486f
--- /dev/null
+++ b/src/rocca/RoccaTrainThenTest.java
@@ -0,0 +1,109 @@
+/*
+ * PAMGUARD - Passive Acoustic Monitoring GUARDianship.
+ * To assist in the Detection Classification and Localisation
+ * of marine mammals (cetaceans).
+ *
+ * Copyright (C) 2006
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package rocca;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+public class RoccaTrainThenTest {
+
+ RoccaTrainClassifier roccaTrainClassifier;
+
+ RoccaClassifyThis roccaClassifyThis;
+
+
+ /**
+ * Main Constructor
+ * @param roccaProcess
+ */
+ public RoccaTrainThenTest(RoccaProcess roccaProcess) {
+
+
+ // let the user select the csv file containing the training and testing dataset(s)
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setDialogTitle("Select csv file with the training/testing pairs");
+ fileChooser.setFileHidingEnabled(true);
+ fileChooser.setApproveButtonText("Select");
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ FileNameExtensionFilter restrict = new FileNameExtensionFilter("Only .csv files", "csv");
+ fileChooser.addChoosableFileFilter(restrict);
+
+ int state = fileChooser.showOpenDialog(null);
+ if (state == JFileChooser.APPROVE_OPTION) {
+
+ // load the file
+ try {
+ File csvDataPairs = fileChooser.getSelectedFile();
+ BufferedReader br = new BufferedReader(new FileReader(csvDataPairs));
+ String curPath = csvDataPairs.getParent();
+
+ // main loop
+ // read through the csv file one line at a time. The first column should contain the training dataset filename,
+ // and the second column the testing dataset filename. Paths should be relative to the path containing
+ // the csv file
+ String line = "";
+ String splitBy = ",";
+ while ((line=br.readLine())!=null) {
+
+ String[] filenames = line.split(splitBy);
+
+ // train the classifier
+ File arffFile = new File(curPath + File.separator + filenames[0]);
+ roccaTrainClassifier = new RoccaTrainClassifier();
+ String modelName = roccaTrainClassifier.trainClassifier(arffFile);
+ if (modelName == null) {
+ System.out.println("ERROR: could not create classifier model from "+arffFile);
+ continue;
+ }
+
+ // set the classifier as the current one in RoccaParameters
+ roccaProcess.roccaControl.roccaParameters.setRoccaClassifierModelFilename(new File(modelName));
+
+
+ // test the classifier with the testing dataset
+ File testFile = new File(curPath + File.separator + filenames[1]);
+ roccaClassifyThis = new RoccaClassifyThis();
+ roccaClassifyThis.runTheClassifier(testFile, roccaProcess);
+
+ }
+
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ }
+ } else {
+ return;
+ }
+ }
+
+}
diff --git a/src/spectrogramNoiseReduction/SpectrogramNoiseControl.java b/src/spectrogramNoiseReduction/SpectrogramNoiseControl.java
index cbaa23b0..f884a242 100644
--- a/src/spectrogramNoiseReduction/SpectrogramNoiseControl.java
+++ b/src/spectrogramNoiseReduction/SpectrogramNoiseControl.java
@@ -6,6 +6,7 @@ import java.awt.event.ActionListener;
import java.io.Serializable;
import javax.swing.JMenuItem;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings;
import PamController.PamControllerInterface;
@@ -22,7 +23,10 @@ public class SpectrogramNoiseControl extends PamControlledUnit implements PamSet
protected SpectrogramNoiseProcess spectrogramNoiseProcess;
public SpectrogramNoiseControl(String unitName) {
- super("Spectrogram Noise Reduction", unitName);
+ this(null, unitName);
+ }
+ public SpectrogramNoiseControl(PamConfiguration pamConfiguration, String unitName) {
+ super(pamConfiguration, "Spectrogram Noise Reduction", unitName);
spectrogramNoiseProcess = new SpectrogramNoiseProcess(this);
addPamProcess(spectrogramNoiseProcess);
diff --git a/src/spectrogramNoiseReduction/SpectrogramNoiseProcess.java b/src/spectrogramNoiseReduction/SpectrogramNoiseProcess.java
index d1fbf34f..480adc5e 100644
--- a/src/spectrogramNoiseReduction/SpectrogramNoiseProcess.java
+++ b/src/spectrogramNoiseReduction/SpectrogramNoiseProcess.java
@@ -15,6 +15,7 @@ import spectrogramNoiseReduction.threshold.ThresholdParams;
import fftManager.FFTDataBlock;
import fftManager.FFTDataUnit;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamController;
import PamUtils.complex.ComplexArray;
@@ -64,7 +65,11 @@ public class SpectrogramNoiseProcess extends PamProcess {
@Override
public void setupProcess() {
super.setupProcess();
- sourceData = (FFTDataBlock) PamController.getInstance().getDataBlock(FFTDataUnit.class,
+
+ PamConfiguration mainConfig = PamController.getInstance().getPamConfiguration();
+ PamConfiguration localConfig = getPamControlledUnit().getPamConfiguration();
+
+ sourceData = (FFTDataBlock) getPamControlledUnit().getPamConfiguration().getDataBlock(FFTDataUnit.class,
getNoiseSettings().dataSource);
setParentDataBlock(sourceData);
diff --git a/src/targetMotionModule/TargetMotionLocaliser.java b/src/targetMotionModule/TargetMotionLocaliser.java
index 359da442..6791d819 100644
--- a/src/targetMotionModule/TargetMotionLocaliser.java
+++ b/src/targetMotionModule/TargetMotionLocaliser.java
@@ -64,7 +64,7 @@ public class TargetMotionLocaliser extends AbstractLocali
// public boolean showTMDialog(T dataUnit) {
// if (targetMotionMainPanel == null) {
-////targetMotionDialog = new TargetMotionMainPanel(pamControlledUnit.getPamView().getGuiFrame(), this);
+////targetMotionDialog = new TargetMotionMainPanel(pamControlledUnit.getGuiFrame(), this);
// }
// targetMotionMainPanel.updateCurrentControlPanel();
// return true;
diff --git a/src/targetMotionModule/offline/TMOfflineFunctions.java b/src/targetMotionModule/offline/TMOfflineFunctions.java
index 7e0b92ed..86d5af80 100644
--- a/src/targetMotionModule/offline/TMOfflineFunctions.java
+++ b/src/targetMotionModule/offline/TMOfflineFunctions.java
@@ -54,7 +54,7 @@ public class TMOfflineFunctions {
//when we change datablock the taks group is going to stay the same- need to make sure it changes
if (batchLocaliseDialog == null || currentDataBlock!=targetMotionControl.getCurrentDataBlock()) {
- batchLocaliseDialog = new TMOLProcessDialog(targetMotionControl.getPamView().getGuiFrame(),
+ batchLocaliseDialog = new TMOLProcessDialog(targetMotionControl.getGuiFrame(),
getOfflineTaskGroup(), "Batch Localise");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
}
diff --git a/src/targetMotionOld/TargetMotionLocaliser.java b/src/targetMotionOld/TargetMotionLocaliser.java
index fa3f7a2b..dc0c6321 100644
--- a/src/targetMotionOld/TargetMotionLocaliser.java
+++ b/src/targetMotionOld/TargetMotionLocaliser.java
@@ -153,7 +153,7 @@ public class TargetMotionLocaliser extends AbstractLoc
public boolean showTMDialog(T dataUnit) {
if (targetMotionDialog == null) {
- targetMotionDialog = new TargetMotionDialog(pamControlledUnit.getPamView().getGuiFrame(), this);
+ targetMotionDialog = new TargetMotionDialog(pamControlledUnit.getGuiFrame(), this);
}
targetMotionDialog.updateEventList();
targetMotionDialog.setDataUnit(dataUnit);
diff --git a/src/videoRangePanel/VRControl.java b/src/videoRangePanel/VRControl.java
index 9357737b..a8225eeb 100644
--- a/src/videoRangePanel/VRControl.java
+++ b/src/videoRangePanel/VRControl.java
@@ -1,6 +1,7 @@
package videoRangePanel;
import java.util.List;
+import java.awt.Frame;
import java.awt.Point;
import java.io.File;
import java.io.Serializable;
@@ -361,9 +362,9 @@ public class VRControl extends PamControlledUnit implements PamSettings {
* @param frame
* @param tab- the tab to open the settings dialog on.
*/
- public void settingsButtonAWT(JFrame frame, int tab) {
+ public void settingsButtonAWT(Frame frame, int tab) {
if (frame == null) {
- frame = getPamView().getGuiFrame();
+ frame = getGuiFrame();
}
VRParameters newParams = VRParametersDialog.showDialog(frame, this, tab);
if (newParams != null) {
diff --git a/src/videoRangePanel/importTideData/TideManager.java b/src/videoRangePanel/importTideData/TideManager.java
index cd769dc8..593a4c45 100644
--- a/src/videoRangePanel/importTideData/TideManager.java
+++ b/src/videoRangePanel/importTideData/TideManager.java
@@ -105,7 +105,7 @@ public class TideManager extends DataImport {
// }
// else dir=null;
//
-// String newFile=PamFileBrowser.fileBrowser(vrControl.getPamView().getGuiFrame(),dir,PamFileBrowser.OPEN_FILE,"txt");
+// String newFile=PamFileBrowser.fileBrowser(vrControl.getGuiFrame(),dir,PamFileBrowser.OPEN_FILE,"txt");
//
// return newFile;
// }
diff --git a/src/videoRangePanel/layoutAWT/VRSidePanel.java b/src/videoRangePanel/layoutAWT/VRSidePanel.java
index c8d943d2..fc1fb6bc 100644
--- a/src/videoRangePanel/layoutAWT/VRSidePanel.java
+++ b/src/videoRangePanel/layoutAWT/VRSidePanel.java
@@ -179,7 +179,7 @@ public class VRSidePanel implements PamSidePanel {
}
if (vrControl.getVRParams().currentImageFile==null) {
- PamDialog.showWarning(vrControl.getPamView().getGuiFrame(), "No image found", "The folder selected did not contain any compatible images");
+ PamDialog.showWarning(vrControl.getGuiFrame(), "No image found", "The folder selected did not contain any compatible images");
return;
}
vrControl.loadFile(vrControl.getVRParams().currentImageFile);
diff --git a/src/videoRangePanel/layoutFX/VRDisplayFX.java b/src/videoRangePanel/layoutFX/VRDisplayFX.java
index 74c7e596..d43850b6 100644
--- a/src/videoRangePanel/layoutFX/VRDisplayFX.java
+++ b/src/videoRangePanel/layoutFX/VRDisplayFX.java
@@ -221,7 +221,7 @@ public class VRDisplayFX extends PamBorderPane implements VRPane {
}
if (vrControl.getVRParams().currentImageFile==null) {
- PamDialog.showWarning(vrControl.getPamView().getGuiFrame(), "No image found", "The folder selected did not contain any compatible images");
+ PamDialog.showWarning(vrControl.getGuiFrame(), "No image found", "The folder selected did not contain any compatible images");
return;
}
//go back up a few levels to load file as update flags etc need to be triggerred.
diff --git a/src/whistlesAndMoans/WhistleMoanControl.java b/src/whistlesAndMoans/WhistleMoanControl.java
index ad72ead7..3a94f629 100644
--- a/src/whistlesAndMoans/WhistleMoanControl.java
+++ b/src/whistlesAndMoans/WhistleMoanControl.java
@@ -19,6 +19,7 @@ import detectionPlotFX.whistleDDPlot.WhistleDDPlotProvider;
import spectrogramNoiseReduction.SpectrogramNoiseProcess;
import whistlesAndMoans.layoutFX.WhistleMoanGUIFX;
import whistlesAndMoans.plots.WhistlePlotProvider;
+import PamController.PamConfiguration;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings;
@@ -55,7 +56,10 @@ public class WhistleMoanControl extends PamControlledUnit implements PamSettings
public static final String UNITTYPE = "WhistlesMoans";
public WhistleMoanControl(String unitName) {
- super(UNITTYPE, unitName);
+ this(null, unitName);
+ }
+ public WhistleMoanControl(PamConfiguration pamConfiguration, String unitName) {
+ super(pamConfiguration, UNITTYPE, unitName);
spectrogramNoiseProcess = new SpectrogramNoiseProcess(this);
addPamProcess(spectrogramNoiseProcess);
diff --git a/src/whistlesAndMoans/WhistleToneConnectProcess.java b/src/whistlesAndMoans/WhistleToneConnectProcess.java
index 4dc46295..c95f69ab 100644
--- a/src/whistlesAndMoans/WhistleToneConnectProcess.java
+++ b/src/whistlesAndMoans/WhistleToneConnectProcess.java
@@ -201,36 +201,20 @@ public class WhistleToneConnectProcess extends PamProcess {
@Override
public void setupProcess() {
super.setupProcess();
+
SpectrogramNoiseProcess snp = whistleMoanControl.getSpectrogramNoiseProcess();
setParentDataBlock(snp.getOutputDataBlock());
if (whistleMoanControl.whistleToneParameters.getDataSource() == null) {
return;
}
- // sourceData = (FFTDataBlock) PamController.getInstance().getDataBlock(FFTDataUnit.class,
- // whistleMoanControl.whistleToneParameters.getDataSource());
- // snp.setParentDataBlock(sourceData);
+
sourceData = (FFTDataBlock) getParentDataBlock(); // our source should always be the output of the SpectrogramNoiseProcess
SpectrogramNoiseSettings specnoiseSettings = whistleMoanControl.whistleToneParameters.getSpecNoiseSettings();
specnoiseSettings.dataSource = whistleMoanControl.whistleToneParameters.getDataSource();
snp.setNoiseSettings(specnoiseSettings);
chanOrSeqMap = whistleMoanControl.whistleToneParameters.getChanOrSeqBitmap(); // the channelMap in WhistleToneParameters object may be a sequence map or a channel map, depending on source
- // if (sourceData != null) {
- //// chanOrSeqMap = getParentDataBlock().getChannelMap() &
- // chanOrSeqMap = getParentDataBlock().getSequenceMap() & // use the sequence bitmap instead of the channel bitmap, in case this is beamformer output
- // whistleMoanControl.whistleToneParameters.getChanOrSeqBitmap();
- // outputData.sortOutputMaps(getParentDataBlock().getChannelMap(), getParentDataBlock().getSequenceMapObject(), chanOrSeqMap);
- // outputData.setFftHop(sourceData.getFftHop());
- // outputData.setFftLength(sourceData.getFftLength());
- //
- // // 2017/11/30 set the whistleLocations channelMap properly
- // whistleLocations.sortOutputMaps(getParentDataBlock().getChannelMap(), getParentDataBlock().getSequenceMapObject(), chanOrSeqMap);
- //
- // // smoothingChannelProcessList = new SmoothingChannelProcess[PamUtils.getHighestChannel(chanOrSeqMap)+1];
- // // for (int i = 0; i < PamUtils.getHighestChannel(chanOrSeqMap)+1; i++) {
- // // smoothingChannelProcessList[i] = new SmoothingChannelProcess();
- // // }
- // }
+
// set the localisation information in the two output datablocks. If the source is using sequence numbers, then we cannot localise
boolean mayBearings = whistleMoanControl.whistleToneParameters.mayHaveBearings();
boolean mayRange = whistleMoanControl.whistleToneParameters.mayHaveRange();