diff --git a/.classpath b/.classpath index 6b516690..43cd7cd5 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/.project b/.project index 275f701e..8ab9c149 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - PamGuard Working + PamGuard GPL diff --git a/pom.xml b/pom.xml index c764dd54..4c3b67bd 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.pamguard PamguardBeta - 2.02.02 + 2.02.03a Pamguard Java12+ Pamguard for Java 12+, using Maven to control dependcies www.pamguard.org diff --git a/src/PamController/PamguardVersionInfo.java b/src/PamController/PamguardVersionInfo.java index cdd0927d..2f8611c7 100644 --- a/src/PamController/PamguardVersionInfo.java +++ b/src/PamController/PamguardVersionInfo.java @@ -31,7 +31,7 @@ public class PamguardVersionInfo { * Version number, major version.minorversion.sub-release. * Note: can't go higher than sub-release 'f' */ - static public final String version = "2.02.03"; + static public final String version = "2.02.03a"; /** * Release date diff --git a/src/gpl/GPLProcess.java b/src/gpl/GPLProcess.java index 45eeaf81..e63dab92 100644 --- a/src/gpl/GPLProcess.java +++ b/src/gpl/GPLProcess.java @@ -87,6 +87,7 @@ public class GPLProcess extends PamBlockProcess { addOutputDataBlock(whitenedSpectrogram); stateDataBlock = new GPLStateDataBlock(this, 0); + stateDataBlock.setBinaryDataSource(new GPLStateDataSource(stateDataBlock)); addOutputDataBlock(stateDataBlock); gplDetectionBlock = new GPLDetectionBlock(this); @@ -780,12 +781,13 @@ public class GPLProcess extends PamBlockProcess { // quiet.noise_floor = 1.; - /** - * This is the call to the detector, which is remembering state, will mostly return - * null, but when there has been a detection, will return an object with time and - * frequency information. - */ - } + + } + /** + * This is the call to the detector, which is remembering state, will mostly return + * null, but when there has been a detection, will return an object with time and + * frequency information. + */ public void runDetector(FFTDataUnit fftDataUnit, double[] wData, double base_in, double ceilnoise, double threshfloor) { // DetectedPeak newPeak = peakDetector.detectPeaks(fftDataUnit, wData, base_in, // gplParams.noise_ceiling * noise_floor, gplParams.thresh * noise_floor); diff --git a/src/gpl/GPLStateDataSource.java b/src/gpl/GPLStateDataSource.java new file mode 100644 index 00000000..0c2ab5d5 --- /dev/null +++ b/src/gpl/GPLStateDataSource.java @@ -0,0 +1,109 @@ +package gpl; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; + +import PamguardMVC.PamDataBlock; +import PamguardMVC.PamDataUnit; +import binaryFileStorage.BinaryDataSource; +import binaryFileStorage.BinaryHeader; +import binaryFileStorage.BinaryObjectData; +import binaryFileStorage.ModuleFooter; +import binaryFileStorage.ModuleHeader; + +public class GPLStateDataSource extends BinaryDataSource { + + private GPLStateDataBlock gplStateDataBlock; + private ByteArrayOutputStream bos; + private DataOutputStream dos; + + public GPLStateDataSource(GPLStateDataBlock gplStateDataBlock) { + super(gplStateDataBlock); + this.gplStateDataBlock = gplStateDataBlock; + } + + @Override + public String getStreamName() { + return "GPL State"; + } + + @Override + public int getStreamVersion() { + return 0; + } + + @Override + public int getModuleVersion() { + return 0; + } + + @Override + public byte[] getModuleHeaderData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public PamDataUnit sinkData(BinaryObjectData binaryObjectData, BinaryHeader bh, int moduleVersion) { + DataInputStream dis = new DataInputStream(new ByteArrayInputStream(binaryObjectData.getData())); + try { + double baseline = dis.readFloat(); + double ceilnoise = dis.readFloat(); + double threshfloor = dis.readFloat();; + int state = dis.readShort(); + GPLStateDataUnit stateData = new GPLStateDataUnit(binaryObjectData.getDataUnitBaseData(), baseline, ceilnoise, threshfloor, state); + return stateData; + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + @Override + public ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData, BinaryHeader bh) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ModuleFooter sinkModuleFooter(BinaryObjectData binaryObjectData, BinaryHeader bh, + ModuleHeader moduleHeader) { + return null; + } + + @Override + public BinaryObjectData getPackedData(PamDataUnit pamDataUnit) { + if (bos == null) { + bos = new ByteArrayOutputStream(14); + dos = new DataOutputStream(bos); + } + else { + bos.reset(); + } + GPLStateDataUnit stateData = (GPLStateDataUnit) pamDataUnit; + try { + dos.writeFloat((float) stateData.getBaseline()); + dos.writeFloat((float) stateData.getCeilnoise()); + dos.writeFloat((float) stateData.getThreshfloor()); + dos.writeShort((short) stateData.getPeakState()); + } catch (IOException e) { + e.printStackTrace(); + } + + BinaryObjectData bod = new BinaryObjectData(1, bos.toByteArray()); + + return bod; + } + + @Override + public void newFileOpened(File outputFile) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/gpl/GPLStateDataUnit.java b/src/gpl/GPLStateDataUnit.java index 2bbaed55..75898ae7 100644 --- a/src/gpl/GPLStateDataUnit.java +++ b/src/gpl/GPLStateDataUnit.java @@ -1,5 +1,6 @@ package gpl; +import PamguardMVC.DataUnitBaseData; import PamguardMVC.PamDataUnit; public class GPLStateDataUnit extends PamDataUnit { @@ -30,6 +31,23 @@ public class GPLStateDataUnit extends PamDataUnit { this.threshfloor = threshfloor; } + /** + * constructor used reading back from binary files. + * @param baseData + * @param baseline + * @param ceilnoise + * @param threshfloor + * @param peakState + */ + public GPLStateDataUnit(DataUnitBaseData baseData,double baseline, + double ceilnoise, double threshfloor, int peakState) { + super(baseData); + this.baseline = baseline; + this.peakState = peakState; + this.ceilnoise = ceilnoise; + this.threshfloor = threshfloor; + } + /** * @return the ceilnoise */