mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
Click event output
This commit is contained in:
parent
5fe0927c10
commit
4d294b56a8
@ -259,6 +259,7 @@ public class StreamerDialog extends PamDialog {
|
|||||||
// }
|
// }
|
||||||
singleInstance.currentArray = currentArray;
|
singleInstance.currentArray = currentArray;
|
||||||
singleInstance.defaultStreamer = streamer;//.clone();
|
singleInstance.defaultStreamer = streamer;//.clone();
|
||||||
|
// singleInstance.st
|
||||||
singleInstance.setParams();
|
singleInstance.setParams();
|
||||||
singleInstance.setVisible(true);
|
singleInstance.setVisible(true);
|
||||||
return singleInstance.defaultStreamer;
|
return singleInstance.defaultStreamer;
|
||||||
@ -549,6 +550,17 @@ public class StreamerDialog extends PamDialog {
|
|||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
OriginSettings os = defaultStreamer.getOriginSettings(currentOriginMethod.getClass());
|
||||||
|
if (os != null) {
|
||||||
|
currentOriginMethod.setOriginSettings(os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
// will throw if it tries to set the wrong type of settings.
|
||||||
|
}
|
||||||
|
|
||||||
enableControls();
|
enableControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package clickDetector;
|
|||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import pamScrollSystem.ViewLoadObserver;
|
import pamScrollSystem.ViewLoadObserver;
|
||||||
|
import tethys.TethysControl;
|
||||||
|
import tethys.pamdata.TethysDataProvider;
|
||||||
import tethys.species.DataBlockSpeciesManager;
|
import tethys.species.DataBlockSpeciesManager;
|
||||||
//import staticLocaliser.StaticLocaliserControl;
|
//import staticLocaliser.StaticLocaliserControl;
|
||||||
//import staticLocaliser.StaticLocaliserProvider;
|
//import staticLocaliser.StaticLocaliserProvider;
|
||||||
@ -14,6 +16,7 @@ import binaryFileStorage.BinaryStore;
|
|||||||
import clickDetector.ClickClassifiers.ClickBlockSpeciesManager;
|
import clickDetector.ClickClassifiers.ClickBlockSpeciesManager;
|
||||||
import clickDetector.dataSelector.ClickDataSelectCreator;
|
import clickDetector.dataSelector.ClickDataSelectCreator;
|
||||||
import clickDetector.offlineFuncs.OfflineClickLogging;
|
import clickDetector.offlineFuncs.OfflineClickLogging;
|
||||||
|
import clickDetector.tethys.ClickTethysDataProvider;
|
||||||
import clickDetector.toad.ClickTOADCalculator;
|
import clickDetector.toad.ClickTOADCalculator;
|
||||||
import dataMap.OfflineDataMap;
|
import dataMap.OfflineDataMap;
|
||||||
import fftManager.fftorganiser.FFTDataOrganiser;
|
import fftManager.fftorganiser.FFTDataOrganiser;
|
||||||
@ -26,6 +29,8 @@ import PamUtils.PamUtils;
|
|||||||
import PamView.GroupedDataSource;
|
import PamView.GroupedDataSource;
|
||||||
import PamView.GroupedSourceParameters;
|
import PamView.GroupedSourceParameters;
|
||||||
import PamguardMVC.AcousticDataBlock;
|
import PamguardMVC.AcousticDataBlock;
|
||||||
|
import PamguardMVC.DataAutomation;
|
||||||
|
import PamguardMVC.DataAutomationInfo;
|
||||||
import PamguardMVC.FFTDataHolderBlock;
|
import PamguardMVC.FFTDataHolderBlock;
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
@ -69,6 +74,8 @@ public class ClickDataBlock extends AcousticDataBlock<ClickDetection> implement
|
|||||||
|
|
||||||
private ClickTOADCalculator clickTOADCalculator;
|
private ClickTOADCalculator clickTOADCalculator;
|
||||||
|
|
||||||
|
private ClickTethysDataProvider clickTethysDataProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Click detector loading has to be a bit different to normal - first
|
* Click detector loading has to be a bit different to normal - first
|
||||||
* data are loaded from the binary store, then a subset of these data
|
* data are loaded from the binary store, then a subset of these data
|
||||||
@ -316,5 +323,18 @@ public class ClickDataBlock extends AcousticDataBlock<ClickDetection> implement
|
|||||||
return clickBlockSpeciesManager;
|
return clickBlockSpeciesManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TethysDataProvider getTethysDataProvider(TethysControl tethysControl) {
|
||||||
|
if (clickTethysDataProvider == null) {
|
||||||
|
clickTethysDataProvider = new ClickTethysDataProvider(tethysControl, this);
|
||||||
|
}
|
||||||
|
return clickTethysDataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataAutomationInfo getDataAutomationInfo() {
|
||||||
|
return new DataAutomationInfo(DataAutomation.AUTOMATIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,10 @@ import PamController.PamViewParameters;
|
|||||||
import PamUtils.PamCalendar;
|
import PamUtils.PamCalendar;
|
||||||
import PamView.symbol.StandardSymbolManager;
|
import PamView.symbol.StandardSymbolManager;
|
||||||
import pamScrollSystem.ViewLoadObserver;
|
import pamScrollSystem.ViewLoadObserver;
|
||||||
|
import tethys.TethysControl;
|
||||||
|
import tethys.pamdata.TethysDataProvider;
|
||||||
|
import tethys.species.DataBlockSpeciesManager;
|
||||||
|
import clickDetector.ClickDetection;
|
||||||
//import staticLocaliser.StaticLocaliserControl;
|
//import staticLocaliser.StaticLocaliserControl;
|
||||||
//import staticLocaliser.StaticLocaliserProvider;
|
//import staticLocaliser.StaticLocaliserProvider;
|
||||||
//import staticLocaliser.panels.AbstractLocaliserControl;
|
//import staticLocaliser.panels.AbstractLocaliserControl;
|
||||||
@ -23,7 +27,12 @@ import pamScrollSystem.ViewLoadObserver;
|
|||||||
import clickDetector.ClickDetector;
|
import clickDetector.ClickDetector;
|
||||||
import clickDetector.ClickTrainDetection;
|
import clickDetector.ClickTrainDetection;
|
||||||
import clickDetector.dataSelector.ClickTrainDataSelectorCreator;
|
import clickDetector.dataSelector.ClickTrainDataSelectorCreator;
|
||||||
|
import clickDetector.tethys.ClickEventSpeciesManager;
|
||||||
|
import clickDetector.tethys.ClickEventTethysDataProvider;
|
||||||
|
import clickDetector.tethys.ClickTethysDataProvider;
|
||||||
import dataMap.OfflineDataMap;
|
import dataMap.OfflineDataMap;
|
||||||
|
import PamguardMVC.DataAutomation;
|
||||||
|
import PamguardMVC.DataAutomationInfo;
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
import PamguardMVC.dataOffline.OfflineDataLoadInfo;
|
import PamguardMVC.dataOffline.OfflineDataLoadInfo;
|
||||||
@ -49,6 +58,8 @@ public class OfflineEventDataBlock extends SuperDetDataBlock<OfflineEventDataUni
|
|||||||
|
|
||||||
private ClickDetector clickDetector;
|
private ClickDetector clickDetector;
|
||||||
private ClickTrainDataSelectorCreator clickTrainDataSelectorCreator;
|
private ClickTrainDataSelectorCreator clickTrainDataSelectorCreator;
|
||||||
|
private ClickEventSpeciesManager eventSpeciesManager;
|
||||||
|
private ClickEventTethysDataProvider eventTethysDataProvider;
|
||||||
|
|
||||||
public OfflineEventDataBlock(String dataName,
|
public OfflineEventDataBlock(String dataName,
|
||||||
ClickDetector parentProcess, int channelMap) {
|
ClickDetector parentProcess, int channelMap) {
|
||||||
@ -284,17 +295,28 @@ public class OfflineEventDataBlock extends SuperDetDataBlock<OfflineEventDataUni
|
|||||||
return (clickDetector.getClickDataBlock() == subDataBlock || clickDetector.getTrackedClicks() == subDataBlock);
|
return (clickDetector.getClickDataBlock() == subDataBlock || clickDetector.getTrackedClicks() == subDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int nName = 0;
|
|
||||||
// @Override
|
@Override
|
||||||
// public String getDataName() {
|
public DataBlockSpeciesManager<OfflineEventDataUnit> getDatablockSpeciesManager() {
|
||||||
// // TODO Auto-generated method stub
|
if (eventSpeciesManager == null) {
|
||||||
// System.out.println("Call into getDataName " + ++nName);
|
eventSpeciesManager = new ClickEventSpeciesManager(clickDetector, this);
|
||||||
// if (nName == 58) {
|
}
|
||||||
//
|
return eventSpeciesManager;
|
||||||
// System.out.println("Call into getDataName " + ++nName);
|
}
|
||||||
// }
|
|
||||||
// return super.getDataName();
|
@Override
|
||||||
// }
|
public TethysDataProvider getTethysDataProvider(TethysControl tethysControl) {
|
||||||
|
if (eventTethysDataProvider == null) {
|
||||||
|
eventTethysDataProvider = new ClickEventTethysDataProvider(tethysControl, this);
|
||||||
|
}
|
||||||
|
return eventTethysDataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataAutomationInfo getDataAutomationInfo() {
|
||||||
|
return new DataAutomationInfo(DataAutomation.MANUALANDAUTOMATIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
53
src/clickDetector/tethys/ClickEventSpeciesManager.java
Normal file
53
src/clickDetector/tethys/ClickEventSpeciesManager.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package clickDetector.tethys;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import clickDetector.ClickControl;
|
||||||
|
import clickDetector.ClickDetector;
|
||||||
|
import clickDetector.offlineFuncs.ClicksOffline;
|
||||||
|
import clickDetector.offlineFuncs.OfflineEventDataBlock;
|
||||||
|
import clickDetector.offlineFuncs.OfflineEventDataUnit;
|
||||||
|
import generalDatabase.lookupTables.LookUpTables;
|
||||||
|
import generalDatabase.lookupTables.LookupItem;
|
||||||
|
import generalDatabase.lookupTables.LookupList;
|
||||||
|
import tethys.species.DataBlockSpeciesCodes;
|
||||||
|
import tethys.species.DataBlockSpeciesManager;
|
||||||
|
|
||||||
|
public class ClickEventSpeciesManager extends DataBlockSpeciesManager {
|
||||||
|
|
||||||
|
private OfflineEventDataBlock eventDataBlock;
|
||||||
|
private ClickDetector clickDetector;
|
||||||
|
private ClickControl clickControl;
|
||||||
|
private ClicksOffline clicksOffline;
|
||||||
|
|
||||||
|
public ClickEventSpeciesManager(ClickDetector clickDetector, OfflineEventDataBlock eventDataBlock) {
|
||||||
|
super(eventDataBlock);
|
||||||
|
this.clickDetector = clickDetector;
|
||||||
|
this.eventDataBlock = eventDataBlock;
|
||||||
|
clickControl = clickDetector.getClickControl();
|
||||||
|
clicksOffline = clickControl.getClicksOffline();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataBlockSpeciesCodes getSpeciesCodes() {
|
||||||
|
LookupList lutList = LookUpTables.getLookUpTables().getLookupList(ClicksOffline.ClickTypeLookupName);
|
||||||
|
if (lutList == null || lutList.getLutList().size() == 0) {
|
||||||
|
return new DataBlockSpeciesCodes("Unknown");
|
||||||
|
}
|
||||||
|
Vector<LookupItem> spList = lutList.getLutList();
|
||||||
|
String[] spNames = new String[spList.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (LookupItem lItem : spList) {
|
||||||
|
spNames[i++] = lItem.getCode();
|
||||||
|
}
|
||||||
|
return new DataBlockSpeciesCodes("Unknown", spNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSpeciesCode(PamDataUnit dataUnit) {
|
||||||
|
OfflineEventDataUnit eventDataUnit = (OfflineEventDataUnit) dataUnit;
|
||||||
|
return eventDataUnit.getEventType();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
src/clickDetector/tethys/ClickEventTethysDataProvider.java
Normal file
72
src/clickDetector/tethys/ClickEventTethysDataProvider.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package clickDetector.tethys;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import clickDetector.offlineFuncs.OfflineEventDataBlock;
|
||||||
|
import clickDetector.offlineFuncs.OfflineEventDataUnit;
|
||||||
|
import nilus.Detection;
|
||||||
|
import nilus.GranularityEnumType;
|
||||||
|
import nilus.Detection.Parameters;
|
||||||
|
import nilus.Detection.Parameters.UserDefined;
|
||||||
|
import tethys.TethysControl;
|
||||||
|
import tethys.output.StreamExportParams;
|
||||||
|
import tethys.output.TethysExportParams;
|
||||||
|
import tethys.pamdata.AutoTethysProvider;
|
||||||
|
import tethys.swing.export.ExportWizardCard;
|
||||||
|
import tethys.swing.export.GranularityCard;
|
||||||
|
|
||||||
|
public class ClickEventTethysDataProvider extends AutoTethysProvider {
|
||||||
|
|
||||||
|
private OfflineEventDataBlock eventDataBlock;
|
||||||
|
|
||||||
|
public ClickEventTethysDataProvider(TethysControl tethysControl, OfflineEventDataBlock eventDataBlock) {
|
||||||
|
super(tethysControl, eventDataBlock);
|
||||||
|
this.eventDataBlock = eventDataBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GranularityEnumType[] getAllowedGranularities() {
|
||||||
|
GranularityEnumType[] allowed = {GranularityEnumType.GROUPED};
|
||||||
|
return allowed;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Detection createDetection(PamDataUnit dataUnit, TethysExportParams tethysExportParams,
|
||||||
|
StreamExportParams streamExportParams) {
|
||||||
|
Detection detection = super.createDetection(dataUnit, tethysExportParams, streamExportParams);
|
||||||
|
if (detection == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
OfflineEventDataUnit eventDataUnit = (OfflineEventDataUnit) dataUnit;
|
||||||
|
detection.setCount(BigInteger.valueOf(eventDataUnit.getSubDetectionsCount()));
|
||||||
|
String comment = eventDataUnit.getComment();
|
||||||
|
if (comment != null && comment.length() > 0) {
|
||||||
|
detection.setComment(comment);
|
||||||
|
}
|
||||||
|
Parameters params = detection.getParameters();
|
||||||
|
addUserNumber(params, "MinNumber", eventDataUnit.getMinNumber());
|
||||||
|
addUserNumber(params, "BestNumber", eventDataUnit.getBestNumber());
|
||||||
|
addUserNumber(params, "MaxNumber", eventDataUnit.getMaxNumber());
|
||||||
|
|
||||||
|
|
||||||
|
return detection;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addUserNumber(Parameters params, String numName, Short number) {
|
||||||
|
if (number == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addUserDefined(params, numName, number.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean wantExportDialogCard(ExportWizardCard wizPanel) {
|
||||||
|
if (wizPanel.getClass() == GranularityCard.class) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
src/clickDetector/tethys/ClickTethysDataProvider.java
Normal file
22
src/clickDetector/tethys/ClickTethysDataProvider.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package clickDetector.tethys;
|
||||||
|
|
||||||
|
import clickDetector.ClickDataBlock;
|
||||||
|
import nilus.GranularityEnumType;
|
||||||
|
import tethys.TethysControl;
|
||||||
|
import tethys.pamdata.AutoTethysProvider;
|
||||||
|
|
||||||
|
public class ClickTethysDataProvider extends AutoTethysProvider {
|
||||||
|
|
||||||
|
private ClickDataBlock clickDataBlock;
|
||||||
|
|
||||||
|
public ClickTethysDataProvider(TethysControl tethysControl, ClickDataBlock clickDataBlock) {
|
||||||
|
super(tethysControl, clickDataBlock);
|
||||||
|
this.clickDataBlock = clickDataBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GranularityEnumType[] getAllowedGranularities() {
|
||||||
|
return GranularityEnumType.values(); // everything !
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -387,6 +387,7 @@ public class SQLTypes {
|
|||||||
return timestamp.getTime() + tz.getOffset(timestamp.getTime());
|
return timestamp.getTime() + tz.getOffset(timestamp.getTime());
|
||||||
}
|
}
|
||||||
else if (timeValue instanceof String) {
|
else if (timeValue instanceof String) {
|
||||||
|
timeValue = ((String) timeValue).replace("'", "");
|
||||||
return PamCalendar.millisFromDateString((String) timeValue, false);
|
return PamCalendar.millisFromDateString((String) timeValue, false);
|
||||||
}
|
}
|
||||||
if (timeValue instanceof Long) {
|
if (timeValue instanceof Long) {
|
||||||
|
@ -2,6 +2,7 @@ package tethys.deployment;
|
|||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -302,7 +303,7 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
// do the lot, whatever ...
|
// do the lot, whatever ...
|
||||||
selectedDeployments = getDeploymentOverview().getRecordingPeriods();
|
selectedDeployments = getDeploymentOverview().getRecordingPeriods();
|
||||||
int freeId = getTethysControl().getDeploymentHandler().getFirstFreeDeploymentId();
|
int freeId = getTethysControl().getDeploymentHandler().getFirstFreeDeploymentId();
|
||||||
RecordingPeriod onePeriod = new RecordingPeriod(selectedDeployments.get(freeId).getRecordStart(),
|
RecordingPeriod onePeriod = new RecordingPeriod(selectedDeployments.get(0).getRecordStart(),
|
||||||
selectedDeployments.get(selectedDeployments.size()-1).getRecordStop());
|
selectedDeployments.get(selectedDeployments.size()-1).getRecordStop());
|
||||||
Deployment deployment = createDeploymentDocument(freeId, onePeriod);
|
Deployment deployment = createDeploymentDocument(freeId, onePeriod);
|
||||||
// fill in a few things from here
|
// fill in a few things from here
|
||||||
@ -487,7 +488,15 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
ons[i] = tempPeriods.get(i).getDuration()/1000.;
|
ons[i] = tempPeriods.get(i).getDuration()/1000.;
|
||||||
gaps[i] = (tempPeriods.get(i+1).getRecordStart()-tempPeriods.get(i).getRecordStop())/1000.;
|
gaps[i] = (tempPeriods.get(i+1).getRecordStart()-tempPeriods.get(i).getRecordStop())/1000.;
|
||||||
}
|
}
|
||||||
// now look at how consistent those values are
|
/* now look at how consistent those values are
|
||||||
|
* But some data gets messed by small gaps, so want to
|
||||||
|
* remove outliers and concentrate on say 80% of the data.
|
||||||
|
*/
|
||||||
|
ons = getDistributionCentre(ons, 80);
|
||||||
|
gaps = getDistributionCentre(gaps, 80);
|
||||||
|
Arrays.sort(gaps);
|
||||||
|
|
||||||
|
|
||||||
STD std = new STD();
|
STD std = new STD();
|
||||||
double onsMean = std.getMean(ons);
|
double onsMean = std.getMean(ons);
|
||||||
double onsSTD = std.getSTD(ons);
|
double onsSTD = std.getSTD(ons);
|
||||||
@ -498,6 +507,27 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
return cycleInfo;
|
return cycleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the central part of a distribution without any outliers so
|
||||||
|
* that we can get a better assessment of duty cycle.
|
||||||
|
* @param data unsorted distribution data.
|
||||||
|
* @param percent percentage to include (half this removed from top and bottom)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private double[] getDistributionCentre(double[] data, double percent) {
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Arrays.sort(data);
|
||||||
|
int nRem = (int) Math.round(data.length * (100-percent)/200);
|
||||||
|
int newLen = data.length-nRem*2;
|
||||||
|
double[] subdata = Arrays.copyOfRange(data, nRem, data.length-2*nRem);
|
||||||
|
if (subdata.length < 2) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
return subdata;
|
||||||
|
}
|
||||||
|
|
||||||
private ArrayList<RecordingPeriod> extractTimesFromStatus(ArrayList<DaqStatusDataUnit> allStatusData) {
|
private ArrayList<RecordingPeriod> extractTimesFromStatus(ArrayList<DaqStatusDataUnit> allStatusData) {
|
||||||
ArrayList<RecordingPeriod> tempPeriods = new ArrayList<>();
|
ArrayList<RecordingPeriod> tempPeriods = new ArrayList<>();
|
||||||
long dataStart = Long.MAX_VALUE;
|
long dataStart = Long.MAX_VALUE;
|
||||||
|
@ -14,6 +14,8 @@ import PamguardMVC.PamDataBlock;
|
|||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
import PamguardMVC.PamProcess;
|
import PamguardMVC.PamProcess;
|
||||||
import PamguardMVC.dataSelector.DataSelector;
|
import PamguardMVC.dataSelector.DataSelector;
|
||||||
|
import PamguardMVC.superdet.SuperDetDataBlock;
|
||||||
|
import PamguardMVC.superdet.SuperDetDataBlock.ViewerLoadPolicy;
|
||||||
import dataMap.OfflineDataMap;
|
import dataMap.OfflineDataMap;
|
||||||
import dataMap.OfflineDataMapPoint;
|
import dataMap.OfflineDataMapPoint;
|
||||||
import nilus.AlgorithmType;
|
import nilus.AlgorithmType;
|
||||||
@ -25,6 +27,7 @@ import nilus.DetectionEffort;
|
|||||||
import nilus.DetectionEffortKind;
|
import nilus.DetectionEffortKind;
|
||||||
import nilus.DetectionGroup;
|
import nilus.DetectionGroup;
|
||||||
import nilus.Detections;
|
import nilus.Detections;
|
||||||
|
import nilus.GranularityEnumType;
|
||||||
import nilus.Helper;
|
import nilus.Helper;
|
||||||
import tethys.TethysControl;
|
import tethys.TethysControl;
|
||||||
import tethys.TethysTimeFuncs;
|
import tethys.TethysTimeFuncs;
|
||||||
@ -337,12 +340,42 @@ public class DetectionsHandler {
|
|||||||
* @param exportWorkerCard
|
* @param exportWorkerCard
|
||||||
*/
|
*/
|
||||||
public void startExportThread(PamDataBlock pamDataBlock, StreamExportParams streamExportParams, DetectionExportObserver exportObserver) {
|
public void startExportThread(PamDataBlock pamDataBlock, StreamExportParams streamExportParams, DetectionExportObserver exportObserver) {
|
||||||
|
checkGranularity(pamDataBlock, streamExportParams);
|
||||||
tethysControl.getTethysExportParams().setStreamParams(pamDataBlock, streamExportParams);
|
tethysControl.getTethysExportParams().setStreamParams(pamDataBlock, streamExportParams);
|
||||||
activeExport = true;
|
activeExport = true;
|
||||||
exportWorker = new ExportWorker(pamDataBlock, streamExportParams, exportObserver);
|
exportWorker = new ExportWorker(pamDataBlock, streamExportParams, exportObserver);
|
||||||
exportWorker.execute();
|
exportWorker.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fudge because some outputs don't show the granularity card, but need to
|
||||||
|
* make sure that it's set to the correct only option ..
|
||||||
|
* @param pamDataBlock
|
||||||
|
* @param streamExportParams
|
||||||
|
*/
|
||||||
|
private void checkGranularity(PamDataBlock pamDataBlock, StreamExportParams streamExportParams) {
|
||||||
|
if (streamExportParams == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TethysDataProvider tethysProvider = pamDataBlock.getTethysDataProvider(tethysControl);
|
||||||
|
if (tethysProvider == null) return;
|
||||||
|
GranularityEnumType[] allowed = tethysProvider.getAllowedGranularities();
|
||||||
|
if (allowed == null || allowed.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < allowed.length; i++) {
|
||||||
|
if (allowed[i] == streamExportParams.granularity) {
|
||||||
|
return; // matches allowed value, so OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* if we get here, it's all wrong, so set to the first allowed value
|
||||||
|
* which will be the only one if the card wasn't shown
|
||||||
|
*/
|
||||||
|
streamExportParams.granularity = allowed[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void cancelExport() {
|
public void cancelExport() {
|
||||||
activeExport = false;
|
activeExport = false;
|
||||||
}
|
}
|
||||||
@ -382,6 +415,14 @@ public class DetectionsHandler {
|
|||||||
int exportCount = 0;
|
int exportCount = 0;
|
||||||
long lastUnitTime = 0;
|
long lastUnitTime = 0;
|
||||||
DetectionExportProgress prog;
|
DetectionExportProgress prog;
|
||||||
|
ViewerLoadPolicy viewerLoadPolicy = ViewerLoadPolicy.LOAD_UTCNORMAL;
|
||||||
|
if (dataBlock instanceof SuperDetDataBlock) {
|
||||||
|
SuperDetDataBlock superDataBlock = (SuperDetDataBlock) dataBlock;
|
||||||
|
viewerLoadPolicy = superDataBlock.getViewerLoadPolicy();
|
||||||
|
}
|
||||||
|
if (viewerLoadPolicy == null) {
|
||||||
|
viewerLoadPolicy = ViewerLoadPolicy.LOAD_UTCNORMAL;
|
||||||
|
}
|
||||||
GranularityHandler granularityHandler = GranularityHandler.getHandler(streamExportParams.granularity, tethysControl, dataBlock, exportParams, streamExportParams);
|
GranularityHandler granularityHandler = GranularityHandler.getHandler(streamExportParams.granularity, tethysControl, dataBlock, exportParams, streamExportParams);
|
||||||
for (PDeployment deployment : deployments) {
|
for (PDeployment deployment : deployments) {
|
||||||
int documentCount = 0;
|
int documentCount = 0;
|
||||||
@ -392,6 +433,7 @@ public class DetectionsHandler {
|
|||||||
// export everything in that deployment.
|
// export everything in that deployment.
|
||||||
// need to loop through all map points in this interval.
|
// need to loop through all map points in this interval.
|
||||||
List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints();
|
List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints();
|
||||||
|
|
||||||
for (OfflineDataMapPoint mapPoint : mapPoints) {
|
for (OfflineDataMapPoint mapPoint : mapPoints) {
|
||||||
if (!activeExport) {
|
if (!activeExport) {
|
||||||
prog = new DetectionExportProgress(deployment, null,
|
prog = new DetectionExportProgress(deployment, null,
|
||||||
@ -418,6 +460,12 @@ public class DetectionsHandler {
|
|||||||
if (dets != null) {
|
if (dets != null) {
|
||||||
exportCount+=dets.length;
|
exportCount+=dets.length;
|
||||||
documentCount+=dets.length;
|
documentCount+=dets.length;
|
||||||
|
|
||||||
|
if (exportCount % 100 == 0) {
|
||||||
|
prog = new DetectionExportProgress(deployment, null,
|
||||||
|
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||||
|
exportObserver.update(prog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Detection det = dataProvider.createDetection(dataUnit, exportParams, streamExportParams);
|
// Detection det = dataProvider.createDetection(dataUnit, exportParams, streamExportParams);
|
||||||
// exportCount++;
|
// exportCount++;
|
||||||
@ -430,6 +478,10 @@ public class DetectionsHandler {
|
|||||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||||
exportObserver.update(prog);
|
exportObserver.update(prog);
|
||||||
|
|
||||||
|
if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// if (documentCount > 500000 && mapPoint != dataMap.getLastMapPoint()) {
|
// if (documentCount > 500000 && mapPoint != dataMap.getLastMapPoint()) {
|
||||||
// prog = new DetectionExportProgress(deployment, currentDetections,
|
// prog = new DetectionExportProgress(deployment, currentDetections,
|
||||||
// lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING);
|
// lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING);
|
||||||
@ -480,11 +532,19 @@ public class DetectionsHandler {
|
|||||||
int exportCount = 0;
|
int exportCount = 0;
|
||||||
long lastUnitTime = 0;
|
long lastUnitTime = 0;
|
||||||
DetectionExportProgress prog;
|
DetectionExportProgress prog;
|
||||||
|
ViewerLoadPolicy viewerLoadPolicy = ViewerLoadPolicy.LOAD_UTCNORMAL;
|
||||||
|
if (dataBlock instanceof SuperDetDataBlock) {
|
||||||
|
SuperDetDataBlock superDataBlock = (SuperDetDataBlock) dataBlock;
|
||||||
|
viewerLoadPolicy = superDataBlock.getViewerLoadPolicy();
|
||||||
|
}
|
||||||
|
if (viewerLoadPolicy == null) {
|
||||||
|
viewerLoadPolicy = ViewerLoadPolicy.LOAD_UTCNORMAL;
|
||||||
|
}
|
||||||
GranularityHandler granularityHandler = GranularityHandler.getHandler(streamExportParams.granularity, tethysControl, dataBlock, exportParams, streamExportParams);
|
GranularityHandler granularityHandler = GranularityHandler.getHandler(streamExportParams.granularity, tethysControl, dataBlock, exportParams, streamExportParams);
|
||||||
for (PDeployment deployment : deployments) {
|
for (PDeployment deployment : deployments) {
|
||||||
int documentCount = 0;
|
int documentCount = 0;
|
||||||
prog = new DetectionExportProgress(deployment, null,
|
prog = new DetectionExportProgress(deployment, null,
|
||||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
|
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||||
exportObserver.update(prog);
|
exportObserver.update(prog);
|
||||||
granularityHandler.prepare(deployment.getAudioStart());
|
granularityHandler.prepare(deployment.getAudioStart());
|
||||||
// export everything in that deployment.
|
// export everything in that deployment.
|
||||||
@ -523,10 +583,11 @@ public class DetectionsHandler {
|
|||||||
onEffort.getDetection().add(dets[dd]);
|
onEffort.getDetection().add(dets[dd]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Detection det = dataProvider.createDetection(dataUnit, exportParams, streamExportParams);
|
if (exportCount % 100 == 0) {
|
||||||
// exportCount++;
|
prog = new DetectionExportProgress(deployment, null,
|
||||||
// documentCount++;
|
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
|
||||||
// onEffort.getDetection().add(det);
|
exportObserver.update(prog);
|
||||||
|
}
|
||||||
lastUnitTime = dataUnit.getTimeMilliseconds();
|
lastUnitTime = dataUnit.getTimeMilliseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,6 +607,10 @@ public class DetectionsHandler {
|
|||||||
}
|
}
|
||||||
currentDetections = null;
|
currentDetections = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,30 +7,26 @@ import tethys.TethysControl;
|
|||||||
import tethys.output.StreamExportParams;
|
import tethys.output.StreamExportParams;
|
||||||
import tethys.output.TethysExportParams;
|
import tethys.output.TethysExportParams;
|
||||||
|
|
||||||
public class GroupedGranularityHandler extends GranularityHandler {
|
public class GroupedGranularityHandler extends CallGranularityHandler {
|
||||||
|
|
||||||
public GroupedGranularityHandler(TethysControl tethysControl, PamDataBlock dataBlock,
|
public GroupedGranularityHandler(TethysControl tethysControl, PamDataBlock dataBlock,
|
||||||
TethysExportParams tethysExportParams, StreamExportParams streamExportParams) {
|
TethysExportParams tethysExportParams, StreamExportParams streamExportParams) {
|
||||||
super(tethysControl, dataBlock, tethysExportParams, streamExportParams);
|
super(tethysControl, dataBlock, tethysExportParams, streamExportParams);
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(long timeMillis) {
|
public void prepare(long timeMillis) {
|
||||||
// TODO Auto-generated method stub
|
super.prepare(timeMillis);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Detection[] addDataUnit(PamDataUnit dataUnit) {
|
public Detection[] addDataUnit(PamDataUnit dataUnit) {
|
||||||
// TODO Auto-generated method stub
|
return super.addDataUnit(dataUnit);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Detection[] cleanup(long timeMillis) {
|
public Detection[] cleanup(long timeMillis) {
|
||||||
// TODO Auto-generated method stub
|
return super.cleanup(timeMillis);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class TethysExportParams implements Serializable, Cloneable{
|
|||||||
public static final long serialVersionUID = 1L;
|
public static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need to add lots of other parameters here, such as the connection detils
|
* Need to add lots of other parameters here, such as the connection details
|
||||||
* for the tethys database.
|
* for the tethys database.
|
||||||
*/
|
*/
|
||||||
public String serverName = "http://localhost";
|
public String serverName = "http://localhost";
|
||||||
|
@ -63,8 +63,8 @@ public class TethysExportDialog extends PamDialog {
|
|||||||
setResizable(true);
|
setResizable(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Deprecated
|
||||||
public static TethysExportParams showDialog(Window parentFrame, TethysControl tethysControl) {
|
private static TethysExportParams showDialog(Window parentFrame, TethysControl tethysControl) {
|
||||||
if (singleInstance == null || singleInstance.getOwner() != parentFrame || singleInstance.tethysControl != tethysControl) {
|
if (singleInstance == null || singleInstance.getOwner() != parentFrame || singleInstance.tethysControl != tethysControl) {
|
||||||
singleInstance = new TethysExportDialog(parentFrame, tethysControl);
|
singleInstance = new TethysExportDialog(parentFrame, tethysControl);
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ abstract public class AutoTethysProvider implements TethysDataProvider {
|
|||||||
nilus.Detection.Parameters detParams = new nilus.Detection.Parameters();
|
nilus.Detection.Parameters detParams = new nilus.Detection.Parameters();
|
||||||
detection.setParameters(detParams);
|
detection.setParameters(detParams);
|
||||||
double[] freqs = dataUnit.getFrequency();
|
double[] freqs = dataUnit.getFrequency();
|
||||||
if (freqs != null) {
|
if (freqs != null && freqs[1] != 0) {
|
||||||
detParams.setMinFreqHz(freqs[0]);
|
detParams.setMinFreqHz(freqs[0]);
|
||||||
detParams.setMaxFreqHz(freqs[1]);
|
detParams.setMaxFreqHz(freqs[1]);
|
||||||
}
|
}
|
||||||
@ -366,11 +366,14 @@ abstract public class AutoTethysProvider implements TethysDataProvider {
|
|||||||
el.setAttribute("BinaryFile", fileInf.getShortFileName(2048));
|
el.setAttribute("BinaryFile", fileInf.getShortFileName(2048));
|
||||||
el.setAttribute("FileIndex", Long.valueOf(fileInf.getIndexInFile()).toString());
|
el.setAttribute("FileIndex", Long.valueOf(fileInf.getIndexInFile()).toString());
|
||||||
}
|
}
|
||||||
|
if (dataUnit.getDatabaseIndex() >= 0) {
|
||||||
|
addUserDefined(detParams, "DatabaseId", String.format("%d", dataUnit.getDatabaseIndex()));
|
||||||
|
}
|
||||||
|
|
||||||
return detection;
|
return detection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Element addUserDefined(Parameters parameters, String parameterName, String parameterValue) {
|
public Element addUserDefined(Parameters parameters, String parameterName, String parameterValue) {
|
||||||
UserDefined userDefined = parameters.getUserDefined();
|
UserDefined userDefined = parameters.getUserDefined();
|
||||||
if (userDefined == null) {
|
if (userDefined == null) {
|
||||||
userDefined = new UserDefined();
|
userDefined = new UserDefined();
|
||||||
|
@ -183,7 +183,7 @@ public class DatablockSynchPanel extends TethysGUIPanel {
|
|||||||
OfflineDataMap dataMap = synchInfo.getDataBlock().getPrimaryDataMap();
|
OfflineDataMap dataMap = synchInfo.getDataBlock().getPrimaryDataMap();
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return synchInfo.getDataBlock().getDataName();
|
return synchInfo.getDataBlock().getLongDataName();
|
||||||
case 1:
|
case 1:
|
||||||
if (dataMap == null) {
|
if (dataMap == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -53,7 +53,7 @@ public class DetectionsExportPanel extends TethysGUIPanel implements StreamTable
|
|||||||
if (selectedDataBlock == null) {
|
if (selectedDataBlock == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DetectionsExportWizard.showDilaog(getTethysControl().getGuiFrame(), getTethysControl(), selectedDataBlock);
|
DetectionsExportWizard.showDialog(getTethysControl().getGuiFrame(), getTethysControl(), selectedDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,7 +82,7 @@ public class DetectionsExportWizard extends PamDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showDilaog(Window parentFrame, TethysControl tethysControl, PamDataBlock dataBlock) {
|
public static void showDialog(Window parentFrame, TethysControl tethysControl, PamDataBlock dataBlock) {
|
||||||
DetectionsExportWizard wiz = new DetectionsExportWizard(parentFrame, tethysControl, dataBlock);
|
DetectionsExportWizard wiz = new DetectionsExportWizard(parentFrame, tethysControl, dataBlock);
|
||||||
wiz.setParams();
|
wiz.setParams();
|
||||||
wiz.setVisible(true);
|
wiz.setVisible(true);
|
||||||
|
@ -103,6 +103,7 @@ public class ExportWorkerCard extends ExportWizardCard implements DetectionExpor
|
|||||||
|
|
||||||
protected void exportData() {
|
protected void exportData() {
|
||||||
DetectionsHandler detHandler = getTethysControl().getDetectionsHandler();
|
DetectionsHandler detHandler = getTethysControl().getDetectionsHandler();
|
||||||
|
|
||||||
detHandler.startExportThread(getDataBlock(), streamExportParams, this);
|
detHandler.startExportThread(getDataBlock(), streamExportParams, this);
|
||||||
enableControls(DetectionExportProgress.STATE_GATHERING);
|
enableControls(DetectionExportProgress.STATE_GATHERING);
|
||||||
}
|
}
|
||||||
@ -128,7 +129,14 @@ public class ExportWorkerCard extends ExportWizardCard implements DetectionExpor
|
|||||||
if (progress == null) {
|
if (progress == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (progress.totalUnits > 0) {
|
if (progress.state == DetectionExportProgress.STATE_COUNTING) {
|
||||||
|
itemCount.setText("0");
|
||||||
|
projectedCount.setText(String.format("%d", progress.exportCount));
|
||||||
|
skipCount.setText(String.format("%d", progress.skipCount));
|
||||||
|
long perc = (progress.exportCount+progress.skipCount) * 100 / progress.totalUnits;
|
||||||
|
progressBar.setValue((int) perc);
|
||||||
|
}
|
||||||
|
else if (progress.totalUnits > 0) {
|
||||||
itemCount.setText(String.format("%d", progress.exportCount));
|
itemCount.setText(String.format("%d", progress.exportCount));
|
||||||
skipCount.setText(String.format("%d", progress.skipCount));
|
skipCount.setText(String.format("%d", progress.skipCount));
|
||||||
long totExpected = progress.totalUnits;
|
long totExpected = progress.totalUnits;
|
||||||
@ -136,7 +144,6 @@ public class ExportWorkerCard extends ExportWizardCard implements DetectionExpor
|
|||||||
totExpected *= progress.exportCount/(progress.exportCount+progress.skipCount);
|
totExpected *= progress.exportCount/(progress.exportCount+progress.skipCount);
|
||||||
}
|
}
|
||||||
projectedCount.setText(String.format("%d", totExpected));
|
projectedCount.setText(String.format("%d", totExpected));
|
||||||
itemCount.setText(String.format("%d", totExpected));
|
|
||||||
long perc = (progress.exportCount+progress.skipCount) * 100 / progress.totalUnits;
|
long perc = (progress.exportCount+progress.skipCount) * 100 / progress.totalUnits;
|
||||||
progressBar.setValue((int) perc);
|
progressBar.setValue((int) perc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user