mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 14:42:27 +00:00
Merge branch 'main' of https://github.com/PAMGuard/PAMGuard
This commit is contained in:
commit
4ec3b42d2b
5
.gitignore
vendored
5
.gitignore
vendored
@ -19,6 +19,7 @@
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
!src/test/**/*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
*.dll
|
||||
@ -37,6 +38,10 @@ bin/
|
||||
.classpath
|
||||
target/WMM.COF
|
||||
|
||||
# IntellIJ
|
||||
.idea
|
||||
|
||||
# Eclipse
|
||||
settings.xml
|
||||
.classpath
|
||||
.classpath
|
||||
|
45
pom.xml
45
pom.xml
@ -182,7 +182,15 @@
|
||||
-->
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<reuseForks>false</reuseForks>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Plugin which creates a .dmg file for MacOS.
|
||||
<plugin>
|
||||
@ -228,7 +236,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin> -->
|
||||
|
||||
</plugins>
|
||||
|
||||
|
||||
@ -325,16 +332,6 @@
|
||||
<url>https://nexus.bedatadriven.com/content/groups/public/</url>
|
||||
</repository>
|
||||
|
||||
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>talan</id>
|
||||
<name>talan</name>
|
||||
<url>https://nexus.talanlabs.com/content/repositories/releases/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<url>https://repo1.maven.org/maven2</url>
|
||||
@ -344,6 +341,17 @@
|
||||
|
||||
|
||||
<!-- ************************* Dependencies ************************************* -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>5.11.3</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<!--jpam project - utilities -->
|
||||
@ -351,6 +359,13 @@
|
||||
<groupId>io.github.macster110</groupId>
|
||||
<artifactId>jpamutils</artifactId>
|
||||
<version>0.0.59d</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- com.github.psambit9791:wavfile:jar:0.1 pulls in various junit dependencies which breaks our own testing -->
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--jpam project - Deep learning java library -->
|
||||
@ -1049,5 +1064,11 @@
|
||||
|
||||
|
||||
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -200,6 +200,50 @@ public class GlobalMedium {
|
||||
return zString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string description of the dB reference for a power spectral density.
|
||||
* @param currentMedium - the current medium.
|
||||
* @return string of dB reference
|
||||
*/
|
||||
public static String getdBPSDString(SoundMedium currentMedium) {
|
||||
String zString;
|
||||
switch (currentMedium) {
|
||||
case Air:
|
||||
zString = "dB re 400\u00B5Pa\u00B2/Hz";
|
||||
break;
|
||||
case Water:
|
||||
zString = "dB re 1\u00B5Pa\u00B2/Hz";
|
||||
break;
|
||||
default:
|
||||
zString = "dB re 1\u00B5Pa\u00B2/Hz";
|
||||
break;
|
||||
}
|
||||
|
||||
return zString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string description of the dB reference for a sound exposure level.
|
||||
* @param currentMedium - the current medium.
|
||||
* @return string of dB reference
|
||||
*/
|
||||
public static String getdBSELString(SoundMedium currentMedium) {
|
||||
String zString;
|
||||
switch (currentMedium) {
|
||||
case Air:
|
||||
zString = "dB re 400\u00B5Pa\u00B2s";
|
||||
break;
|
||||
case Water:
|
||||
zString = "dB re 1\u00B5Pa\u00B2s";
|
||||
break;
|
||||
default:
|
||||
zString = "dB re 1\u00B5Pa\u00B2s";
|
||||
break;
|
||||
}
|
||||
|
||||
return zString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the z coefficient value for displays. Height are always stored so
|
||||
* that +z points up (i.e. -g). In display height is input as depth as so must
|
||||
|
@ -136,6 +136,21 @@ public class GlobalMediumManager implements PamSettings {
|
||||
return GlobalMedium.getdBRefString(globalMediumParams.currentMedium);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string for the default dB reference unit for power spectral density e.g. dB re 1uPa^2/Hz.
|
||||
* @return the string for dB values.
|
||||
*/
|
||||
public String getdBPSDString() {
|
||||
return GlobalMedium.getdBPSDString(globalMediumParams.currentMedium);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string for the default dB reference unit for power spectral density e.g. dB re 1uPa^2/Hz.
|
||||
* @return the string for dB values.
|
||||
*/
|
||||
public String getdBSELString() {
|
||||
return GlobalMedium.getdBSELString(globalMediumParams.currentMedium);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height coefficient value for displays. Heights are always stored so
|
||||
|
@ -809,7 +809,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
|
||||
createColours();
|
||||
|
||||
timeAxis = new PamAxis(10, 0, imageWidth, 0, 0,
|
||||
spectrogramParameters.displayLength, true, "seconds", "%3.1f");
|
||||
spectrogramParameters.displayLength, true, "Time (s)", "%3.1f");
|
||||
spectrogramAxis.setNorthAxis(timeAxis);
|
||||
|
||||
if (rangeSpinner != null) {
|
||||
@ -817,13 +817,15 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
|
||||
}
|
||||
|
||||
double fScale = 1;
|
||||
String westLabel = "Frequency (Hz)";
|
||||
if (spectrogramParameters.frequencyLimits[1] > 2000) {
|
||||
fScale = 1000;
|
||||
westLabel = "Frequency (kHz)";
|
||||
}
|
||||
|
||||
frequencyAxis = new PamAxis(0, 200, 0, 10,
|
||||
spectrogramParameters.frequencyLimits[0] / fScale,
|
||||
spectrogramParameters.frequencyLimits[1] / fScale, true, "",
|
||||
spectrogramParameters.frequencyLimits[1] / fScale, true, westLabel,
|
||||
null);
|
||||
frequencyAxis.setFractionalScale(true);
|
||||
frequencyAxis.setCrampLabels(true);
|
||||
@ -1696,9 +1698,11 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
|
||||
// setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10));
|
||||
setLayout(new BorderLayout());
|
||||
add(new AmplitudeBar(), BorderLayout.CENTER);
|
||||
|
||||
String label = String.format("PSD (%s)", PamController.getInstance().getGlobalMediumManager().getdBPSDString());
|
||||
amplitudeAxis = new PamAxis(0, 200, 0, 10,
|
||||
spectrogramParameters.amplitudeLimits[0],
|
||||
spectrogramParameters.amplitudeLimits[1], false, "", "%3.0f");
|
||||
spectrogramParameters.amplitudeLimits[1], false, label, "%3.0f");
|
||||
setEastAxis(amplitudeAxis);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import generalDatabase.SQLLoggingAddon;
|
||||
* @see SoloAnnotationType
|
||||
*
|
||||
*/
|
||||
public abstract class DataAnnotationType<TDataAnnotation extends DataAnnotation> {
|
||||
public abstract class DataAnnotationType<TDataAnnotation extends DataAnnotation<?>> {
|
||||
|
||||
public abstract String getAnnotationName();
|
||||
|
||||
|
@ -5,7 +5,7 @@ import PamguardMVC.dataSelector.DataSelectorCreator;
|
||||
import annotation.DataAnnotation;
|
||||
import annotation.DataAnnotationType;
|
||||
|
||||
public abstract class AnnotationDataSelCreator<TDataAnnotation extends DataAnnotation> extends DataSelectorCreator {
|
||||
public abstract class AnnotationDataSelCreator<TDataAnnotation extends DataAnnotation<?>> extends DataSelectorCreator {
|
||||
|
||||
private DataAnnotationType<TDataAnnotation> dataAnnotationType;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import PamguardMVC.dataSelector.DataSelector;
|
||||
import annotation.DataAnnotation;
|
||||
import annotation.DataAnnotationType;
|
||||
|
||||
public abstract class AnnotationDataSelector<TDataAnnotation extends DataAnnotation> extends DataSelector {
|
||||
public abstract class AnnotationDataSelector<TDataAnnotation extends DataAnnotation<?>> extends DataSelector {
|
||||
|
||||
private DataAnnotationType<TDataAnnotation> annotationType;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import annotation.DataAnnotation;
|
||||
import annotation.DataAnnotationType;
|
||||
import pamViewFX.fxSettingsPanes.DynamicSettingsPane;
|
||||
|
||||
public abstract class ScalarDataSelector<TDataAnnotation extends DataAnnotation> extends AnnotationDataSelector<TDataAnnotation> {
|
||||
public abstract class ScalarDataSelector<TDataAnnotation extends DataAnnotation<?>> extends AnnotationDataSelector<TDataAnnotation> {
|
||||
|
||||
/**
|
||||
* @return the scalarDataParams
|
||||
|
@ -3,11 +3,11 @@ package annotation.string;
|
||||
import annotation.DataAnnotation;
|
||||
import annotation.DataAnnotationType;
|
||||
|
||||
public class StringAnnotation extends DataAnnotation {
|
||||
public class StringAnnotation<T extends DataAnnotationType<?>> extends DataAnnotation<T> {
|
||||
|
||||
private String string;
|
||||
|
||||
public StringAnnotation(DataAnnotationType dataAnnotationType) {
|
||||
public StringAnnotation(T dataAnnotationType) {
|
||||
super(dataAnnotationType);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import annotation.handler.AnnotationOptions;
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
public class StringAnnotationType extends DataAnnotationType<StringAnnotation> {
|
||||
public class StringAnnotationType extends DataAnnotationType<StringAnnotation<?>> {
|
||||
|
||||
private String annotationName;
|
||||
private StringSQLLogging sqlAddon;
|
||||
|
@ -4,11 +4,11 @@ import PamUtils.PamCalendar;
|
||||
import annotation.DataAnnotation;
|
||||
import annotation.DataAnnotationType;
|
||||
|
||||
public class TimestampAnnotation extends DataAnnotation {
|
||||
public class TimestampAnnotation<T extends DataAnnotationType<?>> extends DataAnnotation<T> {
|
||||
|
||||
private long timestamp;
|
||||
|
||||
public TimestampAnnotation(DataAnnotationType dataAnnotationType) {
|
||||
public TimestampAnnotation(T dataAnnotationType) {
|
||||
super(dataAnnotationType);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import annotation.DataAnnotationType;
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
public class TimestampAnnotationType extends DataAnnotationType<TimestampAnnotation> {
|
||||
public class TimestampAnnotationType extends DataAnnotationType<TimestampAnnotation<?>> {
|
||||
|
||||
private String annotationName;
|
||||
private TimestampSQLLogging sqlAddon;
|
||||
|
@ -3,14 +3,14 @@ package annotation.userforms;
|
||||
import annotation.DataAnnotation;
|
||||
import annotation.DataAnnotationType;
|
||||
|
||||
public class UserFormAnnotation extends DataAnnotation {
|
||||
public class UserFormAnnotation<T extends DataAnnotationType<?>> extends DataAnnotation<T> {
|
||||
|
||||
/**
|
||||
* Data extracted from the logger form.
|
||||
*/
|
||||
private Object[] loggerFormData;
|
||||
|
||||
public UserFormAnnotation(DataAnnotationType dataAnnotationType, Object[] loggerFormData) {
|
||||
public UserFormAnnotation(T dataAnnotationType, Object[] loggerFormData) {
|
||||
super(dataAnnotationType);
|
||||
this.setLoggerFormData(loggerFormData);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import loggerForms.FormDescription;
|
||||
import loggerForms.FormsControl;
|
||||
import loggerForms.LoggerForm;
|
||||
|
||||
public class UserFormAnnotationType extends DataAnnotationType<UserFormAnnotation> {
|
||||
public class UserFormAnnotationType extends DataAnnotationType<UserFormAnnotation<?>> {
|
||||
|
||||
|
||||
private UserFormAnnotationOptions userFormAnnotationOptions;
|
||||
@ -201,7 +201,7 @@ public class UserFormAnnotationType extends DataAnnotationType<UserFormAnnotatio
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationBinaryHandler<UserFormAnnotation> getBinaryHandler() {
|
||||
public AnnotationBinaryHandler<UserFormAnnotation<?>> getBinaryHandler() {
|
||||
if (userFormBinaryHandler == null) {
|
||||
synchronized (this) {
|
||||
if (userFormBinaryHandler == null) {
|
||||
|
@ -42,7 +42,7 @@ public class DbHtDisplayDialog extends PamDialog {
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
JPanel scalePanel = new JPanel(new GridBagLayout());
|
||||
scalePanel.setBorder(new TitledBorder("Amlitude Scale"));
|
||||
scalePanel.setBorder(new TitledBorder("Amplitude Scale"));
|
||||
GridBagConstraints c = new PamGridBagContraints();
|
||||
c.gridwidth = 3;
|
||||
addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c);
|
||||
|
@ -16,7 +16,7 @@ import us.hebi.matlab.mat.types.Struct;
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class MLCPODExport extends MLDataUnitExport<PamDataUnit>{
|
||||
public class MLCPODExport extends MLDataUnitExport<PamDataUnit<?, ?>>{
|
||||
|
||||
@Override
|
||||
public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) {
|
||||
|
@ -14,7 +14,7 @@ import us.hebi.matlab.mat.types.Struct;
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class MLRawExport extends MLDataUnitExport<PamDataUnit>{
|
||||
public class MLRawExport extends MLDataUnitExport<PamDataUnit<?,?>>{
|
||||
|
||||
@Override
|
||||
public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) {
|
||||
|
@ -10,7 +10,7 @@ import cpod.CPODClick;
|
||||
import export.MLExport.MLCPODExport;
|
||||
|
||||
|
||||
public class RCPODExport extends RDataUnitExport<PamDataUnit> {
|
||||
public class RCPODExport extends RDataUnitExport<PamDataUnit<?, ?>> {
|
||||
|
||||
@Override
|
||||
public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) {
|
||||
|
@ -10,7 +10,7 @@ import org.renjin.sexp.ListVector.NamedBuilder;
|
||||
|
||||
import clickDetector.ClickDetection;
|
||||
|
||||
public class RRawExport extends RDataUnitExport<PamDataUnit> {
|
||||
public class RRawExport extends RDataUnitExport<PamDataUnit<?,?>> {
|
||||
|
||||
@Override
|
||||
public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) {
|
||||
|
@ -9,7 +9,7 @@ import clickDetector.ClickDetection;
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class RawHolderWavExport extends WavDataUnitExport<PamDataUnit> {
|
||||
public class RawHolderWavExport extends WavDataUnitExport<PamDataUnit<?,?>> {
|
||||
|
||||
@Override
|
||||
public double[][] getWavClip(PamDataUnit dataUnit) {
|
||||
|
@ -136,7 +136,8 @@ public class FFTPluginPanelProvider implements DisplayPanelProvider {
|
||||
isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW;
|
||||
setupPanel();
|
||||
|
||||
westAxis = new PamAxis(0, 0, 1, 1, getScaleMin(), getScaleMax(), true, "dB", "%.0f");
|
||||
String label = String.format("PSD (%s)", PamController.getInstance().getGlobalMediumManager().getdBPSDString());
|
||||
westAxis = new PamAxis(0, 0, 1, 1, getScaleMin(), getScaleMax(), true, label, "%.0f");
|
||||
westAxis.setInterval(20);
|
||||
//southAxis = new PamAxis(0, 0, 10, 10, 0, pamFFTProcess.getSampleRate()/2/1000, true, "kHz", "%.0f");
|
||||
southAxis = new PamAxis(0, 0, 1, 1, 0, fftDataBlock.getSampleRate()/2/1000, false, "kHz", "%.0f");
|
||||
|
@ -10,11 +10,8 @@ import javax.swing.JButton;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamController.*;
|
||||
import PamController.soundMedium.GlobalMediumManager;
|
||||
import PamView.PamTabPanel;
|
||||
import noiseOneBand.offline.OneBandSummaryTask;
|
||||
import offlineProcessing.DataCopyTask;
|
||||
@ -22,13 +19,16 @@ import offlineProcessing.OLProcessDialog;
|
||||
import offlineProcessing.OfflineTaskGroup;
|
||||
|
||||
public class OneBandControl extends PamControlledUnit implements PamSettings {
|
||||
|
||||
/**
|
||||
* The number of measures taken by {@link OneBandControl}.
|
||||
* See {@link OneBandControl#getMeasurementName(int)} for description and units of each measure.
|
||||
*/
|
||||
public static final int NMEASURES = 4;
|
||||
public static final String[] measureNames = {"RMS", "0-Peak", "Peak-Peak", "Integrated SEL"};
|
||||
private OneBandProcess oneBandProcess;
|
||||
private OneBandPulseProcess pulseProcess;
|
||||
|
||||
private final OneBandProcess oneBandProcess;
|
||||
private final OneBandPulseProcess pulseProcess;
|
||||
protected OneBandParameters oneBandParameters = new OneBandParameters();
|
||||
private OneBandTabPanel dBHtTabPanel;
|
||||
private final OneBandTabPanel dBHtTabPanel;
|
||||
private OfflineTaskGroup offlineTaskGroup;
|
||||
private OLProcessDialog olProcessDialog;
|
||||
|
||||
@ -66,6 +66,32 @@ public class OneBandControl extends PamControlledUnit implements PamSettings {
|
||||
return dBHtTabPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the measurement name for a given index (0 <= index < {@link OneBandControl#NMEASURES}).
|
||||
* This requires access to the Global Medium Manager to report on the correct units.
|
||||
*
|
||||
* @param index The index of the measure.
|
||||
* @return The text representation of the relevant measure, including units.
|
||||
*/
|
||||
public static String getMeasurementName(int index) {
|
||||
GlobalMediumManager gmm = PamController.getInstance().getGlobalMediumManager();
|
||||
String dbRef = gmm.getdBRefString();
|
||||
String selDbRef = gmm.getdBSELString();
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
return String.format("RMS (%s)", dbRef);
|
||||
case 1:
|
||||
return String.format("0-Peak (%s)", dbRef);
|
||||
case 2:
|
||||
return String.format("Peak-Peak (%s)", dbRef);
|
||||
case 3:
|
||||
return String.format("Integrated SEL (%s)", selDbRef);
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + index);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see PamController.PamControlledUnit#createDetectionMenu(java.awt.Frame)
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ public class OneBandDisplayDialog extends PamDialog {
|
||||
mainPanel.add(tabPane);
|
||||
|
||||
JPanel scalePanel = new JPanel(new GridBagLayout());
|
||||
scalePanel.setBorder(new TitledBorder("Amlitude Scale"));
|
||||
scalePanel.setBorder(new TitledBorder("Amplitude Scale"));
|
||||
GridBagConstraints c = new PamGridBagContraints();
|
||||
c.gridwidth = 3;
|
||||
addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c);
|
||||
@ -62,14 +62,14 @@ public class OneBandDisplayDialog extends PamDialog {
|
||||
c.gridx++;
|
||||
addComponent(scalePanel, minAmp = new JTextField(5), c);
|
||||
c.gridx++;
|
||||
addComponent(scalePanel, new JLabel(" dB re 1\u03BCPa ", SwingConstants.LEFT), c);
|
||||
addComponent(scalePanel, new JLabel(" dB", SwingConstants.LEFT), c);
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
addComponent(scalePanel, new JLabel("Max ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
addComponent(scalePanel, maxAmp = new JTextField(5), c);
|
||||
c.gridx++;
|
||||
addComponent(scalePanel, new JLabel(" dB re 1\u03BCPa ", SwingConstants.LEFT), c);
|
||||
addComponent(scalePanel, new JLabel(" dB", SwingConstants.LEFT), c);
|
||||
|
||||
tabPane.add(scalePanel, "Scale");
|
||||
|
||||
@ -91,7 +91,7 @@ public class OneBandDisplayDialog extends PamDialog {
|
||||
for (int i = 0; i < OneBandControl.NMEASURES; i++) {
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
addComponent(symPanel, showMeasure[i] = new JCheckBox("Show " + OneBandControl.measureNames[i]), c);
|
||||
addComponent(symPanel, showMeasure[i] = new JCheckBox("Show " + OneBandControl.getMeasurementName(i)), c);
|
||||
}
|
||||
tabPane.add(symPanel, "Symbols");
|
||||
|
||||
|
@ -508,7 +508,7 @@ public class OneBandDisplayPanel {
|
||||
OneBandDisplayParams params = getDisplayParams(panelType);
|
||||
for (int i = OneBandControl.NMEASURES-1; i >= 0; i--) {
|
||||
if ((params.showWhat & 1<<i) != 0) {
|
||||
keyPanel.add(new SymbolKeyItem(measureSymbols[i], OneBandControl.measureNames[i]));
|
||||
keyPanel.add(new SymbolKeyItem(measureSymbols[i], OneBandControl.getMeasurementName(i)));
|
||||
}
|
||||
}
|
||||
if (displayParams.colourByChannel) {
|
||||
|
@ -8,6 +8,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import PamController.soundMedium.GlobalMediumManager;
|
||||
import PamView.dialog.PamDialog;
|
||||
import noiseOneBand.OneBandAlarmParameters;
|
||||
import noiseOneBand.OneBandControl;
|
||||
@ -28,7 +29,7 @@ public class OneBandAlarmParamsDialog extends PamDialog {
|
||||
mainPanel.setBorder(new TitledBorder("Select measure"));
|
||||
ButtonGroup bg = new ButtonGroup();
|
||||
for (int i = 0; i < OneBandControl.NMEASURES; i++) {
|
||||
measures[i] = new JRadioButton(OneBandControl.measureNames[i]);
|
||||
measures[i] = new JRadioButton(OneBandControl.getMeasurementName(i));
|
||||
bg.add(measures[i]);
|
||||
mainPanel.add(measures[i]);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package test.export;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
||||
import test.helper.PamControllerTestHelper;
|
||||
import clickDetector.ClickControl;
|
||||
import clickDetector.ClickDetector;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import clickDetector.ClickDetection;
|
||||
@ -18,14 +18,16 @@ public class ExportTest {
|
||||
* Test exporting detections to mat files.
|
||||
*/
|
||||
@Test
|
||||
public void matFileTest() {
|
||||
|
||||
public void matFileTest() throws Exception {
|
||||
PamControllerTestHelper.InitializePamControllerForTesting();
|
||||
|
||||
System.out.println("Matched template classifier test: match corr");
|
||||
|
||||
//create a list of click detections.
|
||||
ClickDetection clickDetection = new ClickDetection(0, 0, 0, null, null, 0);
|
||||
|
||||
|
||||
|
||||
//create a list of click detections.
|
||||
ClickControl control = new ClickControl("name");
|
||||
ClickDetector detector = new ClickDetector(control);
|
||||
ClickDetection clickDetection = new ClickDetection(0, 0, 0, detector, null, 0);
|
||||
|
||||
//now open the mat file and check that we have all the data from these click detections.
|
||||
|
||||
}
|
||||
|
29
src/test/helper/PamControllerTestHelper.java
Normal file
29
src/test/helper/PamControllerTestHelper.java
Normal file
@ -0,0 +1,29 @@
|
||||
package test.helper;
|
||||
|
||||
import PamController.PamController;
|
||||
import PamController.PamSettingManager;
|
||||
import pamguard.GlobalArguments;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Helper to initialize a headless {@link PamController} from unit tests.
|
||||
* This will only initialize the {@link PamController} once; tests are responsible for cleaning
|
||||
* up any changes they make to the configuration.
|
||||
*/
|
||||
public class PamControllerTestHelper {
|
||||
private static boolean isInitialized = false;
|
||||
|
||||
public static void InitializePamControllerForTesting() throws IOException {
|
||||
if (!isInitialized) {
|
||||
isInitialized = true;
|
||||
File file = File.createTempFile("OneBandControlTest", "psfx");
|
||||
file.deleteOnExit();
|
||||
|
||||
GlobalArguments.setParam(GlobalArguments.BATCHFLAG, "true");
|
||||
PamSettingManager.remote_psf = file.getAbsolutePath();
|
||||
PamController.create(PamController.RUN_NOTHING);
|
||||
}
|
||||
}
|
||||
}
|
41
src/test/noiseOneBand/OneBandControlTest.java
Normal file
41
src/test/noiseOneBand/OneBandControlTest.java
Normal file
@ -0,0 +1,41 @@
|
||||
package test.noiseOneBand;
|
||||
|
||||
import PamController.PamController;
|
||||
import PamController.soundMedium.GlobalMedium;
|
||||
import test.helper.PamControllerTestHelper;
|
||||
import noiseOneBand.OneBandControl;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class OneBandControlTest {
|
||||
@BeforeAll
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
PamControllerTestHelper.InitializePamControllerForTesting();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MeasurementnameTest() {
|
||||
try {
|
||||
assertEquals(4, OneBandControl.NMEASURES);
|
||||
assertThrows(Exception.class, () -> OneBandControl.getMeasurementName(4));
|
||||
|
||||
PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Water, false);
|
||||
assertEquals("RMS (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(0));
|
||||
assertEquals("0-Peak (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(1));
|
||||
assertEquals("Peak-Peak (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(2));
|
||||
assertEquals("Integrated SEL (dB re 1\u00B5Pa\u00B2s)", OneBandControl.getMeasurementName(3));
|
||||
|
||||
PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Air, false);
|
||||
assertEquals("RMS (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(0));
|
||||
assertEquals("0-Peak (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(1));
|
||||
assertEquals("Peak-Peak (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(2));
|
||||
assertEquals("Integrated SEL (dB re 400\u00B5Pa\u00B2s)", OneBandControl.getMeasurementName(3));
|
||||
} finally {
|
||||
PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Water, false);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user