mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2025-04-15 21:46:33 +00:00
Update batch tasks for bearings
update batch offline tasks so that they support the bearing localiser
This commit is contained in:
parent
ccc59c7b79
commit
6b63f14d5d
@ -6,8 +6,9 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-21">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -143,3 +143,4 @@ dependency-reduced-pom.xml
|
||||
.settings/org.eclipse.jdt.core.prefs
|
||||
.settings/org.eclipse.core.resources.prefs
|
||||
.classpath
|
||||
.settings/org.eclipse.jdt.core.prefs
|
||||
|
@ -11,9 +11,9 @@ org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=19
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.compliance=19
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -23,4 +23,4 @@ org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
||||
org.eclipse.jdt.core.compiler.source=19
|
||||
|
@ -491,14 +491,14 @@ final public class PamModel implements PamSettings {
|
||||
mi.setHelpPoint("utilities/tethys/docs/tethys_overview.html");
|
||||
mi.setAllowedModes(PamPluginInterface.VIEWERONLY);
|
||||
|
||||
if (isViewer) {
|
||||
// if (isViewer) {
|
||||
mi = PamModuleInfo.registerControlledUnit(RavenControl.class.getName(), RavenControl.defaultName);
|
||||
mi.setToolTipText("Import data from Raven selection tables");
|
||||
mi.setModulesMenuGroup(utilitiesGroup);
|
||||
mi.setHidden(!SMRUEnable.isEnable());
|
||||
mi.setAllowedModes(PamPluginInterface.VIEWERONLY);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
/*
|
||||
* ************* End Utilities Group *******************
|
||||
|
@ -13,13 +13,16 @@ import javax.swing.JMenuItem;
|
||||
|
||||
import Localiser.LocalisationAlgorithm;
|
||||
import Localiser.LocalisationAlgorithmInfo;
|
||||
import PamController.PamConfiguration;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamDetection.LocContents;
|
||||
import PamUtils.SimpleObservable;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import bearinglocaliser.algorithms.BearingAlgorithm;
|
||||
import bearinglocaliser.algorithms.BearingAlgorithmProvider;
|
||||
@ -56,8 +59,12 @@ public class BearingLocaliserControl extends PamControlledUnit implements PamSet
|
||||
private SimpleObservable<PamDataUnit> configObservable = new SimpleObservable<>();
|
||||
|
||||
private OLProcessDialog olProcessDialog;
|
||||
|
||||
private OfflineTaskGroup bearingTaskGroup;
|
||||
|
||||
private BLOfflineTask bearingOfflineTask;
|
||||
|
||||
public BearingLocaliserControl(String unitName) {
|
||||
public BearingLocaliserControl(PamConfiguration pamConfiguration, String unitName) {
|
||||
super(unitType, unitName);
|
||||
|
||||
detectionMonitor = new DetectionMonitor(this);
|
||||
@ -74,6 +81,11 @@ public class BearingLocaliserControl extends PamControlledUnit implements PamSet
|
||||
UserDisplayControl.addUserDisplayProvider(bearingDisplayProvider);
|
||||
|
||||
PamSettingManager.getInstance().registerSettings(this);
|
||||
|
||||
boolean secondConfig = pamConfiguration != PamController.getInstance().getPamConfiguration();
|
||||
if (isViewer() || secondConfig) {
|
||||
getOfflineTasks();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -114,13 +126,21 @@ public class BearingLocaliserControl extends PamControlledUnit implements PamSet
|
||||
return menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create single instance of offline tasks so that it can be created in
|
||||
* constructor and get's registered for offline batch processing.
|
||||
* @return
|
||||
*/
|
||||
private OfflineTaskGroup getOfflineTasks() {
|
||||
bearingTaskGroup = new OfflineTaskGroup(this, this.getUnitName());
|
||||
bearingTaskGroup.addTask(bearingOfflineTask = new BLOfflineTask(this));
|
||||
return bearingTaskGroup;
|
||||
}
|
||||
|
||||
protected void showOfflineDialog(Frame parentFrame) {
|
||||
// if (olProcessDialog == null) {
|
||||
OfflineTaskGroup otg = new OfflineTaskGroup(this, this.getUnitName());
|
||||
otg.addTask(new BLOfflineTask(this));
|
||||
otg.setPrimaryDataBlock(detectionMonitor.getParentDataBlock());
|
||||
olProcessDialog = new OLProcessDialog(parentFrame, otg, getUnitName());
|
||||
// }
|
||||
OfflineTaskGroup otg = getOfflineTasks();
|
||||
bearingTaskGroup.setPrimaryDataBlock(detectionMonitor.getParentDataBlock());
|
||||
olProcessDialog = new OLProcessDialog(parentFrame, otg, getUnitName());
|
||||
olProcessDialog.setVisible(true);
|
||||
}
|
||||
|
||||
@ -288,4 +308,14 @@ public class BearingLocaliserControl extends PamControlledUnit implements PamSet
|
||||
public LocalizationOptionsPanel getLocalizationOptionsPanel(Window parent, LocalizationBuilder locBuilder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setParentDataBlock(PamDataBlock sourceDataBlock) {
|
||||
PamDataBlock parentblock = detectionMonitor.getParentDataBlock();
|
||||
if (bearingTaskGroup != null) {
|
||||
bearingTaskGroup.setPrimaryDataBlock(detectionMonitor.getParentDataBlock());
|
||||
}
|
||||
if (bearingOfflineTask != null) {
|
||||
bearingOfflineTask.checkDataBlocks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,10 @@ public class BearingProcess extends PamInstantProcess {
|
||||
private void setSourceDataBlock() {
|
||||
|
||||
BearingLocaliserParams params = bearingLocaliserControl.getBearingLocaliserParams();
|
||||
sourceDataBlock = PamController.getInstance().getDataBlockByLongName(params.getDataSource());
|
||||
sourceDataBlock = bearingLocaliserControl.getPamConfiguration().getDataBlockByLongName(params.getDataSource());
|
||||
setParentDataBlock(sourceDataBlock);
|
||||
// need to tell offlinetasks in the controller that this has happened.
|
||||
bearingLocaliserControl.setParentDataBlock(sourceDataBlock);
|
||||
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class DetectionMonitor extends PamInstantProcess {
|
||||
if (params.detectionSource == null) {
|
||||
return;
|
||||
}
|
||||
PamDataBlock sourceData = PamController.getInstance().getDataBlockByLongName(params.detectionSource);
|
||||
PamDataBlock sourceData = bearingLocaliserControl.getPamConfiguration().getDataBlockByLongName(params.detectionSource);
|
||||
setParentDataBlock(sourceData);
|
||||
if (sourceData != null) {
|
||||
/*
|
||||
|
@ -17,16 +17,26 @@ public class BLOfflineTask extends OfflineTask {
|
||||
private PamDataBlock detectionBlock, rawOrFFTBlock;
|
||||
|
||||
public BLOfflineTask(BearingLocaliserControl bearingLocaliserControl) {
|
||||
super(bearingLocaliserControl.getDetectionMonitor().getParentDataBlock());
|
||||
detectionBlock = bearingLocaliserControl.getDetectionMonitor().getParentDataBlock();
|
||||
super(bearingLocaliserControl, bearingLocaliserControl.getDetectionMonitor().getParentDataBlock());
|
||||
this.bearingLocaliserControl = bearingLocaliserControl;
|
||||
bearingProcess = bearingLocaliserControl.getBearingProcess();
|
||||
this.addRequiredDataBlock(rawOrFFTBlock = bearingProcess.getParentDataBlock());
|
||||
addAffectedDataBlock(detectionBlock);
|
||||
checkDataBlocks();
|
||||
// PamDataBlock detectionSource = bearingLocaliserControl.getDetectionMonitor().getParentDataBlock();
|
||||
// this.setParentDataBlock(detectionSource);
|
||||
// setParentDataBlock(bearingProcess.getParentDataBlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* do checks on the datablocks. Needed when this is running as an offline task since
|
||||
* if was probably impossible to set these when it was constructed.
|
||||
*/
|
||||
public void checkDataBlocks() {
|
||||
detectionBlock = bearingLocaliserControl.getDetectionMonitor().getParentDataBlock();
|
||||
this.addRequiredDataBlock(rawOrFFTBlock = bearingProcess.getParentDataBlock());
|
||||
setParentDataBlock(detectionBlock);
|
||||
addAffectedDataBlock(detectionBlock);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@ -103,4 +113,11 @@ public class BLOfflineTask extends OfflineTask {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRun() {
|
||||
// TODO Auto-generated method stub
|
||||
super.canRun();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ public class PamConnection {
|
||||
private Connection connection;
|
||||
|
||||
private SQLTypes sqlTypes;
|
||||
|
||||
private String databaseName;
|
||||
|
||||
/**
|
||||
* Constructor needs a connection object and an sqlTypes object.
|
||||
@ -61,4 +63,12 @@ public class PamConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public String getDatabaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
public void setDatabaseName(String databaseName) {
|
||||
this.databaseName = databaseName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -270,7 +270,9 @@ public class SqliteSystem extends DBSystem implements PamSettings {
|
||||
return null;
|
||||
}
|
||||
// System.out.println("------------------------------- OpenedSQLite database " + dbName + " handle " + con);
|
||||
return new PamConnection(this, con, sqlTypes);
|
||||
PamConnection connection = new PamConnection(this, con, sqlTypes);
|
||||
connection.setDatabaseName(dbName);
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -287,6 +287,9 @@ public abstract class OfflineTask<T extends PamDataUnit> {
|
||||
* @param dataBlockInfo required data block with pre and post load times.
|
||||
*/
|
||||
public void addRequiredDataBlock(RequiredDataBlockInfo dataBlockInfo) {
|
||||
if (dataBlockInfo == null || dataBlockInfo.getPamDataBlock() == null) {
|
||||
return;
|
||||
}
|
||||
if (requiredDatablocks == null) {
|
||||
requiredDatablocks = new ArrayList<RequiredDataBlockInfo>();
|
||||
}
|
||||
@ -346,6 +349,9 @@ public abstract class OfflineTask<T extends PamDataUnit> {
|
||||
* @param dataBlock affected data block.
|
||||
*/
|
||||
public void addAffectedDataBlock(PamDataBlock dataBlock) {
|
||||
if (dataBlock == null) {
|
||||
return;
|
||||
}
|
||||
if (affectedDataBlocks == null) {
|
||||
affectedDataBlocks = new ArrayList<PamDataBlock>();
|
||||
}
|
||||
@ -381,7 +387,11 @@ public abstract class OfflineTask<T extends PamDataUnit> {
|
||||
if (affectedDataBlocks == null || affectedDataBlocks.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
String blocks = affectedDataBlocks.get(0).getDataName();
|
||||
PamDataBlock block0 = affectedDataBlocks.get(0);
|
||||
if (block0 == null) {
|
||||
return null;
|
||||
}
|
||||
String blocks = block0.getDataName();
|
||||
for (int i = 1; i < affectedDataBlocks.size(); i++) {
|
||||
blocks += "; " + affectedDataBlocks.get(i).getDataName();
|
||||
}
|
||||
@ -469,9 +479,43 @@ public abstract class OfflineTask<T extends PamDataUnit> {
|
||||
}
|
||||
|
||||
for (PamDataBlock aBlock:affectedDataBlocks) {
|
||||
if (isInputBlock(aBlock)) {
|
||||
System.out.printf("Task %s: Don't delete data from \"%s\" since it input to this task",
|
||||
this.getName(), aBlock.getLongDataName());
|
||||
continue;
|
||||
}
|
||||
deleteOldData(aBlock, taskGroupParams);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See if the input to the task is the same as the output of
|
||||
* the task. If this is the case, then FFS don't delete the input data.
|
||||
* @return
|
||||
*/
|
||||
private boolean isInputBlock(PamDataBlock aDataBlock) {
|
||||
if (parentDataBlock == aDataBlock) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* See if the data block is one of the required datablocks.
|
||||
* @param aDataBlock
|
||||
* @return
|
||||
*/
|
||||
private boolean isRequiredBlock(PamDataBlock aDataBlock) {
|
||||
if (requiredDatablocks != null) {
|
||||
for (int i = 0; i < requiredDatablocks.size(); i++) {
|
||||
RequiredDataBlockInfo blockInf = requiredDatablocks.get(i);
|
||||
if (blockInf != null && blockInf.getPamDataBlock() == aDataBlock) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the old data before re-analysis. Any sub detections are removed from the
|
||||
|
@ -871,6 +871,9 @@ public class OfflineTaskGroup implements PamSettings {
|
||||
for (int i = 0; i < requiredDataBlocks.size(); i++) {
|
||||
RequiredDataBlockInfo blockInfo = requiredDataBlocks.get(i);
|
||||
PamDataBlock aDataBlock = blockInfo.getPamDataBlock();
|
||||
if (aDataBlock == null) {
|
||||
continue;
|
||||
}
|
||||
long reqStart = procDataStart - blockInfo.getPreLoadTime();
|
||||
long reqEnd = procDataEnd + blockInfo.getPostLoadTime();
|
||||
// if (aDataBlock.getCurrentViewDataStart() > reqStart ||
|
||||
|
@ -271,13 +271,15 @@ public class OfflineTaskManager implements TaskMonitor {
|
||||
groupParams.deleteOld = true;
|
||||
groupParams.taskNote = "Batch process at " + PamCalendar.formatDBDateTime(System.currentTimeMillis());
|
||||
int nT = taskGroup.getNTasks();
|
||||
boolean sameIO = false;
|
||||
for (int i = 0; i < nT; i++) {
|
||||
OfflineTask task = taskGroup.getTask(i);
|
||||
String taskName = task.getLongName();
|
||||
boolean enable = commandLineTasks.contains(taskName);
|
||||
groupParams.setTaskSelection(i, enable);
|
||||
System.out.printf("Set task eneable state for %s : %s in %s\n", taskName, enable, taskGroup.getUnitType());
|
||||
System.out.printf("Set task enable state for %s : %s in %s\n", taskName, enable, taskGroup.getUnitType());
|
||||
}
|
||||
|
||||
System.out.println("Tasks in group is now " + taskGroup.getNTasks());
|
||||
}
|
||||
/*
|
||||
|
@ -413,26 +413,31 @@ public class AcousticScrollerFX extends AbstractPamScrollerFX {
|
||||
//removing the sync lock here was reallt helpful in preventing lock ups - especially because the datagram does not
|
||||
//load wghen the scroller moves.
|
||||
//synchronized (acousticScrollerGraphics.getDataBlock().getSynchLock()) {
|
||||
while (it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
|
||||
// if (count%500==0){
|
||||
// AcousticDataGramGraphics acousticDataGramGraphics=(AcousticDataGramGraphics) acousticScrollerGraphics;
|
||||
// System.out.println("Hello datagram load: " + count+ " "+ acousticScrollerGraphics.getDataBlock().getUnitsCount() +
|
||||
// " "+acousticDataGramGraphics.getDataGramStore().currentIndex);
|
||||
// }
|
||||
// count++;
|
||||
currentCount++;
|
||||
// if (count%500==0){
|
||||
// AcousticDataGramGraphics acousticDataGramGraphics=(AcousticDataGramGraphics) acousticScrollerGraphics;
|
||||
// System.out.println("Hello datagram load: " + count+ " "+ acousticScrollerGraphics.getDataBlock().getUnitsCount() +
|
||||
// " "+acousticDataGramGraphics.getDataGramStore().currentIndex);
|
||||
// }
|
||||
// count++;
|
||||
currentCount++;
|
||||
|
||||
try {
|
||||
acousticScrollerGraphics.addNewData(it.next());
|
||||
|
||||
if (this.isCancelled()){
|
||||
return;
|
||||
}
|
||||
|
||||
Platform.runLater(()->{
|
||||
repaint(30);
|
||||
});
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Error in AcousticScrollerFX: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (this.isCancelled()){
|
||||
return;
|
||||
}
|
||||
|
||||
Platform.runLater(()->{
|
||||
repaint(30);
|
||||
});
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,15 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import PamController.PamConfiguration;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import generalDatabase.DBControlUnit;
|
||||
import ravendata.swing.RavenImportDialog;
|
||||
|
||||
/**
|
||||
@ -81,6 +84,18 @@ public class RavenControl extends PamControlledUnit implements PamSettings {
|
||||
if (ravenData != null) {
|
||||
ravenProcess.createPAMGuardData(fileReader, ravenData);
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PamController.getInstance().notifyModelChanged(PamController.EXTERNAL_DATA_IMPORTED);
|
||||
}
|
||||
});
|
||||
DBControlUnit dbControl = DBControlUnit.findDatabaseControl();
|
||||
if (dbControl != null) {
|
||||
dbControl.commitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,6 +90,7 @@ public class RavenProcess extends PamProcess {
|
||||
/**
|
||||
* Had to add an offset for some messed up Raven data. May or may not have to include
|
||||
* this as an option in future releases.
|
||||
* Offset of 2843100 needed for mn23_055a tag data.
|
||||
*/
|
||||
long offsetMillis = 0;//2843100;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user