mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Merge branch 'Tethys' of C:\Users\dg50\source\repos\PAMGuardTethys into
Tethys
This commit is contained in:
commit
9a0005861c
@ -6,7 +6,7 @@
|
|||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
@ -17,5 +17,10 @@
|
|||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/dg50/Tethys/NilusXMLGenerator/target/nilus-1.5.jar">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="javadoc_location" value="jar:file:/C:/Users/dg50/Tethys/NilusXMLGenerator/target/nilus-1.5-javadoc.jar!/"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
23
pom.xml
23
pom.xml
@ -555,8 +555,29 @@
|
|||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
|
</dependency>-->
|
||||||
|
<!-- From NilusXMLGenerator POM at https://bitbucket.org/tethysacousticmetadata/nilusxmlgenerator/src/master/-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.persistence</groupId>
|
||||||
|
<artifactId>org.eclipse.persistence.moxy</artifactId>
|
||||||
|
<version>2.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
<version>2.4.0-b180830.0359</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jaxb</groupId>
|
||||||
|
<artifactId>jaxb-runtime</artifactId>
|
||||||
|
<version>2.4.0-b180830.0438</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jaxb</groupId>
|
||||||
|
<artifactId>jaxb-xjc</artifactId>
|
||||||
|
<version>2.4.0-b180830.0438</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.jflac/jflac-codec -->
|
<!-- https://mvnrepository.com/artifact/org.jflac/jflac-codec -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -697,7 +697,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
|||||||
if (currentFile > 0 && currentFile >= allFiles.size()) {
|
if (currentFile > 0 && currentFile >= allFiles.size()) {
|
||||||
fileListComplete();
|
fileListComplete();
|
||||||
}
|
}
|
||||||
// System.out.println("FolderinputSytem: daqHasEnded");
|
System.out.println("FolderinputSytem: daqHasEnded");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFolderProgress() {
|
private void setFolderProgress() {
|
||||||
|
@ -295,7 +295,8 @@ public class GpsLogger extends SQLLogging {
|
|||||||
* time from the UTC column which is NOT the GpsData time which was the real GPS time.
|
* time from the UTC column which is NOT the GpsData time which was the real GPS time.
|
||||||
*/
|
*/
|
||||||
int gpsIntTimeVal = gpsTime.getIntegerValue();
|
int gpsIntTimeVal = gpsTime.getIntegerValue();
|
||||||
Object ts = getTableDefinition().getTimeStampItem().getValue();
|
PamTableDefinition pamTableDef = (PamTableDefinition) getTableDefinition();
|
||||||
|
Object ts = pamTableDef.getTimeStampItem().getValue();
|
||||||
long gpsDate = sqlTypes.millisFromTimeStamp(ts);
|
long gpsDate = sqlTypes.millisFromTimeStamp(ts);
|
||||||
if (gpsDate%1000 == 0) {
|
if (gpsDate%1000 == 0) {
|
||||||
// some databases may have stored the milliseconds, in which
|
// some databases may have stored the milliseconds, in which
|
||||||
|
@ -8,14 +8,13 @@ import java.sql.Types;
|
|||||||
|
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
//import pamDatabase.SQLLogging;
|
//import pamDatabase.SQLLogging;
|
||||||
//import PamguardMVC.RecyclingDataBlock;
|
//import PamguardMVC.RecyclingDataBlock;
|
||||||
import generalDatabase.PamDetectionLogging;
|
import generalDatabase.PamDetectionLogging;
|
||||||
|
|
||||||
public class IshLogger extends PamDetectionLogging {
|
public class IshLogger extends PamDetectionLogging {
|
||||||
IshDetControl ishDetControl;
|
IshDetControl ishDetControl;
|
||||||
PamTableDefinition tableDefinition;
|
|
||||||
PamTableItem systemDate, durationSecs, secSinceStart, peakHeight;
|
PamTableItem systemDate, durationSecs, secSinceStart, peakHeight;
|
||||||
// Peak is more important than start time for matched filter & spectrogram correlation
|
// Peak is more important than start time for matched filter & spectrogram correlation
|
||||||
PamTableItem peakSample, peakDelaySecs;
|
PamTableItem peakSample, peakDelaySecs;
|
||||||
@ -25,7 +24,7 @@ public class IshLogger extends PamDetectionLogging {
|
|||||||
super(pamDataBlock, UPDATE_POLICY_WRITENEW);
|
super(pamDataBlock, UPDATE_POLICY_WRITENEW);
|
||||||
this.ishDetControl = ishDetControl;
|
this.ishDetControl = ishDetControl;
|
||||||
|
|
||||||
tableDefinition = getTableDefinition();
|
EmptyTableDefinition tableDefinition = getTableDefinition();
|
||||||
|
|
||||||
// PamTableItem tableItem;
|
// PamTableItem tableItem;
|
||||||
// setUpdatePolicy(UPDATE_POLICY_WRITENEW);
|
// setUpdatePolicy(UPDATE_POLICY_WRITENEW);
|
||||||
|
@ -14,14 +14,13 @@ import IshmaelDetector.IshDetection;
|
|||||||
import PamUtils.LatLong;
|
import PamUtils.LatLong;
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
//import pamDatabase.SQLLogging;
|
//import pamDatabase.SQLLogging;
|
||||||
//import PamguardMVC.RecyclingDataBlock;
|
//import PamguardMVC.RecyclingDataBlock;
|
||||||
import generalDatabase.PamDetectionLogging;
|
import generalDatabase.PamDetectionLogging;
|
||||||
|
|
||||||
public class IshLocSqlLogging extends PamDetectionLogging {
|
public class IshLocSqlLogging extends PamDetectionLogging {
|
||||||
IshLocControl ishLocControl;
|
IshLocControl ishLocControl;
|
||||||
PamTableDefinition tableDefinition;
|
|
||||||
PamTableItem systemDate, durationSecs, secSinceStart, peakHeight;
|
PamTableItem systemDate, durationSecs, secSinceStart, peakHeight;
|
||||||
private PamTableItem latitude, longitude, refLatitude, refLongitude, x, y, z;
|
private PamTableItem latitude, longitude, refLatitude, refLongitude, x, y, z;
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ public class IshLocSqlLogging extends PamDetectionLogging {
|
|||||||
super(pamDataBlock, UPDATE_POLICY_WRITENEW);
|
super(pamDataBlock, UPDATE_POLICY_WRITENEW);
|
||||||
this.ishLocControl = ishDetControl;
|
this.ishLocControl = ishDetControl;
|
||||||
|
|
||||||
tableDefinition = getTableDefinition();
|
EmptyTableDefinition tableDefinition = getTableDefinition();
|
||||||
tableDefinition.addTableItem(latitude = new PamTableItem("Latitude", Types.DOUBLE));
|
tableDefinition.addTableItem(latitude = new PamTableItem("Latitude", Types.DOUBLE));
|
||||||
tableDefinition.addTableItem(longitude = new PamTableItem("Longitude", Types.DOUBLE));
|
tableDefinition.addTableItem(longitude = new PamTableItem("Longitude", Types.DOUBLE));
|
||||||
tableDefinition.addTableItem(refLatitude = new PamTableItem("ReferenceLatitude", Types.DOUBLE));
|
tableDefinition.addTableItem(refLatitude = new PamTableItem("ReferenceLatitude", Types.DOUBLE));
|
||||||
|
@ -85,7 +85,15 @@ public class GebcoMapFile implements MapFileManager {
|
|||||||
* @see Map.MapFile#readFileData(java.io.File)
|
* @see Map.MapFile#readFileData(java.io.File)
|
||||||
*/
|
*/
|
||||||
public boolean readFileData(File file) {
|
public boolean readFileData(File file) {
|
||||||
return readMapFile(file, true);
|
try {
|
||||||
|
return readMapFile(file, true);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
// trap error someone reported at end November 22. Suspect it was their corrupt map file causing problems.
|
||||||
|
String err = String.format("Map file %s is missing or corrupt and cannot be loaded", file.getName());
|
||||||
|
WarnOnce.showWarning("Map File Error", err, WarnOnce.OK_OPTION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean readMapFile(File gebcoFile, boolean readContours) {
|
private boolean readMapFile(File gebcoFile, boolean readContours) {
|
||||||
|
@ -1155,6 +1155,8 @@ public class PamController implements PamControllerInterface, PamSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (saveSettings) {
|
if (saveSettings) {
|
||||||
|
startTime = PamCalendar.getSessionStartTime();
|
||||||
|
// System.out.printf("Saving settings for start time %s\n", PamCalendar.formatDBDateTime(startTime));
|
||||||
saveSettings(PamCalendar.getSessionStartTime());
|
saveSettings(PamCalendar.getSessionStartTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,6 +1315,9 @@ public class PamController implements PamControllerInterface, PamSettings {
|
|||||||
}
|
}
|
||||||
guiFrameManager.pamEnded();
|
guiFrameManager.pamEnded();
|
||||||
|
|
||||||
|
long stopTime = PamCalendar.getTimeInMillis();
|
||||||
|
saveEndSettings(stopTime);
|
||||||
|
|
||||||
// no good having this here since it get's called at the end of every file.
|
// no good having this here since it get's called at the end of every file.
|
||||||
// if (GlobalArguments.getParam(PamController.AUTOEXIT) != null) {
|
// if (GlobalArguments.getParam(PamController.AUTOEXIT) != null) {
|
||||||
//// can exit here, since we've auto started, can auto exit.
|
//// can exit here, since we've auto started, can auto exit.
|
||||||
@ -1431,6 +1436,26 @@ public class PamController implements PamControllerInterface, PamSettings {
|
|||||||
pamConfiguration.saveSettings(timeNow);
|
pamConfiguration.saveSettings(timeNow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets called in pamStart and may / will attempt to store all
|
||||||
|
* PAMGUARD settings via the database and binary storage modules.
|
||||||
|
*/
|
||||||
|
private void saveEndSettings(long timeNow) {
|
||||||
|
// System.out.printf("Updating settings with end time %s\n", PamCalendar.formatDBDateTime(timeNow));
|
||||||
|
ArrayList<PamControlledUnit> pamControlledUnits = pamConfiguration.getPamControlledUnits();
|
||||||
|
PamControlledUnit pcu;
|
||||||
|
PamSettingsSource settingsSource;
|
||||||
|
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
|
||||||
|
pcu = pamControlledUnits.get(iU);
|
||||||
|
if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
|
||||||
|
settingsSource = (PamSettingsSource) pcu;
|
||||||
|
settingsSource.saveEndSettings(timeNow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export configuration into an XML file
|
* Export configuration into an XML file
|
||||||
* @param parentFrame
|
* @param parentFrame
|
||||||
|
@ -20,6 +20,14 @@ public interface PamSettingsSource {
|
|||||||
*/
|
*/
|
||||||
public boolean saveStartSettings(long timeNow);
|
public boolean saveStartSettings(long timeNow);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save settings when processing ends.
|
||||||
|
* This may just be an update of the settings saves with saveStartSettings, e.g. an end time.
|
||||||
|
* @param timeNow
|
||||||
|
* @return true if saved correctly.
|
||||||
|
*/
|
||||||
|
public boolean saveEndSettings(long timeNow);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of different settings
|
* Get the number of different settings
|
||||||
* within the settings source.
|
* within the settings source.
|
||||||
|
@ -371,6 +371,32 @@ public class PamguardXMLWriter implements PamSettings {
|
|||||||
* @return xml content as a a string.
|
* @return xml content as a a string.
|
||||||
*/
|
*/
|
||||||
public String getAsString(Document doc) {
|
public String getAsString(Document doc) {
|
||||||
|
return getAsString(doc, true);
|
||||||
|
// try {
|
||||||
|
// DOMSource domSource = new DOMSource(doc);
|
||||||
|
// StringWriter writer = new StringWriter();
|
||||||
|
// StreamResult result = new StreamResult(writer);
|
||||||
|
// TransformerFactory tf = TransformerFactory.newInstance();
|
||||||
|
// Transformer transformer = tf.newTransformer();
|
||||||
|
// transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||||
|
// transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
|
||||||
|
//// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
|
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||||
|
// transformer.transform(domSource, result);
|
||||||
|
// return writer.toString();
|
||||||
|
// } catch (TransformerException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the xml document as a String.
|
||||||
|
* @param doc xml document
|
||||||
|
* @param indent Indent / format the document.
|
||||||
|
* @return xml content as a a string.
|
||||||
|
*/
|
||||||
|
public String getAsString(Document doc, boolean indent) {
|
||||||
try {
|
try {
|
||||||
DOMSource domSource = new DOMSource(doc);
|
DOMSource domSource = new DOMSource(doc);
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
@ -380,7 +406,7 @@ public class PamguardXMLWriter implements PamSettings {
|
|||||||
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||||
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
|
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
|
||||||
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no");
|
||||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||||
transformer.transform(domSource, result);
|
transformer.transform(domSource, result);
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
@ -765,9 +791,10 @@ public class PamguardXMLWriter implements PamSettings {
|
|||||||
processData.setAttribute("Name", process.getProcessName());
|
processData.setAttribute("Name", process.getProcessName());
|
||||||
PamDataBlock source = process.getParentDataBlock();
|
PamDataBlock source = process.getParentDataBlock();
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
Element inputEl = doc.createElement("Input");
|
Element inputEl = source.getDataBlockXML(doc);
|
||||||
inputEl.setAttribute("Name", source.getLongDataName());
|
// Element inputEl = doc.createElement("Input");
|
||||||
inputEl.setAttribute("Channels", String.format("0x%X", source.getChannelMap()));
|
// inputEl.setAttribute("Name", source.getLongDataName());
|
||||||
|
// inputEl.setAttribute("Channels", String.format("0x%X", source.getChannelMap()));
|
||||||
processData.appendChild(inputEl);
|
processData.appendChild(inputEl);
|
||||||
}
|
}
|
||||||
int nOut = process.getNumOutputDataBlocks();
|
int nOut = process.getNumOutputDataBlocks();
|
||||||
|
@ -44,9 +44,11 @@ import whistlesAndMoans.AbstractWhistleDataUnit;
|
|||||||
import fftManager.FFTDataUnit;
|
import fftManager.FFTDataUnit;
|
||||||
import fftManager.PamFFTControl;
|
import fftManager.PamFFTControl;
|
||||||
import group3dlocaliser.Group3DLocaliserControl;
|
import group3dlocaliser.Group3DLocaliserControl;
|
||||||
|
import metadata.MetaDataContol;
|
||||||
import meygenturbine.MeygenTurbine;
|
import meygenturbine.MeygenTurbine;
|
||||||
import printscreen.PrintScreenControl;
|
import printscreen.PrintScreenControl;
|
||||||
import rockBlock.RockBlockControl;
|
import rockBlock.RockBlockControl;
|
||||||
|
import tethys.TethysControl;
|
||||||
import turbineops.TurbineOperationControl;
|
import turbineops.TurbineOperationControl;
|
||||||
import GPS.GpsDataUnit;
|
import GPS.GpsDataUnit;
|
||||||
import NMEA.NMEADataUnit;
|
import NMEA.NMEADataUnit;
|
||||||
@ -454,6 +456,19 @@ final public class PamModel implements PamSettings {
|
|||||||
mi.setToolTipText("Manage automated data backups");
|
mi.setToolTipText("Manage automated data backups");
|
||||||
mi.setModulesMenuGroup(utilitiesGroup);
|
mi.setModulesMenuGroup(utilitiesGroup);
|
||||||
mi.setMaxNumber(1);
|
mi.setMaxNumber(1);
|
||||||
|
|
||||||
|
|
||||||
|
mi = PamModuleInfo.registerControlledUnit(MetaDataContol.class.getName(), MetaDataContol.unitType);
|
||||||
|
mi.setToolTipText("Deployment Meta Data");
|
||||||
|
mi.setModulesMenuGroup(utilitiesGroup);
|
||||||
|
mi.setMaxNumber(1);
|
||||||
|
|
||||||
|
if (isViewer) {
|
||||||
|
mi = PamModuleInfo.registerControlledUnit(TethysControl.class.getName(), TethysControl.defaultName);
|
||||||
|
mi.setToolTipText("Interface to Tethys Database");
|
||||||
|
mi.setModulesMenuGroup(utilitiesGroup);
|
||||||
|
mi.setMaxNumber(1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ************* End Utilities Group *******************
|
* ************* End Utilities Group *******************
|
||||||
|
@ -34,6 +34,11 @@ abstract public class PamParameterData {
|
|||||||
*/
|
*/
|
||||||
private String postTitle;
|
private String postTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* field length for automatic dialogs.
|
||||||
|
*/
|
||||||
|
private int fieldLength;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parentObject
|
* @param parentObject
|
||||||
@ -45,6 +50,21 @@ abstract public class PamParameterData {
|
|||||||
this.field = field;
|
this.field = field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parentObject
|
||||||
|
* @param field
|
||||||
|
* @param shortName
|
||||||
|
* @param toolTip
|
||||||
|
* @param fieldLength length of text in automatic dialogs.
|
||||||
|
*/
|
||||||
|
public PamParameterData(Object parentObject, Field field, String shortName, String toolTip, int fieldLength) {
|
||||||
|
super();
|
||||||
|
this.field = field;
|
||||||
|
this.shortName = shortName;
|
||||||
|
this.toolTip = toolTip;
|
||||||
|
this.fieldLength = fieldLength;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parentObject
|
* @param parentObject
|
||||||
* @param field
|
* @param field
|
||||||
@ -58,7 +78,6 @@ abstract public class PamParameterData {
|
|||||||
this.toolTip = toolTip;
|
this.toolTip = toolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param shortName the shortName to set
|
* @param shortName the shortName to set
|
||||||
*/
|
*/
|
||||||
@ -66,6 +85,20 @@ abstract public class PamParameterData {
|
|||||||
this.shortName = shortName;
|
this.shortName = shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set info about a parameter
|
||||||
|
* @param shortName short name, e.g. to use in a dialog
|
||||||
|
* @param postTitle post title, e.g. text coming after a data entry field in a dialog
|
||||||
|
* @param toolTip tool tip to display over the component in a dialog.
|
||||||
|
* @param fieldLength length of text in automatic dialogs.
|
||||||
|
*/
|
||||||
|
public void setInfo(String shortName, String postTitle, String toolTip, int fieldLength) {
|
||||||
|
this.shortName = shortName;
|
||||||
|
this.postTitle = postTitle;
|
||||||
|
this.toolTip = toolTip;
|
||||||
|
this.fieldLength = fieldLength;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set info about a parameter
|
* Set info about a parameter
|
||||||
* @param shortName short name, e.g. to use in a dialog
|
* @param shortName short name, e.g. to use in a dialog
|
||||||
@ -136,6 +169,9 @@ abstract public class PamParameterData {
|
|||||||
* @return a short name for the field, suitable for use in dialogs.
|
* @return a short name for the field, suitable for use in dialogs.
|
||||||
*/
|
*/
|
||||||
public String getShortName() {
|
public String getShortName() {
|
||||||
|
if (shortName == null) {
|
||||||
|
return getFieldName();
|
||||||
|
}
|
||||||
return shortName;
|
return shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,5 +202,19 @@ abstract public class PamParameterData {
|
|||||||
return String.format("Param %s class %s", getFieldName(), getDataClass());
|
return String.format("Param %s class %s", getFieldName(), getDataClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the fieldLength
|
||||||
|
*/
|
||||||
|
public int getFieldLength() {
|
||||||
|
return fieldLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fieldLength the fieldLength to set
|
||||||
|
*/
|
||||||
|
public void setFieldLength(int fieldLength) {
|
||||||
|
this.fieldLength = fieldLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,12 @@ public class PamParameterDataGetter extends PrivatePamParameterData {
|
|||||||
if (setter == null) {
|
if (setter == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// need to convert the type
|
||||||
|
Object convObj = convertStringType(data);
|
||||||
try {
|
try {
|
||||||
setter.invoke(getParentObject(), data);
|
Object parentObj = getParentObject();
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
setter.invoke(parentObj, convObj);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -286,4 +286,5 @@ public class PamParameterSet {
|
|||||||
public PamParameterData removeParameterData(String paramName) {
|
public PamParameterData removeParameterData(String paramName) {
|
||||||
return parameterDatas.remove(paramName);
|
return parameterDatas.remove(paramName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
73
src/PamModel/parametermanager/ParameterSetManager.java
Normal file
73
src/PamModel/parametermanager/ParameterSetManager.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package PamModel.parametermanager;
|
||||||
|
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
|
import PamModel.parametermanager.swing.ManagedParameterDialog;
|
||||||
|
import generalDatabase.parameterstore.ParameterDatabaseStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just about everything giving overall control of some managed parameters.
|
||||||
|
* May be a bit too specific on first cut and need to be abstracted.
|
||||||
|
* Testing on 'Deployment' data.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public class ParameterSetManager<T extends ManagedParameters> {
|
||||||
|
|
||||||
|
private T managedParams;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public ParameterSetManager(T defaultParams, String name) {
|
||||||
|
setManagedParams(defaultParams);
|
||||||
|
this.name = name;
|
||||||
|
// if (managedParams == null) {
|
||||||
|
// managedParams = new T();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the managedParams
|
||||||
|
*/
|
||||||
|
public T getManagedParams() {
|
||||||
|
return managedParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param managedParams the managedParams to set
|
||||||
|
*/
|
||||||
|
public void setManagedParams(T managedParams) {
|
||||||
|
this.managedParams = managedParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JMenuItem getMenuItem(Window parent) {
|
||||||
|
if (managedParams == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JMenuItem menuItem = new JMenuItem(name + " ...");
|
||||||
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
showDialog(parent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return menuItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showDialog(Window parent) {
|
||||||
|
ManagedParameterDialog<T> dialog = new ManagedParameterDialog<T>(parent, name, managedParams);
|
||||||
|
T newParams = dialog.showDialog(parent, name, managedParams);
|
||||||
|
|
||||||
|
if (newParams != null) {
|
||||||
|
ParameterDatabaseStore paramDatabase = new ParameterDatabaseStore("MetaData");
|
||||||
|
paramDatabase.saveParameterSet(newParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package PamModel.parametermanager;
|
package PamModel.parametermanager;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract instance of PamParameterDataInterface which implements everything
|
* Abstract instance of PamParameterDataInterface which implements everything
|
||||||
@ -36,9 +37,48 @@ public abstract class PrivatePamParameterData extends PamParameterData {
|
|||||||
* This should really be implemented in every concrete class, but no time to do that now. Aim to delete
|
* This should really be implemented in every concrete class, but no time to do that now. Aim to delete
|
||||||
* this function here, then go through and implement everywhere ...
|
* this function here, then go through and implement everywhere ...
|
||||||
*/
|
*/
|
||||||
return false;
|
// return false;
|
||||||
|
Object convData = convertStringType(data);
|
||||||
|
getField().set(this, convData);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert a string type to a different type appropriate for the field in
|
||||||
|
* question.
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object convertStringType(Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (value instanceof String == false) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
String str = (String) value;
|
||||||
|
Type type = getField().getGenericType();
|
||||||
|
Class<?> cls = getField().getType();
|
||||||
|
String clsName = cls.getName();
|
||||||
|
switch (clsName) {
|
||||||
|
case "int":
|
||||||
|
case "Integer":
|
||||||
|
return Integer.valueOf(str);
|
||||||
|
case "double":
|
||||||
|
case "Double":
|
||||||
|
return Double.valueOf(str);
|
||||||
|
case "float":
|
||||||
|
case "Float":
|
||||||
|
return Float.valueOf(str);
|
||||||
|
case "short":
|
||||||
|
case "Short":
|
||||||
|
return Short.valueOf(str);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package PamModel.parametermanager.swing;
|
||||||
|
|
||||||
|
import java.awt.Window;
|
||||||
|
|
||||||
|
import PamModel.parametermanager.ManagedParameters;
|
||||||
|
import PamView.dialog.PamDialog;
|
||||||
|
|
||||||
|
public class ManagedParameterDialog<T extends ManagedParameters> extends PamDialog {
|
||||||
|
|
||||||
|
private T params;
|
||||||
|
|
||||||
|
private ManagedParameterPanel<T> parameterPanel;
|
||||||
|
|
||||||
|
public ManagedParameterDialog(Window parentFrame, String title, T params) {
|
||||||
|
super(parentFrame, title, false);
|
||||||
|
parameterPanel = new ManagedParameterPanel<T>(params);
|
||||||
|
setDialogComponent(parameterPanel.getPanel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public T showDialog(Window parentFrame, String title, T parameters) {
|
||||||
|
// ManagedParameterDialog dialog = new ManagedParameterDialog<>(parentFrame, title, parameters);
|
||||||
|
setParams(parameters);
|
||||||
|
setVisible(true);
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setParams(T params) {
|
||||||
|
this.params = params;
|
||||||
|
this.parameterPanel.setParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getParams() {
|
||||||
|
return parameterPanel.getParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelButtonPressed() {
|
||||||
|
params = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreDefaultSettings() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
149
src/PamModel/parametermanager/swing/ManagedParameterPanel.java
Normal file
149
src/PamModel/parametermanager/swing/ManagedParameterPanel.java
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
package PamModel.parametermanager.swing;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.text.JTextComponent;
|
||||||
|
|
||||||
|
import PamModel.parametermanager.FieldNotFoundException;
|
||||||
|
import PamModel.parametermanager.ManagedParameters;
|
||||||
|
import PamModel.parametermanager.PamParameterData;
|
||||||
|
import PamModel.parametermanager.PamParameterSet;
|
||||||
|
import PamView.dialog.PamDialog;
|
||||||
|
import PamView.dialog.PamGridBagContraints;
|
||||||
|
|
||||||
|
public class ManagedParameterPanel<T extends ManagedParameters> {
|
||||||
|
|
||||||
|
private JPanel mainPanel;
|
||||||
|
private Collection<PamParameterData> parameterSet;
|
||||||
|
|
||||||
|
private static final int DEFAULT_TEXT_LENGTH = 6;
|
||||||
|
private static final int MAX_SINGLE_LINE_LENGTH = 40;
|
||||||
|
|
||||||
|
private JTextComponent[] textComponents;
|
||||||
|
|
||||||
|
public ManagedParameterPanel(T parameterExample) {
|
||||||
|
|
||||||
|
mainPanel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints c = new PamGridBagContraints();
|
||||||
|
PamParameterSet exampleSet = parameterExample.getParameterSet();
|
||||||
|
parameterSet = exampleSet.getParameterCollection();
|
||||||
|
int n = parameterSet.size();
|
||||||
|
textComponents = new JTextComponent[n];
|
||||||
|
int i = 0;
|
||||||
|
for (PamParameterData paramData : parameterSet) {
|
||||||
|
textComponents[i] = createComponent(paramData);
|
||||||
|
c.gridx = 0;
|
||||||
|
c.fill = GridBagConstraints.NONE;
|
||||||
|
c.anchor = GridBagConstraints.NORTHEAST;
|
||||||
|
mainPanel.add(new JLabel(paramData.getShortName(), JLabel.RIGHT), c);
|
||||||
|
c.gridx++;
|
||||||
|
if (textComponents[i] instanceof JTextArea) {
|
||||||
|
c.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c.fill = GridBagConstraints.NONE;
|
||||||
|
}
|
||||||
|
c.anchor = GridBagConstraints.WEST;
|
||||||
|
mainPanel.add(textComponents[i], c);
|
||||||
|
|
||||||
|
textComponents[i].setToolTipText(getTipText(paramData));
|
||||||
|
|
||||||
|
c.gridy++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTipText(PamParameterData paramData) {
|
||||||
|
String tip = paramData.getToolTip();
|
||||||
|
if (tip != null) {
|
||||||
|
return tip;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return paramData.getFieldName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JTextComponent createComponent(PamParameterData paramData) {
|
||||||
|
int textLen = paramData.getFieldLength();
|
||||||
|
if (textLen == 0) {
|
||||||
|
textLen = DEFAULT_TEXT_LENGTH;
|
||||||
|
}
|
||||||
|
if (textLen <= MAX_SINGLE_LINE_LENGTH) {
|
||||||
|
return new JTextField(textLen);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
JTextField dummyField = new JTextField(2);
|
||||||
|
// dummyField.getBorder().
|
||||||
|
JTextArea textArea = new JTextArea(textLen/MAX_SINGLE_LINE_LENGTH+1, MAX_SINGLE_LINE_LENGTH);
|
||||||
|
textArea.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
||||||
|
return textArea;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JComponent getPanel() {
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(T params) {
|
||||||
|
int i = 0;
|
||||||
|
PamParameterData newParamData = null;
|
||||||
|
Object data = null;
|
||||||
|
for (PamParameterData paramData : this.parameterSet) {
|
||||||
|
// find the parameter in the new parameters (parameterSet is just a formatting placeholder)
|
||||||
|
try {
|
||||||
|
newParamData = params.getParameterSet().findParameterData(paramData.getFieldName());
|
||||||
|
} catch (FieldNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
data = newParamData.getData();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (data != null) {
|
||||||
|
textComponents[i].setText(data.toString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
textComponents[i].setText(null);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getParams(T params) {
|
||||||
|
int i = 0;
|
||||||
|
PamParameterData newParamData = null;
|
||||||
|
Object data = null;
|
||||||
|
for (PamParameterData paramData : this.parameterSet) {
|
||||||
|
// find the parameter in the new parameters (parameterSet is just a formatting placeholder)
|
||||||
|
try {
|
||||||
|
newParamData = params.getParameterSet().findParameterData(paramData.getFieldName());
|
||||||
|
} catch (FieldNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
String txt = textComponents[i].getText();
|
||||||
|
try {
|
||||||
|
newParamData.setData(txt);
|
||||||
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
|
String msg = "Invalid parameter. Data type should be " + paramData.getField().getType().getName();
|
||||||
|
return PamDialog.showWarning(null, newParamData.getShortName(), msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package PamguardMVC;
|
package PamguardMVC;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import PamController.PamControllerInterface;
|
import PamController.PamControllerInterface;
|
||||||
import PamguardMVC.nanotime.NanosFromSamples;
|
import PamguardMVC.nanotime.NanosFromSamples;
|
||||||
|
|
||||||
@ -90,5 +93,12 @@ abstract public class AcousticDataBlock <Tunit extends PamDataUnit> extends PamD
|
|||||||
return parentSourceData;
|
return parentSourceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Element getDataBlockXML(Document doc) {
|
||||||
|
Element el = super.getDataBlockXML(doc);
|
||||||
|
el.setAttribute("SampleRate", String.format("%3.1f", getSampleRate()));
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package PamguardMVC;
|
package PamguardMVC;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import dataPlotsFX.data.DataTypeInfo;
|
import dataPlotsFX.data.DataTypeInfo;
|
||||||
|
|
||||||
abstract public class DataBlock2D<Tunit extends PamDataUnit> extends AcousticDataBlock<Tunit> {
|
abstract public class DataBlock2D<Tunit extends PamDataUnit> extends AcousticDataBlock<Tunit> {
|
||||||
@ -39,4 +42,18 @@ abstract public class DataBlock2D<Tunit extends PamDataUnit> extends AcousticDat
|
|||||||
* @return data type information.
|
* @return data type information.
|
||||||
*/
|
*/
|
||||||
abstract public DataTypeInfo getScaleInfo();
|
abstract public DataTypeInfo getScaleInfo();
|
||||||
|
|
||||||
|
public Element getDataBlockXML(Document doc) {
|
||||||
|
Element el = super.getDataBlockXML(doc);
|
||||||
|
DataTypeInfo dti = getScaleInfo();
|
||||||
|
if (dti != null) {
|
||||||
|
if (dti.dataType != null) {
|
||||||
|
el.setAttribute("DataType", dti.dataType.toString());
|
||||||
|
}
|
||||||
|
if (dti.dataUnits != null) {
|
||||||
|
el.setAttribute("DataUnits", dti.dataUnits.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return el;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,10 +44,14 @@ import javax.swing.Timer;
|
|||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import org.springframework.core.GenericTypeResolver;
|
import org.springframework.core.GenericTypeResolver;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import Acquisition.AcquisitionControl;
|
import Acquisition.AcquisitionControl;
|
||||||
import Acquisition.AcquisitionProcess;
|
import Acquisition.AcquisitionProcess;
|
||||||
import pamScrollSystem.ViewLoadObserver;
|
import pamScrollSystem.ViewLoadObserver;
|
||||||
|
import tethys.pamdata.AutoTethysProvider;
|
||||||
|
import tethys.pamdata.TethysDataProvider;
|
||||||
import dataGram.DatagramProvider;
|
import dataGram.DatagramProvider;
|
||||||
import dataMap.BespokeDataMapGraphic;
|
import dataMap.BespokeDataMapGraphic;
|
||||||
import dataMap.OfflineDataMap;
|
import dataMap.OfflineDataMap;
|
||||||
@ -62,6 +66,7 @@ import PamController.PamController;
|
|||||||
import PamController.PamControllerInterface;
|
import PamController.PamControllerInterface;
|
||||||
import PamDetection.LocContents;
|
import PamDetection.LocContents;
|
||||||
import PamDetection.LocalisationInfo;
|
import PamDetection.LocalisationInfo;
|
||||||
|
import PamDetection.PamDetection;
|
||||||
import PamUtils.PamCalendar;
|
import PamUtils.PamCalendar;
|
||||||
import PamUtils.PamUtils;
|
import PamUtils.PamUtils;
|
||||||
import PamView.symbol.PamSymbolManager;
|
import PamView.symbol.PamSymbolManager;
|
||||||
@ -2863,8 +2868,11 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
|||||||
private Vector<OfflineDataMap> offlineDataMaps = null;
|
private Vector<OfflineDataMap> offlineDataMaps = null;
|
||||||
|
|
||||||
private SQLLogging logging;
|
private SQLLogging logging;
|
||||||
|
|
||||||
|
private TethysDataProvider tethysDataProvider;
|
||||||
|
|
||||||
private JSONObjectDataSource jsonDataSource;
|
private JSONObjectDataSource jsonDataSource;
|
||||||
|
|
||||||
|
|
||||||
public Vector<ProcessAnnotation> getProcessAnnotations() {
|
public Vector<ProcessAnnotation> getProcessAnnotations() {
|
||||||
return processAannotations;
|
return processAannotations;
|
||||||
@ -3074,6 +3082,26 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
|||||||
public SQLLogging getLogging() {
|
public SQLLogging getLogging() {
|
||||||
return logging;
|
return logging;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a data provider for Tethys. These will probably need
|
||||||
|
* to be bespoke, but for now will autogenerate based on the SALLogging information.
|
||||||
|
* @return the tethysDataProvider
|
||||||
|
*/
|
||||||
|
public TethysDataProvider getTethysDataProvider() {
|
||||||
|
if (tethysDataProvider == null && PamDetection.class.isAssignableFrom(unitClass) && getLogging() != null) {
|
||||||
|
tethysDataProvider = new AutoTethysProvider(this);
|
||||||
|
}
|
||||||
|
return tethysDataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a data provider for Tethys.
|
||||||
|
* @param tethysDataProvider the tethysDataProvider to set
|
||||||
|
*/
|
||||||
|
public void setTethysDataProvider(TethysDataProvider tethysDataProvider) {
|
||||||
|
this.tethysDataProvider = tethysDataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
final public boolean getCanLog() {
|
final public boolean getCanLog() {
|
||||||
return (logging != null);
|
return (logging != null);
|
||||||
@ -4229,4 +4257,23 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
|||||||
public void setBackgroundManager(BackgroundManager backgroundManager) {
|
public void setBackgroundManager(BackgroundManager backgroundManager) {
|
||||||
this.backgroundManager = backgroundManager;
|
this.backgroundManager = backgroundManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a brief summary of datablock to include in XML descriptions.
|
||||||
|
* Basic output is very simple. Expect other datablock to extend this by
|
||||||
|
* adding additional attributes.
|
||||||
|
* @param doc
|
||||||
|
* @return XML element with description of data.
|
||||||
|
*/
|
||||||
|
public Element getDataBlockXML(Document doc) {
|
||||||
|
Element inputEl = doc.createElement("Input");
|
||||||
|
if (getParentProcess() != null && getParentProcess().getPamControlledUnit() != null) {
|
||||||
|
PamControlledUnit pcu = getParentProcess().getPamControlledUnit();
|
||||||
|
inputEl.setAttribute("ModuleType", pcu.getUnitType());
|
||||||
|
inputEl.setAttribute("ModuleName", pcu.getUnitName());
|
||||||
|
}
|
||||||
|
inputEl.setAttribute("Name", getLongDataName());
|
||||||
|
inputEl.setAttribute("Channels", String.format("0x%X", getChannelMap()));
|
||||||
|
return inputEl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import PamDetection.AcousticSQLLogging;
|
|||||||
import PamUtils.PamUtils;
|
import PamUtils.PamUtils;
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLTypes;
|
import generalDatabase.SQLTypes;
|
||||||
@ -26,7 +27,7 @@ public class RWESQLLogging extends AcousticSQLLogging {
|
|||||||
angles = new PamTableItem[maxAngles];
|
angles = new PamTableItem[maxAngles];
|
||||||
angleErrors = new PamTableItem[maxAngles];
|
angleErrors = new PamTableItem[maxAngles];
|
||||||
|
|
||||||
PamTableDefinition tableDef = getTableDefinition();
|
EmptyTableDefinition tableDef = getTableDefinition();
|
||||||
tableDef.addTableItem(score = new PamTableItem("score", Types.INTEGER));
|
tableDef.addTableItem(score = new PamTableItem("score", Types.INTEGER));
|
||||||
tableDef.addTableItem(signal = new PamTableItem("signal", Types.DOUBLE));
|
tableDef.addTableItem(signal = new PamTableItem("signal", Types.DOUBLE));
|
||||||
tableDef.addTableItem(noise = new PamTableItem("noise", Types.DOUBLE));
|
tableDef.addTableItem(noise = new PamTableItem("noise", Types.DOUBLE));
|
||||||
|
@ -56,7 +56,8 @@ public class ArraySensorLogging extends SQLLogging {
|
|||||||
AnalogSensorData aData = new AnalogSensorData(rawValue, calValue);
|
AnalogSensorData aData = new AnalogSensorData(rawValue, calValue);
|
||||||
sensorData[i] = aData;
|
sensorData[i] = aData;
|
||||||
}
|
}
|
||||||
int chanMap = getTableDefinition().getChannelBitmap().getIntegerValue();
|
PamTableDefinition pamTableDef = (PamTableDefinition) getTableDefinition();
|
||||||
|
int chanMap = pamTableDef.getChannelBitmap().getIntegerValue();
|
||||||
int streamer = PamUtils.getSingleChannel(chanMap);
|
int streamer = PamUtils.getSingleChannel(chanMap);
|
||||||
if (streamer < 0) streamer = 0;
|
if (streamer < 0) streamer = 0;
|
||||||
AnalogArraySensorDataUnit asdu = new AnalogArraySensorDataUnit(timeMilliseconds, streamer, sensorData);
|
AnalogArraySensorDataUnit asdu = new AnalogArraySensorDataUnit(timeMilliseconds, streamer, sensorData);
|
||||||
|
@ -3,6 +3,7 @@ package annotation.calcs.snr;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -21,13 +22,13 @@ public class SnrSqlAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(snr);
|
pamTableDefinition.addTableItem(snr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
SNRAnnotation snrAnnotation = (SNRAnnotation) pamDataUnit.findDataAnnotation(SNRAnnotation.class);
|
SNRAnnotation snrAnnotation = (SNRAnnotation) pamDataUnit.findDataAnnotation(SNRAnnotation.class);
|
||||||
if (snrAnnotation == null) {
|
if (snrAnnotation == null) {
|
||||||
@ -40,7 +41,7 @@ public class SnrSqlAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
Double snrVal = (Double) snr.getValue();
|
Double snrVal = (Double) snr.getValue();
|
||||||
if (snrVal != null) {
|
if (snrVal != null) {
|
||||||
|
@ -3,6 +3,7 @@ package annotation.calcs.spl;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -25,7 +26,7 @@ public class SPLSqlAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(rms);
|
pamTableDefinition.addTableItem(rms);
|
||||||
pamTableDefinition.addTableItem(zeroPeak);
|
pamTableDefinition.addTableItem(zeroPeak);
|
||||||
pamTableDefinition.addTableItem(peakPeak);
|
pamTableDefinition.addTableItem(peakPeak);
|
||||||
@ -33,7 +34,7 @@ public class SPLSqlAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
SPLAnnotation splAnnotation = (SPLAnnotation) pamDataUnit.findDataAnnotation(SPLAnnotation.class);
|
SPLAnnotation splAnnotation = (SPLAnnotation) pamDataUnit.findDataAnnotation(SPLAnnotation.class);
|
||||||
if (splAnnotation == null) {
|
if (splAnnotation == null) {
|
||||||
@ -52,7 +53,7 @@ public class SPLSqlAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
SPLAnnotation splAnnotation = new SPLAnnotation(splAnnotationType);
|
SPLAnnotation splAnnotation = new SPLAnnotation(splAnnotationType);
|
||||||
if (splAnnotation != null) {
|
if (splAnnotation != null) {
|
||||||
|
@ -3,6 +3,7 @@ package annotation.calcs.wav;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -21,13 +22,13 @@ public class WavSqlAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(wavFileName);
|
pamTableDefinition.addTableItem(wavFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
WavAnnotation annotation = (WavAnnotation) pamDataUnit.findDataAnnotation(WavAnnotation.class);
|
WavAnnotation annotation = (WavAnnotation) pamDataUnit.findDataAnnotation(WavAnnotation.class);
|
||||||
if (annotation == null) {
|
if (annotation == null) {
|
||||||
@ -40,7 +41,7 @@ public class WavSqlAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
String fileName = (String) wavFileName.getValue();
|
String fileName = (String) wavFileName.getValue();
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
|
@ -15,6 +15,7 @@ import PamView.dialog.GenericSwingDialog;
|
|||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
import generalDatabase.DBControlUnit;
|
import generalDatabase.DBControlUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.SQLLogging;
|
import generalDatabase.SQLLogging;
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ public abstract class OneStopAnnotationHandler extends AnnotationChoiceHandler i
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// get, modify and set the modified tabelDef
|
// get, modify and set the modified tabelDef
|
||||||
PamTableDefinition tableDef = logging.getBaseTableDefinition();
|
EmptyTableDefinition tableDef = logging.getBaseTableDefinition();
|
||||||
logging.setTableDefinition(tableDef);
|
logging.setTableDefinition(tableDef);
|
||||||
addAnnotationSqlAddons(logging); // this will add the additional columns.
|
addAnnotationSqlAddons(logging); // this will add the additional columns.
|
||||||
DBControlUnit dbc = DBControlUnit.findDatabaseControl();
|
DBControlUnit dbc = DBControlUnit.findDatabaseControl();
|
||||||
|
@ -3,6 +3,7 @@ package annotation.localise.targetmotion;
|
|||||||
import Localiser.detectionGroupLocaliser.GroupLocalisation;
|
import Localiser.detectionGroupLocaliser.GroupLocalisation;
|
||||||
import PamDetection.AbstractLocalisation;
|
import PamDetection.AbstractLocalisation;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.SQLTypes;
|
import generalDatabase.SQLTypes;
|
||||||
import targetMotionOld.TargetMotionSQLLogging;
|
import targetMotionOld.TargetMotionSQLLogging;
|
||||||
@ -17,7 +18,7 @@ public class TMAnnotationLogging extends TargetMotionSQLLogging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
boolean ans = super.loadData(sqlTypes, pamTableDefinition, pamDataUnit);
|
boolean ans = super.loadData(sqlTypes, pamTableDefinition, pamDataUnit);
|
||||||
if (ans == false) return false;
|
if (ans == false) return false;
|
||||||
AbstractLocalisation loc = pamDataUnit.getLocalisation();
|
AbstractLocalisation loc = pamDataUnit.getLocalisation();
|
||||||
|
@ -3,6 +3,7 @@ package annotation.string;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -24,12 +25,12 @@ public class StringSQLLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(notes);
|
pamTableDefinition.addTableItem(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
StringAnnotation stringAnnotation = (StringAnnotation) pamDataUnit.findDataAnnotation(StringAnnotation.class,
|
StringAnnotation stringAnnotation = (StringAnnotation) pamDataUnit.findDataAnnotation(StringAnnotation.class,
|
||||||
stringAnnotationType.getAnnotationName());
|
stringAnnotationType.getAnnotationName());
|
||||||
if (stringAnnotation == null) {
|
if (stringAnnotation == null) {
|
||||||
@ -42,7 +43,7 @@ public class StringSQLLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
try {
|
try {
|
||||||
String note = notes.getDeblankedStringValue();
|
String note = notes.getDeblankedStringValue();
|
||||||
if (note != null && note.length() > 0) {
|
if (note != null && note.length() > 0) {
|
||||||
|
@ -3,6 +3,7 @@ package annotation.timestamp;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -22,12 +23,12 @@ public class TimestampSQLLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(timestamp);
|
pamTableDefinition.addTableItem(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
TimestampAnnotation timestampAnnotation = (TimestampAnnotation) pamDataUnit.findDataAnnotation(TimestampAnnotation.class,
|
TimestampAnnotation timestampAnnotation = (TimestampAnnotation) pamDataUnit.findDataAnnotation(TimestampAnnotation.class,
|
||||||
timestampAnnotationType.getAnnotationName());
|
timestampAnnotationType.getAnnotationName());
|
||||||
if (timestampAnnotation == null) {
|
if (timestampAnnotation == null) {
|
||||||
@ -40,7 +41,7 @@ public class TimestampSQLLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
try {
|
try {
|
||||||
TimestampAnnotation timestampAnnotation = new TimestampAnnotation(timestampAnnotationType);
|
TimestampAnnotation timestampAnnotation = new TimestampAnnotation(timestampAnnotationType);
|
||||||
Long note = sqlTypes.millisFromTimeStamp(timestamp.getValue());
|
Long note = sqlTypes.millisFromTimeStamp(timestamp.getValue());
|
||||||
|
@ -3,6 +3,7 @@ package annotation.userforms;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -32,7 +33,7 @@ public class UserFormSQLAddon implements SQLLoggingAddon {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
loggerTableItems.clear();
|
loggerTableItems.clear();
|
||||||
FormDescription formDescription = userFormAnnotationType.findFormDescription();
|
FormDescription formDescription = userFormAnnotationType.findFormDescription();
|
||||||
if (formDescription == null) {
|
if (formDescription == null) {
|
||||||
@ -58,7 +59,7 @@ public class UserFormSQLAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
if (pamDataUnit == null) {
|
if (pamDataUnit == null) {
|
||||||
clearTableItems();
|
clearTableItems();
|
||||||
return false;
|
return false;
|
||||||
@ -103,7 +104,7 @@ public class UserFormSQLAddon implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
FormDescription formDescription = userFormAnnotationType.findFormDescription();
|
FormDescription formDescription = userFormAnnotationType.findFormDescription();
|
||||||
if (formDescription == null) {
|
if (formDescription == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,6 +6,7 @@ import PamDetection.LocContents;
|
|||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
import beamformer.loc.BeamFormerLocalisation;
|
import beamformer.loc.BeamFormerLocalisation;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -29,7 +30,7 @@ public class BFAnnotationLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(bfPhones);
|
pamTableDefinition.addTableItem(bfPhones);
|
||||||
pamTableDefinition.addTableItem(bfArrayType);
|
pamTableDefinition.addTableItem(bfArrayType);
|
||||||
pamTableDefinition.addTableItem(bfContents);
|
pamTableDefinition.addTableItem(bfContents);
|
||||||
@ -38,7 +39,7 @@ public class BFAnnotationLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
bfPhones.setValue(null);
|
bfPhones.setValue(null);
|
||||||
bfArrayType.setValue(null);
|
bfArrayType.setValue(null);
|
||||||
bfContents.setValue(null);
|
bfContents.setValue(null);
|
||||||
@ -64,7 +65,7 @@ public class BFAnnotationLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
Float[] Angles = new Float[2];
|
Float[] Angles = new Float[2];
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
Angles[i] = (Float) angle[i].getFloatValue();
|
Angles[i] = (Float) angle[i].getFloatValue();
|
||||||
|
@ -4,6 +4,7 @@ import java.sql.Types;
|
|||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
import bearinglocaliser.BearingLocalisation;
|
import bearinglocaliser.BearingLocalisation;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -34,7 +35,7 @@ public class BearingAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(algoName);
|
pamTableDefinition.addTableItem(algoName);
|
||||||
pamTableDefinition.addTableItem(bfPhones);
|
pamTableDefinition.addTableItem(bfPhones);
|
||||||
pamTableDefinition.addTableItem(bfArrayType);
|
pamTableDefinition.addTableItem(bfArrayType);
|
||||||
@ -48,7 +49,7 @@ public class BearingAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
algoName.setValue(null);
|
algoName.setValue(null);
|
||||||
bfPhones.setValue(null);
|
bfPhones.setValue(null);
|
||||||
bfArrayType.setValue(null);
|
bfArrayType.setValue(null);
|
||||||
@ -96,7 +97,7 @@ public class BearingAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
Float[] Angles = new Float[2];
|
Float[] Angles = new Float[2];
|
||||||
int nNans = 0;
|
int nNans = 0;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
@ -110,6 +110,12 @@ public class BinarySettingsStorage implements PamSettingsSource {
|
|||||||
return false;*/
|
return false;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveEndSettings(long timeNow) {
|
||||||
|
// do nothing at the end of a run with binary store.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// private boolean writeData(DataOutputStream dos, int objectId, byte[] data) {
|
// private boolean writeData(DataOutputStream dos, int objectId, byte[] data) {
|
||||||
// int totalLen = data.length + 16;
|
// int totalLen = data.length + 16;
|
||||||
// int dataLen = data.length;
|
// int dataLen = data.length;
|
||||||
|
@ -540,6 +540,12 @@ PamSettingsSource, DataOutputStore {
|
|||||||
return binarySettingsStorage.saveStartSettings(timeNow);
|
return binarySettingsStorage.saveStartSettings(timeNow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveEndSettings(long timeNow) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNumSettings() {
|
public int getNumSettings() {
|
||||||
if (binarySettingsStorage == null) {
|
if (binarySettingsStorage == null) {
|
||||||
|
@ -46,6 +46,7 @@ public class BinaryStoreProcess extends PamProcess {
|
|||||||
startTime = PamCalendar.getTimeInMillis();
|
startTime = PamCalendar.getTimeInMillis();
|
||||||
long round = binaryStore.binaryStoreSettings.fileSeconds * 1000;
|
long round = binaryStore.binaryStoreSettings.fileSeconds * 1000;
|
||||||
nextFileTime = (startTime/round) * round + round;
|
nextFileTime = (startTime/round) * round + round;
|
||||||
|
// this was a print of the time of the NEXT binary file. Not really of interest.
|
||||||
// System.out.println("Next file start at " + PamCalendar.formatDateTime(nextFileTime));
|
// System.out.println("Next file start at " + PamCalendar.formatDateTime(nextFileTime));
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
timer.schedule(new FileTimerTask(), 1000, 1000);
|
timer.schedule(new FileTimerTask(), 1000, 1000);
|
||||||
|
@ -3,6 +3,7 @@ package clickDetector.ClickClassifiers.annotation;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -33,12 +34,12 @@ public class ClickAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(classifierSetTable);
|
pamTableDefinition.addTableItem(classifierSetTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
ClickClassifierAnnotation clickAnnotation = (ClickClassifierAnnotation) pamDataUnit.findDataAnnotation(ClickClassificationType.class);
|
ClickClassifierAnnotation clickAnnotation = (ClickClassifierAnnotation) pamDataUnit.findDataAnnotation(ClickClassificationType.class);
|
||||||
|
|
||||||
//create a comma delimited string
|
//create a comma delimited string
|
||||||
@ -53,7 +54,7 @@ public class ClickAnnotationSQL implements SQLLoggingAddon {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
String array = classifierSetTable.getDeblankedStringValue();
|
String array = classifierSetTable.getDeblankedStringValue();
|
||||||
|
|
||||||
//read in the classification set. This a list of all the classifiers the clicks passed.
|
//read in the classification set. This a list of all the classifiers the clicks passed.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package clickDetector;
|
package clickDetector;
|
||||||
|
|
||||||
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.SQLTypes;
|
import generalDatabase.SQLTypes;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
import clickDetector.offlineFuncs.OfflineEventDataUnit;
|
import clickDetector.offlineFuncs.OfflineEventDataUnit;
|
||||||
@ -30,7 +31,8 @@ public class TrackedClickGroupLogging extends ClickGroupLogging {
|
|||||||
boolean isUpdate = true;
|
boolean isUpdate = true;
|
||||||
// Timestamp ts = (Timestamp) getTableDefinition().getTimeStampItem().getValue();
|
// Timestamp ts = (Timestamp) getTableDefinition().getTimeStampItem().getValue();
|
||||||
// long t = PamCalendar.millisFromTimeStamp(ts);
|
// long t = PamCalendar.millisFromTimeStamp(ts);
|
||||||
int updateIndex = (Integer) getTableDefinition().getUpdateReference().getValue();
|
PamTableDefinition tableDef = (PamTableDefinition) getTableDefinition();
|
||||||
|
int updateIndex = (Integer) tableDef.getUpdateReference().getValue();
|
||||||
if (updateIndex > 0) {
|
if (updateIndex > 0) {
|
||||||
tcg = this.clickGroupDataBlock.findByDatabaseIndex(updateIndex);
|
tcg = this.clickGroupDataBlock.findByDatabaseIndex(updateIndex);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class ClickTrainDataSelector2 extends DataSelector {
|
|||||||
}
|
}
|
||||||
SQLLogging logging = getPamDataBlock().getLogging();
|
SQLLogging logging = getPamDataBlock().getLogging();
|
||||||
if (logging == null) return null; //cannot happen!
|
if (logging == null) return null; //cannot happen!
|
||||||
PamTableDefinition tableDef = logging.getTableDefinition();
|
EmptyTableDefinition tableDef = logging.getTableDefinition();
|
||||||
if (params.isIncludeUnclassified()) {
|
if (params.isIncludeUnclassified()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1628,8 +1628,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane<ClickTypeProperty> {
|
|||||||
|
|
||||||
p.setLayout(new GridBagLayout());
|
p.setLayout(new GridBagLayout());
|
||||||
GridBagConstraints c = new PamGridBagContraints();
|
GridBagConstraints c = new PamGridBagContraints();
|
||||||
|
|
||||||
|
|
||||||
// c.gridx = 0;
|
// c.gridx = 0;
|
||||||
// addComponent(p, enableBearings, c);
|
// addComponent(p, enableBearings, c);
|
||||||
// c.gridx += c.gridwidth;
|
// c.gridx += c.gridwidth;
|
||||||
@ -1737,7 +1736,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane<ClickTypeProperty> {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// else multiChan = true;
|
// else multiChan = true;
|
||||||
// Debug.out.println("Check multi-channel: " + multiChan);
|
//// Debug.out.println("Check multi-channel: " + multiChan);
|
||||||
|
|
||||||
return multiChan;
|
return multiChan;
|
||||||
}
|
}
|
||||||
|
@ -102,16 +102,17 @@ public class DatabaseChecks {
|
|||||||
long resultTime;
|
long resultTime;
|
||||||
long firstTime = Long.MAX_VALUE;
|
long firstTime = Long.MAX_VALUE;
|
||||||
long lastTime = Long.MIN_VALUE;
|
long lastTime = Long.MIN_VALUE;
|
||||||
|
PamTableDefinition pamTableDef = (PamTableDefinition) clickLogging.getTableDefinition();
|
||||||
try {
|
try {
|
||||||
Statement stmt = con.getConnection().createStatement();
|
Statement stmt = con.getConnection().createStatement();
|
||||||
ResultSet result = stmt.executeQuery(sqlStr);
|
ResultSet result = stmt.executeQuery(sqlStr);
|
||||||
while (result.next()) {
|
while (result.next()) {
|
||||||
nClicks++;
|
nClicks++;
|
||||||
clickLogging.transferDataFromResult(sqlTypes, result);
|
clickLogging.transferDataFromResult(sqlTypes, result);
|
||||||
ts = clickLogging.getTableDefinition().getTimeStampItem().getValue();
|
ts = pamTableDef.getTimeStampItem().getValue();
|
||||||
resultTime = sqlTypes.millisFromTimeStamp(ts);
|
resultTime = sqlTypes.millisFromTimeStamp(ts);
|
||||||
if (resultTime%1000 == 0) {
|
if (resultTime%1000 == 0) {
|
||||||
resultTime += clickLogging.getTableDefinition().getTimeStampMillis().getIntegerValue();
|
resultTime += pamTableDef.getTimeStampMillis().getIntegerValue();
|
||||||
}
|
}
|
||||||
firstTime = Math.min(firstTime, resultTime);
|
firstTime = Math.min(firstTime, resultTime);
|
||||||
lastTime = Math.max(lastTime, resultTime);
|
lastTime = Math.max(lastTime, resultTime);
|
||||||
@ -188,7 +189,7 @@ public class DatabaseChecks {
|
|||||||
eventDataBlock.addPamData(event);
|
eventDataBlock.addPamData(event);
|
||||||
PamConnection con = DBControlUnit.findConnection();
|
PamConnection con = DBControlUnit.findConnection();
|
||||||
// now find a cursor and save it.
|
// now find a cursor and save it.
|
||||||
PamTableDefinition eventTableDef = eventDataBlock.getLogging().getTableDefinition();
|
PamTableDefinition eventTableDef = (PamTableDefinition) eventDataBlock.getLogging().getTableDefinition();
|
||||||
PamCursor cursor = eventDataBlock.getLogging().getViewerCursorFinder().getCursor(con, eventTableDef);
|
PamCursor cursor = eventDataBlock.getLogging().getViewerCursorFinder().getCursor(con, eventTableDef);
|
||||||
cursor.immediateInsert(con);
|
cursor.immediateInsert(con);
|
||||||
int newId = event.getDatabaseIndex();
|
int newId = event.getDatabaseIndex();
|
||||||
|
@ -277,13 +277,14 @@ public class OfflineClickLogging extends SQLLogging {
|
|||||||
Integer millis;
|
Integer millis;
|
||||||
Object ts;
|
Object ts;
|
||||||
SQLTypes sqlTypes = dbControl.getConnection().getSqlTypes();
|
SQLTypes sqlTypes = dbControl.getConnection().getSqlTypes();
|
||||||
|
PamTableDefinition tableDef = (PamTableDefinition) getTableDefinition();
|
||||||
try {
|
try {
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
transferDataFromResult(sqlTypes, resultSet);
|
transferDataFromResult(sqlTypes, resultSet);
|
||||||
ts = getTableDefinition().getTimeStampItem().getValue();
|
ts = tableDef.getTimeStampItem().getValue();
|
||||||
long m = SQLTypes.millisFromTimeStamp(ts);
|
long m = SQLTypes.millisFromTimeStamp(ts);
|
||||||
if (m%1000 == 0) {
|
if (m%1000 == 0) {
|
||||||
millis = (Integer) getTableDefinition().getTimeStampMillis().getValue();
|
millis = (Integer) tableDef.getTimeStampMillis().getValue();
|
||||||
if (millis != null) {
|
if (millis != null) {
|
||||||
m += millis;
|
m += millis;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public class RainbowDatabseConverter {
|
|||||||
|
|
||||||
ClickDataBlock clickDataBlock = clickControl.getClickDataBlock();
|
ClickDataBlock clickDataBlock = clickControl.getClickDataBlock();
|
||||||
clickLogging = new ClickImportLogging(clickControl);
|
clickLogging = new ClickImportLogging(clickControl);
|
||||||
PamTableDefinition tableDef = clickLogging.getTableDefinition();
|
PamTableDefinition tableDef = (PamTableDefinition) clickLogging.getTableDefinition();
|
||||||
boolean ok = checkTable(pamConnection, tableDef);
|
boolean ok = checkTable(pamConnection, tableDef);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
System.out.println("Error in Pamguard clicks table");
|
System.out.println("Error in Pamguard clicks table");
|
||||||
@ -156,7 +156,7 @@ public class RainbowDatabseConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
eventLogging = new OfflineEventLogging(clickControl, clickControl.getClickDetector().getOfflineEventDataBlock());
|
eventLogging = new OfflineEventLogging(clickControl, clickControl.getClickDetector().getOfflineEventDataBlock());
|
||||||
tableDef = eventLogging.getTableDefinition();
|
tableDef = (PamTableDefinition) eventLogging.getTableDefinition();
|
||||||
ok = checkTable(pamConnection, tableDef);
|
ok = checkTable(pamConnection, tableDef);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
System.out.println("Error in Pamguard events table");
|
System.out.println("Error in Pamguard events table");
|
||||||
|
@ -125,7 +125,7 @@ public class TrackedGroupSqlLogging extends SQLLogging {
|
|||||||
*/
|
*/
|
||||||
protected void updateData(SQLTypes sqlTypes, PamDataUnit pamDataUnit) {
|
protected void updateData(SQLTypes sqlTypes, PamDataUnit pamDataUnit) {
|
||||||
|
|
||||||
PamTableDefinition tableDef = getTableDefinition();
|
PamTableDefinition tableDef = (PamTableDefinition) getTableDefinition();
|
||||||
PamTableItem tableItem;
|
PamTableItem tableItem;
|
||||||
|
|
||||||
tableDef.getIndexItem().setValue(pamDataUnit.getDatabaseIndex());
|
tableDef.getIndexItem().setValue(pamDataUnit.getDatabaseIndex());
|
||||||
|
@ -4,6 +4,9 @@ import java.util.List;
|
|||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import PamView.GeneralProjector.ParameterType;
|
import PamView.GeneralProjector.ParameterType;
|
||||||
import PamView.GeneralProjector.ParameterUnits;
|
import PamView.GeneralProjector.ParameterUnits;
|
||||||
import PamguardMVC.DataBlock2D;
|
import PamguardMVC.DataBlock2D;
|
||||||
@ -186,6 +189,13 @@ public class FFTDataBlock extends DataBlock2D<FFTDataUnit> {
|
|||||||
public DataTypeInfo getScaleInfo() {
|
public DataTypeInfo getScaleInfo() {
|
||||||
return dataTypeInfo;
|
return dataTypeInfo;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public Element getDataBlockXML(Document doc) {
|
||||||
|
Element el = super.getDataBlockXML(doc);
|
||||||
|
el.setAttribute("FFTLength", String.format("%d", getFftLength()));
|
||||||
|
el.setAttribute("FFTHop", String.format("%d", getFftHop()));
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -577,10 +577,16 @@ PamSettingsSource {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean saveStartSettings(long timeNow) {
|
public boolean saveStartSettings(long timeNow) {
|
||||||
return dbProcess.saveStartSettings();
|
return dbProcess.saveStartSettings(timeNow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveEndSettings(long timeNow) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNumSettings() {
|
public int getNumSettings() {
|
||||||
if (dbSettingsStore == null) {
|
if (dbSettingsStore == null) {
|
||||||
|
@ -102,6 +102,8 @@ public class DBProcess extends PamProcess {
|
|||||||
dbSpecials.add(logSettings = new LogSettings(databaseControll, "Pamguard Settings", false));
|
dbSpecials.add(logSettings = new LogSettings(databaseControll, "Pamguard Settings", false));
|
||||||
dbSpecials.add(logLastSettings = new LogSettings(databaseControll, "Pamguard Settings Last", true));
|
dbSpecials.add(logLastSettings = new LogSettings(databaseControll, "Pamguard Settings Last", true));
|
||||||
dbSpecials.add(logViewerSettings = new LogSettings(databaseControll, "Pamguard Settings Viewer", true));
|
dbSpecials.add(logViewerSettings = new LogSettings(databaseControll, "Pamguard Settings Viewer", true));
|
||||||
|
|
||||||
|
dbSpecials.add(new LogXMLSettings(databaseControll));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,9 +115,13 @@ public class DBProcess extends PamProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean saveStartSettings() {
|
protected boolean saveStartSettings(long timeNow) {
|
||||||
PamConnection con = databaseControll.getConnection();
|
PamConnection con = databaseControll.getConnection();
|
||||||
if (con != null) {
|
if (con != null) {
|
||||||
|
/**
|
||||||
|
* This first one is the 'old' pre 2022 method which saves a serialised lump of all
|
||||||
|
* the settings in the database. It ain't broke, so not fixing it.
|
||||||
|
*/
|
||||||
for (int i = 0; i < dbSpecials.size(); i++) {
|
for (int i = 0; i < dbSpecials.size(); i++) {
|
||||||
dbSpecials.get(i).pamStart(con);
|
dbSpecials.get(i).pamStart(con);
|
||||||
}
|
}
|
||||||
@ -124,6 +130,11 @@ public class DBProcess extends PamProcess {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean saveEndSettings(long timeNow) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pamStop() {
|
public void pamStop() {
|
||||||
PamConnection con = databaseControll.getConnection();
|
PamConnection con = databaseControll.getConnection();
|
||||||
@ -212,7 +223,7 @@ public class DBProcess extends PamProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dataBlocks = PamController.getInstance().getDataBlocks();
|
dataBlocks = PamController.getInstance().getDataBlocks();
|
||||||
PamTableDefinition tableDefinition;
|
EmptyTableDefinition tableDefinition;
|
||||||
SQLLogging logging;
|
SQLLogging logging;
|
||||||
|
|
||||||
// for each datablock, check that the process can log (ignoring GPS process)
|
// for each datablock, check that the process can log (ignoring GPS process)
|
||||||
|
@ -48,7 +48,7 @@ public class DBSchemaWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PamTableDefinition tableDef = logging.getTableDefinition();
|
EmptyTableDefinition tableDef = logging.getTableDefinition();
|
||||||
tableDef = logging.getBaseTableDefinition();
|
tableDef = logging.getBaseTableDefinition();
|
||||||
|
|
||||||
if (tableDef instanceof PamTableDefinition) {
|
if (tableDef instanceof PamTableDefinition) {
|
||||||
@ -63,13 +63,14 @@ public class DBSchemaWriter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportDatabaseSchema(File outputFolder, PamDataBlock dataBlock, SQLLogging logging, PamTableDefinition tableDef) {
|
/**
|
||||||
|
* Generate an xml schema for a datablock.
|
||||||
/**
|
* @param dataBlock
|
||||||
* write a parent item, e.g. if tableDef is a sub class of PamTableDefinition
|
* @param logging
|
||||||
*/
|
* @param tableDef
|
||||||
// String parentName = writeParentTableSchema(outputFolder, dataBlock, tableDef);
|
* @return
|
||||||
|
*/
|
||||||
|
public Document generateDatabaseSchema(PamDataBlock dataBlock, SQLLogging logging, EmptyTableDefinition tableDef) {
|
||||||
String tableName = tableDef.getTableName();
|
String tableName = tableDef.getTableName();
|
||||||
Document doc = PamUtils.XMLUtils.createBlankDoc();
|
Document doc = PamUtils.XMLUtils.createBlankDoc();
|
||||||
Element schemaEl = doc.createElement("xs:schema");
|
Element schemaEl = doc.createElement("xs:schema");
|
||||||
@ -95,7 +96,20 @@ public class DBSchemaWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportDatabaseSchema(File outputFolder, PamDataBlock dataBlock, SQLLogging logging, EmptyTableDefinition tableDef) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* write a parent item, e.g. if tableDef is a sub class of PamTableDefinition
|
||||||
|
*/
|
||||||
|
// String parentName = writeParentTableSchema(outputFolder, dataBlock, tableDef);
|
||||||
|
|
||||||
|
Document doc = generateDatabaseSchema(dataBlock, logging, tableDef);
|
||||||
|
|
||||||
|
String tableName = tableDef.getTableName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File outputFile = new File(outputFolder, tableName+".xsd");
|
File outputFile = new File(outputFolder, tableName+".xsd");
|
||||||
XMLUtils.writeToFile(doc, outputFile);
|
XMLUtils.writeToFile(doc, outputFile);
|
||||||
|
@ -9,7 +9,7 @@ import PamguardMVC.PamDataUnit;
|
|||||||
* @author Doug Gillespie
|
* @author Doug Gillespie
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract public class DbSpecial extends SQLLogging{
|
abstract public class DbSpecial extends SQLLogging {
|
||||||
|
|
||||||
private DBControl dbControl;
|
private DBControl dbControl;
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ public class EmptyTableDefinition implements Cloneable {
|
|||||||
* @param tableName
|
* @param tableName
|
||||||
* @return reference to the database deinition if it exists, or null
|
* @return reference to the database deinition if it exists, or null
|
||||||
*/
|
*/
|
||||||
static PamTableDefinition findTableDefinition(String tableName) {
|
static EmptyTableDefinition findTableDefinition(String tableName) {
|
||||||
String searchName = EmptyTableDefinition.deblankString(tableName);
|
String searchName = EmptyTableDefinition.deblankString(tableName);
|
||||||
SQLLogging log = SQLLogging.findLogger(searchName);
|
SQLLogging log = SQLLogging.findLogger(searchName);
|
||||||
if (log == null) return null;
|
if (log == null) return null;
|
||||||
@ -389,6 +389,15 @@ public class EmptyTableDefinition implements Cloneable {
|
|||||||
this.updatePolicy = updatePolicy;
|
this.updatePolicy = updatePolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PamConnection getCheckedConnection() {
|
||||||
|
return checkedConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckedConnection(PamConnection checkedConnection) {
|
||||||
|
this.checkedConnection = checkedConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EmptyTableDefinition clone() {
|
protected EmptyTableDefinition clone() {
|
||||||
try {
|
try {
|
||||||
|
@ -23,7 +23,7 @@ import PamUtils.PamCalendar;
|
|||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions for writing Pamguard Settings into any database as character data
|
* Functions for writing serialised Pamguard Settings into any database as character data
|
||||||
* Runs at DAQ start, goes through the settings manager list and for each
|
* Runs at DAQ start, goes through the settings manager list and for each
|
||||||
* set of settings, it serialises the settings data into a binary array, this
|
* set of settings, it serialises the settings data into a binary array, this
|
||||||
* is then converted from binary data to 6 bit ascii data (using the character set
|
* is then converted from binary data to 6 bit ascii data (using the character set
|
||||||
@ -185,6 +185,7 @@ public class LogSettings extends DbSpecial {
|
|||||||
DeserialisationWarning dsWarning = new DeserialisationWarning(getDbControl().getDatabaseName());
|
DeserialisationWarning dsWarning = new DeserialisationWarning(getDbControl().getDatabaseName());
|
||||||
|
|
||||||
SQLTypes sqlTypes = con.getSqlTypes();
|
SQLTypes sqlTypes = con.getSqlTypes();
|
||||||
|
|
||||||
boolean haveData;
|
boolean haveData;
|
||||||
if (result != null) try {
|
if (result != null) try {
|
||||||
haveData = result.next();
|
haveData = result.next();
|
||||||
@ -193,7 +194,7 @@ public class LogSettings extends DbSpecial {
|
|||||||
// transfer data back into the tableItems store.
|
// transfer data back into the tableItems store.
|
||||||
transferDataFromResult(sqlTypes, result);
|
transferDataFromResult(sqlTypes, result);
|
||||||
|
|
||||||
tableItem = getTableDefinition().getTimeStampItem();
|
tableItem = tableDef.getTimeStampItem();
|
||||||
// timestamp = (Timestamp) tableItem.getTimestampValue();
|
// timestamp = (Timestamp) tableItem.getTimestampValue();
|
||||||
timeMillis = sqlTypes.millisFromTimeStamp(tableItem.getValue());
|
timeMillis = sqlTypes.millisFromTimeStamp(tableItem.getValue());
|
||||||
|
|
||||||
|
75
src/generalDatabase/LogXMLDataUnit.java
Normal file
75
src/generalDatabase/LogXMLDataUnit.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package generalDatabase;
|
||||||
|
|
||||||
|
import PamController.PamSettings;
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* simple data unit for use with the LogXMLSettings class
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LogXMLDataUnit extends PamDataUnit {
|
||||||
|
|
||||||
|
private long processTime;
|
||||||
|
private PamSettings pamSettings;
|
||||||
|
private String xml;
|
||||||
|
private Long dataEnd, processEnd;
|
||||||
|
|
||||||
|
public LogXMLDataUnit(long timeMilliseconds, long processTime, PamSettings pamSettings, String xml) {
|
||||||
|
super(timeMilliseconds);
|
||||||
|
this.processTime = processTime;
|
||||||
|
this.pamSettings = pamSettings;
|
||||||
|
this.xml = xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dataEnd
|
||||||
|
*/
|
||||||
|
public Long getDataEnd() {
|
||||||
|
return dataEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dataEnd the dataEnd to set
|
||||||
|
*/
|
||||||
|
public void setDataEnd(Long dataEnd) {
|
||||||
|
this.dataEnd = dataEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the processEnd
|
||||||
|
*/
|
||||||
|
public Long getProcessEnd() {
|
||||||
|
return processEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param processEnd the processEnd to set
|
||||||
|
*/
|
||||||
|
public void setProcessEnd(Long processEnd) {
|
||||||
|
this.processEnd = processEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the processTime
|
||||||
|
*/
|
||||||
|
public long getProcessTime() {
|
||||||
|
return processTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the pamSettings
|
||||||
|
*/
|
||||||
|
public PamSettings getPamSettings() {
|
||||||
|
return pamSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the xml
|
||||||
|
*/
|
||||||
|
public String getXml() {
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
123
src/generalDatabase/LogXMLSettings.java
Normal file
123
src/generalDatabase/LogXMLSettings.java
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
package generalDatabase;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
import PamController.PamControlledUnit;
|
||||||
|
import PamController.PamController;
|
||||||
|
import PamController.PamSettings;
|
||||||
|
import PamController.PamguardVersionInfo;
|
||||||
|
import PamController.settings.output.xml.PamguardXMLWriter;
|
||||||
|
import PamUtils.PamCalendar;
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
/**
|
||||||
|
* 2022 Additional say of saving settings for each module into the database in more human readable
|
||||||
|
* XML format. <p>
|
||||||
|
* In other ways, similar to LogSettings which saves serialised Java. This will write a line
|
||||||
|
* per module. A main difference is that on pamStop it will update the end time for each line, so
|
||||||
|
* that we have a record of analysis effort for each module. Will therefore need to store the last
|
||||||
|
* index of the entry for each module, so that we can update the appropriate row.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LogXMLSettings extends DbSpecial {
|
||||||
|
|
||||||
|
private XMLSettingsTableDefinition xmlTableDef;
|
||||||
|
|
||||||
|
private HashMap<String, LogXMLDataUnit> moduleRows;
|
||||||
|
|
||||||
|
private PamguardXMLWriter xmlWriter;
|
||||||
|
|
||||||
|
public LogXMLSettings(DBControl dbControl) {
|
||||||
|
super(dbControl);
|
||||||
|
xmlTableDef = new XMLSettingsTableDefinition("Module Effort");
|
||||||
|
setTableDefinition(xmlTableDef);
|
||||||
|
moduleRows = new HashMap<>();
|
||||||
|
xmlWriter = PamguardXMLWriter.getXMLWriter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pamStart(PamConnection con) {
|
||||||
|
long time = PamCalendar.getTimeInMillis();
|
||||||
|
saveModuleSettings(con, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pamStop(PamConnection con) {
|
||||||
|
long time = PamCalendar.getTimeInMillis();
|
||||||
|
updateModuleSettings(con, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveModuleSettings(PamConnection con, long dataTime) {
|
||||||
|
int n = PamController.getInstance().getNumControlledUnits();
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
saveModuleSettings(con, dataTime, now, PamController.getInstance().getControlledUnit(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveModuleSettings(PamConnection con, long dataTime, long now, PamControlledUnit controlledUnit) {
|
||||||
|
if (controlledUnit instanceof PamSettings == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PamSettings pamSettings = (PamSettings) controlledUnit;
|
||||||
|
Serializable settings = pamSettings.getSettingsReference();
|
||||||
|
Document doc = xmlWriter.writeOneModule(pamSettings, dataTime);
|
||||||
|
String xmlString = xmlWriter.getAsString(doc, true);
|
||||||
|
LogXMLDataUnit logXMLDataUnit = new LogXMLDataUnit(dataTime, now, pamSettings, xmlString);
|
||||||
|
|
||||||
|
logData(logXMLDataUnit);
|
||||||
|
int dbIndex = logXMLDataUnit.getDatabaseIndex();
|
||||||
|
moduleRows.put(getModuleHash(pamSettings), logXMLDataUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateModuleSettings(PamConnection con, long dataTime) {
|
||||||
|
int n = PamController.getInstance().getNumControlledUnits();
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
updateModuleSettings(con, dataTime, now, PamController.getInstance().getControlledUnit(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateModuleSettings(PamConnection con, long dataTime, long now, PamControlledUnit controlledUnit) {
|
||||||
|
if (controlledUnit instanceof PamSettings == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PamSettings pamSettings = (PamSettings) controlledUnit;
|
||||||
|
LogXMLDataUnit logXMLDataUnit = moduleRows.get(getModuleHash(pamSettings));
|
||||||
|
if (logXMLDataUnit == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logXMLDataUnit.setDataEnd(dataTime);
|
||||||
|
logXMLDataUnit.setProcessEnd(now);
|
||||||
|
reLogData(con, logXMLDataUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getModuleHash(PamSettings pamSettings) {
|
||||||
|
if (pamSettings == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return pamSettings.getUnitName()+pamSettings.getUnitType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTableData(SQLTypes sqlTypes, PamDataUnit pamDataUnit) {
|
||||||
|
LogXMLDataUnit logXMLDataUnit = (LogXMLDataUnit) pamDataUnit;
|
||||||
|
PamSettings pamSettings = logXMLDataUnit.getPamSettings();
|
||||||
|
|
||||||
|
xmlTableDef.getDataStart().setValue(sqlTypes.getTimeStamp(pamDataUnit.getTimeMilliseconds()));
|
||||||
|
xmlTableDef.getDataEnd().setValue(sqlTypes.getTimeStamp(logXMLDataUnit.getDataEnd()));
|
||||||
|
xmlTableDef.getProcessStart().setValue(sqlTypes.getTimeStamp(logXMLDataUnit.getProcessTime()));
|
||||||
|
xmlTableDef.getProcessEnd().setValue(sqlTypes.getTimeStamp(logXMLDataUnit.getProcessEnd()));
|
||||||
|
xmlTableDef.getName().setValue(pamSettings.getUnitName());
|
||||||
|
xmlTableDef.getType().setValue(pamSettings.getUnitType());
|
||||||
|
xmlTableDef.getPamGuardVersion().setValue(PamguardVersionInfo.version);
|
||||||
|
xmlTableDef.getSettingsVersion().setValue(pamSettings.getSettingsVersion());
|
||||||
|
xmlTableDef.getXmlSettings().setValue(logXMLDataUnit.getXml());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -192,14 +192,7 @@ public class PamTableDefinition extends EmptyTableDefinition implements Cloneabl
|
|||||||
public PamTableItem getUidItem() {
|
public PamTableItem getUidItem() {
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
public PamConnection getCheckedConnection() {
|
|
||||||
return checkedConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCheckedConnection(PamConnection checkedConnection) {
|
|
||||||
this.checkedConnection = checkedConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PamTableItem getUpdateReference() {
|
public PamTableItem getUpdateReference() {
|
||||||
return updateReference;
|
return updateReference;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ public class PamTableItem implements Cloneable {
|
|||||||
* column for use in cross referencing.
|
* column for use in cross referencing.
|
||||||
*/
|
*/
|
||||||
public static PamTableItem findTableItem(String tableName, String columnName) {
|
public static PamTableItem findTableItem(String tableName, String columnName) {
|
||||||
PamTableDefinition tableDef = EmptyTableDefinition.
|
EmptyTableDefinition tableDef = EmptyTableDefinition.
|
||||||
findTableDefinition(EmptyTableDefinition.deblankString(tableName));
|
findTableDefinition(EmptyTableDefinition.deblankString(tableName));
|
||||||
if (tableDef == null) return null;
|
if (tableDef == null) return null;
|
||||||
return tableDef.findTableItem(EmptyTableDefinition.deblankString(columnName));
|
return tableDef.findTableItem(EmptyTableDefinition.deblankString(columnName));
|
||||||
|
@ -92,7 +92,7 @@ public abstract class SQLLogging {
|
|||||||
* Reference to the table definition object.
|
* Reference to the table definition object.
|
||||||
* This MUST be set from within the concrete logging class.
|
* This MUST be set from within the concrete logging class.
|
||||||
*/
|
*/
|
||||||
private PamTableDefinition pamTableDefinition;
|
private EmptyTableDefinition pamTableDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More and more data blocks are starting to use annotations, which require
|
* More and more data blocks are starting to use annotations, which require
|
||||||
@ -102,7 +102,7 @@ public abstract class SQLLogging {
|
|||||||
* table definition is set, so that it can be got and modified by the
|
* table definition is set, so that it can be got and modified by the
|
||||||
* annotation handler shortly after the main table is created.
|
* annotation handler shortly after the main table is created.
|
||||||
*/
|
*/
|
||||||
private PamTableDefinition baseTableDefinition;
|
private EmptyTableDefinition baseTableDefinition;
|
||||||
|
|
||||||
// private long selectT1, selectT2;
|
// private long selectT1, selectT2;
|
||||||
private PamViewParameters currentViewParameters;
|
private PamViewParameters currentViewParameters;
|
||||||
@ -190,7 +190,7 @@ public abstract class SQLLogging {
|
|||||||
ArrayList<PamDataBlock> blockList = PamController.getInstance()
|
ArrayList<PamDataBlock> blockList = PamController.getInstance()
|
||||||
.getDataBlocks();
|
.getDataBlocks();
|
||||||
SQLLogging logger;
|
SQLLogging logger;
|
||||||
PamTableDefinition tableDef;
|
EmptyTableDefinition tableDef;
|
||||||
for (int i = 0; i < blockList.size(); i++) {
|
for (int i = 0; i < blockList.size(); i++) {
|
||||||
if ((logger = blockList.get(i).getLogging()) != null) {
|
if ((logger = blockList.get(i).getLogging()) != null) {
|
||||||
tableDef = logger.getTableDefinition();
|
tableDef = logger.getTableDefinition();
|
||||||
@ -234,7 +234,7 @@ public abstract class SQLLogging {
|
|||||||
* @return a Pamguard database table definition object
|
* @return a Pamguard database table definition object
|
||||||
* @see PamTableDefinition
|
* @see PamTableDefinition
|
||||||
*/
|
*/
|
||||||
public final PamTableDefinition getTableDefinition() {
|
public final EmptyTableDefinition getTableDefinition() {
|
||||||
return pamTableDefinition;
|
return pamTableDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ public abstract class SQLLogging {
|
|||||||
*
|
*
|
||||||
* @param pamTableDefinition PamTableDefinition to set
|
* @param pamTableDefinition PamTableDefinition to set
|
||||||
*/
|
*/
|
||||||
public void setTableDefinition(PamTableDefinition pamTableDefinition) {
|
public void setTableDefinition(EmptyTableDefinition pamTableDefinition) {
|
||||||
this.pamTableDefinition = pamTableDefinition;
|
this.pamTableDefinition = pamTableDefinition;
|
||||||
if (baseTableDefinition == null && pamTableDefinition != null) {
|
if (baseTableDefinition == null && pamTableDefinition != null) {
|
||||||
baseTableDefinition = pamTableDefinition.clone();
|
baseTableDefinition = pamTableDefinition.clone();
|
||||||
@ -293,37 +293,42 @@ public abstract class SQLLogging {
|
|||||||
* @param superDetection
|
* @param superDetection
|
||||||
*/
|
*/
|
||||||
protected void fillTableData(SQLTypes sqlTypes, PamDataUnit pamDataUnit, PamDataUnit superDetection) {
|
protected void fillTableData(SQLTypes sqlTypes, PamDataUnit pamDataUnit, PamDataUnit superDetection) {
|
||||||
|
|
||||||
|
EmptyTableDefinition emptyTableDef = getTableDefinition();
|
||||||
|
|
||||||
PamTableDefinition tableDef = getTableDefinition();
|
|
||||||
PamTableItem tableItem;
|
PamTableItem tableItem;
|
||||||
|
|
||||||
tableDef.getIndexItem().setValue(pamDataUnit.getDatabaseIndex());
|
emptyTableDef.getIndexItem().setValue(pamDataUnit.getDatabaseIndex());
|
||||||
/*
|
|
||||||
* All tables have a timestamp near the front of the table. And all data
|
if (emptyTableDef instanceof PamTableDefinition) {
|
||||||
* units have a time in milliseconds, so always fill this in !
|
PamTableDefinition tableDef = (PamTableDefinition) emptyTableDef;
|
||||||
*/
|
/*
|
||||||
tableDef.getTimeStampItem().setValue(
|
* All tables have a timestamp near the front of the table. And all data
|
||||||
sqlTypes.getTimeStamp(pamDataUnit.getTimeMilliseconds()));
|
* units have a time in milliseconds, so always fill this in !
|
||||||
|
*/
|
||||||
|
tableDef.getTimeStampItem().setValue(
|
||||||
|
sqlTypes.getTimeStamp(pamDataUnit.getTimeMilliseconds()));
|
||||||
|
|
||||||
tableDef.getTimeStampMillis().setValue((int) (pamDataUnit.getTimeMilliseconds()%1000));
|
tableDef.getTimeStampMillis().setValue((int) (pamDataUnit.getTimeMilliseconds()%1000));
|
||||||
|
|
||||||
tableDef.getLocalTimeItem().setValue(sqlTypes.getLocalTimeStamp(pamDataUnit.getTimeMilliseconds()));
|
tableDef.getLocalTimeItem().setValue(sqlTypes.getLocalTimeStamp(pamDataUnit.getTimeMilliseconds()));
|
||||||
|
|
||||||
tableDef.getPCTimeItem().setValue(sqlTypes.getTimeStamp(System.currentTimeMillis()));
|
tableDef.getPCTimeItem().setValue(sqlTypes.getTimeStamp(System.currentTimeMillis()));
|
||||||
|
|
||||||
tableDef.getUidItem().setValue(pamDataUnit.getUID());
|
tableDef.getUidItem().setValue(pamDataUnit.getUID());
|
||||||
|
|
||||||
tableDef.getChannelBitmap().setValue(pamDataUnit.getChannelBitmap());
|
tableDef.getChannelBitmap().setValue(pamDataUnit.getChannelBitmap());
|
||||||
|
|
||||||
tableDef.getSequenceBitmap().setValue(pamDataUnit.getSequenceBitmapObject());
|
tableDef.getSequenceBitmap().setValue(pamDataUnit.getSequenceBitmapObject());
|
||||||
|
|
||||||
if (tableDef.getUpdateReference() != null) {
|
if (tableDef.getUpdateReference() != null) {
|
||||||
tableDef.getUpdateReference().setValue(pamDataUnit.getDatabaseIndex());
|
tableDef.getUpdateReference().setValue(pamDataUnit.getDatabaseIndex());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < tableDef.getTableItemCount(); i++) {
|
for (int i = 0; i < emptyTableDef.getTableItemCount(); i++) {
|
||||||
|
|
||||||
tableItem = tableDef.getTableItem(i);
|
tableItem = emptyTableDef.getTableItem(i);
|
||||||
// if (tableItem.isCounter()) {
|
// if (tableItem.isCounter()) {
|
||||||
// tableItem.setValue(1);
|
// tableItem.setValue(1);
|
||||||
// }
|
// }
|
||||||
@ -333,8 +338,8 @@ public abstract class SQLLogging {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tableDef instanceof PamSubtableDefinition) {
|
if (emptyTableDef instanceof PamSubtableDefinition) {
|
||||||
PamSubtableDefinition subTableDef = (PamSubtableDefinition) tableDef;
|
PamSubtableDefinition subTableDef = (PamSubtableDefinition) emptyTableDef;
|
||||||
fillSubTableData(subTableDef, pamDataUnit, superDetection);
|
fillSubTableData(subTableDef, pamDataUnit, superDetection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +530,7 @@ public abstract class SQLLogging {
|
|||||||
}
|
}
|
||||||
// now put some sql into the statement
|
// now put some sql into the statement
|
||||||
// if (resultSet == null) {
|
// if (resultSet == null) {
|
||||||
PamTableDefinition tableDef = getTableDefinition();
|
EmptyTableDefinition tableDef = getTableDefinition();
|
||||||
String sqlString = tableDef.getSQLSelectString(con.getSqlTypes());
|
String sqlString = tableDef.getSQLSelectString(con.getSqlTypes());
|
||||||
// sqlString = "select \"comment\" from userinput";
|
// sqlString = "select \"comment\" from userinput";
|
||||||
try {
|
try {
|
||||||
@ -1079,7 +1084,7 @@ public abstract class SQLLogging {
|
|||||||
|
|
||||||
public boolean transferDataFromResult(SQLTypes sqlTypes, ResultSet resultSet) {
|
public boolean transferDataFromResult(SQLTypes sqlTypes, ResultSet resultSet) {
|
||||||
|
|
||||||
PamTableDefinition tableDef = getTableDefinition();
|
EmptyTableDefinition tableDef = getTableDefinition();
|
||||||
PamTableItem tableItem;
|
PamTableItem tableItem;
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < tableDef.getTableItemCount(); i++) {
|
for (int i = 0; i < tableDef.getTableItemCount(); i++) {
|
||||||
@ -1090,17 +1095,20 @@ public abstract class SQLLogging {
|
|||||||
// Timestamp ts = (Timestamp) getTableDefinition().getTimeStampItem().getValue();
|
// Timestamp ts = (Timestamp) getTableDefinition().getTimeStampItem().getValue();
|
||||||
// Timestamp ts = getTableDefinition().getTimeStampItem().getTimestampValue();
|
// Timestamp ts = getTableDefinition().getTimeStampItem().getTimestampValue();
|
||||||
// lastTime = sqlTypes.millisFromTimeStamp(ts);
|
// lastTime = sqlTypes.millisFromTimeStamp(ts);
|
||||||
lastTime = sqlTypes.millisFromTimeStamp(getTableDefinition().getTimeStampItem().getValue());
|
|
||||||
if (lastTime%1000 == 0) {
|
|
||||||
// some databases may have stored the milliseconds, in which
|
|
||||||
// case this next bit is redundant.
|
|
||||||
lastTime += getTableDefinition().getTimeStampMillis().getIntegerValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
lastLoadIndex = getTableDefinition().getIndexItem().getIntegerValue();
|
lastLoadIndex = getTableDefinition().getIndexItem().getIntegerValue();
|
||||||
lastLoadUID = getTableDefinition().getUidItem().getLongObject();
|
if (tableDef instanceof PamTableDefinition) {
|
||||||
lastChannelBitmap = getTableDefinition().getChannelBitmap().getIntegerValue();
|
PamTableDefinition pamTableDef = (PamTableDefinition) tableDef;
|
||||||
lastSequenceBitmap = getTableDefinition().getSequenceBitmap().getIntegerObject();
|
lastTime = sqlTypes.millisFromTimeStamp(pamTableDef.getTimeStampItem().getValue());
|
||||||
|
if (lastTime%1000 == 0) {
|
||||||
|
// some databases may have stored the milliseconds, in which
|
||||||
|
// case this next bit is redundant.
|
||||||
|
lastTime += pamTableDef.getTimeStampMillis().getIntegerValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastLoadUID = pamTableDef.getUidItem().getLongObject();
|
||||||
|
lastChannelBitmap = pamTableDef.getChannelBitmap().getIntegerValue();
|
||||||
|
lastSequenceBitmap = pamTableDef.getSequenceBitmap().getIntegerObject();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -1757,7 +1765,7 @@ public abstract class SQLLogging {
|
|||||||
* annotation handler shortly after the main table is created.
|
* annotation handler shortly after the main table is created.
|
||||||
* @return the baseTableDefinition
|
* @return the baseTableDefinition
|
||||||
*/
|
*/
|
||||||
public PamTableDefinition getBaseTableDefinition() {
|
public EmptyTableDefinition getBaseTableDefinition() {
|
||||||
return baseTableDefinition;
|
return baseTableDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ public interface SQLLoggingAddon {
|
|||||||
* Add a load of columns to an existing table definition
|
* Add a load of columns to an existing table definition
|
||||||
* @param pamTableDefinition
|
* @param pamTableDefinition
|
||||||
*/
|
*/
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition);
|
public void addTableItems(EmptyTableDefinition pamTableDefinition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save data - that is transfer data from the pamDataUnit to the data objects
|
* Save data - that is transfer data from the pamDataUnit to the data objects
|
||||||
@ -24,7 +24,7 @@ public interface SQLLoggingAddon {
|
|||||||
* @param pamDataUnit data unit
|
* @param pamDataUnit data unit
|
||||||
* @return true if successful
|
* @return true if successful
|
||||||
*/
|
*/
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load data - that is read data from the table definition and turn it into something sensible
|
* Load data - that is read data from the table definition and turn it into something sensible
|
||||||
@ -33,7 +33,7 @@ public interface SQLLoggingAddon {
|
|||||||
* @param pamDataUnit data unit
|
* @param pamDataUnit data unit
|
||||||
* @return true if successful
|
* @return true if successful
|
||||||
*/
|
*/
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a name for the SQLLogging Addon. this is used
|
* Get a name for the SQLLogging Addon. this is used
|
||||||
|
94
src/generalDatabase/XMLSettingsTableDefinition.java
Normal file
94
src/generalDatabase/XMLSettingsTableDefinition.java
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
package generalDatabase;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
|
import PamguardMVC.PamConstants;
|
||||||
|
|
||||||
|
public class XMLSettingsTableDefinition extends EmptyTableDefinition {
|
||||||
|
|
||||||
|
private PamTableItem dataStart, dataEnd, processStart, processEnd, type, name, pamGuardVersion, settingsVersion, xmlSettings;
|
||||||
|
|
||||||
|
public XMLSettingsTableDefinition(String tableName) {
|
||||||
|
super(tableName, SQLLogging.UPDATE_POLICY_WRITENEW);
|
||||||
|
pamTableItems.add(dataStart = new PamTableItem("Data Start", Types.TIMESTAMP, "Data start time"));
|
||||||
|
pamTableItems.add(dataEnd = new PamTableItem("Data End", Types.TIMESTAMP, "Data end time"));
|
||||||
|
pamTableItems.add(processStart = new PamTableItem("Process Start", Types.TIMESTAMP, "Process start time"));
|
||||||
|
pamTableItems.add(processEnd = new PamTableItem("Process End", Types.TIMESTAMP, "Process end time"));
|
||||||
|
addTableItem(type = new PamTableItem("unitType", Types.CHAR, PamConstants.MAX_ITEM_NAME_LENGTH));
|
||||||
|
addTableItem(name = new PamTableItem("unitName", Types.CHAR, PamConstants.MAX_ITEM_NAME_LENGTH));
|
||||||
|
addTableItem(pamGuardVersion = new PamTableItem("PAMGuardVersion", Types.INTEGER));
|
||||||
|
addTableItem(settingsVersion = new PamTableItem("SettingsVersion", Types.INTEGER));
|
||||||
|
addTableItem(xmlSettings = new PamTableItem("XMLSettings", Types.VARCHAR));
|
||||||
|
setUseCheatIndexing(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dataStart
|
||||||
|
*/
|
||||||
|
public PamTableItem getDataStart() {
|
||||||
|
return dataStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dataEnd
|
||||||
|
*/
|
||||||
|
public PamTableItem getDataEnd() {
|
||||||
|
return dataEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the processStart
|
||||||
|
*/
|
||||||
|
public PamTableItem getProcessStart() {
|
||||||
|
return processStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the processEnd
|
||||||
|
*/
|
||||||
|
public PamTableItem getProcessEnd() {
|
||||||
|
return processEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the type
|
||||||
|
*/
|
||||||
|
public PamTableItem getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public PamTableItem getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the pamGuardVersion
|
||||||
|
*/
|
||||||
|
public PamTableItem getPamGuardVersion() {
|
||||||
|
return pamGuardVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the settingsVersion
|
||||||
|
*/
|
||||||
|
public PamTableItem getSettingsVersion() {
|
||||||
|
return settingsVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the xmlSettings
|
||||||
|
*/
|
||||||
|
public PamTableItem getXmlSettings() {
|
||||||
|
return xmlSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
187
src/generalDatabase/parameterstore/ParameterDatabaseStore.java
Normal file
187
src/generalDatabase/parameterstore/ParameterDatabaseStore.java
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
package generalDatabase.parameterstore;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import PamModel.parametermanager.ManagedParameters;
|
||||||
|
import PamModel.parametermanager.PamParameterData;
|
||||||
|
import PamModel.parametermanager.PamParameterSet;
|
||||||
|
import generalDatabase.DBControlUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
|
import generalDatabase.PamConnection;
|
||||||
|
import generalDatabase.PamTableItem;
|
||||||
|
import generalDatabase.SQLTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store parameters from a managed parameter set in the PAMGuard database. These go into a dead simple table, which has
|
||||||
|
* two columns. The first is a name, the second a string value. Each parameter can only appear once.
|
||||||
|
* This works with ManagedParameters using the same names and field names that go into the xml output.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ParameterDatabaseStore {
|
||||||
|
|
||||||
|
|
||||||
|
private EmptyTableDefinition tableDef;
|
||||||
|
private PamTableItem nameItem, dataItem;
|
||||||
|
|
||||||
|
public ParameterDatabaseStore(String tableName) {
|
||||||
|
tableDef = new EmptyTableDefinition(tableName);
|
||||||
|
tableDef.addTableItem(nameItem = new PamTableItem("ParameterName", Types.VARCHAR));
|
||||||
|
tableDef.addTableItem(dataItem = new PamTableItem("Value", Types.VARCHAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean saveParameterSet(ManagedParameters managedParameters) {
|
||||||
|
if (managedParameters == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return saveParameterSet(managedParameters.getClass().getSimpleName(), managedParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean saveParameterSet(String name, ManagedParameters managedParameters) {
|
||||||
|
DBControlUnit dbControl = DBControlUnit.findDatabaseControl();
|
||||||
|
if (dbControl == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PamConnection con = dbControl.getConnection();
|
||||||
|
if (checkTable(con) == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String prefix;
|
||||||
|
if (name == null) {
|
||||||
|
prefix = "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prefix = name + ".";
|
||||||
|
}
|
||||||
|
PamParameterSet paramSet = managedParameters.getParameterSet();
|
||||||
|
Collection<PamParameterData> params = paramSet.getParameterCollection();
|
||||||
|
for (PamParameterData paramData : params) {
|
||||||
|
String paramName = paramData.getFieldName();
|
||||||
|
paramName = prefix + paramName;
|
||||||
|
Object data = null;
|
||||||
|
try {
|
||||||
|
data = paramData.getData();// .getField().get(managedParameters);
|
||||||
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// System.out.printf("Store param \"%s\" as \"%s\"\n", paramName, data);
|
||||||
|
saveToDatabase(con, paramName, data);
|
||||||
|
}
|
||||||
|
dbControl.commitChanges();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean saveToDatabase(PamConnection con, String name, Object data) {
|
||||||
|
int[] existing = findExistingRows(con, name);
|
||||||
|
boolean ok = true;
|
||||||
|
if (existing == null || existing.length == 0) {
|
||||||
|
ok |= newRecord(con, name, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok |= updateRecord(con, existing[0], name, data);
|
||||||
|
if (existing.length > 1) {
|
||||||
|
for (int i = 1; i < existing.length; i++) {
|
||||||
|
ok |= deleteDuplicateRow(con, existing[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] findExistingRows(PamConnection con, String name) {
|
||||||
|
/**
|
||||||
|
* Find existing rows with that name.
|
||||||
|
*/
|
||||||
|
int[] rows = new int[0];
|
||||||
|
if (con == null) {
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
String qStr = String.format("SELECT Id FROM %s WHERE %s='%s'", tableDef.getTableName(), nameItem.getName(), name);
|
||||||
|
try {
|
||||||
|
Statement stmt = con.getConnection().createStatement();
|
||||||
|
ResultSet res = stmt.executeQuery(qStr);
|
||||||
|
while (res.next()) {
|
||||||
|
int rowId = res.getInt(1);
|
||||||
|
rows = Arrays.copyOf(rows, rows.length+1);
|
||||||
|
rows[rows.length-1] = rowId;
|
||||||
|
}
|
||||||
|
res.close();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean newRecord(PamConnection con, String name, Object data) {
|
||||||
|
|
||||||
|
String insertStr = tableDef.getSQLInsertString(con.getSqlTypes());
|
||||||
|
try {
|
||||||
|
PreparedStatement stmt = con.getConnection().prepareStatement(insertStr);
|
||||||
|
stmt.setString(1, name);
|
||||||
|
if (data == null) {
|
||||||
|
stmt.setNull(2, Types.VARCHAR);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stmt.setString(2, data.toString());
|
||||||
|
}
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean updateRecord(PamConnection con, int iRow, String name, Object data) {
|
||||||
|
SQLTypes st = con.getSqlTypes();
|
||||||
|
String updateString = String.format("UPDATE %s SET %s = '%s' WHERE Id = %d", tableDef.getTableName(),
|
||||||
|
st.formatColumnName(dataItem.getName()), data, iRow);
|
||||||
|
|
||||||
|
try {
|
||||||
|
PreparedStatement stmt = con.getConnection().prepareStatement(updateString);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean deleteDuplicateRow(PamConnection con, int rowId) {
|
||||||
|
|
||||||
|
String delStr = String.format("DELETE FROM %s WHERE Id=%d", tableDef.getTableName(), rowId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
PreparedStatement stmt = con.getConnection().prepareStatement(delStr);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkTable(PamConnection con) {
|
||||||
|
DBControlUnit dbControl = DBControlUnit.findDatabaseControl();
|
||||||
|
if (dbControl == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
dbControl.commitChanges();
|
||||||
|
return dbControl.getDbProcess().checkTable(tableDef);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import java.sql.Types;
|
|||||||
import PamDetection.AcousticSQLLogging;
|
import PamDetection.AcousticSQLLogging;
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLTypes;
|
import generalDatabase.SQLTypes;
|
||||||
@ -22,7 +23,7 @@ public class GPLLogging extends AcousticSQLLogging {
|
|||||||
super(gplDetectionBlock, gplControlledUnit.getUnitName() + " Detections");
|
super(gplDetectionBlock, gplControlledUnit.getUnitName() + " Detections");
|
||||||
this.gplControlledUnit = gplControlledUnit;
|
this.gplControlledUnit = gplControlledUnit;
|
||||||
|
|
||||||
PamTableDefinition pamTable = getTableDefinition();
|
EmptyTableDefinition pamTable = getTableDefinition();
|
||||||
pamTable.addTableItem(peakValue = new PamTableItem("PeakValue", Types.REAL));
|
pamTable.addTableItem(peakValue = new PamTableItem("PeakValue", Types.REAL));
|
||||||
pamTable.addTableItem(contourArea = new PamTableItem("ContourArea", Types.REAL));
|
pamTable.addTableItem(contourArea = new PamTableItem("ContourArea", Types.REAL));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package loc3d_Thode;
|
package loc3d_Thode;
|
||||||
|
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamDetectionLogging;
|
import generalDatabase.PamDetectionLogging;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
@ -17,7 +18,6 @@ public class TowedArray3DSQLLogging extends PamDetectionLogging {
|
|||||||
|
|
||||||
TowedArray3DController towedArray3DController;
|
TowedArray3DController towedArray3DController;
|
||||||
|
|
||||||
PamTableDefinition tableDefinition;
|
|
||||||
|
|
||||||
PamTableItem dateItem, range_boat_Item, range_f_Item, range_r_Item, depthItem, azi_boat_Item,azi_f_Item, azi_r_Item, tdd_Item,
|
PamTableItem dateItem, range_boat_Item, range_f_Item, range_r_Item, depthItem, azi_boat_Item,azi_f_Item, azi_r_Item, tdd_Item,
|
||||||
bearing_f_Item,bearing_r_Item, tds_f_Item, tds_r_Item, za_f_Item, za_r_Item;
|
bearing_f_Item,bearing_r_Item, tds_f_Item, tds_r_Item, za_f_Item, za_r_Item;
|
||||||
@ -34,14 +34,14 @@ public class TowedArray3DSQLLogging extends PamDetectionLogging {
|
|||||||
this.towedArray3DController = towedArray3DController;
|
this.towedArray3DController = towedArray3DController;
|
||||||
|
|
||||||
// create the table definition.
|
// create the table definition.
|
||||||
tableDefinition = createTableDefinition();
|
EmptyTableDefinition tableDefinition = createTableDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PamTableDefinition createTableDefinition() {
|
public EmptyTableDefinition createTableDefinition() {
|
||||||
|
|
||||||
|
|
||||||
// PamTableDefinition tableDef = new PamTableDefinition(towedArray3DController.getUnitName(), getUpdatePolicy());
|
// PamTableDefinition tableDef = new PamTableDefinition(towedArray3DController.getUnitName(), getUpdatePolicy());
|
||||||
PamTableDefinition tableDef = super.getTableDefinition();
|
EmptyTableDefinition tableDef = super.getTableDefinition();
|
||||||
tableDef.setUpdatePolicy(SQLLogging.UPDATE_POLICY_WRITENEW);
|
tableDef.setUpdatePolicy(SQLLogging.UPDATE_POLICY_WRITENEW);
|
||||||
|
|
||||||
// PamTableItem tableItem;
|
// PamTableItem tableItem;
|
||||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
import PamUtils.PamArrayUtils;
|
import PamUtils.PamArrayUtils;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
import PamguardMVC.debug.Debug;
|
import PamguardMVC.debug.Debug;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -49,7 +50,7 @@ public class MatchedClickAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(typeTable);
|
pamTableDefinition.addTableItem(typeTable);
|
||||||
pamTableDefinition.addTableItem(mtThresholdsTable);
|
pamTableDefinition.addTableItem(mtThresholdsTable);
|
||||||
pamTableDefinition.addTableItem(mtMatchCorrsTable);
|
pamTableDefinition.addTableItem(mtMatchCorrsTable);
|
||||||
@ -58,7 +59,7 @@ public class MatchedClickAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
|
|
||||||
MatchedClickAnnotation clickAnnotation =
|
MatchedClickAnnotation clickAnnotation =
|
||||||
(MatchedClickAnnotation) pamDataUnit.findDataAnnotation(MatchedClickAnnotation.class);
|
(MatchedClickAnnotation) pamDataUnit.findDataAnnotation(MatchedClickAnnotation.class);
|
||||||
@ -95,7 +96,7 @@ public class MatchedClickAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
|
|
||||||
String threshold = mtThresholdsTable.getDeblankedStringValue();
|
String threshold = mtThresholdsTable.getDeblankedStringValue();
|
||||||
String mtMatchCorrs = mtMatchCorrsTable.getDeblankedStringValue();
|
String mtMatchCorrs = mtMatchCorrsTable.getDeblankedStringValue();
|
||||||
|
44
src/metadata/MetaDataContol.java
Normal file
44
src/metadata/MetaDataContol.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package metadata;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
|
import PamController.PamControlledUnit;
|
||||||
|
import PamModel.parametermanager.ParameterSetManager;
|
||||||
|
import generalDatabase.parameterstore.ParameterDatabaseStore;
|
||||||
|
import metadata.deployment.DeploymentData;
|
||||||
|
|
||||||
|
public class MetaDataContol extends PamControlledUnit {
|
||||||
|
|
||||||
|
public static final String unitType = "Meta Data";
|
||||||
|
|
||||||
|
private DeploymentData deploymentData = new DeploymentData();
|
||||||
|
|
||||||
|
private ParameterSetManager<DeploymentData> deploymentSetManager;
|
||||||
|
|
||||||
|
|
||||||
|
public MetaDataContol(String unitName) {
|
||||||
|
super(unitType, unitName);
|
||||||
|
deploymentSetManager = new ParameterSetManager<DeploymentData>(deploymentData, "Deployment Data");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JMenuItem createFileMenu(JFrame parentFrame) {
|
||||||
|
return deploymentSetManager.getMenuItem(parentFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the deploymentData
|
||||||
|
*/
|
||||||
|
public DeploymentData getDeploymentData() {
|
||||||
|
return deploymentData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param deploymentData the deploymentData to set
|
||||||
|
*/
|
||||||
|
public void setDeploymentData(DeploymentData deploymentData) {
|
||||||
|
this.deploymentData = deploymentData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
266
src/metadata/deployment/DeploymentData.java
Normal file
266
src/metadata/deployment/DeploymentData.java
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
package metadata.deployment;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import PamModel.parametermanager.FieldNotFoundException;
|
||||||
|
import PamModel.parametermanager.ManagedParameters;
|
||||||
|
import PamModel.parametermanager.PamParameterSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to hold Deployment data in a form consistent with the ANSI PAM
|
||||||
|
* Standard. This has been keep separate from the Tethys Interface to keep it
|
||||||
|
* easy to benefit from these data without using Tethys itself.
|
||||||
|
*
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DeploymentData implements Serializable, Cloneable, ManagedParameters {
|
||||||
|
|
||||||
|
public static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String that uniquely identifies this deployment.
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of project associated with this deployment. Can be related to a
|
||||||
|
* geographic region, funding source, etc
|
||||||
|
*/
|
||||||
|
private String project;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deployment identifier, a number related to either the Nth deployment
|
||||||
|
* operation in a series of deployments or the Nth deployment at a specific
|
||||||
|
* site. This is different from Id which is unique across all deployments
|
||||||
|
*/
|
||||||
|
private int deploymentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alternative deployment description.
|
||||||
|
*/
|
||||||
|
private String deploymentAlias;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name for current location.
|
||||||
|
*/
|
||||||
|
private String site;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alternative names for the deployment location
|
||||||
|
*/
|
||||||
|
private String siteAliases;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of deployment cruise.
|
||||||
|
*/
|
||||||
|
private String cruise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On what platform is the instrument deployed? (e.g. mooring, tag)
|
||||||
|
*/
|
||||||
|
private String platform = "Unknown";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of geographic region.
|
||||||
|
*/
|
||||||
|
private String region;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrument type, e.g. HARP, EAR, Popup, DMON, etc.
|
||||||
|
*/
|
||||||
|
private String instrumentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrument identifier, e.g. serial number
|
||||||
|
*/
|
||||||
|
private String instrumentId;
|
||||||
|
|
||||||
|
public DeploymentData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DeploymentData clone() {
|
||||||
|
try {
|
||||||
|
return (DeploymentData) super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PamParameterSet getParameterSet() {
|
||||||
|
PamParameterSet ps = PamParameterSet.autoGenerate(this);
|
||||||
|
try {
|
||||||
|
ps.findParameterData("id").setInfo("Unique Id", null, "String that uniquely identifies this deployment", 128);
|
||||||
|
// ps.setOrder("id", 0);
|
||||||
|
ps.findParameterData("project").setInfo("Project Name", null, "Name of project associated with this deployment. Can be related to a geographic region, funding source, etc", 200);
|
||||||
|
ps.findParameterData("deploymentId").setInfo("Deployment Identifier", null, "Deployment identifier, a number related to either the Nth deployment operation in a series of deployments or the Nth deployment at a specific site. This is different from Id which is unique across all deployments");
|
||||||
|
ps.findParameterData("deploymentAlias").setInfo("Alternative deployment description", null, "Alternative deployment description", 20);
|
||||||
|
ps.findParameterData("site").setInfo("Site name", null, "Name for current location", 40);
|
||||||
|
ps.findParameterData("siteAliases").setInfo("Alternative site name", null, "Alternative site description", 40);
|
||||||
|
ps.findParameterData("cruise").setInfo("Deployment cruise", null, "Name of deployment cruise");
|
||||||
|
ps.findParameterData("platform").setInfo("Platform type", null, "On what platform is the instrument deployed? (e.g. mooring, tag)", 20);
|
||||||
|
ps.findParameterData("region").setInfo("Geographic Region", "", "Name of geographic region", 40);
|
||||||
|
} catch (FieldNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id the id to set
|
||||||
|
*/
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the project
|
||||||
|
*/
|
||||||
|
public String getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param project the project to set
|
||||||
|
*/
|
||||||
|
public void setProject(String project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the deploymentId
|
||||||
|
*/
|
||||||
|
public int getDeploymentId() {
|
||||||
|
return deploymentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param deploymentId the deploymentId to set
|
||||||
|
*/
|
||||||
|
public void setDeploymentId(int deploymentId) {
|
||||||
|
this.deploymentId = deploymentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the deplomentAlias
|
||||||
|
*/
|
||||||
|
public String getDeploymentAlias() {
|
||||||
|
return deploymentAlias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param deplomentAlias the deplomentAlias to set
|
||||||
|
*/
|
||||||
|
public void setDeploymentAlias(String deplomentAlias) {
|
||||||
|
this.deploymentAlias = deplomentAlias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the site
|
||||||
|
*/
|
||||||
|
public String getSite() {
|
||||||
|
return site;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param site the site to set
|
||||||
|
*/
|
||||||
|
public void setSite(String site) {
|
||||||
|
this.site = site;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the siteAliases
|
||||||
|
*/
|
||||||
|
public String getSiteAliases() {
|
||||||
|
return siteAliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param siteAliases the siteAliases to set
|
||||||
|
*/
|
||||||
|
public void setSiteAliases(String siteAliases) {
|
||||||
|
this.siteAliases = siteAliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the cruise
|
||||||
|
*/
|
||||||
|
public String getCruise() {
|
||||||
|
return cruise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cruise the cruise to set
|
||||||
|
*/
|
||||||
|
public void setCruise(String cruise) {
|
||||||
|
this.cruise = cruise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the platform
|
||||||
|
*/
|
||||||
|
public String getPlatform() {
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param platform the platform to set
|
||||||
|
*/
|
||||||
|
public void setPlatform(String platform) {
|
||||||
|
this.platform = platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the region
|
||||||
|
*/
|
||||||
|
public String getRegion() {
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param region the region to set
|
||||||
|
*/
|
||||||
|
public void setRegion(String region) {
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the instrumentType
|
||||||
|
*/
|
||||||
|
public String getInstrumentType() {
|
||||||
|
return instrumentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param instrumentType the instrumentType to set
|
||||||
|
*/
|
||||||
|
public void setInstrumentType(String instrumentType) {
|
||||||
|
this.instrumentType = instrumentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the instrumentId
|
||||||
|
*/
|
||||||
|
public String getInstrumentId() {
|
||||||
|
return instrumentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param instrumentId the instrumentId to set
|
||||||
|
*/
|
||||||
|
public void setInstrumentId(String instrumentId) {
|
||||||
|
this.instrumentId = instrumentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
40
src/metadata/deployment/QAData.java
Normal file
40
src/metadata/deployment/QAData.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package metadata.deployment;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import PamModel.parametermanager.ManagedParameters;
|
||||||
|
import PamModel.parametermanager.PamParameterSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Largely the content of the Tethys QualityAssurance schema
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class QAData implements Serializable, Cloneable, ManagedParameters {
|
||||||
|
|
||||||
|
public static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String objectives;
|
||||||
|
|
||||||
|
private String qaAbstract;
|
||||||
|
|
||||||
|
private String method;
|
||||||
|
|
||||||
|
private String responsibleName;
|
||||||
|
private String responsibleOrganisation;
|
||||||
|
private String responsiblePosition;
|
||||||
|
private String responsiblePhone;
|
||||||
|
private String responsibleAddress;
|
||||||
|
private String responsibleEmail;
|
||||||
|
|
||||||
|
public QAData() {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PamParameterSet getParameterSet() {
|
||||||
|
PamParameterSet ps = PamParameterSet.autoGenerate(this);
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,6 +3,7 @@ package nidaqdev.networkdaq;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -20,12 +21,12 @@ public class NIDaqLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
pamTableDefinition.addTableItem(crioTemperature);
|
pamTableDefinition.addTableItem(crioTemperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
Double lastTemp = niNetworkDaq.getLastTemperature();
|
Double lastTemp = niNetworkDaq.getLastTemperature();
|
||||||
if (lastTemp == null) {
|
if (lastTemp == null) {
|
||||||
crioTemperature.setValue(null);
|
crioTemperature.setValue(null);
|
||||||
@ -38,7 +39,7 @@ public class NIDaqLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package rawDeepLearningClassifier.logging;
|
package rawDeepLearningClassifier.logging;
|
||||||
|
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
import generalDatabase.SQLTypes;
|
import generalDatabase.SQLTypes;
|
||||||
@ -12,19 +13,19 @@ public class DLAnnotationSQL implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import PamDetection.AbstractLocalisation;
|
|||||||
import PamDetection.LocContents;
|
import PamDetection.LocContents;
|
||||||
import PamUtils.LatLong;
|
import PamUtils.LatLong;
|
||||||
import PamguardMVC.PamDataUnit;
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
import generalDatabase.SQLLoggingAddon;
|
import generalDatabase.SQLLoggingAddon;
|
||||||
@ -119,7 +120,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTableItems(PamTableDefinition pamTableDefinition) {
|
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
|
||||||
|
|
||||||
|
|
||||||
pamTableDefinition.addTableItem(modelName);
|
pamTableDefinition.addTableItem(modelName);
|
||||||
@ -146,7 +147,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
AbstractLocalisation tmResult = pamDataUnit.getLocalisation();
|
AbstractLocalisation tmResult = pamDataUnit.getLocalisation();
|
||||||
clearEverything();
|
clearEverything();
|
||||||
@ -218,7 +219,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean saveGroupLocalisation(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
private boolean saveGroupLocalisation(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit, GroupLocalisation groupLocalisation) {
|
PamDataUnit pamDataUnit, GroupLocalisation groupLocalisation) {
|
||||||
|
|
||||||
int nAmbiguities = groupLocalisation.getAmbiguityCount();
|
int nAmbiguities = groupLocalisation.getAmbiguityCount();
|
||||||
@ -239,7 +240,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean saveGroupLocalisation(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
private boolean saveGroupLocalisation(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit, int resultIndex, GroupLocResult tmResult) {
|
PamDataUnit pamDataUnit, int resultIndex, GroupLocResult tmResult) {
|
||||||
|
|
||||||
|
|
||||||
@ -323,7 +324,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit) {
|
PamDataUnit pamDataUnit) {
|
||||||
|
|
||||||
GroupLocalisation tml = new GroupLocalisation(pamDataUnit, null);
|
GroupLocalisation tml = new GroupLocalisation(pamDataUnit, null);
|
||||||
@ -341,7 +342,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GroupLocResult loadLocResult(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
|
private GroupLocResult loadLocResult(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
|
||||||
PamDataUnit pamDataUnit, GroupLocalisation tml, int resultIndex) {
|
PamDataUnit pamDataUnit, GroupLocalisation tml, int resultIndex) {
|
||||||
|
|
||||||
double latVal, longVal;
|
double latVal, longVal;
|
||||||
|
93
src/tethys/TethysControl.java
Normal file
93
src/tethys/TethysControl.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package tethys;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
|
import PamController.PamControlledUnit;
|
||||||
|
import PamController.PamController;
|
||||||
|
import PamguardMVC.PamDataBlock;
|
||||||
|
import nilus.Deployment;
|
||||||
|
import nilus.Deployment.Instrument;
|
||||||
|
import tethys.output.StreamExportParams;
|
||||||
|
import tethys.output.TethysExportParams;
|
||||||
|
import tethys.output.TethysExporter;
|
||||||
|
import tethys.output.swing.TethysExportDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick play with a simple system for outputting data to Tethys. At it's start
|
||||||
|
* this is simply going to offer a dialog and have a few functions which show how
|
||||||
|
* to access data within PAMGuard.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TethysControl extends PamControlledUnit {
|
||||||
|
|
||||||
|
public static final String unitType = "Tethys Interface";
|
||||||
|
public static String defaultName = "Tethys";
|
||||||
|
|
||||||
|
|
||||||
|
private TethysExportParams tethysExportParams = new TethysExportParams();
|
||||||
|
|
||||||
|
|
||||||
|
public TethysControl(String unitName) {
|
||||||
|
super(unitType, unitName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JMenuItem createFileMenu(JFrame parentFrame) {
|
||||||
|
JMenu tethysMenu = new JMenu("Tethys");
|
||||||
|
JMenuItem tethysExport = new JMenuItem("Export ...");
|
||||||
|
tethysMenu.add(tethysExport);
|
||||||
|
tethysExport.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
tethysExport(parentFrame);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return tethysMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tethysExportParams
|
||||||
|
*/
|
||||||
|
public TethysExportParams getTethysExportParams() {
|
||||||
|
return tethysExportParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We'll probably want to
|
||||||
|
* @param parentFrame
|
||||||
|
*/
|
||||||
|
protected void tethysExport(JFrame parentFrame) {
|
||||||
|
TethysExportParams newExportParams = TethysExportDialog.showDialog(parentFrame, this);
|
||||||
|
if (newExportParams != null) {
|
||||||
|
// dialog returns null if cancel was pressed.
|
||||||
|
tethysExportParams = newExportParams;
|
||||||
|
exportTethysData(tethysExportParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We'll arrive here if the dialog has been opened and we want to export Tethys data.
|
||||||
|
* @param tethysExportParams2
|
||||||
|
*/
|
||||||
|
private void exportTethysData(TethysExportParams tethysExportParams) {
|
||||||
|
TethysExporter tethysExporter = new TethysExporter(this, tethysExportParams);
|
||||||
|
tethysExporter.doExport();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A name for any deta selectors.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getDataSelectName() {
|
||||||
|
return getUnitName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
24
src/tethys/dbxml/DBXMLConnect.java
Normal file
24
src/tethys/dbxml/DBXMLConnect.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package tethys.dbxml;
|
||||||
|
|
||||||
|
import tethys.TethysControl;
|
||||||
|
|
||||||
|
public class DBXMLConnect {
|
||||||
|
|
||||||
|
private TethysControl tethysControl;
|
||||||
|
|
||||||
|
public DBXMLConnect(TethysControl tethysControl) {
|
||||||
|
this.tethysControl = tethysControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean openDatabase() {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeDatabase() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// add whatever calls are necessary to set up schema's etc.
|
||||||
|
|
||||||
|
}
|
85
src/tethys/deployment/DeploymentWrapper.java
Normal file
85
src/tethys/deployment/DeploymentWrapper.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package tethys.deployment;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.AnnotatedType;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBElement;
|
||||||
|
import javax.xml.bind.Marshaller;
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
import javax.xml.validation.Schema;
|
||||||
|
|
||||||
|
import nilus.Deployment.Data.Audio;
|
||||||
|
import nilus.Deployment;
|
||||||
|
import nilus.Deployment.Data;
|
||||||
|
import nilus.Deployment.Instrument;
|
||||||
|
|
||||||
|
public class DeploymentWrapper<T extends Serializable> {
|
||||||
|
|
||||||
|
public DeploymentWrapper(T tethysObject) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getFieldNames() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Serializable> getComplexObjects() {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// quick play with some JAXB objects to see what they can do.
|
||||||
|
Deployment deployment = new Deployment();
|
||||||
|
|
||||||
|
Class<? extends Deployment> deploymentClass = deployment.getClass();
|
||||||
|
Annotation[] annots = deploymentClass.getAnnotations();
|
||||||
|
AnnotatedType[] annotInterfaces = deploymentClass.getAnnotatedInterfaces();
|
||||||
|
Annotation[] declAnnots = deploymentClass.getDeclaredAnnotations();
|
||||||
|
|
||||||
|
Instrument instrument = new Instrument();
|
||||||
|
instrument.setID("22");
|
||||||
|
instrument.setType("SoundTrap");
|
||||||
|
QName qName = new QName("Instrument");
|
||||||
|
JAXBElement<Instrument> jInst = new JAXBElement<Deployment.Instrument>(qName, Instrument.class, instrument);
|
||||||
|
deployment.getContent().add(jInst);
|
||||||
|
|
||||||
|
Deployment.Data data = new Data();
|
||||||
|
Audio audio = new Audio();
|
||||||
|
audio.setProcessed("??");
|
||||||
|
data.setAudio(audio);
|
||||||
|
JAXBElement jData = new JAXBElement<Deployment.Data>(new QName("Data"), Data.class, data);
|
||||||
|
deployment.getContent().add(jData);
|
||||||
|
|
||||||
|
String project = "Project Name";
|
||||||
|
JAXBElement<String> jProj = new JAXBElement<String>(new QName("Project"), String.class, project);
|
||||||
|
deployment.getContent().add(jProj);
|
||||||
|
|
||||||
|
String aaa = "Project Something else";
|
||||||
|
JAXBElement<String> jProj2 = new JAXBElement<String>(new QName("Region"), String.class, aaa);
|
||||||
|
deployment.getContent().add(jProj2);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
JAXBContext jContext = JAXBContext.newInstance(Deployment.class);
|
||||||
|
Marshaller mar = (Marshaller) jContext.createMarshaller();
|
||||||
|
mar.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||||
|
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
mar.marshal(deployment, bos);
|
||||||
|
String xml = new String(bos.toByteArray());
|
||||||
|
System.out.println(xml);
|
||||||
|
// Schema schema = mar.getSchema(); // is null. Can't generate it's own it seems.
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
src/tethys/deployment/PamDeployment.java
Normal file
64
src/tethys/deployment/PamDeployment.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package tethys.deployment;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import nilus.DeploymentRecoveryDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper and functions associated with the Tethys Deployment object which can
|
||||||
|
* exchange these with the PAMGuard database and display Everything is just held
|
||||||
|
* within a list, in no particular order, which getContent public
|
||||||
|
*
|
||||||
|
* This is from the Deployment JavaDoc. TBH it's pretty horrible, since it's possible to have
|
||||||
|
* more than one of each type of object in the list, so not sure what to do about that. Would be nicer
|
||||||
|
* as a HashTable. however we are where we're are for now. Start by focussing on getting the
|
||||||
|
* content saved for each type
|
||||||
|
*
|
||||||
|
* List<Serializable> getContent()
|
||||||
|
*
|
||||||
|
* Gets the value of the content property. This accessor method returns a
|
||||||
|
* reference to the live list,not a snapshot. Therefore any modification you
|
||||||
|
* make to the returned list will be present inside the JAXB object.This is why
|
||||||
|
* there is not a set method for the content property.
|
||||||
|
*
|
||||||
|
* For example, to add a new item, do as follows: getContent().add(newItem);
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Objects of the following type(s) are allowed in the list JAXBElement<String>
|
||||||
|
* JAXBElement<String>
|
||||||
|
* JAXBElement<Integer>
|
||||||
|
* JAXBElement<DeploymentRecoveryDetails>
|
||||||
|
* JAXBElement<String>
|
||||||
|
* JAXBElement<Deployment.SamplingDetails>
|
||||||
|
* JAXBElement<Deployment.Sensors>
|
||||||
|
* JAXBElement<Deployment.Instrument>
|
||||||
|
* JAXBElement<String>
|
||||||
|
* JAXBElement<Deployment.Data>
|
||||||
|
* JAXBElement<String> String
|
||||||
|
* JAXBElement<AcousticDataQAType>
|
||||||
|
* JAXBElement<Deployment.SiteAliases>
|
||||||
|
* JAXBElement<String>
|
||||||
|
* JAXBElement<DeploymentRecoveryDetails>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PamDeployment {
|
||||||
|
|
||||||
|
public PamDeployment() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeploymentRecoveryDetails getDeploymentRecoveryDetails() {
|
||||||
|
DeploymentRecoveryDetails drd = new DeploymentRecoveryDetails();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ripApart(Serializable object) {
|
||||||
|
Class cls = object.getClass();
|
||||||
|
// cls.get
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
src/tethys/output/StreamExportParams.java
Normal file
27
src/tethys/output/StreamExportParams.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package tethys.output;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parameters controlling export of a single stream.
|
||||||
|
* Starts just with a boolean 'selected', but may grow.
|
||||||
|
* These all contain data names rather than references to a Datablock so that
|
||||||
|
* they can be serialised.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StreamExportParams implements Serializable {
|
||||||
|
|
||||||
|
public static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public StreamExportParams(String longDataName, boolean selected) {
|
||||||
|
super();
|
||||||
|
this.longDataName = longDataName;
|
||||||
|
this.selected = selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String longDataName;
|
||||||
|
|
||||||
|
public boolean selected;
|
||||||
|
|
||||||
|
}
|
59
src/tethys/output/TethysExportParams.java
Normal file
59
src/tethys/output/TethysExportParams.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package tethys.output;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import PamguardMVC.PamDataBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parameters for controlling export of Tethys data.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TethysExportParams implements Serializable, Cloneable{
|
||||||
|
|
||||||
|
public static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Need to add lots of other parameters here, such as the connection detils
|
||||||
|
* for the tethys database.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private HashMap<String, StreamExportParams> streamParamsMap = new HashMap();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TethysExportParams clone() {
|
||||||
|
try {
|
||||||
|
return (TethysExportParams) super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set stream export parameters for a given datablock.
|
||||||
|
* @param dataBlock
|
||||||
|
* @param exportParams
|
||||||
|
*/
|
||||||
|
public void setStreamParams(PamDataBlock dataBlock, StreamExportParams exportParams) {
|
||||||
|
setStreamParams(dataBlock.getLongDataName(), exportParams);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set stream export parameters for a given data name.
|
||||||
|
* @param dataBlock
|
||||||
|
* @param exportParams
|
||||||
|
*/
|
||||||
|
public void setStreamParams(String longDataName, StreamExportParams exportParams) {
|
||||||
|
streamParamsMap.put(longDataName, exportParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamExportParams getStreamParams(PamDataBlock dataBlock) {
|
||||||
|
return getStreamParams(dataBlock.getLongDataName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private StreamExportParams getStreamParams(String longDataName) {
|
||||||
|
return streamParamsMap.get(longDataName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
272
src/tethys/output/TethysExporter.java
Normal file
272
src/tethys/output/TethysExporter.java
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
package tethys.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
import Acquisition.AcquisitionControl;
|
||||||
|
import Acquisition.AcquisitionProcess;
|
||||||
|
import Array.ArrayManager;
|
||||||
|
import Array.Hydrophone;
|
||||||
|
import Array.PamArray;
|
||||||
|
import Array.SnapshotGeometry;
|
||||||
|
import PamController.PamControlledUnit;
|
||||||
|
import PamController.PamController;
|
||||||
|
import PamController.settings.output.xml.PamguardXMLWriter;
|
||||||
|
import PamUtils.PamCalendar;
|
||||||
|
import PamguardMVC.PamDataBlock;
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import PamguardMVC.dataSelector.DataSelector;
|
||||||
|
import generalDatabase.DBSchemaWriter;
|
||||||
|
import generalDatabase.SQLLogging;
|
||||||
|
import metadata.MetaDataContol;
|
||||||
|
import metadata.deployment.DeploymentData;
|
||||||
|
import tethys.TethysControl;
|
||||||
|
import tethys.dbxml.DBXMLConnect;
|
||||||
|
import tethys.pamdata.TethysDataProvider;
|
||||||
|
import tethys.pamdata.TethysSchema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class sitting at the centre of all operations. It will talk to PAMGuard objects to get schemas and data
|
||||||
|
* and talk to the database connection to move data out (and possibly in). Eventually, a lot of the functionality
|
||||||
|
* in here will be moved to worker threads (SwingWorker?) so that it's easy to keep dialogs alive, show
|
||||||
|
* progress for big export jobs, etc. For now though, it's a relatively simple set of function which
|
||||||
|
* we can use to a) open the database, b) check everything such as schemas, etc. c) export data and d) clean up.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TethysExporter {
|
||||||
|
|
||||||
|
private TethysControl tethysControl;
|
||||||
|
private TethysExportParams tethysExportParams;
|
||||||
|
|
||||||
|
private DBXMLConnect dbxmlConnect;
|
||||||
|
|
||||||
|
public TethysExporter(TethysControl tethysControl, TethysExportParams tethysExportParams) {
|
||||||
|
this.tethysControl = tethysControl;
|
||||||
|
this.tethysExportParams = tethysExportParams;
|
||||||
|
dbxmlConnect = new DBXMLConnect(tethysControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the work. In reality this will need an awful lot of changing, for instance
|
||||||
|
* to provide feedback to an observer class to show progress on the display.
|
||||||
|
* @return OK if success.
|
||||||
|
*/
|
||||||
|
public boolean doExport() {
|
||||||
|
|
||||||
|
boolean dbOK = dbxmlConnect.openDatabase();
|
||||||
|
if (!dbOK) {
|
||||||
|
/*
|
||||||
|
* should we set up some exceptions to throw ? Can be a lot
|
||||||
|
* more informative than a simple 'false'
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapshotGeometry arrayGeometry = findArrayGeometrey();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call some general export function
|
||||||
|
*/
|
||||||
|
exportGeneralData(tethysExportParams);
|
||||||
|
/*
|
||||||
|
* go through the export params and call something for every
|
||||||
|
* data block that's enabled.
|
||||||
|
*/
|
||||||
|
ArrayList<PamDataBlock> allDataBlocks = PamController.getInstance().getDataBlocks();
|
||||||
|
for (PamDataBlock aDataBlock : allDataBlocks) {
|
||||||
|
StreamExportParams streamExportParams = tethysExportParams.getStreamParams(aDataBlock);
|
||||||
|
if (streamExportParams == null || streamExportParams.selected == false) {
|
||||||
|
continue; // not interested in this one.
|
||||||
|
}
|
||||||
|
exportDataStream(aDataBlock, tethysExportParams, streamExportParams);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Then do whatever else is needed to complete the document.
|
||||||
|
*/
|
||||||
|
|
||||||
|
dbxmlConnect.closeDatabase();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find Deployment data. This is stored in a separate PAMGuard module, which may not
|
||||||
|
* be present.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DeploymentData findDeploymentData() {
|
||||||
|
/**
|
||||||
|
* What to do if this isn't present or is incomplete ? Should we be showing this in the
|
||||||
|
* main export dialog at some point ? More a Q for when we make a nicer UI later in the project.
|
||||||
|
*/
|
||||||
|
MetaDataContol metaControl = (MetaDataContol) PamController.getInstance().findControlledUnit(MetaDataContol.unitType);
|
||||||
|
if (metaControl == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return metaControl.getDeploymentData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnapshotGeometry findArrayGeometrey() {
|
||||||
|
/*
|
||||||
|
* this should never be null, but again, we might want to put some warnings
|
||||||
|
* and exception handlers in here anyway. Really just an example to show how
|
||||||
|
* to find this. We'll need to dig a bit elsewhere to get more detailed
|
||||||
|
* hydrophone information.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* In PAMGuard hydrophones are assigned to streamers, which can have different methods for estimating
|
||||||
|
* their positions from GPS. The geometry is a sum of xyz in the streamer and xyz in the hydrophone object
|
||||||
|
* Within a streamer, hydrophones are considered rigid relative to each other. The stremer will floow
|
||||||
|
* a choice of modesl (rigid, threading, etc) to estimate it's position relative to the GPS track. Different
|
||||||
|
* errors are used when estimating localisation errors within and between streamers.
|
||||||
|
* The Snapshot geometry sorts a lot of this out for a point in time and will give back a single object
|
||||||
|
* which is most of what we'll be wanting.
|
||||||
|
*/
|
||||||
|
PamArray currentArray = ArrayManager.getArrayManager().getCurrentArray();
|
||||||
|
SnapshotGeometry currentGeometry = currentArray.getSnapshotGeometry(PamCalendar.getTimeInMillis());
|
||||||
|
/*
|
||||||
|
* The following lines of code show how to get more detailed calibration info for each
|
||||||
|
* hydrophone, but we'll have to think about the easiest way to repackage this for Tethys.
|
||||||
|
* e.g. this function could be modified to return the correct Tethys object in one go.
|
||||||
|
*/
|
||||||
|
ArrayList<Hydrophone> hydrophones = currentArray.getHydrophoneArray();
|
||||||
|
/*
|
||||||
|
* each object in the list will have more detailed cal information for each phone. But
|
||||||
|
* for the full system calibration we'd need to go to the Acquisition module.
|
||||||
|
*/
|
||||||
|
AcquisitionControl daqControl = (AcquisitionControl) PamController.getInstance().findControlledUnit(AcquisitionControl.unitType);
|
||||||
|
if (daqControl != null) {
|
||||||
|
AcquisitionProcess daqProcess = daqControl.getAcquisitionProcess();
|
||||||
|
for (int iPhone = 0; iPhone < hydrophones.size(); iPhone++) {
|
||||||
|
Hydrophone aPhone = hydrophones.get(iPhone);
|
||||||
|
double totalCal = -daqProcess.rawAmplitude2dB(1, iPhone, false);
|
||||||
|
System.out.printf("hydrophone %d has sensitivity %3.1fdB + gain %3.1fdB. Total calibration is %3.1fdB re1U/uPa\n",
|
||||||
|
iPhone, aPhone.getSensitivity(), aPhone.getPreampGain(), totalCal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return currentGeometry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No idea if we need this or not. May want to return something different to void, e.g.
|
||||||
|
* a reference to the main object for a tethys export. I've no idea !
|
||||||
|
* @param tethysExportParams2
|
||||||
|
*/
|
||||||
|
private void exportGeneralData(TethysExportParams tethysExportParams) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Here is where we export data for a specific data stream to Tethys.
|
||||||
|
*
|
||||||
|
* @param aDataBlock
|
||||||
|
* @param tethysExportParams
|
||||||
|
* @param streamExportParams
|
||||||
|
*/
|
||||||
|
private void exportDataStream(PamDataBlock aDataBlock, TethysExportParams tethysExportParams,
|
||||||
|
StreamExportParams streamExportParams) {
|
||||||
|
/**
|
||||||
|
* This will probably need to be passed additional parameters and may also want to return something
|
||||||
|
* other than void in order to build a bigger Tethys document.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Some examples of how to do whatever is needed to get schema and data out of PAMGuard.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* first we'll probably want a reference to the module containing the data.
|
||||||
|
* in principle this can't get null, since the datablock was found be searching in
|
||||||
|
* the other direction.
|
||||||
|
*/
|
||||||
|
PamControlledUnit pamControlledUnit = aDataBlock.getParentProcess().getPamControlledUnit();
|
||||||
|
|
||||||
|
TethysDataProvider dataProvider = aDataBlock.getTethysDataProvider();
|
||||||
|
|
||||||
|
PamguardXMLWriter pamXMLWriter = PamguardXMLWriter.getXMLWriter();
|
||||||
|
|
||||||
|
if (dataProvider == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TethysSchema tethysSchema = dataProvider.getSchema();
|
||||||
|
/*
|
||||||
|
* the schema should have a Document object in it. If we wanted to turn
|
||||||
|
* that into an XML string we can ...
|
||||||
|
* (though I'd assume that having the Document is more useful)
|
||||||
|
*/
|
||||||
|
String schemaXMLString = pamXMLWriter.getAsString(tethysSchema.getXsd(), false);
|
||||||
|
// System.out.printf("Schema for %s is %s\n", aDataBlock.getDataName(), schemaXMLString);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the XML settings for that datablock. This is (or should be
|
||||||
|
* the parameters that were controlling that module, with adequate data about
|
||||||
|
* upstream modules). I think this has to go somewhere into the Detections document.
|
||||||
|
*/
|
||||||
|
Document doc = pamXMLWriter.writeOneModule(pamXMLWriter, System.currentTimeMillis());
|
||||||
|
String moduleXML = null;
|
||||||
|
if (doc != null) {
|
||||||
|
// this string should be XML of all the settings for the module controlling this datablock.
|
||||||
|
moduleXML = pamXMLWriter.getAsString(doc, true); // change to false to get smaller xml
|
||||||
|
System.out.printf("Module settings for datablock %s are:\n", moduleXML);
|
||||||
|
System.out.println(moduleXML);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Now can go through the data. Probably, we'll want to go through all the data in
|
||||||
|
* the project, but we can hold off on that for now and just go for data that
|
||||||
|
* are in memory. We'll also have to think a lot about updating parts of the
|
||||||
|
* database which have been reprocessed - what we want to do, should eventually all
|
||||||
|
* be options set in the dialog and available within TethysExportParams
|
||||||
|
* For now though, we're just going to export data that are in memory.
|
||||||
|
* Once basic export is working, I can easily enough write something which will go
|
||||||
|
* through an entire data set, go through between two times, etc.
|
||||||
|
*/
|
||||||
|
// so this is a way of iterating through the data that are in memory, which will do for now ..
|
||||||
|
// do it with a data copy which can avoid synchronising the entire block for what may be a long time
|
||||||
|
// the copy function is itself synched, and is quite fast, so easier and safe this way
|
||||||
|
ArrayList<PamDataUnit> dataCopy = aDataBlock.getDataCopy();
|
||||||
|
DataSelector dataSelector = aDataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
|
||||||
|
int nSkipped = 0;
|
||||||
|
int nExport = 0;
|
||||||
|
|
||||||
|
for (PamDataUnit aData : dataCopy) {
|
||||||
|
/*
|
||||||
|
* see if we want this data unit. PAMGuard has a complicated system of data selectors specific to
|
||||||
|
* each data type. These are centrally managed so you don't need to worry too much about them. They
|
||||||
|
* are identified by name for each data stream and the behaviour here should follow the selections you
|
||||||
|
* made in the dialog.
|
||||||
|
* the data selection system allows different displays to show different data, so a stream can have many differently
|
||||||
|
* named selectors active at any one time, all doing different things in different parts of PAMGuard.
|
||||||
|
*/
|
||||||
|
if (dataSelector != null) {
|
||||||
|
if (dataSelector.scoreData(aData) <= 0) {
|
||||||
|
nSkipped++;
|
||||||
|
continue; // don't want this one.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* then we do whatever we need to do to convert this into something for Tethys
|
||||||
|
* this might happen in the tethysSchema object for each data stream ????
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
nExport ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.printf("Exported %d data units and skipped %d in %s", nExport, nSkipped, aDataBlock.getLongDataName());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
187
src/tethys/output/swing/TethysExportDialog.java
Normal file
187
src/tethys/output/swing/TethysExportDialog.java
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
package tethys.output.swing;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
|
import PamController.PamController;
|
||||||
|
import PamView.dialog.PamDialog;
|
||||||
|
import PamView.dialog.PamGridBagContraints;
|
||||||
|
import PamguardMVC.PamDataBlock;
|
||||||
|
import PamguardMVC.dataSelector.DataSelector;
|
||||||
|
import tethys.TethysControl;
|
||||||
|
import tethys.output.StreamExportParams;
|
||||||
|
import tethys.output.TethysExportParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start of a dialog for controlling the export of Tethys data. For first iteration
|
||||||
|
* this will just be a list of output streams (PamDataBlocks) which have a database
|
||||||
|
* connection. Each will have a checkbox. On OK it will return back a class listing
|
||||||
|
* what to output and the calling function can do as it will. Future versions will
|
||||||
|
* probably want to push the functionality into a SwingWorker to show progress, etc.
|
||||||
|
* but that can come later.
|
||||||
|
*
|
||||||
|
* Normally, I use single instance dialogs for this sort of thing.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TethysExportDialog extends PamDialog {
|
||||||
|
|
||||||
|
private static TethysExportDialog singleInstance;
|
||||||
|
|
||||||
|
private TethysControl tethysControl;
|
||||||
|
|
||||||
|
private TethysExportParams exportParams;
|
||||||
|
|
||||||
|
private JPanel streamsPanel;
|
||||||
|
|
||||||
|
private ArrayList<DataStreamSet> dataStreamSets = new ArrayList<>();
|
||||||
|
|
||||||
|
private TethysExportDialog(Window parentFrame, TethysControl tethysControl) {
|
||||||
|
super(parentFrame, "Tethys Export", false);
|
||||||
|
this.tethysControl = tethysControl;
|
||||||
|
|
||||||
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
|
/*
|
||||||
|
* Expect to add at least one more panel at the top of this to have options
|
||||||
|
* for things like connection details to the database. If not another panel,
|
||||||
|
* then they can be arranged on tabs, as a wizard, etc.
|
||||||
|
*/
|
||||||
|
streamsPanel = new JPanel();
|
||||||
|
streamsPanel.setBorder(new TitledBorder("Data Streams"));
|
||||||
|
mainPanel.add(BorderLayout.CENTER, streamsPanel);
|
||||||
|
|
||||||
|
setDialogComponent(mainPanel);
|
||||||
|
setResizable(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TethysExportParams showDialog(Window parentFrame, TethysControl tethysControl) {
|
||||||
|
if (singleInstance == null || singleInstance.getOwner() != parentFrame || singleInstance.tethysControl != tethysControl) {
|
||||||
|
singleInstance = new TethysExportDialog(parentFrame, tethysControl);
|
||||||
|
}
|
||||||
|
singleInstance.makeStreamsPanel();
|
||||||
|
singleInstance.setParams();
|
||||||
|
singleInstance.setVisible(true);
|
||||||
|
return singleInstance.exportParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remake the panel. Gets rebuilt whenever dialog opens in case
|
||||||
|
* the list of available data has changed.
|
||||||
|
*/
|
||||||
|
private void makeStreamsPanel() {
|
||||||
|
streamsPanel.removeAll();
|
||||||
|
streamsPanel.setLayout(new GridBagLayout());
|
||||||
|
GridBagConstraints c = new PamGridBagContraints();
|
||||||
|
dataStreamSets = findDataStreams();
|
||||||
|
streamsPanel.add(new JLabel(" Data Stream ", JLabel.CENTER), c);
|
||||||
|
c.gridx++;
|
||||||
|
streamsPanel.add(new JLabel(" Data Select ", JLabel.CENTER), c);
|
||||||
|
for (DataStreamSet aSet : dataStreamSets) {
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy++;
|
||||||
|
streamsPanel.add(aSet.checkBox, c);
|
||||||
|
// try to add a data selector
|
||||||
|
DataSelector dataSelector = aSet.dataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
|
||||||
|
if (dataSelector != null) {
|
||||||
|
c.gridx++;
|
||||||
|
JButton button = dataSelector.getDialogButton(this);
|
||||||
|
if (button != null) {
|
||||||
|
streamsPanel.add(button, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a set of data blocks that can provide Tethys data.
|
||||||
|
* @return datablocks which can provide Tethys data
|
||||||
|
*/
|
||||||
|
private ArrayList<DataStreamSet> findDataStreams() {
|
||||||
|
ArrayList<DataStreamSet> sets = new ArrayList<>();
|
||||||
|
ArrayList<PamDataBlock> allDataBlocks = PamController.getInstance().getDataBlocks();
|
||||||
|
for (PamDataBlock aDataBlock : allDataBlocks) {
|
||||||
|
if (aDataBlock.getTethysDataProvider() != null) {
|
||||||
|
sets.add(new DataStreamSet(aDataBlock));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sets;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setParams() {
|
||||||
|
this.exportParams = tethysControl.getTethysExportParams();
|
||||||
|
if (exportParams == null) {
|
||||||
|
exportParams = new TethysExportParams();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
exportParams = exportParams.clone();
|
||||||
|
}
|
||||||
|
setParams(exportParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setParams(TethysExportParams exportParams) {
|
||||||
|
if (exportParams == null || dataStreamSets == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (DataStreamSet streamSet : dataStreamSets) {
|
||||||
|
StreamExportParams streamOpts = exportParams.getStreamParams(streamSet.dataBlock);
|
||||||
|
if (streamOpts == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
streamSet.checkBox.setSelected(streamOpts.selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getParams() {
|
||||||
|
if (exportParams == null || dataStreamSets == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int nSel = 0;
|
||||||
|
for (DataStreamSet streamSet : dataStreamSets) {
|
||||||
|
StreamExportParams streamOpts = new StreamExportParams(streamSet.dataBlock.getLongDataName(), streamSet.checkBox.isSelected());
|
||||||
|
exportParams.setStreamParams(streamSet.dataBlock, streamOpts);
|
||||||
|
nSel++;
|
||||||
|
}
|
||||||
|
return nSel > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelButtonPressed() {
|
||||||
|
exportParams = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreDefaultSettings() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DataStreamSet {
|
||||||
|
|
||||||
|
private PamDataBlock dataBlock;
|
||||||
|
|
||||||
|
private JCheckBox checkBox;
|
||||||
|
|
||||||
|
public DataStreamSet(PamDataBlock dataBlock) {
|
||||||
|
super();
|
||||||
|
this.dataBlock = dataBlock;
|
||||||
|
checkBox = new JCheckBox(dataBlock.getDataName());
|
||||||
|
checkBox.setToolTipText(dataBlock.getLongDataName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/tethys/pamdata/AutoTethysProvider.java
Normal file
42
src/tethys/pamdata/AutoTethysProvider.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package tethys.pamdata;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
import PamguardMVC.PamDataBlock;
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
import generalDatabase.DBSchemaWriter;
|
||||||
|
import generalDatabase.SQLLogging;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically provides Tethys data based on the SQL database interface
|
||||||
|
* for a data block.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AutoTethysProvider implements TethysDataProvider {
|
||||||
|
|
||||||
|
private PamDataBlock pamDataBlock;
|
||||||
|
|
||||||
|
public AutoTethysProvider(PamDataBlock pamDataBlock) {
|
||||||
|
this.pamDataBlock = pamDataBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TethysSchema getSchema() {
|
||||||
|
SQLLogging logging = pamDataBlock.getLogging();
|
||||||
|
if (logging == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DBSchemaWriter schemaWriter = new DBSchemaWriter();
|
||||||
|
Document doc = schemaWriter.generateDatabaseSchema(pamDataBlock, logging, logging.getTableDefinition());
|
||||||
|
TethysSchema schema = new TethysSchema(doc);
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TethysDataPoint getDataPoint(PamDataUnit pamDataUnit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/tethys/pamdata/TethysDataPoint.java
Normal file
18
src/tethys/pamdata/TethysDataPoint.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package tethys.pamdata;
|
||||||
|
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will be a unit of Tethys Data, e.g. a Detection.
|
||||||
|
* Can it also be used for things like GPS data ?
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TethysDataPoint {
|
||||||
|
|
||||||
|
public TethysDataPoint(PamDataUnit dataUnit) {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
32
src/tethys/pamdata/TethysDataProvider.java
Normal file
32
src/tethys/pamdata/TethysDataProvider.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package tethys.pamdata;
|
||||||
|
|
||||||
|
import PamguardMVC.PamDataUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any PAMGuard data stream which can provide Detection data to PAMGuard will
|
||||||
|
* be able to return one of these. It will provide a schema and a function which
|
||||||
|
* can turn individual data units into data formatted for Tethys. The nature of how these
|
||||||
|
* work TBD.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface TethysDataProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the Tethys schema for this type of data in whatever
|
||||||
|
* form we decide it's best stored in, an XML string, or what ?
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public TethysSchema getSchema();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will convert a data unit for this provider into whatever format we need the
|
||||||
|
* data to be in for Tethys. Some base function but also bespoke stuff depending on the
|
||||||
|
* data type. Will probably need writing for every module individually?
|
||||||
|
* @param pamDataUnit
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public TethysDataPoint getDataPoint(PamDataUnit pamDataUnit);
|
||||||
|
|
||||||
|
}
|
32
src/tethys/pamdata/TethysSchema.java
Normal file
32
src/tethys/pamdata/TethysSchema.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package tethys.pamdata;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* object for a Tethys Schema. This may just be a very simple
|
||||||
|
* wrapper around an XML string, or a JAXB object or something,
|
||||||
|
* but may get more sophisticated. TBD in discussions with SDSU
|
||||||
|
*/
|
||||||
|
public class TethysSchema {
|
||||||
|
|
||||||
|
private Document schemaDoc;
|
||||||
|
|
||||||
|
public TethysSchema(Document doc) {
|
||||||
|
this.setXsd(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the xsd
|
||||||
|
*/
|
||||||
|
public Document getXsd() {
|
||||||
|
return schemaDoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param xsd the xsd to set
|
||||||
|
*/
|
||||||
|
public void setXsd(Document xsd) {
|
||||||
|
this.schemaDoc = xsd;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package whistleDetector;
|
package whistleDetector;
|
||||||
|
|
||||||
|
import generalDatabase.EmptyTableDefinition;
|
||||||
import generalDatabase.PamDetectionLogging;
|
import generalDatabase.PamDetectionLogging;
|
||||||
import generalDatabase.PamTableDefinition;
|
import generalDatabase.PamTableDefinition;
|
||||||
import generalDatabase.PamTableItem;
|
import generalDatabase.PamTableItem;
|
||||||
@ -24,7 +25,7 @@ public class WhistleLogger extends PamDetectionLogging {
|
|||||||
|
|
||||||
this.whistleControl = whistleControl;
|
this.whistleControl = whistleControl;
|
||||||
|
|
||||||
PamTableDefinition tableDefinition = getTableDefinition();
|
EmptyTableDefinition tableDefinition = getTableDefinition();
|
||||||
tableDefinition.addTableItem(sliceCount = new PamTableItem("SliceCount", Types.INTEGER));
|
tableDefinition.addTableItem(sliceCount = new PamTableItem("SliceCount", Types.INTEGER));
|
||||||
tableDefinition.addTableItem(length = new PamTableItem("WhistleLength", Types.DOUBLE));
|
tableDefinition.addTableItem(length = new PamTableItem("WhistleLength", Types.DOUBLE));
|
||||||
tableDefinition.addTableItem(minFreq = new PamTableItem("MinFreq", Types.DOUBLE));
|
tableDefinition.addTableItem(minFreq = new PamTableItem("MinFreq", Types.DOUBLE));
|
||||||
|
Loading…
Reference in New Issue
Block a user