From 07f4398a1d56b9b56e2640f816c64b71ceeeb09d Mon Sep 17 00:00:00 2001
From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date: Tue, 25 Jun 2024 09:25:10 +0100
Subject: [PATCH 1/2] Update .classpath
Fix classpath file
---
.classpath | 1 +
1 file changed, 1 insertion(+)
diff --git a/.classpath b/.classpath
index 053df83d..49faf461 100644
--- a/.classpath
+++ b/.classpath
@@ -5,6 +5,7 @@
+
From 0165982a222ae134e9eb767684bb38cbe7b61cd0 Mon Sep 17 00:00:00 2001
From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date: Fri, 12 Jul 2024 16:57:28 +0100
Subject: [PATCH 2/2] Work on localisation export
Not ready to rock yet.
---
dependency-reduced-pom.xml | 2 +-
src/Acquisition/AcquisitionControl.java | 11 +
src/Localiser/LocalisationAlgorithm.java | 21 ++
.../bearingLoc/BearingLocaliser.java | 3 +-
.../bearingLoc/CombinedBearingLocaliser.java | 6 +
.../bearingLoc/LSQBearingLocaliser.java | 6 +
.../bearingLoc/MLGridBearingLocaliser.java | 6 +
.../bearingLoc/MLGridBearingLocaliser2.java | 6 +
.../bearingLoc/MLLineBearingLocaliser2.java | 7 +
.../bearingLoc/PairBearingLocaliser.java | 216 +++++++++---------
.../bearingLoc/SimplexBearingLocaliser.java | 6 +
src/PamDetection/LocContents.java | 42 +++-
src/PamModel/PamModuleInfo.java | 7 +
src/RightWhaleEdgeDetector/RWEProcess.java | 8 +-
src/Spectrogram/SpectrogramDisplay.java | 5 +
src/asiojni/AsioDriverInfos.java | 61 +++--
src/clickDetector/ClickDetector.java | 36 ++-
.../tethys/ClickEventTethysDataProvider.java | 20 +-
src/tethys/detection/DetectionsHandler.java | 86 ++++---
.../localization/LocalizationHandler.java | 20 +-
.../localization/TethysLocalisationInfo.java | 40 ++++
src/tethys/niluswraps/PGranularityType.java | 2 +-
src/tethys/output/StreamExportParams.java | 15 +-
src/tethys/pamdata/AutoTethysProvider.java | 38 +++
src/tethys/pamdata/TethysDataProvider.java | 27 ++-
.../swing/export/DetectionsExportWizard.java | 2 +-
src/tethys/swing/export/GranularityCard.java | 150 +++++++++---
.../dataSelector/WMDDataSelector.java | 4 +
28 files changed, 631 insertions(+), 222 deletions(-)
create mode 100644 src/Localiser/LocalisationAlgorithm.java
create mode 100644 src/tethys/localization/TethysLocalisationInfo.java
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 36fc4eea..02e9f7ce 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -4,7 +4,7 @@
org.pamguard
Pamguard
Pamguard
- 2.02.11f
+ 2.02.12
Pamguard using Maven to control dependencies
www.pamguard.org
diff --git a/src/Acquisition/AcquisitionControl.java b/src/Acquisition/AcquisitionControl.java
index af2dddae..952aabcd 100644
--- a/src/Acquisition/AcquisitionControl.java
+++ b/src/Acquisition/AcquisitionControl.java
@@ -173,8 +173,19 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
registerDaqSystem(new SoundCardSystem(this));
if (PlatformInfo.calculateOS() == OSType.WINDOWS) {
+ long tic = System.currentTimeMillis();
+ long toc = tic;
registerDaqSystem(new ASIOSoundSystem(this));
+ toc = System.currentTimeMillis();
+ if (toc-tic>1000) {
+ System.out.printf("Registering ASIOSoundSystem took %3.1fs\n", (double)(toc-tic)/1000.);
+ }
+ tic = System.currentTimeMillis();
registerDaqSystem(new NewAsioSoundSystem(this));
+ toc = System.currentTimeMillis();
+ if (toc-tic>1000) {
+ System.out.printf("Registering NewAsioSoundSystem took %3.1fs\n", (double)(toc-tic)/1000.);
+ }
}
registerDaqSystem(new FileInputSystem(this));
registerDaqSystem(folderSystem = new FolderInputSystem(this));
diff --git a/src/Localiser/LocalisationAlgorithm.java b/src/Localiser/LocalisationAlgorithm.java
new file mode 100644
index 00000000..5a67799e
--- /dev/null
+++ b/src/Localiser/LocalisationAlgorithm.java
@@ -0,0 +1,21 @@
+package Localiser;
+
+import PamDetection.LocContents;
+import PamDetection.LocalisationInfo;
+
+/**
+ * Interface to attach to localisation algorithms which can provide basic information
+ * (primarily for better book keeping and Tethys output)
+ * @author dg50
+ *
+ */
+public interface LocalisationAlgorithm {
+
+ /**
+ * Get the likely content flags for this localiser.
+ * @see LocalisationInfo
+ * @see LocContents
+ * @return localisation flags.
+ */
+ public int getLocalisationContents();
+}
diff --git a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/BearingLocaliser.java b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/BearingLocaliser.java
index c640b238..82a77a5a 100644
--- a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/BearingLocaliser.java
+++ b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/BearingLocaliser.java
@@ -1,5 +1,6 @@
package Localiser.algorithms.timeDelayLocalisers.bearingLoc;
+import Localiser.LocalisationAlgorithm;
import pamMaths.PamVector;
/**
@@ -8,7 +9,7 @@ import pamMaths.PamVector;
* @author Doug Gillespie
*
*/
-public interface BearingLocaliser {
+public interface BearingLocaliser extends LocalisationAlgorithm {
/**
* Do any preparation necessary (e.g. creation of look up tables)
diff --git a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/CombinedBearingLocaliser.java b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/CombinedBearingLocaliser.java
index c987d7f1..7c9c791e 100644
--- a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/CombinedBearingLocaliser.java
+++ b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/CombinedBearingLocaliser.java
@@ -1,5 +1,6 @@
package Localiser.algorithms.timeDelayLocalisers.bearingLoc;
+import PamDetection.LocContents;
import pamMaths.PamVector;
public class CombinedBearingLocaliser implements BearingLocaliser {
@@ -23,6 +24,11 @@ public class CombinedBearingLocaliser implements BearingLocaliser {
firstSimplexStep[0] = firstSimplexStep[1] = Math.PI/180.;
}
+ @Override
+ public int getLocalisationContents() {
+ return LocContents.HAS_BEARING | LocContents.HAS_AMBIGUITY;
+ }
+
@Override
public void prepare(int[] arrayElements, long timeMillis, double timingError) {
firstLocaliser.prepare(arrayElements, timeMillis, timingError);
diff --git a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/LSQBearingLocaliser.java b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/LSQBearingLocaliser.java
index 9a232857..effbff21 100644
--- a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/LSQBearingLocaliser.java
+++ b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/LSQBearingLocaliser.java
@@ -5,6 +5,7 @@ import Array.PamArray;
import Jama.LUDecomposition;
import Jama.Matrix;
import Jama.QRDecomposition;
+import PamDetection.LocContents;
import PamUtils.PamUtils;
import pamMaths.PamVector;
@@ -30,6 +31,11 @@ public class LSQBearingLocaliser implements BearingLocaliser {
this.timingError = timingError;
}
+ @Override
+ public int getLocalisationContents() {
+ return LocContents.HAS_BEARING | LocContents.HAS_AMBIGUITY;
+ }
+
@Override
public void prepare(int[] arrayElements, long timeMillis, double timingError) {
/*
diff --git a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser.java b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser.java
index 6294a676..65cfbfc5 100644
--- a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser.java
+++ b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser.java
@@ -6,6 +6,7 @@ import Array.ArrayManager;
import Array.PamArray;
import Jama.Matrix;
import Localiser.algorithms.Correlations;
+import PamDetection.LocContents;
import PamUtils.ArrayDump;
import PamUtils.PamUtils;
import PamUtils.SystemTiming;
@@ -60,6 +61,11 @@ public class MLGridBearingLocaliser implements BearingLocaliser {
public void prepare(int[] arrayElements, long timMillis, double timingError) {
prepare(arrayElements, timMillis, timingError, Math.toRadians(1), Math.toRadians(1));
}
+
+ @Override
+ public int getLocalisationContents() {
+ return LocContents.HAS_BEARING | LocContents.HAS_AMBIGUITY;
+ }
synchronized private void prepare(int[] arrayElements, long timeMillis, double timingError, double thetaStep, double phiStep) {
this.timingError = timingError;
diff --git a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser2.java b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser2.java
index f71b54db..e507c945 100644
--- a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser2.java
+++ b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLGridBearingLocaliser2.java
@@ -8,6 +8,7 @@ import Jama.Matrix;
import Localiser.algorithms.Correlations;
import Localiser.algorithms.PeakPosition2D;
import Localiser.algorithms.PeakSearch;
+import PamDetection.LocContents;
import PamUtils.ArrayDump;
import PamUtils.PamUtils;
import PamUtils.SystemTiming;
@@ -72,6 +73,11 @@ public class MLGridBearingLocaliser2 implements BearingLocaliser {
this.useDefaults=true;
prepare(arrayElements, timMillis, timingError, Math.toRadians(3), Math.toRadians(3));
}
+
+ @Override
+ public int getLocalisationContents() {
+ return LocContents.HAS_BEARING | LocContents.HAS_AMBIGUITY;
+ }
synchronized private void prepare(int[] arrayElements, long timeMillis, double timingError, double thetaStep, double phiStep) {
this.timingError = timingError;
diff --git a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLLineBearingLocaliser2.java b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLLineBearingLocaliser2.java
index b04de1da..f8ce4723 100644
--- a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLLineBearingLocaliser2.java
+++ b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/MLLineBearingLocaliser2.java
@@ -3,6 +3,8 @@
*/
package Localiser.algorithms.timeDelayLocalisers.bearingLoc;
+import PamDetection.LocContents;
+
/**
* @author dg50
*
@@ -19,6 +21,11 @@ public class MLLineBearingLocaliser2 extends MLGridBearingLocaliser2 {
// TODO Auto-generated constructor stub
}
+ @Override
+ public int getLocalisationContents() {
+ return LocContents.HAS_BEARING | LocContents.HAS_AMBIGUITY | LocContents.HAS_AMBIGUITY;
+ }
+
/**
* Convert a bin into an angle.
* @param bin bin index
diff --git a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/PairBearingLocaliser.java b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/PairBearingLocaliser.java
index 59c166fd..4fc259df 100644
--- a/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/PairBearingLocaliser.java
+++ b/src/Localiser/algorithms/timeDelayLocalisers/bearingLoc/PairBearingLocaliser.java
@@ -6,6 +6,7 @@ import Array.ArrayManager;
import Array.PamArray;
import Jama.Matrix;
import Jama.QRDecomposition;
+import PamDetection.LocContents;
import PamUtils.PamUtils;
import pamMaths.PamVector;
@@ -17,111 +18,111 @@ import pamMaths.PamVector;
*/
public class PairBearingLocaliser implements BearingLocaliser {
- public class LSQBearingLocaliser implements BearingLocaliser {
-
- private int hydrophoneBitMap;
- private long timeMillis;
- private double timingError;
-
- private Matrix hydrophoneVectors, hydrophoneUnitVectors;
- private double[] hydrophoneSpacing;
- private PamArray currentArray;
- private int arrayType;
- private PamVector[] arrayAxis;
- // private LUDecomposition luHydrophoneUnitMatrix;
- private QRDecomposition qrHydrophones;
-
- public LSQBearingLocaliser(int hydrophoneBitMap, long timeMillis, double timingError) {
- this.hydrophoneBitMap = hydrophoneBitMap;
- this.timeMillis = timeMillis;
- this.timingError = timingError;
- }
-
- @Override
- public void prepare(int[] arrayElements, long timeMillis, double timingError) {
- /*
- * Set up the matrixes of inter hydrophone vectors.
- */
-
- hydrophoneBitMap = PamUtils.makeChannelMap(arrayElements);
- ArrayManager arrayManager = ArrayManager.getArrayManager();
- currentArray = arrayManager.getCurrentArray();
- arrayType = arrayManager.getArrayShape(currentArray, hydrophoneBitMap);
-
- arrayAxis = arrayManager.getArrayDirections(currentArray, hydrophoneBitMap);
-
- int nHyd = arrayElements.length;
- int nDelay = (nHyd*(nHyd-1))/2;
- hydrophoneVectors = new Matrix(nDelay, 3);
- hydrophoneUnitVectors = new Matrix(nDelay, 3);
- hydrophoneSpacing = new double[nDelay];
- int iRow = 0;
- for (int i = 0; i < nHyd; i++) {
- PamVector vi = currentArray.getAbsHydrophoneVector(i, timeMillis);
- for (int j = i+1; j 1000) {
+ System.out.printf("Module %s-%s was slow to load, taking %3.1f seconds\n", newUnit.getUnitType(),
+ newUnit.getUnitName(), (double)(toc-tic)/1000.);
+ }
setNInstances(nInstances + 1);
diff --git a/src/RightWhaleEdgeDetector/RWEProcess.java b/src/RightWhaleEdgeDetector/RWEProcess.java
index 0a3dabc4..7d8fe023 100644
--- a/src/RightWhaleEdgeDetector/RWEProcess.java
+++ b/src/RightWhaleEdgeDetector/RWEProcess.java
@@ -62,7 +62,7 @@ public class RWEProcess extends PamProcess {
this.rweControl = rweControl;
rweDataBlock = new RWEDataBlock(rweControl, rweControl.getUnitName(), this, 0);
addOutputDataBlock(rweDataBlock);
- rweDataBlock.setLocalisationContents(LocContents.HAS_BEARING);
+// rweDataBlock.setLocalisationContents(LocContents.HAS_BEARING);
rweDataBlock.setDatagramProvider(new RWEDatagramProvider());
rweDataBlock.setOverlayDraw(new RWEOverlayGraphics(this, rweDataBlock));
StandardSymbolManager symbolManager = symbolManager = new RWESymbolManager(rweDataBlock, RWEOverlayGraphics.defaultSymbol, true);
@@ -138,6 +138,11 @@ public class RWEProcess extends PamProcess {
rweChannelProcesses[i] = new RWEChannelProcess(this, i);
}
}
+ int nChan = PamUtils.getNumChannels(channelMap);
+ if (nChan > 1) {
+ // really needs properly setting up with channel groups
+ rweDataBlock.setLocalisationContents(LocContents.HAS_BEARING);
+ }
// checkBearingLocaliser(sourceDataBlock.getChannelMap());
}
@@ -433,6 +438,7 @@ public class RWEProcess extends PamProcess {
int hydrophoneMap = sourceDataBlock.getChannelListManager().channelIndexesToPhones(chanMap);
return findBearingLocaliser(hydrophoneMap);
}
+
private synchronized BearingLocaliser findBearingLocaliser(int hydrophoneMap) {
int nPhones = PamUtils.getNumChannels(hydrophoneMap);
if (nPhones < 2) {
diff --git a/src/Spectrogram/SpectrogramDisplay.java b/src/Spectrogram/SpectrogramDisplay.java
index 08a7bf2d..02b0548c 100644
--- a/src/Spectrogram/SpectrogramDisplay.java
+++ b/src/Spectrogram/SpectrogramDisplay.java
@@ -132,6 +132,7 @@ import PamguardMVC.PamProcess;
import PamguardMVC.PamRawDataBlock;
import PamguardMVC.SimpleDataObserver;
import PamguardMVC.dataOffline.OfflineDataLoading;
+import PamguardMVC.dataSelector.DataSelectParams;
import PamguardMVC.dataSelector.DataSelector;
import dataPlotsFX.data.DataTypeInfo;
import fftManager.FFTDataBlock;
@@ -2927,6 +2928,10 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
// PamCalendar.formatTime(currentTimeMilliseconds)));
String name = spectrogramDisplay.getDataSelectorName(panelId);
DataSelector dataSelector = usedDataBlock.getDataSelector(name, false);
+
+ if (dataSelector.getParams().getCombinationFlag() == DataSelectParams.DATA_SELECT_DISABLE) {
+ dataSelector = null;
+ }
directDrawProjector.setDataSelector(dataSelector);
if (usedDataBlock.getPamSymbolManager() != null) {
directDrawProjector.setPamSymbolChooser(usedDataBlock.getPamSymbolManager().getSymbolChooser(name, directDrawProjector));
diff --git a/src/asiojni/AsioDriverInfos.java b/src/asiojni/AsioDriverInfos.java
index 6eecfae0..91603dae 100644
--- a/src/asiojni/AsioDriverInfos.java
+++ b/src/asiojni/AsioDriverInfos.java
@@ -25,7 +25,15 @@ public class AsioDriverInfos {
}
+ /**
+ * Gets called back from the jni call to callJniGetAsioDrivers
+ * @param driverName
+ * @param maxChannels
+ * @param sampleRateInfo
+ */
public void addDriverToList(String driverName, int[] maxChannels, int[]sampleRateInfo){
+ lastDriverEnumeration = System.currentTimeMillis();
+ System.out.printf("Getting driver detail for ASIO %s took %3.1fs\n", driverName, (double) (lastDriverEnumeration-driverEnumerationStart)/1000.);
ArrayListsampleRates = new ArrayList();
ArrayListmaxAvailableChannels = new ArrayList();
for(int i = 0;i getAsioDriverList() {
clearDriverList();
+ long t1 = System.currentTimeMillis();
+ driverEnumerationStart = t1;
asioJniInterface.callJniGetAsioDrivers(this);
+ long t2 = System.currentTimeMillis();
+ System.out.printf("Call to asioJniInterface.callJniGetAsioDrivers took %3.1fs\n", (double) (t2-t1)/1000.);
+
for(int i = 0; i 1000) {
+ System.out.printf("Checking cababilities for ASIO %s took %3.1fs\n", asioDriverList.get(i).driverName,
+ (double) (toc-tic)/1000.);
+ }
+ }
+ // System.out.println();
+ // System.out.println("Java:: just called asioJniInterface.callJniGetAsioDrivers(this);");
+ // System.out.flush();
+
return asioDriverList;
}
@@ -65,11 +87,14 @@ public class AsioDriverInfos {
// System.out.println("getCurrentAsioDriverList():: asioDriverList.size()=" + asioDriverList.size());
// System.out.flush();
if(asioDriverList.size()==0){
- return asioDriverList = getAsioDriverList();
- }
- else{
- return asioDriverList;
+ long tic = System.currentTimeMillis();
+ asioDriverList = getAsioDriverList();
+ long toc = System.currentTimeMillis();
+ if (toc-tic>1000) {
+ System.out.printf("Enumerating ASIO driver list took %3.1fs\n", (double)(toc-tic)/1000.);
+ }
}
+ return asioDriverList;
}
diff --git a/src/clickDetector/ClickDetector.java b/src/clickDetector/ClickDetector.java
index 2ee4ece2..930458ce 100644
--- a/src/clickDetector/ClickDetector.java
+++ b/src/clickDetector/ClickDetector.java
@@ -312,19 +312,19 @@ public class ClickDetector extends PamProcess {
offlineEventDataBlock.SetLogging(offlineEventLogging);
targetMotionSQLLogging = new TargetMotionSQLLogging(2);
offlineEventLogging.addAddOn(targetMotionSQLLogging);
- if (isViewer) {
- // offlineEventDataBlock = new
- // OfflineEventDataBlock(clickControl.getUnitName()+"_OfflineEvents",
- // this, 0);
- // offlineEventLogging = new OfflineEventLogging(clickControl,
- // offlineEventDataBlock);
- // targetMotionSQLLogging = new TargetMotionSQLLogging(2);
- // offlineEventLogging.addAddOn(targetMotionSQLLogging);
- // offlineEventDataBlock.SetLogging(offlineEventLogging);
- } else { // for normal and mixed mode.
+// if (isViewer) {
+// // offlineEventDataBlock = new
+// // OfflineEventDataBlock(clickControl.getUnitName()+"_OfflineEvents",
+// // this, 0);
+// // offlineEventLogging = new OfflineEventLogging(clickControl,
+// // offlineEventDataBlock);
+// // targetMotionSQLLogging = new TargetMotionSQLLogging(2);
+// // offlineEventLogging.addAddOn(targetMotionSQLLogging);
+// // offlineEventDataBlock.SetLogging(offlineEventLogging);
+// } else { // for normal and mixed mode.
offlineEventDataBlock.setLocalisationContents(LocContents.HAS_BEARING | LocContents.HAS_RANGE
| LocContents.HAS_LATLONG | LocContents.HAS_AMBIGUITY | LocContents.HAS_PERPENDICULARERRORS);
- }
+// }
// set up the subtable for the Event Logger, and force creation
offlineEventLogging.setSubLogging(getClickDataBlock().getOfflineClickLogging());
@@ -458,6 +458,8 @@ public class ClickDetector extends PamProcess {
nChannelGroups = GroupedSourcePanel.countChannelGroups(cp.getChannelBitmap(), cp.getChannelGroups());
int groupChannels;
channelGroupDetectors = new ChannelGroupDetector[nChannelGroups];
+
+ int locContents = 0;
for (int i = 0; i < nChannelGroups; i++) {
groupChannels = GroupedSourcePanel.getGroupChannels(i, cp.getChannelBitmap(), cp.getChannelGroups());
channelGroupDetectors[i] = new ChannelGroupDetector(i, groupChannels);
@@ -467,9 +469,21 @@ public class ClickDetector extends PamProcess {
if (multiThread) {
channelGroupDetectors[i].halfBuiltClicks.addObserver(newClickMonitor, true);
}
+ if (channelGroupDetectors[i].bearingLocaliser != null) {
+ locContents |= channelGroupDetectors[i].bearingLocaliser.getLocalisationContents();
+ }
// System.out.println("Group " + i + " contains channels list " +
// groupChannels);
}
+ outputClickData.setLocalisationContents(locContents);
+ if (locContents == 0) {
+ offlineEventDataBlock.setLocalisationContents(0);
+ }
+ else {
+ int eventLocCont = LocContents.HAS_LATLONG | LocContents.HAS_XYZ | LocContents.HAS_RANGE;
+ eventLocCont |= (locContents & LocContents.HAS_AMBIGUITY);
+ offlineEventDataBlock.setLocalisationContents(eventLocCont);
+ }
globalChannelList = new int[nChan = PamUtils
.getNumChannels(clickControl.clickParameters.getChannelBitmap())];
diff --git a/src/clickDetector/tethys/ClickEventTethysDataProvider.java b/src/clickDetector/tethys/ClickEventTethysDataProvider.java
index bbc5d1fd..9f6629d9 100644
--- a/src/clickDetector/tethys/ClickEventTethysDataProvider.java
+++ b/src/clickDetector/tethys/ClickEventTethysDataProvider.java
@@ -27,6 +27,7 @@ public class ClickEventTethysDataProvider extends AutoTethysProvider {
@Override
public GranularityEnumType[] getAllowedGranularities() {
+ // these are by definition grouped.
GranularityEnumType[] allowed = {GranularityEnumType.GROUPED};
return allowed;
}
@@ -59,14 +60,19 @@ public class ClickEventTethysDataProvider extends AutoTethysProvider {
addUserDefined(params, numName, number.toString());
}
+// @Override
+// public boolean wantExportDialogCard(ExportWizardCard wizPanel) {
+//// if (wizPanel.getClass() == GranularityCard.class) {
+//// return false;
+//// }
+//// else {
+// return true;
+//// }
+// }
+
@Override
- public boolean wantExportDialogCard(ExportWizardCard wizPanel) {
- if (wizPanel.getClass() == GranularityCard.class) {
- return false;
- }
- else {
- return true;
- }
+ public boolean granularityOK(GranularityEnumType granularityType) {
+ return true;
}
}
diff --git a/src/tethys/detection/DetectionsHandler.java b/src/tethys/detection/DetectionsHandler.java
index cd995bbb..3d3e1c13 100644
--- a/src/tethys/detection/DetectionsHandler.java
+++ b/src/tethys/detection/DetectionsHandler.java
@@ -26,6 +26,7 @@ import dataMap.OfflineDataMap;
import dataMap.OfflineDataMapPoint;
import nilus.AlgorithmType;
import nilus.AlgorithmType.SupportSoftware;
+import nilus.Localize.Localizations;
import nilus.DataSourceType;
import nilus.Deployment;
import nilus.Detection;
@@ -380,8 +381,10 @@ public class DetectionsHandler extends CollectionHandler {
}
return exportCount;
- }/**
- * Export detections in all deployments for this PAMGuard dataset.
+ }
+
+ /**
+ * Export detections and localisations in all deployments for this PAMGuard dataset.
* @param dataBlock
* @param streamExportParams
* @param exportObserver
@@ -396,7 +399,14 @@ public class DetectionsHandler extends CollectionHandler {
DBXMLConnect dbxmlConnect = tethysControl.getDbxmlConnect();
DeploymentHandler depHandler = tethysControl.getDeploymentHandler();
ArrayList deployments = depHandler.getMatchedDeployments();
- Detections currentDetections = null;
+
+ /*
+ * The main documents for both dets and locs.
+ */
+ Detections detectionsDocument = null;
+ Localizations localisationsDocument = null;
+ DetectionGroup onEffortDetections = null;
+
OfflineDataMap dataMap = dataBlock.getPrimaryDataMap();
DataSelector dataSelector = dataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
int totalCount = dataMap.getDataCount();
@@ -427,16 +437,23 @@ public class DetectionsHandler extends CollectionHandler {
List mapPoints = dataMap.getMapPoints();
for (OfflineDataMapPoint mapPoint : mapPoints) {
if (!activeExport) {
- prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
+ prog = new DetectionExportProgress(deployment, detectionsDocument,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_CANCELED);
exportObserver.update(prog);
break;
}
- if (currentDetections == null) {
+ if (detectionsDocument == null && streamExportParams.exportDetections) {
// needed in inner loop in case doc gets written at 500000.
- currentDetections = startDetectionsDocument(deployment, dataBlock, streamExportParams);
- currentDetections.getEffort().setStart(TethysTimeFuncs.xmlGregCalFromMillis(deployment.getAudioStart()));
+ detectionsDocument = startDetectionsDocument(deployment, dataBlock, streamExportParams);
+ detectionsDocument.getEffort().setStart(TethysTimeFuncs.xmlGregCalFromMillis(deployment.getAudioStart()));
+ onEffortDetections = detectionsDocument.getOnEffort();
+ }
+ else {
+ onEffortDetections = null;
+ }
+ if (localisationsDocument == null && streamExportParams.exportLocalisations) {
+ localisationsDocument = startLocalisationDocument(deployment, dataBlock, streamExportParams);
}
if (mapPoint.getEndTime() < deployment.getAudioStart()) {
@@ -449,7 +466,6 @@ public class DetectionsHandler extends CollectionHandler {
ArrayList dataCopy = dataBlock.getDataCopy(deployment.getAudioStart(), deployment.getAudioEnd(), true, dataSelector);
Collections.sort(dataCopy);
skipCount += dataBlock.getUnitsCount() - dataCopy.size();
- DetectionGroup onEffort = currentDetections.getOnEffort();
for (PamDataUnit dataUnit : dataCopy) {
/*
* Here is where we need to handle the different granularities.
@@ -459,11 +475,13 @@ public class DetectionsHandler extends CollectionHandler {
for (int dd = 0; dd < dets.length; dd++) {
exportCount++;
documentCount++;
- onEffort.getDetection().add(dets[dd]);
+ if (streamExportParams.exportDetections) {
+ onEffortDetections.getDetection().add(dets[dd]);
+ }
}
}
if (exportCount % 100 == 0) {
- prog = new DetectionExportProgress(deployment, currentDetections, totalMapPoints, doneMapPoints,
+ prog = new DetectionExportProgress(deployment, detectionsDocument, totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
exportObserver.update(prog);
}
@@ -471,23 +489,25 @@ public class DetectionsHandler extends CollectionHandler {
}
doneMapPoints ++;
- prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
+ prog = new DetectionExportProgress(deployment, detectionsDocument,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
exportObserver.update(prog);
if (documentCount > 50000000 && mapPoint != dataMap.getLastMapPoint()) {
- prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
+ prog = new DetectionExportProgress(deployment, detectionsDocument,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING);
exportObserver.update(prog);
- closeDetectionsDocument(currentDetections, mapPoint.getEndTime());
- try {
- if (checkDetectionsDocument(currentDetections, granularityHandler)) {
- dbxmlConnect.postAndLog(currentDetections);
+ if (detectionsDocument != null) {
+ closeDetectionsDocument(detectionsDocument, mapPoint.getEndTime());
+ try {
+ if (checkDetectionsDocument(detectionsDocument, granularityHandler)) {
+ dbxmlConnect.postAndLog(detectionsDocument);
+ }
+ } catch (TethysException e) {
+ tethysControl.showException(e);
}
- } catch (TethysException e) {
- tethysControl.showException(e);
+ detectionsDocument = null;
}
- currentDetections = null;
}
if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) {
@@ -502,26 +522,26 @@ public class DetectionsHandler extends CollectionHandler {
return DetectionExportProgress.STATE_CANCELED;
}
- if (currentDetections != null) {
+ if (detectionsDocument != null) {
Detection dets[] = granularityHandler.cleanup(deployment.getAudioEnd());
if (dets != null) {
for (int dd = 0; dd < dets.length; dd++) {
exportCount++;
documentCount++;
- currentDetections.getOnEffort().getDetection().add(dets[dd]);
+ detectionsDocument.getOnEffort().getDetection().add(dets[dd]);
}
}
- prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
+ prog = new DetectionExportProgress(deployment, detectionsDocument,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING);
- closeDetectionsDocument(currentDetections, deployment.getAudioEnd());
+ closeDetectionsDocument(detectionsDocument, deployment.getAudioEnd());
try {
- if (checkDetectionsDocument(currentDetections, granularityHandler)) {
- dbxmlConnect.postAndLog(currentDetections);
+ if (checkDetectionsDocument(detectionsDocument, granularityHandler)) {
+ dbxmlConnect.postAndLog(detectionsDocument);
}
} catch (TethysException e) {
tethysControl.showException(e);
}
- currentDetections = null;
+ detectionsDocument = null;
}
}
@@ -531,6 +551,20 @@ public class DetectionsHandler extends CollectionHandler {
return DetectionExportProgress.STATE_COMPLETE;
}
+ private Localizations startLocalisationDocument(PDeployment deployment, PamDataBlock dataBlock,
+ StreamExportParams streamExportParams) {
+ Localizations localisations = new Localizations();
+ try {
+ Helper.createRequiredElements(localisations);
+ } catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return localisations;
+ }
+
+
/**
* Start a new detections document for the deployment and datablock.
* Add all the standard information to the top of the Document
diff --git a/src/tethys/localization/LocalizationHandler.java b/src/tethys/localization/LocalizationHandler.java
index 3751df93..69105b5e 100644
--- a/src/tethys/localization/LocalizationHandler.java
+++ b/src/tethys/localization/LocalizationHandler.java
@@ -1,17 +1,17 @@
package tethys.localization;
-//import nilus.CylindricalCoordinateType;
-//import nilus.LocalizationType;
-//import nilus.Localize.Effort.CoordinateReferenceSystem;
+import nilus.CylindricalCoordinateType;
+import nilus.LocalizationType;
+import nilus.Localize.Effort.CoordinateReferenceSystem;
public class LocalizationHandler {
-// public LocalizationType getLoc() {
-// LocalizationType lt = new LocalizationType();
-// CylindricalCoordinateType cct = new CylindricalCoordinateType();
-//// cct.set
-// CoordinateReferenceSystem cr;
-// return null;
-// }
+ public LocalizationType getLoc() {
+ LocalizationType lt = new LocalizationType();
+ CylindricalCoordinateType cct = new CylindricalCoordinateType();
+// cct.set
+ CoordinateReferenceSystem cr;
+ return null;
+ }
}
diff --git a/src/tethys/localization/TethysLocalisationInfo.java b/src/tethys/localization/TethysLocalisationInfo.java
new file mode 100644
index 00000000..e8ef5e96
--- /dev/null
+++ b/src/tethys/localization/TethysLocalisationInfo.java
@@ -0,0 +1,40 @@
+package tethys.localization;
+
+import PamDetection.LocContents;
+import PamDetection.LocalisationInfo;
+import PamguardMVC.PamDataBlock;
+
+/**
+ * Summary of localisation info in a datablock, specific to Tethys needs.
+ * @author dg50
+ *
+ */
+public class TethysLocalisationInfo {
+
+ private PamDataBlock pamDataBlock;
+
+ public TethysLocalisationInfo(PamDataBlock pamDataBlock) {
+ this.pamDataBlock = pamDataBlock;
+ }
+
+ public String getLoclisationTypes() {
+ LocalisationInfo locCont = pamDataBlock.getLocalisationContents();
+ if (locCont == null || locCont.getLocContent() == 0) {
+ return null;
+ }
+ String str = null;
+ int[] mainTypes = LocContents.mainTypes;
+ for (int i = 0; i < mainTypes.length; i++) {
+ if (locCont.hasLocContent(mainTypes[i])) {
+ if (str == null) {
+ str = LocContents.getTypeString(mainTypes[i]);
+ }
+ else {
+ str += ", " + LocContents.getTypeString(mainTypes[i]);
+ }
+ }
+ }
+ return str;
+ }
+
+}
diff --git a/src/tethys/niluswraps/PGranularityType.java b/src/tethys/niluswraps/PGranularityType.java
index ee898d64..c8a58a0b 100644
--- a/src/tethys/niluswraps/PGranularityType.java
+++ b/src/tethys/niluswraps/PGranularityType.java
@@ -20,7 +20,7 @@ public class PGranularityType {
case BINNED:
return "Binned";
case CALL:
- return "Call";
+ return "Call / detection";
case ENCOUNTER:
return "Encounter";
case GROUPED:
diff --git a/src/tethys/output/StreamExportParams.java b/src/tethys/output/StreamExportParams.java
index ca4b18ed..82d1c9ce 100644
--- a/src/tethys/output/StreamExportParams.java
+++ b/src/tethys/output/StreamExportParams.java
@@ -26,11 +26,19 @@ public class StreamExportParams implements Serializable {
/**
* Datablock long data name (used instead of datablock
- * reference so this object and serialise.
+ * reference so this object is serialise.
*/
public String longDataName;
- public boolean selected;
+ /**
+ * Have selected export of detections.
+ */
+ public boolean exportDetections;
+
+ /**
+ * Have selected export of localisations.
+ */
+ public boolean exportLocalisations;
/**
* Granularity type, binned, call, encounter, grouped.
@@ -74,10 +82,9 @@ public class StreamExportParams implements Serializable {
return detectionDescription;
}
- public StreamExportParams(TethysControl tethysControl, PamDataBlock dataBlock, boolean selected) {
+ public StreamExportParams(TethysControl tethysControl, PamDataBlock dataBlock) {
super();
this.longDataName = dataBlock.getLongDataName();
- this.selected = selected;
autoFill(tethysControl, dataBlock);
}
diff --git a/src/tethys/pamdata/AutoTethysProvider.java b/src/tethys/pamdata/AutoTethysProvider.java
index 8c40e41b..2af977d9 100644
--- a/src/tethys/pamdata/AutoTethysProvider.java
+++ b/src/tethys/pamdata/AutoTethysProvider.java
@@ -13,6 +13,7 @@ import PamController.PamControlledUnit;
import PamController.PamSettings;
import PamController.PamguardVersionInfo;
import PamController.settings.output.xml.PamguardXMLWriter;
+import PamDetection.LocalisationInfo;
import PamUtils.XMLUtils;
import PamguardMVC.DataAutomationInfo;
import PamguardMVC.DataUnitBaseData;
@@ -37,6 +38,7 @@ import nilus.SpeciesIDType;
import tethys.TethysControl;
import tethys.TethysTimeFuncs;
import tethys.detection.DetectionsHandler;
+import tethys.localization.TethysLocalisationInfo;
import tethys.niluswraps.PDeployment;
import tethys.output.StreamExportParams;
import tethys.output.TethysExportParams;
@@ -505,5 +507,41 @@ abstract public class AutoTethysProvider implements TethysDataProvider {
return tethysControl;
}
+ @Override
+ public boolean hasDetections() {
+ return true;
+ }
+
+
+ @Override
+ public boolean canExportLocalisations(GranularityEnumType granularityType) {
+ LocalisationInfo locCont = pamDataBlock.getLocalisationContents();
+ if (locCont == null) {
+ return false;
+ }
+ return (locCont.getLocContent() > 0 & granularityOK(granularityType));
+ }
+
+ /**
+ * Granularity is OK for export.
+ * @param granularityType
+ * @return
+ */
+ public boolean granularityOK(GranularityEnumType granularityType) {
+ return (granularityType == null || granularityType == GranularityEnumType.CALL);
+ }
+
+ @Override
+ public TethysLocalisationInfo getLocalisationInfo() {
+ LocalisationInfo locCont = pamDataBlock.getLocalisationContents();
+ if (locCont == null || locCont.getLocContent() == 0) {
+ return null;
+ }
+ else {
+ return new TethysLocalisationInfo(pamDataBlock);
+ }
+ }
+
+
}
diff --git a/src/tethys/pamdata/TethysDataProvider.java b/src/tethys/pamdata/TethysDataProvider.java
index f273c3bd..9ce542b8 100644
--- a/src/tethys/pamdata/TethysDataProvider.java
+++ b/src/tethys/pamdata/TethysDataProvider.java
@@ -2,6 +2,7 @@ package tethys.pamdata;
import java.util.List;
+import PamDetection.LocalisationInfo;
import PamguardMVC.PamDataUnit;
import nilus.AlgorithmType;
import nilus.AlgorithmType.Parameters;
@@ -10,6 +11,7 @@ import nilus.DescriptionType;
import nilus.Detection;
import nilus.DetectionEffortKind;
import nilus.GranularityEnumType;
+import tethys.localization.TethysLocalisationInfo;
import tethys.niluswraps.PDeployment;
import tethys.output.StreamExportParams;
import tethys.output.TethysExportParams;
@@ -81,7 +83,23 @@ public interface TethysDataProvider {
* @return A name, similar to datablock.getLongDataName(), but no spaces.
*/
public String getDetectionsName();
-
+
+ /**
+ * True if the datablock is detections. This will (nearly) always
+ * be true or the block wouldn't have a TethysDataProvider, however
+ * there may be one or two localisers that should really only output
+ * localisation information.
+ * @return
+ */
+ public boolean hasDetections();
+
+ /**
+ * See if it's possible for this block to export localisations. This may
+ * depend on the selected granularity.
+ * @param granularityType
+ * @return
+ */
+ public boolean canExportLocalisations(GranularityEnumType granularityType);
/**
* Create a Tethys Detection object from a PamDataUnit.
@@ -120,5 +138,12 @@ public interface TethysDataProvider {
*/
public boolean wantExportDialogCard(ExportWizardCard wizPanel);
+ /**
+ * Get localisation info for the datablock. Can be null, but probably never is. More likely to have a zero of available types;
+ * @return
+ */
+ public TethysLocalisationInfo getLocalisationInfo();
+
+
}
diff --git a/src/tethys/swing/export/DetectionsExportWizard.java b/src/tethys/swing/export/DetectionsExportWizard.java
index edfe80fd..d1ab314a 100644
--- a/src/tethys/swing/export/DetectionsExportWizard.java
+++ b/src/tethys/swing/export/DetectionsExportWizard.java
@@ -42,7 +42,7 @@ public class DetectionsExportWizard extends PamWizard {
streamExportParams = tethysControl.getTethysExportParams().getStreamParams(dataBlock);
if (streamExportParams == null) {
- streamExportParams = new StreamExportParams(tethysControl, dataBlock, false);
+ streamExportParams = new StreamExportParams(tethysControl, dataBlock);
}
tethysDataProvider = dataBlock.getTethysDataProvider(tethysControl);
getMainPanel().add(BorderLayout.NORTH, new ExportStreamInfoPanel(dataBlock));
diff --git a/src/tethys/swing/export/GranularityCard.java b/src/tethys/swing/export/GranularityCard.java
index e88f9b2d..22f235e6 100644
--- a/src/tethys/swing/export/GranularityCard.java
+++ b/src/tethys/swing/export/GranularityCard.java
@@ -9,6 +9,7 @@ import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
@@ -17,9 +18,6 @@ import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
-import org.w3c.dom.Document;
-
-import PamController.settings.output.xml.PamguardXMLWriter;
import PamView.dialog.PamGridBagContraints;
import PamView.panel.WestAlignedPanel;
import PamguardMVC.PamDataBlock;
@@ -28,6 +26,7 @@ import PamguardMVC.dataSelector.DataSelector;
import PamguardMVC.dataSelector.DataSelectorChangeListener;
import nilus.GranularityEnumType;
import tethys.TethysControl;
+import tethys.localization.TethysLocalisationInfo;
import tethys.niluswraps.PGranularityType;
import tethys.output.StreamExportParams;
import tethys.pamdata.TethysDataProvider;
@@ -40,22 +39,51 @@ public class GranularityCard extends ExportWizardCard {
private JTextField binLength, minBinnedCalls, encounterGap, minEncounterCalls;
+ private JCheckBox exportDetections, exportLocalisations;
+
+ private JLabel localisationTypes;
+
private JRadioButton groupChannels, separateChannels;
private DataSelector dataSelector;
private DetectionsExportWizard detectionsExportWizard;
- private int encounterIndex, binnedIndex;
+ private int callIndex, encounterIndex, binnedIndex;
private GranularityEnumType[] allowedGranularities;
+ private TethysDataProvider tethysDataProvider;
+
public GranularityCard(DetectionsExportWizard detectionsExportWizard, TethysControl tethysControl, PamDataBlock dataBlock) {
super(tethysControl, detectionsExportWizard, "Granularity", dataBlock);
this.detectionsExportWizard = detectionsExportWizard;
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- TethysDataProvider tethysDataProvider = dataBlock.getTethysDataProvider(tethysControl);
+ tethysDataProvider = dataBlock.getTethysDataProvider(tethysControl);
+
+ GranularityChange gc = new GranularityChange();
+
+ exportDetections = new JCheckBox("Export Detections");
+ exportLocalisations = new JCheckBox("Export Localisations");
+ exportDetections.addActionListener(gc);
+ exportLocalisations.addActionListener(gc);
+ JPanel whatPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints cw = new PamGridBagContraints();
+ cw.gridwidth = 2;
+ whatPanel.add(exportDetections, cw);
+ cw.gridy++;
+ whatPanel.add(exportLocalisations, cw);
+ cw.gridwidth = 1;
+ cw.gridy++;
+ whatPanel.add(new JLabel("Loclisation types: ", JLabel.RIGHT), cw);
+ cw.gridx++;
+ whatPanel.add(localisationTypes = new JLabel("none"), cw);
+ JPanel walPanel = new WestAlignedPanel(whatPanel);
+ walPanel.setBorder(new TitledBorder("What to export"));
+ this.add(walPanel);
+ localisationTypes.setToolTipText("Not all listed localisation types may be present in actual data");
+
// granularity
allowedGranularities = tethysDataProvider.getAllowedGranularities();
granularities = new JRadioButton[allowedGranularities.length];
@@ -63,7 +91,6 @@ public class GranularityCard extends ExportWizardCard {
GridBagConstraints c = new PamGridBagContraints();
granPanel.setBorder(new TitledBorder("Granularity"));
ButtonGroup granGroup = new ButtonGroup();
- GranularityChange gc = new GranularityChange();
binLength = new JTextField(5);
minBinnedCalls = new JTextField(5);
encounterGap = new JTextField(5);
@@ -75,6 +102,9 @@ public class GranularityCard extends ExportWizardCard {
granularities[i].addActionListener(gc);
granPanel.add(granularities[i], c);
granGroup.add(granularities[i]);
+ if (allowedGranularities[i] == GranularityEnumType.CALL) {
+ callIndex = i;
+ }
if (allowedGranularities[i] == GranularityEnumType.BINNED) {
binnedIndex = i;
c.gridx++;
@@ -149,16 +179,6 @@ public class GranularityCard extends ExportWizardCard {
}
- private void enableControls() {
- binLength.setEnabled(granularities[binnedIndex].isSelected());
- minBinnedCalls.setEnabled(granularities[binnedIndex].isSelected());
- encounterGap.setEnabled(granularities[encounterIndex].isSelected());
- minEncounterCalls.setEnabled(granularities[encounterIndex].isSelected());
- boolean binOrencount = granularities[binnedIndex].isSelected() | granularities[encounterIndex].isSelected();
- separateChannels.setEnabled(binOrencount);
- groupChannels.setEnabled(binOrencount);
- }
-
protected void newDataSelection() {
if (dataSelector == null) {
return;
@@ -177,12 +197,9 @@ public class GranularityCard extends ExportWizardCard {
@Override
public boolean getParams(StreamExportParams streamExportParams) {
- for (int i = 0; i < allowedGranularities.length; i++) {
- if (granularities[i].isSelected()) {
- streamExportParams.granularity = allowedGranularities[i];
- break;
- }
- }
+
+ streamExportParams.granularity = getCurrentGranularity();
+
if (streamExportParams.granularity == GranularityEnumType.BINNED) {
try {
streamExportParams.binDurationS = Double.valueOf(binLength.getText());
@@ -214,22 +231,87 @@ public class GranularityCard extends ExportWizardCard {
streamExportParams.separateChannels = separateChannels.isSelected();
+ streamExportParams.exportDetections = exportDetections.isSelected();
+
+ streamExportParams.exportLocalisations = exportLocalisations.isSelected();
+
+ if (streamExportParams.exportDetections == false && streamExportParams.exportLocalisations == false) {
+ return detectionsExportWizard.showWarning("You must select Detections or Localisations for export");
+ }
+
return streamExportParams.granularity != null;
}
- @Override
- public void setParams(StreamExportParams streamExportParams) {
- for (int i = 0; i < granularities.length; i++) {
- granularities[i].setSelected(streamExportParams.granularity == allowedGranularities[i]);
+ private GranularityEnumType getCurrentGranularity() {
+ for (int i = 0; i < allowedGranularities.length; i++) {
+ if (granularities[i].isSelected()) {
+ return allowedGranularities[i];
+ }
}
- binLength.setText(String.format("%3.1f", streamExportParams.binDurationS));
- minBinnedCalls.setText(String.format("%d", streamExportParams.minBinCount));
- encounterGap.setText(String.format("%3.1f", streamExportParams.encounterGapS));
- minEncounterCalls.setText(String.format("%d", streamExportParams.minEncounterCount));
- separateChannels.setSelected(streamExportParams.separateChannels);
- groupChannels.setSelected(streamExportParams.separateChannels == false);
- newDataSelection();
- enableControls();
+ return null;
+ }
+
+ @Override
+ public void setParams(StreamExportParams streamExportParams) {
+ for (int i = 0; i < granularities.length; i++) {
+ granularities[i].setSelected(streamExportParams.granularity == allowedGranularities[i]);
+ }
+ binLength.setText(String.format("%3.1f", streamExportParams.binDurationS));
+ minBinnedCalls.setText(String.format("%d", streamExportParams.minBinCount));
+ encounterGap.setText(String.format("%3.1f", streamExportParams.encounterGapS));
+ minEncounterCalls.setText(String.format("%d", streamExportParams.minEncounterCount));
+ separateChannels.setSelected(streamExportParams.separateChannels);
+ groupChannels.setSelected(streamExportParams.separateChannels == false);
+ String locStr = getLocInfString();
+ if (locStr == null) {
+ localisationTypes.setText("none");
+ // exportDetections.setSelected(true);
+ exportLocalisations.setSelected(false);
+ }
+ else {
+ localisationTypes.setText(locStr);
+ }
+
+ exportDetections.setSelected(streamExportParams.exportDetections);
+ exportLocalisations.setSelected(streamExportParams.exportLocalisations);
+
+ newDataSelection();
+ enableControls();
+ }
+
+ private void enableControls() {
+ String locStr = getLocInfString();
+ boolean dets = exportDetections.isSelected();
+ boolean locs = exportLocalisations.isSelected();
+ granularities[binnedIndex].setEnabled(!locs);
+ granularities[encounterIndex].setEnabled(!locs);
+ GranularityEnumType granularity = getCurrentGranularity();
+ boolean canLoc = tethysDataProvider.canExportLocalisations(granularity);
+ exportLocalisations.setEnabled(canLoc);
+ if (canLoc == false) {
+ exportLocalisations.setSelected(false);
+ exportDetections.setSelected(true);
+ }
+
+ if (granularities.length == 1) {
+ granularities[0].setSelected(true);
+ }
+
+ binLength.setEnabled(granularities[binnedIndex].isSelected());
+ minBinnedCalls.setEnabled(granularities[binnedIndex].isSelected());
+ encounterGap.setEnabled(granularities[encounterIndex].isSelected());
+ minEncounterCalls.setEnabled(granularities[encounterIndex].isSelected());
+ boolean binOrencount = granularities[binnedIndex].isSelected() | granularities[encounterIndex].isSelected();
+ separateChannels.setEnabled(binOrencount);
+ groupChannels.setEnabled(binOrencount);
+ }
+
+ private String getLocInfString() {
+ TethysLocalisationInfo locInf = getDataBlock().getTethysDataProvider(getTethysControl()).getLocalisationInfo();
+ if (locInf == null) {
+ return null;
+ }
+ return locInf.getLoclisationTypes();
}
}
diff --git a/src/whistlesAndMoans/dataSelector/WMDDataSelector.java b/src/whistlesAndMoans/dataSelector/WMDDataSelector.java
index 34ec0027..62db9587 100644
--- a/src/whistlesAndMoans/dataSelector/WMDDataSelector.java
+++ b/src/whistlesAndMoans/dataSelector/WMDDataSelector.java
@@ -39,6 +39,10 @@ public class WMDDataSelector extends DataSelector {
@Override
public double scoreData(PamDataUnit pamDataUnit) {
+ int combFlag = wmAlarmParameters.getCombinationFlag();
+ if (combFlag == DataSelectParams.DATA_SELECT_DISABLE) {
+ return 1;
+ }
ConnectedRegionDataUnit crDataUnit = (ConnectedRegionDataUnit) pamDataUnit;
return (wantWhistle(crDataUnit) ? 1: 0);
}