mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
update sud file management to more efficiently skip to the correct part
of a sud file when reading data offline.
This commit is contained in:
parent
60435e567a
commit
fa5fe9943d
@ -4,7 +4,7 @@
|
|||||||
<groupId>org.pamguard</groupId>
|
<groupId>org.pamguard</groupId>
|
||||||
<artifactId>Pamguard</artifactId>
|
<artifactId>Pamguard</artifactId>
|
||||||
<name>Pamguard Java12+</name>
|
<name>Pamguard Java12+</name>
|
||||||
<version>2.02.09</version>
|
<version>2.02.09b</version>
|
||||||
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
|
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
|
||||||
<url>www.pamguard.org</url>
|
<url>www.pamguard.org</url>
|
||||||
<organization>
|
<organization>
|
||||||
|
8
pom.xml
8
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.pamguard</groupId>
|
<groupId>org.pamguard</groupId>
|
||||||
<artifactId>Pamguard</artifactId>
|
<artifactId>Pamguard</artifactId>
|
||||||
<version>2.02.09a</version>
|
<version>2.02.09b</version>
|
||||||
<name>Pamguard Java12+</name>
|
<name>Pamguard Java12+</name>
|
||||||
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
|
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
|
||||||
<url>www.pamguard.org</url>
|
<url>www.pamguard.org</url>
|
||||||
@ -782,13 +782,13 @@
|
|||||||
|
|
||||||
<!-- not in Maven repository
|
<!-- not in Maven repository
|
||||||
you may need to copy files from your downloaded PAMGuard source code, e.g. C:\Users\*yourreposfolder*\source\repos\PAMGuardPAMGuard\repo\pamguard\org\x3\2.2.2 to
|
you may need to copy files from your downloaded PAMGuard source code, e.g. C:\Users\*yourreposfolder*\source\repos\PAMGuardPAMGuard\repo\pamguard\org\x3\2.2.2 to
|
||||||
C:\Users\*yourusername*\.m2\repository\pamguard\org\x3\2.2.2
|
C:\Users\*yourusername*\.m2\repository\pamguard\org\x3\2.2.2-->
|
||||||
-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pamguard.org</groupId>
|
<groupId>pamguard.org</groupId>
|
||||||
<artifactId>x3</artifactId>
|
<artifactId>x3</artifactId>
|
||||||
<version>2.2.2</version>
|
<version>2.2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/it.sauronsoftware/jave -->
|
<!-- https://mvnrepository.com/artifact/it.sauronsoftware/jave -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -14,6 +14,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
|
|||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
import Acquisition.offlineFuncs.AquisitionLoadPoint;
|
import Acquisition.offlineFuncs.AquisitionLoadPoint;
|
||||||
import PamDetection.RawDataUnit;
|
import PamDetection.RawDataUnit;
|
||||||
|
//import PamUtils.CPUMonitor;
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import PamguardMVC.dataOffline.OfflineDataLoadInfo;
|
import PamguardMVC.dataOffline.OfflineDataLoadInfo;
|
||||||
import dataMap.OfflineDataMap;
|
import dataMap.OfflineDataMap;
|
||||||
@ -70,9 +71,13 @@ public class WavAudioFile implements PamAudioFileLoader {
|
|||||||
FileDataMapPoint mapPoint = offlineFileServer.findFirstMapPoint(mapIt, offlineDataLoadInfo.getStartMillis(), offlineDataLoadInfo.getEndMillis());
|
FileDataMapPoint mapPoint = offlineFileServer.findFirstMapPoint(mapIt, offlineDataLoadInfo.getStartMillis(), offlineDataLoadInfo.getEndMillis());
|
||||||
|
|
||||||
if (openSoundFile(mapPoint.getSoundFile()) == false) {
|
if (openSoundFile(mapPoint.getSoundFile()) == false) {
|
||||||
System.out.println("Could not open .wav sound file " + mapPoint.getSoundFile().getAbsolutePath());
|
System.out.println("Could not open sound file " + mapPoint.getSoundFile().getAbsolutePath());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (offlineDataLoadInfo.cancel) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
File soundFile;
|
File soundFile;
|
||||||
|
|
||||||
ByteConverter byteConverter = ByteConverter.createByteConverter(audioFormat);
|
ByteConverter byteConverter = ByteConverter.createByteConverter(audioFormat);
|
||||||
@ -106,7 +111,11 @@ public class WavAudioFile implements PamAudioFileLoader {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//System.out.println("Skipped " + skipped+ " " + skipBytes + " " + audioInputStream.available());
|
//System.out.println("Skipped " + skipped+ " " + skipBytes + " " + audioInputStream.available());
|
||||||
|
// CPUMonitor cpuMonitor = new CPUMonitor();
|
||||||
|
// cpuMonitor.start();
|
||||||
skipped = audioInputStream.skip(skipBytes);
|
skipped = audioInputStream.skip(skipBytes);
|
||||||
|
// cpuMonitor.stop();
|
||||||
|
// System.out.println(cpuMonitor.getSummary("Sound skip: " + skipBytes + " bytes "));
|
||||||
//System.out.println("Offline " + (offlineDataLoadInfo.getStartMillis()-currentTime) + " ms : frame size: " + audioFormat.getFrameSize());
|
//System.out.println("Offline " + (offlineDataLoadInfo.getStartMillis()-currentTime) + " ms : frame size: " + audioFormat.getFrameSize());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -31,7 +31,7 @@ public class PamguardVersionInfo {
|
|||||||
* Version number, major version.minorversion.sub-release.
|
* Version number, major version.minorversion.sub-release.
|
||||||
* Note: can't go higher than sub-release 'f'
|
* Note: can't go higher than sub-release 'f'
|
||||||
*/
|
*/
|
||||||
static public final String version = "2.02.09a";
|
static public final String version = "2.02.09b";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release date
|
* Release date
|
||||||
|
@ -129,8 +129,8 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
this.orderOfflineData(offlineDataInfo);
|
this.orderOfflineData(offlineDataInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all raw and FFT data blocks prior to a new load.
|
* Clears all raw and FFT data blocks prior to a new load.
|
||||||
*/
|
*/
|
||||||
@ -140,7 +140,7 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
datablocks.get(i).clearAll();
|
datablocks.get(i).clearAll();
|
||||||
datablocks.get(i).clearDeletedList();
|
datablocks.get(i).clearDeletedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
datablocks = PamController.getInstance().getRawDataBlocks();
|
datablocks = PamController.getInstance().getRawDataBlocks();
|
||||||
for (int i=0; i<datablocks.size(); i++) {
|
for (int i=0; i<datablocks.size(); i++) {
|
||||||
datablocks.get(i).clearAll();
|
datablocks.get(i).clearAll();
|
||||||
@ -175,62 +175,62 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
long t4 = t2;
|
long t4 = t2;
|
||||||
// String orderDates = String.format(" %s to %s",
|
// String orderDates = String.format(" %s to %s",
|
||||||
// PamCalendar.formatDateTime(startMillis), PamCalendar.formatDateTime(endMillis));
|
// PamCalendar.formatDateTime(startMillis), PamCalendar.formatDateTime(endMillis));
|
||||||
// System.out.printf("Offline data order in %s %s from %s to %s\n", pamDataBlock.getDataName(), offlineDataInfo.toString(),
|
// System.out.printf("Offline data order in %s %s from %s to %s\n", pamDataBlock.getDataName(), offlineDataInfo.toString(),
|
||||||
// PamCalendar.formatDBDateTime(offlineDataInfo.getStartMillis()),
|
// PamCalendar.formatDBDateTime(offlineDataInfo.getStartMillis()),
|
||||||
// PamCalendar.formatDBDateTime(offlineDataInfo.getEndMillis()));
|
// PamCalendar.formatDBDateTime(offlineDataInfo.getEndMillis()));
|
||||||
// if (offlineDataInfo.getEndMillis()-offlineDataInfo.getStartMillis() > 3600000L) {
|
// if (offlineDataInfo.getEndMillis()-offlineDataInfo.getStartMillis() > 3600000L) {
|
||||||
// System.out.printf("Stupid long load time !");
|
// System.out.printf("Stupid long load time !");
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
try {
|
try {
|
||||||
if (orderData != null) {
|
if (orderData != null) {
|
||||||
// System.out.println("order Data is not null");
|
// System.out.println("order Data is not null");
|
||||||
if (orderData.isDone() == false) {
|
if (orderData.isDone() == false) {
|
||||||
switch (offlineDataInfo.getInterrupt()) {
|
switch (offlineDataInfo.getInterrupt()) {
|
||||||
case OFFLINE_DATA_INTERRUPT:
|
case OFFLINE_DATA_INTERRUPT:
|
||||||
// System.out.println("Request order cancelling");
|
// System.out.println("Request order cancelling");
|
||||||
|
|
||||||
|
|
||||||
if (orderData.cancelOrder()) {
|
if (orderData.cancelOrder()) {
|
||||||
|
|
||||||
while (orderData!=null || !orderData.isDone()) {
|
while (orderData!=null || !orderData.isDone()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// System.out.println("Old order could not be cancelled");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OFFLINE_DATA_CANCEL:
|
||||||
|
// System.out.println("Don't order new data " + orderDates);
|
||||||
|
return;
|
||||||
|
case OFFLINE_DATA_WAIT:
|
||||||
|
int waitCount = 0;
|
||||||
|
t3 = System.currentTimeMillis();
|
||||||
|
waitingDataLoads.add(offlineDataInfo);
|
||||||
|
return;
|
||||||
|
// // System.out.println("Wait for old lot to complete " + orderDates);
|
||||||
|
// while (true) {
|
||||||
|
// if (orderData==null || orderData.isDone() || orderData.isCancelled()) {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// waitCount++;
|
||||||
|
// try {
|
||||||
|
// Thread.sleep(10, 0);
|
||||||
|
// } catch (InterruptedException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else {
|
t4 = System.currentTimeMillis() - t3;
|
||||||
// System.out.println("Old order could not be cancelled");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OFFLINE_DATA_CANCEL:
|
|
||||||
// System.out.println("Don't order new data " + orderDates);
|
|
||||||
return;
|
|
||||||
case OFFLINE_DATA_WAIT:
|
|
||||||
int waitCount = 0;
|
|
||||||
t3 = System.currentTimeMillis();
|
|
||||||
waitingDataLoads.add(offlineDataInfo);
|
|
||||||
return;
|
|
||||||
// // System.out.println("Wait for old lot to complete " + orderDates);
|
|
||||||
// while (true) {
|
|
||||||
// if (orderData==null || orderData.isDone() || orderData.isCancelled()) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// waitCount++;
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(10, 0);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
t4 = System.currentTimeMillis() - t3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (NullPointerException e) {
|
catch (NullPointerException e) {
|
||||||
// happens when orderData is set null in a different thread.
|
// happens when orderData is set null in a different thread.
|
||||||
}
|
}
|
||||||
@ -244,8 +244,8 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
//t = new Timer(1000, new StartOrderOnTimer(orderData));
|
//t = new Timer(1000, new StartOrderOnTimer(orderData));
|
||||||
} // end of order lock
|
} // end of order lock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the current order.
|
* Cancels the current order.
|
||||||
*/
|
*/
|
||||||
@ -259,16 +259,19 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
* @param que
|
* @param que
|
||||||
*/
|
*/
|
||||||
public void cancelDataOrder(boolean que) {
|
public void cancelDataOrder(boolean que) {
|
||||||
synchronized (orderLock) {
|
// threadMessage("Calling cancelDataOrder");
|
||||||
if (orderData != null) {
|
synchronized (orderLock) {
|
||||||
try {
|
// threadMessage("cancelDataOrder is in synchronized oderLock");
|
||||||
orderData.cancelOrder();
|
if (orderData != null) {
|
||||||
}
|
try {
|
||||||
catch (NullPointerException e) {
|
boolean isCancelled = orderData.cancelOrder();
|
||||||
System.err.println("Null pointer in Cancel data order " + e.getMessage());
|
// threadMessage("candelDataOrder returned: isCancelled = " + isCancelled);
|
||||||
|
}
|
||||||
|
catch (NullPointerException e) {
|
||||||
|
System.err.println("Null pointer in Cancel data order " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (que) this.waitingDataLoads.clear();
|
if (que) this.waitingDataLoads.clear();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -319,16 +322,19 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Integer doInBackground() {
|
protected Integer doInBackground() {
|
||||||
|
// threadMessage("Start background");
|
||||||
try {
|
try {
|
||||||
// System.out.println("Enter get offline data " + pamDataBlock.getDataName() + " Thread " + Thread.currentThread().getName());
|
// System.out.println("Enter get offline data " + pamDataBlock.getDataName() + " Thread " + Thread.currentThread().getName());
|
||||||
|
|
||||||
clearAllFFTBlocks();
|
clearAllFFTBlocks();
|
||||||
|
// threadMessage("Called clearAllFTBlocks");
|
||||||
int ans = getOfflineData(offlineDataInfo);
|
int ans = getOfflineData(offlineDataInfo);
|
||||||
// System.out.println("Leave get offline data " + pamDataBlock.getDataName());
|
// System.out.println("Leave get offline data " + pamDataBlock.getDataName());
|
||||||
|
|
||||||
if (this == orderData) {
|
if (this == orderData) {
|
||||||
orderData = null;
|
orderData = null;
|
||||||
}
|
}
|
||||||
|
// threadMessage("End background exit code " + ans);
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -338,8 +344,8 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
@ -354,7 +360,7 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
status = REQUEST_INTERRUPTED;
|
status = REQUEST_INTERRUPTED;
|
||||||
//check whether the cancelled thread should be saved for later loading.
|
//check whether the cancelled thread should be saved for later loading.
|
||||||
// System.out.println("The load has been cancelled: " + offlineDataInfo.getCurrentObserver().getObserverName());
|
// System.out.println("The load has been cancelled: " + offlineDataInfo.getCurrentObserver().getObserverName());
|
||||||
checkDataReloadQue(offlineDataInfo);
|
checkDataReloadQue(offlineDataInfo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -376,11 +382,11 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("WAITING DATA LOAD");
|
// System.out.println("WAITING DATA LOAD");
|
||||||
for (int i=0; i<waitingDataLoads.size(); i++){
|
for (int i=0; i<waitingDataLoads.size(); i++){
|
||||||
// System.out.println("OfflineDataLoading.Done(): " + waitingDataLoads.get(i).getCurrentObserver().getObserverName());
|
// System.out.println("OfflineDataLoading.Done(): " + waitingDataLoads.get(i).getCurrentObserver().getObserverName());
|
||||||
}
|
}
|
||||||
// System.out.println("WAITING DATA END");
|
// System.out.println("WAITING DATA END");
|
||||||
|
|
||||||
if (!isCancelled()) launchQuedReloadThread();
|
if (!isCancelled()) launchQuedReloadThread();
|
||||||
|
|
||||||
@ -394,11 +400,17 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private void threadMessage(String message) {
|
||||||
|
// String name = Thread.currentThread().getName();
|
||||||
|
// String now = PamCalendar.formatDBDateTime(System.currentTimeMillis(), true);
|
||||||
|
// System.out.printf("Thread %s load for %s at %s: %s\n", name, pamDataBlock.getDataName(), now, message);
|
||||||
|
// }
|
||||||
|
|
||||||
private void launchQuedReloadThread(){
|
private void launchQuedReloadThread(){
|
||||||
// System.out.println(" launchQuedReloadThread(): ");
|
// System.out.println(" launchQuedReloadThread(): ");
|
||||||
if (waitingDataLoads.size()>=1){
|
if (waitingDataLoads.size()>=1){
|
||||||
OfflineDataLoadInfo offlineDataInfo=waitingDataLoads.get(0);
|
OfflineDataLoadInfo offlineDataInfo=waitingDataLoads.get(0);
|
||||||
// System.out.println("Removing: " + offlineDataInfo.getCurrentObserver().getObserverName());
|
// System.out.println("Removing: " + offlineDataInfo.getCurrentObserver().getObserverName());
|
||||||
waitingDataLoads.remove(0);
|
waitingDataLoads.remove(0);
|
||||||
this.orderOfflineData(offlineDataInfo);
|
this.orderOfflineData(offlineDataInfo);
|
||||||
}
|
}
|
||||||
@ -470,15 +482,15 @@ public class OfflineDataLoading<T extends PamDataUnit> {
|
|||||||
|
|
||||||
pamDataBlock.clearAll();
|
pamDataBlock.clearAll();
|
||||||
|
|
||||||
// System.out.println("Start loading some offline data: from " + PamCalendar.formatDateTime(offlineDataInfo.getStartMillis() ) +" to "+
|
// System.out.println("Start loading some offline data: from " + PamCalendar.formatDateTime(offlineDataInfo.getStartMillis() ) +" to "+
|
||||||
// PamCalendar.formatDateTime(offlineDataInfo.getEndMillis() ) + " "+offlineDataInfo.getCurrentObserver().getObserverName() +
|
// PamCalendar.formatDateTime(offlineDataInfo.getEndMillis() ) + " "+offlineDataInfo.getCurrentObserver().getObserverName() +
|
||||||
// " "+offlineDataInfo.getLoadKeepLayers());
|
// " "+offlineDataInfo.getLoadKeepLayers());
|
||||||
|
|
||||||
lastRequestAnswer = pamDataBlock.getParentProcess().getOfflineData(offlineDataInfo);
|
lastRequestAnswer = pamDataBlock.getParentProcess().getOfflineData(offlineDataInfo);
|
||||||
// System.out.println(String.format("getOfflineData %s has %d units ",
|
// System.out.println(String.format("getOfflineData %s has %d units ",
|
||||||
// getDataName(), getUnitsCount()));
|
// getDataName(), getUnitsCount()));
|
||||||
|
|
||||||
// System.out.println("Orderring done: " + offlineDataInfo.getCurrentObserver().getObserverName() + " " + offlineDataInfo.getLoadKeepLayers());
|
// System.out.println("Orderring done: " + offlineDataInfo.getCurrentObserver().getObserverName() + " " + offlineDataInfo.getLoadKeepLayers());
|
||||||
|
|
||||||
//reset some of the changeable variables in offline data info.
|
//reset some of the changeable variables in offline data info.
|
||||||
offlineDataInfo.reset();
|
offlineDataInfo.reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user