mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-29 02:22:22 +00:00
Batch and X3 updates (#105)
* Update FileListWorker.java * Support batch processing Multicast controller and a couple of additional commands to work with the batch processing plugin. * Database float unpack Better unpacking checks of floats coming back from the database * Batch changes Changes in support of batch processing * Small changes for batch processing * update X3 to get Detector parameters X3 and PAMguard updated to get and save the SoundTrap click detector parameters.
This commit is contained in:
parent
317f87265a
commit
56cb06ea1c
@ -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/Java 17">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
2
pom.xml
2
pom.xml
@ -784,7 +784,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pamguard.org</groupId>
|
<groupId>pamguard.org</groupId>
|
||||||
<artifactId>x3</artifactId>
|
<artifactId>x3</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>2.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/it.sauronsoftware/jave -->
|
<!-- https://mvnrepository.com/artifact/it.sauronsoftware/jave -->
|
||||||
|
@ -453,12 +453,18 @@ public class ImportBCLDialog extends PamDialog {
|
|||||||
int nFiles = 0;
|
int nFiles = 0;
|
||||||
int nCDET = 0;
|
int nCDET = 0;
|
||||||
int nDWV = 0;
|
int nDWV = 0;
|
||||||
|
|
||||||
|
STClickControl clickControl = (STClickControl) PamController.getInstance().findControlledUnit(STClickControl.STUNITTYPE, stToolsParams.clickDetName);
|
||||||
|
|
||||||
for (File xmlFile:xmlFiles) {
|
for (File xmlFile:xmlFiles) {
|
||||||
Debug.out.println("Opening xml file " + xmlFile.getAbsolutePath());
|
Debug.out.println("Opening xml file " + xmlFile.getAbsolutePath());
|
||||||
if (xmlFile.getAbsolutePath().equals("E:\\STOctober2016\\335839252\\335839252.161031002807.log.xml")) {
|
// if (xmlFile.getAbsolutePath().equals("E:\\STOctober2016\\335839252\\335839252.161031002807.log.xml")) {
|
||||||
System.out.println("Opening xml file " + xmlFile.getAbsolutePath());
|
// System.out.println("Opening xml file " + xmlFile.getAbsolutePath());
|
||||||
}
|
// }
|
||||||
STXMLFile xmlFileInfo = STXMLFile.openXMLFile(xmlFile, customDateTimeFormat.getText());
|
STXMLFile xmlFileInfo = STXMLFile.openXMLFile(xmlFile, customDateTimeFormat.getText());
|
||||||
|
if (clickControl != null && xmlFileInfo.getSudDetectorInfo() != null) {
|
||||||
|
clickControl.setSudClickDetectorInfo(xmlFileInfo.getSudDetectorInfo());
|
||||||
|
}
|
||||||
|
|
||||||
if (xmlFileInfo == null || xmlFileInfo.getDwvInfo() == null) {
|
if (xmlFileInfo == null || xmlFileInfo.getDwvInfo() == null) {
|
||||||
String title = "Error with Soundtrap file";
|
String title = "Error with Soundtrap file";
|
||||||
|
@ -25,19 +25,26 @@
|
|||||||
package soundtrap;
|
package soundtrap;
|
||||||
|
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
|
||||||
|
import org.pamguard.x3.sud.SUDClickDetectorInfo;
|
||||||
|
|
||||||
import Acquisition.AcquisitionControl;
|
import Acquisition.AcquisitionControl;
|
||||||
import Acquisition.sud.SUDNotificationManager;
|
import PamController.PamControlledUnitSettings;
|
||||||
import PamController.PamController;
|
import PamController.PamController;
|
||||||
import PamguardMVC.PamRawDataBlock;
|
import PamguardMVC.PamRawDataBlock;
|
||||||
import clickDetector.ClickBTDisplay;
|
import clickDetector.ClickBTDisplay;
|
||||||
import clickDetector.ClickControl;
|
import clickDetector.ClickControl;
|
||||||
import clickDetector.ClickDisplay;
|
import clickDetector.ClickDisplay;
|
||||||
import clickDetector.ClickDisplayManager;
|
import clickDetector.ClickDisplayManager;
|
||||||
|
import soundtrap.sud.SUDParamsDialog;
|
||||||
import soundtrap.sud.SudFileDWVHandler;
|
import soundtrap.sud.SudFileDWVHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,6 +53,8 @@ import soundtrap.sud.SudFileDWVHandler;
|
|||||||
*/
|
*/
|
||||||
public class STClickControl extends ClickControl {
|
public class STClickControl extends ClickControl {
|
||||||
|
|
||||||
|
private SUDClickDetectorInfo sudClickDetectorInfo;
|
||||||
|
|
||||||
public static final String STUNITTYPE = "SoundTrap Click Detector";
|
public static final String STUNITTYPE = "SoundTrap Click Detector";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,9 +126,23 @@ public class STClickControl extends ClickControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JMenuItem sudItem = new JMenuItem("Sound Trap settings ...");
|
||||||
|
sudItem.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
showSudParameters(parentFrame);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newMenu.add(sudItem, 0);
|
||||||
|
newMenu.add(new JSeparator(), 1);
|
||||||
|
|
||||||
return newMenu;
|
return newMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showSudParameters(Frame parentFrame) {
|
||||||
|
SUDParamsDialog.showDialog(parentFrame, this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pamStart() {
|
public void pamStart() {
|
||||||
sudFileDWVHandler.pamStart();
|
sudFileDWVHandler.pamStart();
|
||||||
@ -158,5 +181,42 @@ public class STClickControl extends ClickControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSettingsVersion() {
|
||||||
|
return SUDClickDetectorInfo.serialVersionUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Serializable getSettingsReference() {
|
||||||
|
return getSudClickDetectorInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||||
|
Object o = pamControlledUnitSettings.getSettings();
|
||||||
|
if (o instanceof SUDClickDetectorInfo) {
|
||||||
|
sudClickDetectorInfo = (SUDClickDetectorInfo) o;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sudClickDetectorInfo
|
||||||
|
*/
|
||||||
|
public SUDClickDetectorInfo getSudClickDetectorInfo() {
|
||||||
|
if (sudClickDetectorInfo == null) {
|
||||||
|
sudClickDetectorInfo = new SUDClickDetectorInfo();
|
||||||
|
}
|
||||||
|
return sudClickDetectorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sudClickDetectorInfo the sudClickDetectorInfo to set
|
||||||
|
*/
|
||||||
|
public void setSudClickDetectorInfo(SUDClickDetectorInfo sudClickDetectorInfo) {
|
||||||
|
this.sudClickDetectorInfo = sudClickDetectorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.pamguard.x3.sud.SUDClickDetectorInfo;
|
||||||
|
import org.pamguard.x3.sud.SUDXMLUtils;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
@ -41,6 +43,7 @@ public class STXMLFile {
|
|||||||
private WAVInfo wavInfo;
|
private WAVInfo wavInfo;
|
||||||
private String soundTrapId;
|
private String soundTrapId;
|
||||||
private String dateFormat = defaultDateFormat;
|
private String dateFormat = defaultDateFormat;
|
||||||
|
private SUDClickDetectorInfo sudDetectorInfo;
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -70,6 +73,9 @@ public class STXMLFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void unpackXMLDoc() throws Exception{
|
private void unpackXMLDoc() throws Exception{
|
||||||
|
// try to get the new format complete settings as has been developed for the
|
||||||
|
// SUD direct reader.
|
||||||
|
|
||||||
cfgNodes = doc.getElementsByTagName("CFG");
|
cfgNodes = doc.getElementsByTagName("CFG");
|
||||||
NodeList procEvents = doc.getElementsByTagName("PROC_EVENT");
|
NodeList procEvents = doc.getElementsByTagName("PROC_EVENT");
|
||||||
|
|
||||||
@ -232,7 +238,13 @@ public class STXMLFile {
|
|||||||
}
|
}
|
||||||
doc.getDocumentElement().normalize();
|
doc.getDocumentElement().normalize();
|
||||||
|
|
||||||
return new STXMLFile(doc, xmlFile, dateTimeFormat);
|
STXMLFile stXMLFile = new STXMLFile(doc, xmlFile, dateTimeFormat);
|
||||||
|
|
||||||
|
SUDXMLUtils sudXml = new SUDXMLUtils();
|
||||||
|
SUDClickDetectorInfo detectorInfo = sudXml.extractDetectorInfo(doc);
|
||||||
|
stXMLFile.setSudDetectorInfo(detectorInfo);
|
||||||
|
|
||||||
|
return stXMLFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,4 +311,18 @@ public class STXMLFile {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sudDetectorInfo
|
||||||
|
*/
|
||||||
|
public SUDClickDetectorInfo getSudDetectorInfo() {
|
||||||
|
return sudDetectorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sudDetectorInfo the sudDetectorInfo to set
|
||||||
|
*/
|
||||||
|
public void setSudDetectorInfo(SUDClickDetectorInfo sudDetectorInfo) {
|
||||||
|
this.sudDetectorInfo = sudDetectorInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
107
src/soundtrap/sud/SUDParamsDialog.java
Normal file
107
src/soundtrap/sud/SUDParamsDialog.java
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
package soundtrap.sud;
|
||||||
|
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Window;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
|
import org.pamguard.x3.sud.SUDClickDetectorInfo;
|
||||||
|
|
||||||
|
import PamView.dialog.PamDialog;
|
||||||
|
import PamView.dialog.PamGridBagContraints;
|
||||||
|
import soundtrap.STClickControl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display ST detection parameters. These cannot be changed so all boxes are disabled.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SUDParamsDialog extends PamDialog {
|
||||||
|
|
||||||
|
private STClickControl stClickControl;
|
||||||
|
|
||||||
|
private JTextField sampleRate, channels, threshold, blanking, preSamps, postSamps, len;
|
||||||
|
|
||||||
|
private static SUDParamsDialog singleInstance;
|
||||||
|
|
||||||
|
private SUDParamsDialog(Window parentFrame, STClickControl stClickControl) {
|
||||||
|
super(parentFrame, stClickControl.getUnitName(), false);
|
||||||
|
this.stClickControl = stClickControl;
|
||||||
|
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||||
|
mainPanel.setBorder(new TitledBorder("SoundTrap Detector Configuration"));
|
||||||
|
GridBagConstraints c = new PamGridBagContraints();
|
||||||
|
sampleRate = addThing(mainPanel, "Sample Rate", "Hz", c);
|
||||||
|
channels = addThing(mainPanel, "Num Channels", null, c);
|
||||||
|
threshold = addThing(mainPanel, "Threshold", "dB", c);
|
||||||
|
blanking = addThing(mainPanel, "Blanking", "samples", c);
|
||||||
|
preSamps = addThing(mainPanel, "Pre Samples", "samples", c);
|
||||||
|
postSamps = addThing(mainPanel, "Post Samples", "samples", c);
|
||||||
|
len = addThing(mainPanel, "Length", "samples", c);
|
||||||
|
|
||||||
|
setDialogComponent(mainPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showDialog(Window parent, STClickControl stClickControl) {
|
||||||
|
// if (singleInstance == null) {
|
||||||
|
singleInstance = new SUDParamsDialog(parent, stClickControl);
|
||||||
|
// }
|
||||||
|
singleInstance.setParams(stClickControl.getSudClickDetectorInfo());
|
||||||
|
singleInstance.setVisible(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setParams(SUDClickDetectorInfo sudClickDetectorInfo) {
|
||||||
|
sampleRate.setText(String.format("%d", sudClickDetectorInfo.sampleRate));
|
||||||
|
channels.setText(String.format("%d", sudClickDetectorInfo.nChan));
|
||||||
|
threshold.setText(String.format("%3.1f", sudClickDetectorInfo.detThr));
|
||||||
|
blanking.setText(String.format("%d", sudClickDetectorInfo.blankingSamples));
|
||||||
|
preSamps.setText(String.format("%d", sudClickDetectorInfo.preSamples));
|
||||||
|
postSamps.setText(String.format("%d", sudClickDetectorInfo.postSamples));
|
||||||
|
len.setText(String.format("%d", sudClickDetectorInfo.lenSamples));
|
||||||
|
}
|
||||||
|
|
||||||
|
private JTextField addThing(JPanel mainPanel, String title, String postTit, GridBagConstraints c) {
|
||||||
|
c.gridx = 0;
|
||||||
|
mainPanel.add(new JLabel(title, JLabel.RIGHT), c);
|
||||||
|
c.gridx++;
|
||||||
|
STField field = new STField(5);
|
||||||
|
mainPanel.add(field, c);
|
||||||
|
if (postTit != null) {
|
||||||
|
c.gridx++;
|
||||||
|
mainPanel.add(new JLabel(postTit, JLabel.LEFT), c);
|
||||||
|
}
|
||||||
|
c.gridy++;
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getParams() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelButtonPressed() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreDefaultSettings() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class STField extends JTextField {
|
||||||
|
|
||||||
|
public STField(int columns) {
|
||||||
|
super(columns);
|
||||||
|
setEditable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||||||
import org.pamguard.x3.sud.Chunk;
|
import org.pamguard.x3.sud.Chunk;
|
||||||
import org.pamguard.x3.sud.SudAudioInputStream;
|
import org.pamguard.x3.sud.SudAudioInputStream;
|
||||||
import org.pamguard.x3.sud.SudDataInputStream;
|
import org.pamguard.x3.sud.SudDataInputStream;
|
||||||
|
import org.pamguard.x3.sud.SudFileMap;
|
||||||
|
|
||||||
import Acquisition.AcquisitionControl;
|
import Acquisition.AcquisitionControl;
|
||||||
import Acquisition.sud.SUDNotificationHandler;
|
import Acquisition.sud.SUDNotificationHandler;
|
||||||
@ -73,7 +74,15 @@ public class SudFileDWVHandler implements SUDNotificationHandler {
|
|||||||
// this is the wav sample rate, not the detector sample rate, so don't use it
|
// this is the wav sample rate, not the detector sample rate, so don't use it
|
||||||
// sampleRate = sudAudioInputStream.getFormat().getFrameRate();
|
// sampleRate = sudAudioInputStream.getFormat().getFrameRate();
|
||||||
// this is the right one
|
// this is the right one
|
||||||
|
SudFileMap sudMap = sudAudioInputStream.getSudMap();
|
||||||
|
sampleRate = 0;
|
||||||
|
if (sudMap.detectorInfo != null) {
|
||||||
|
sampleRate = sudMap.detectorInfo.sampleRate;
|
||||||
|
stClickControl.setSudClickDetectorInfo(sudMap.detectorInfo);
|
||||||
|
}
|
||||||
|
if (sampleRate == 0) {
|
||||||
sampleRate = sudAudioInputStream.getSudMap().clickDetSampleRate;
|
sampleRate = sudAudioInputStream.getSudMap().clickDetSampleRate;
|
||||||
|
}
|
||||||
fileStartMicros = sudAudioInputStream.getSudMap().getFirstChunkTimeMicros();
|
fileStartMicros = sudAudioInputStream.getSudMap().getFirstChunkTimeMicros();
|
||||||
stClickControl.findRawDataBlock().setChannelMap(1);
|
stClickControl.findRawDataBlock().setChannelMap(1);
|
||||||
stClickControl.findRawDataBlock().setSampleRate((float) sampleRate, true);
|
stClickControl.findRawDataBlock().setSampleRate((float) sampleRate, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user