diff --git a/src/tethys/TethysControl.java b/src/tethys/TethysControl.java index 2e584354..76f7a057 100644 --- a/src/tethys/TethysControl.java +++ b/src/tethys/TethysControl.java @@ -11,6 +11,9 @@ import javax.swing.JMenuItem; import PamController.PamControlledUnit; import PamController.PamController; import PamguardMVC.PamDataBlock; +import metadata.MetaDataContol; +import metadata.deployment.DeploymentData; +import nilus.Deployment.Instrument; import tethys.dbxml.DBXMLConnect; //import nilus.Deployment; //import nilus.Deployment.Instrument; @@ -95,6 +98,33 @@ public class TethysControl extends PamControlledUnit { tethysExporter.doExport(); } + public DeploymentData getGlobalDeplopymentData() { + PamControlledUnit aUnit = PamController.getInstance().findControlledUnit(MetaDataContol.class, null); +// if (aUnit instanceof MetaDataContol == false || true) { +// deployment.setProject("thisIsAProject"); +// deployment.setPlatform("Yay a platform"); +// Instrument instrument = new Instrument(); +// instrument.setType("machiney"); +// instrument.setInstrumentId("12345555"); +// deployment.setInstrument(instrument); +// return false; +// } + + MetaDataContol metaControl = (MetaDataContol) aUnit; + DeploymentData deploymentData = metaControl != null ? metaControl.getDeploymentData() : new DeploymentData(); + + deploymentData.setProject("thisIsAProject"); + deploymentData.setPlatform("Yay a platform"); + deploymentData.setCruise("cruisey"); + deploymentData.setDeploymentId(142536); + deploymentData.setInstrumentId("super instrument"); + deploymentData.setSite("in the ocean somewhere"); + deploymentData.setRegion("ocean water"); + deploymentData.setInstrumentType("sensor of sorts"); + + return deploymentData; + } + /** * A name for any deta selectors. * @return diff --git a/src/tethys/deployment/DeploymentHandler.java b/src/tethys/deployment/DeploymentHandler.java index fdda96e1..2bcdf6b2 100644 --- a/src/tethys/deployment/DeploymentHandler.java +++ b/src/tethys/deployment/DeploymentHandler.java @@ -37,6 +37,7 @@ import nilus.DeploymentRecoveryDetails; import nilus.GeometryTypeM; import nilus.Helper; import pamMaths.PamVector; +import tethys.TethysControl; import tethys.TethysLocationFuncs; import tethys.TethysTimeFuncs; @@ -46,8 +47,15 @@ import tethys.TethysTimeFuncs; * */ public class DeploymentHandler { + + private TethysControl tethysControl; + public DeploymentHandler(TethysControl tethysControl) { + super(); + this.tethysControl = tethysControl; + } + /** * Get an overview of all the deployments. * @return @@ -329,19 +337,19 @@ public class DeploymentHandler { * @param deployment */ private boolean getProjectData(Deployment deployment) { - PamControlledUnit aUnit = PamController.getInstance().findControlledUnit(MetaDataContol.class, null); - if (aUnit instanceof MetaDataContol == false || true) { - deployment.setProject("thisIsAProject"); - deployment.setPlatform("Yay a platform"); - Instrument instrument = new Instrument(); - instrument.setType("machiney"); - instrument.setInstrumentId("12345555"); - deployment.setInstrument(instrument); - return false; - } - - MetaDataContol metaControl = (MetaDataContol) aUnit; - DeploymentData deploymentData = metaControl.getDeploymentData(); +// PamControlledUnit aUnit = PamController.getInstance().findControlledUnit(MetaDataContol.class, null); +// if (aUnit instanceof MetaDataContol == false || true) { +// deployment.setProject("thisIsAProject"); +// deployment.setPlatform("Yay a platform"); +// Instrument instrument = new Instrument(); +// instrument.setType("machiney"); +// instrument.setInstrumentId("12345555"); +// deployment.setInstrument(instrument); +// return false; +// } +// +// MetaDataContol metaControl = (MetaDataContol) aUnit; + DeploymentData deploymentData = tethysControl.getGlobalDeplopymentData(); deployment.setProject(deploymentData.getProject()); deployment.setDeploymentAlias(deploymentData.getDeploymentAlias()); deployment.setSite(deploymentData.getSite()); diff --git a/src/tethys/detection/DetectionsHandler.java b/src/tethys/detection/DetectionsHandler.java index 002f920d..0b6d117b 100644 --- a/src/tethys/detection/DetectionsHandler.java +++ b/src/tethys/detection/DetectionsHandler.java @@ -29,6 +29,9 @@ public class DetectionsHandler { private TethysControl tethysControl; + public int uniqueDetectionsId; + public int uniqueDetectionId; + public DetectionsHandler(TethysControl tethysControl) { super(); this.tethysControl = tethysControl; @@ -142,7 +145,7 @@ public class DetectionsHandler { */ TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(); Detections detections = new Detections(); - detections.setId(deployment.getId()); + detections.setId(String.format("%d", uniqueDetectionsId++)); detections.setDescription(dataProvider.getDescription(deployment, tethysExportParams)); DataSourceType dataSource = new DataSourceType(); dataSource.setDeploymentId(deployment.getId()); @@ -156,7 +159,7 @@ public class DetectionsHandler { List detectionList = detectionGroup.getDetection(); for (int i = 0; i < data.size(); i++) { PamDataUnit dataUnit = data.get(i); - Detection detection = dataProvider.createDetection(dataUnit, tethysExportParams, streamExportParams); + Detection detection = dataProvider.createDetection(dataUnit, tethysExportParams, streamExportParams); if (detection != null) { detectionList.add(detection); } diff --git a/src/tethys/output/TethysExporter.java b/src/tethys/output/TethysExporter.java index 52554f0a..2760099c 100644 --- a/src/tethys/output/TethysExporter.java +++ b/src/tethys/output/TethysExporter.java @@ -168,7 +168,7 @@ public class TethysExporter { //get list of deployment recovery details (start, stop times and lat/long) //deployment details and recovery details are same structure //per pair, go through a loop to fill in each deployment - DeploymentHandler deploymentHandler = new DeploymentHandler(); + DeploymentHandler deploymentHandler = new DeploymentHandler(tethysControl); ArrayList deployRecover = deploymentHandler.getDeployments(); if (deployRecover == null) { diff --git a/src/tethys/pamdata/AutoTethysProvider.java b/src/tethys/pamdata/AutoTethysProvider.java index 681a8913..653c4e4d 100644 --- a/src/tethys/pamdata/AutoTethysProvider.java +++ b/src/tethys/pamdata/AutoTethysProvider.java @@ -92,11 +92,23 @@ public class AutoTethysProvider implements TethysDataProvider { @Override public AlgorithmType getAlgorithm() { AlgorithmType algorithm = new AlgorithmType(); + try { + nilus.Helper.createRequiredElements(algorithm); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } algorithm.setMethod(this.getAlgorithmMethod()); algorithm.setSoftware("PAMGuard"); algorithm.setVersion(PamguardVersionInfo.version); - algorithm.setParameters(this.getAlgorithmParameters()); - + //algorithm.setParameters(this.getAlgorithmParameters()); + return algorithm; }