mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
Updates from DG (#120)
* Stop command small change so command is available as a constant * Lots of small updates to enable opening of a secondary configuration for batch processing control. * Fix user input bug in viewer which created exponential copies of user comments! * Adding TAST trigger alarm action To be competed when GW provide correct string for interface * Echo offline detection Fix up affected datablocks for offline echo detection * fix module import System for importing modules from other psfx files was not working. Probably wasn't working for quite some time. Now fixed. * Bug fixes to Match Template classifier 1) When a large template was imported only 1: fftLength of the mathc waveform was used and so clicks would be correlated with noise. The peak of the template is now used when the peak search function is selected. 2) The plus button in the tab pane had disappeared. 3) Seems like the decimators were the wrong round. So the waveforms were using an up sample function when they should have been using a decimator function. and vice versa...major bug when using different sample rates! * Fix merge Merged in a single commit from Jamies fork that had updates to the template classifier. Then had to make a few changes to get it working with other changes J had made that must have been in other commits. * Logger forms viewer Viewer display of logger forms was throwing exceptions on Boolean values which had been stored as a String or Integer 0 or 1 in some databases. Now fixed to turn these into a sensible boolean value for the data table * Logger form plotting Fixed logger form plotting in Viewer so that points can find their correct GPS position (based on time) * Fix small bugs * Fix settings import not all imports working. Now seems fixed. --------- Co-authored-by: Jamie Mac <macster110@gmail.com>
This commit is contained in:
parent
d1b40c1d86
commit
f9a0716c0f
@ -318,6 +318,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
}
|
||||
selection = folderInputParameters.getSelectedFiles();
|
||||
}
|
||||
if (selection == null) {
|
||||
return 0;
|
||||
}
|
||||
if (selection.length > 0) {
|
||||
System.out.println("FolderInputSystem.makeSelFileList(): Searching for sound files in " + selection[0]);
|
||||
}
|
||||
|
@ -1096,6 +1096,7 @@ public class MapPanel extends JPanelWithPamKey implements PamObserver, ColorMana
|
||||
return;
|
||||
}
|
||||
ds = dataBlock.getDataSelector(simpleMapRef.getUnitName(), false, DATASELECTNAME);
|
||||
// ds = null;
|
||||
ArrayList<PamDataUnit> dataCopy = dataBlock.getDataCopy(earliestToPlot, now, true, ds);
|
||||
duIterator = dataCopy.listIterator();
|
||||
while (duIterator.hasNext()) {
|
||||
|
@ -476,7 +476,7 @@ public class PamSettingManager {
|
||||
*/
|
||||
public PamSettings findSettingsOwner(String unitType, String unitName, String unitClassName) {
|
||||
for (PamSettings owner:owners) {
|
||||
if (owner.getClass() != null) {
|
||||
if (owner.getClass() != null && unitClassName != null) {
|
||||
if (owner.getClass().getName().equals(unitClassName) == false) {
|
||||
continue;
|
||||
}
|
||||
|
@ -58,4 +58,12 @@ public class UsedModuleInfo implements Serializable, ManagedParameters {
|
||||
return ps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unit name of the module being imported.
|
||||
* @return
|
||||
*/
|
||||
public String getUnitName() {
|
||||
return unitName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -116,14 +116,16 @@ public class SettingsImport {
|
||||
*/
|
||||
private PamControlledUnit importReplace(SettingsImportGroup importGroup, String replaceModule) {
|
||||
PamControlledUnitSettings mainSet = importGroup.getMainSettings();
|
||||
PamControlledUnit unit = PamController.getInstance().findControlledUnit(mainSet.getUnitType(), replaceModule);
|
||||
UsedModuleInfo importInfo = importGroup.getUsedModuleInfo();
|
||||
PamControlledUnit unit = PamController.getInstance().findControlledUnit(importInfo.getUnitType(), replaceModule);
|
||||
if (unit == null) {
|
||||
System.out.println("Unable to find " + mainSet.getUnitType() + " " + mainSet.getUnitName() + " for settings replacement");
|
||||
System.out.println("Unable to find " + importInfo.getUnitType() + " " + importInfo.getUnitName() + " for settings replacement");
|
||||
return null;
|
||||
}
|
||||
// check we can cast it to PamSettings
|
||||
if (PamSettings.class.isAssignableFrom(unit.getClass())) {
|
||||
if (PamSettings.class.isAssignableFrom(unit.getClass()) && mainSet != null) {
|
||||
try {
|
||||
mainSet.setUnitName(replaceModule);
|
||||
((PamSettings) unit).restoreSettings(mainSet);
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -132,7 +134,7 @@ public class SettingsImport {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
loadSubUnitSettings(importGroup, mainSet.getUnitName());
|
||||
loadSubUnitSettings(importGroup, replaceModule);
|
||||
return unit;
|
||||
}
|
||||
|
||||
@ -149,7 +151,15 @@ public class SettingsImport {
|
||||
}
|
||||
PamSettingManager setManager = PamSettingManager.getInstance();
|
||||
for (PamControlledUnitSettings pamSettings:subSets) {
|
||||
PamSettings owner = setManager.findSettingsOwner(pamSettings.getUnitType(), unitName, pamSettings.getOwnerClassName());
|
||||
/*
|
||||
* class name in pamSettings is no longer correct, so cannot use pamSettings.getOwnerClassName().
|
||||
* but the classnames of all the sub modules are unknown (and will be different form the unit class name
|
||||
* which can be got from importGroup.getPamModuleInfo().getClassName
|
||||
* so will have to do this only on the unit type and name and hope for no conflicts (catch exception).
|
||||
*/
|
||||
// PamModuleInfo moduleInfo = importGroup.getPamModuleInfo();
|
||||
// String className = moduleInfo.getClassName();
|
||||
PamSettings owner = setManager.findSettingsOwner(pamSettings.getUnitType(), unitName, null);
|
||||
if (owner == null) {
|
||||
System.out.println(String.format("Cannot find settings owner for %s %s in current model", pamSettings.getUnitType(), unitName));
|
||||
continue;
|
||||
@ -168,7 +178,8 @@ public class SettingsImport {
|
||||
|
||||
private PamControlledUnit importNew(SettingsImportGroup importGroup) {
|
||||
PamControlledUnitSettings mainSet = importGroup.getMainSettings();
|
||||
String moduleName = mainSet.getUnitName();
|
||||
UsedModuleInfo importInfo = importGroup.getUsedModuleInfo();
|
||||
String moduleName = importInfo.unitName;
|
||||
|
||||
// check we've got a name that doesnt' exist and replace it if if does.
|
||||
// int startChar = 0;
|
||||
@ -199,11 +210,11 @@ public class SettingsImport {
|
||||
|
||||
PamControlledUnit unit = PamController.getInstance().addModule(PamController.getMainFrame(), moduleInfo);
|
||||
if (unit == null) {
|
||||
System.out.println("Unable to find " + mainSet.getUnitType() + " " + mainSet.getUnitName() + " for settings replacement");
|
||||
System.out.println("Unable to find " + importInfo.getUnitType() + " " + importInfo.getUnitName() + " for settings replacement");
|
||||
return null;
|
||||
}
|
||||
// check we can cast it to PamSettings
|
||||
if (PamSettings.class.isAssignableFrom(unit.getClass())) {
|
||||
if (PamSettings.class.isAssignableFrom(unit.getClass()) && mainSet != null) {
|
||||
try {
|
||||
mainSet.setUnitName(unit.getUnitName()); // need to force the unit name for some modules.
|
||||
((PamSettings) unit).restoreSettings(mainSet);
|
||||
|
@ -195,12 +195,14 @@ public class SettingsImportDialog extends PamDialog {
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
SettingsImportGroup set = groupedSettings.get(rowIndex);
|
||||
PamControlledUnitSettings mainSet = set.getMainSettings();
|
||||
// PamControlledUnitSettings mainSet = set.getMainSettings();
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return mainSet.getUnitType();
|
||||
return set.getUsedModuleInfo().getUnitType();
|
||||
// return mainSet.getUnitType();
|
||||
case 1:
|
||||
return mainSet.getUnitName();
|
||||
return set.getUsedModuleInfo().unitName;
|
||||
// return mainSet.getUnitName();
|
||||
case 2:
|
||||
// return choiceBoxes[rowIndex].getSelectedItem().toString();
|
||||
return set.getImportChoice().toString();
|
||||
|
@ -82,8 +82,10 @@ public class SettingsImportGroup {
|
||||
try {
|
||||
ownerClass = Class.forName(usedModuleInfo.className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
System.out.println("Unknown class in loaded settings: " + usedModuleInfo.className);
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
ArrayList<PamControlledUnit> existingModules =
|
||||
PamController.getInstance().findControlledUnits(ownerClass);
|
||||
|
@ -38,6 +38,14 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
|
||||
import Array.streamerOrigin.GPSOriginMethod;
|
||||
import Array.streamerOrigin.GPSOriginSystem;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethods;
|
||||
import Array.streamerOrigin.OriginIterator;
|
||||
import Array.streamerOrigin.StaticOriginSystem;
|
||||
import GPS.GpsData;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
@ -49,6 +57,7 @@ import pamScrollSystem.ScrollPaneAddon;
|
||||
import PamView.PamTabPanel;
|
||||
import PamView.panel.PamPanel;
|
||||
import PamView.symbol.StandardSymbolManager;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
@ -2021,4 +2030,32 @@ public class FormDescription implements Cloneable, Comparable<FormDescription> {
|
||||
public void setNeedsUDFSave(boolean needsUDFSave) {
|
||||
this.needsUDFSave = needsUDFSave;
|
||||
}
|
||||
|
||||
public GpsData getOriginLatLong(FormsDataUnit formsDataUnit) {
|
||||
GpsData gps = getOrigin(GPSOriginSystem.class, formsDataUnit);
|
||||
if (gps != null) {
|
||||
return gps;
|
||||
}
|
||||
gps = getOrigin(StaticOriginSystem.class, formsDataUnit);
|
||||
return gps;
|
||||
}
|
||||
|
||||
private GpsData getOrigin(Class originClass, FormsDataUnit formsDataUnit) {
|
||||
HydrophoneOriginMethods origins = HydrophoneOriginMethods.getInstance();
|
||||
HydrophoneOriginMethod origin = origins.getMethod(GPSOriginMethod.class, null, null);
|
||||
if (origin == null) {
|
||||
return null;
|
||||
}
|
||||
OriginIterator gpsIter = origin.getGpsDataIterator(PamDataBlock.ITERATOR_END);
|
||||
GpsData prev = null;
|
||||
while (gpsIter.hasPrevious()) {
|
||||
prev = gpsIter.previous();
|
||||
if (prev.getTimeInMillis() < formsDataUnit.getTimeMilliseconds()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -614,6 +614,32 @@ public class FormsControl extends PamControlledUnit {
|
||||
return new ModuleStatus(ModuleStatus.STATUS_OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Some things that are meant to be boolean are coming out as int or string so
|
||||
* need to do some type checking.
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static Boolean checkBadBoolean(Object value) {
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
String str = (String) value;
|
||||
str = str.strip();
|
||||
return str.equals("1") || str.toLowerCase().equals("false");
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
int val = (Integer) value;
|
||||
return val != 0;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
// @Override
|
||||
// public Serializable getSettingsReference() {
|
||||
// return (Serializable) dummyParams;
|
||||
|
@ -208,7 +208,15 @@ public class FormsDataDisplayTable {
|
||||
Object[] fd = pamDataUnit.getFormData();
|
||||
int ctIndex = columnIndex-extraColumns.length;
|
||||
ControlDescription ctrlDescription = formDescription.getInputControlDescriptions().get(ctIndex);
|
||||
return ctrlDescription.formatDataItem(fd[ctIndex]);
|
||||
Object value = ctrlDescription.formatDataItem(fd[ctIndex]);
|
||||
if (value == null) return null;
|
||||
if (getColumnClass(columnIndex) == Boolean.class) {
|
||||
if (value instanceof Boolean == false) {
|
||||
// System.out.println("Bad boolean value: " + value);
|
||||
return FormsControl.checkBadBoolean(value);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
// return fd[ctIndex];
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -252,6 +260,7 @@ public class FormsDataDisplayTable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called when data have changed in the datablock.
|
||||
*/
|
||||
|
@ -87,7 +87,9 @@ public class FormsDataUnit extends PamDataUnit {
|
||||
* we want to as a reference, etc.
|
||||
*/
|
||||
if (recalculate || formOriginLatLong == null) {
|
||||
formOriginLatLong = loggerForm.getOriginLatLong(this);
|
||||
if (formDescription != null) {
|
||||
formOriginLatLong = formDescription.getOriginLatLong(this);
|
||||
}
|
||||
}
|
||||
return formOriginLatLong;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class FormsLogging extends SQLLogging {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// formDescription.getf
|
||||
|
||||
FormsDataUnit formsDataUnit = new FormsDataUnit(null, timeMilliseconds, formDescription, formData);
|
||||
formsDataUnit.setDatabaseIndex(databaseIndex);
|
||||
|
@ -104,7 +104,7 @@ public class LoggerForm{
|
||||
private CounterControl counter;
|
||||
|
||||
|
||||
private HydrophoneOriginMethods origins = HydrophoneOriginMethods.getInstance();
|
||||
// private HydrophoneOriginMethods origins = HydrophoneOriginMethods.getInstance();
|
||||
|
||||
/**
|
||||
* @return the hasCounter
|
||||
@ -911,30 +911,30 @@ public class LoggerForm{
|
||||
return saveButton;
|
||||
}
|
||||
|
||||
public GpsData getOriginLatLong(FormsDataUnit formsDataUnit) {
|
||||
GpsData gps = getOrigin(GPSOriginSystem.class, formsDataUnit);
|
||||
if (gps != null) {
|
||||
return gps;
|
||||
}
|
||||
gps = getOrigin(StaticOriginSystem.class, formsDataUnit);
|
||||
return gps;
|
||||
}
|
||||
|
||||
private GpsData getOrigin(Class originClass, FormsDataUnit formsDataUnit) {
|
||||
HydrophoneOriginMethod origin = origins.getMethod(GPSOriginMethod.class, null, null);
|
||||
if (origin == null) {
|
||||
return null;
|
||||
}
|
||||
OriginIterator gpsIter = origin.getGpsDataIterator(PamDataBlock.ITERATOR_END);
|
||||
GpsData prev = null;
|
||||
while (gpsIter.hasPrevious()) {
|
||||
prev = gpsIter.previous();
|
||||
if (prev.getTimeInMillis() < formsDataUnit.getTimeMilliseconds()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
// public GpsData getOriginLatLong(FormsDataUnit formsDataUnit) {
|
||||
// GpsData gps = getOrigin(GPSOriginSystem.class, formsDataUnit);
|
||||
// if (gps != null) {
|
||||
// return gps;
|
||||
// }
|
||||
// gps = getOrigin(StaticOriginSystem.class, formsDataUnit);
|
||||
// return gps;
|
||||
// }
|
||||
//
|
||||
// private GpsData getOrigin(Class originClass, FormsDataUnit formsDataUnit) {
|
||||
// HydrophoneOriginMethod origin = origins.getMethod(GPSOriginMethod.class, null, null);
|
||||
// if (origin == null) {
|
||||
// return null;
|
||||
// }
|
||||
// OriginIterator gpsIter = origin.getGpsDataIterator(PamDataBlock.ITERATOR_END);
|
||||
// GpsData prev = null;
|
||||
// while (gpsIter.hasPrevious()) {
|
||||
// prev = gpsIter.previous();
|
||||
// if (prev.getTimeInMillis() < formsDataUnit.getTimeMilliseconds()) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return prev;
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
|
@ -9,6 +9,7 @@ import NMEA.NMEADataBlock;
|
||||
import NMEA.NMEADataUnit;
|
||||
import PamView.dialog.PamCheckBox;
|
||||
import PamView.dialog.PamLabel;
|
||||
import loggerForms.FormsControl;
|
||||
import loggerForms.LoggerForm;
|
||||
import loggerForms.controlDescriptions.ControlDescription;
|
||||
|
||||
@ -41,7 +42,7 @@ public class CheckboxControl extends LoggerControl {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
checkBox.setSelected((Boolean) data);
|
||||
checkBox.setSelected(FormsControl.checkBadBoolean(data));
|
||||
}
|
||||
catch(ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -70,7 +70,7 @@ public class FormDataSelector extends DataSelector {
|
||||
@Override
|
||||
public double scoreData(PamDataUnit pamDataUnit) {
|
||||
if (controlDataSelector == null) {
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
Object[] formData = null;
|
||||
if (pamDataUnit instanceof FormsDataUnit) {
|
||||
|
Loading…
Reference in New Issue
Block a user