This reverts commit f52a27ccf2, reversing
changes made to 4a5c6fe52e.
This commit is contained in:
Douglas Gillespie 2023-12-18 13:28:38 +00:00
parent f52a27ccf2
commit 7a321f6d95
70 changed files with 479 additions and 1146 deletions

View File

@ -388,7 +388,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
message += "\n\nFailure to do so may result in PAMGUARD crashing or features not working correctly"; message += "\n\nFailure to do so may result in PAMGUARD crashing or features not working correctly";
int ans = JOptionPane.showConfirmDialog(parentFrame, message, getArrayErrorMessage(error), JOptionPane.YES_NO_OPTION); int ans = JOptionPane.showConfirmDialog(parentFrame, message, getArrayErrorMessage(error), JOptionPane.YES_NO_OPTION);
if (ans == JOptionPane.YES_OPTION) { if (ans == JOptionPane.YES_OPTION) {
ArrayManager.getArrayManager().showArrayDialog(getGuiFrame()); ArrayManager.getArrayManager().showArrayDialog(getPamView().getGuiFrame());
return checkArrayChannels(parentFrame); return checkArrayChannels(parentFrame);
} }

View File

@ -73,7 +73,7 @@ public class IMUControl extends PamControlledUnit implements PamSettings {
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
IMUSettingsDialog.showDialog(getGuiFrame(),THIS); IMUSettingsDialog.showDialog(getPamView().getGuiFrame(),THIS);
} }
} }
@ -89,7 +89,7 @@ public class IMUControl extends PamControlledUnit implements PamSettings {
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
IMUParams newIMUParams=IMUImportDialog.showDialog(getGuiFrame(),THIS, importCSV); IMUParams newIMUParams=IMUImportDialog.showDialog(getPamView().getGuiFrame(),THIS, importCSV);
//if params are not null try and load data //if params are not null try and load data
if (newIMUParams!=null){ if (newIMUParams!=null){
imuParams=newIMUParams; imuParams=newIMUParams;
@ -115,7 +115,7 @@ public class IMUControl extends PamControlledUnit implements PamSettings {
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
IMUParams newIMUParams=IMUCalibrationDialog.showDialog(getGuiFrame(),imuParams); IMUParams newIMUParams=IMUCalibrationDialog.showDialog(getPamView().getGuiFrame(),imuParams);
if (newIMUParams!=null) imuParams=newIMUParams; if (newIMUParams!=null) imuParams=newIMUParams;
updateProcesses(CAL_VALUES_CHANGED); updateProcesses(CAL_VALUES_CHANGED);
} }

View File

@ -91,7 +91,7 @@ public class IMUImportDialog extends PamDialog{
} }
else dir=null; else dir=null;
String newFile=PamFileBrowser.csvFileBrowser(imuControl.getGuiFrame(),dir,PamFileBrowser.OPEN_FILE); String newFile=PamFileBrowser.csvFileBrowser(imuControl.getPamView().getGuiFrame(),dir,PamFileBrowser.OPEN_FILE);
addNewFileToList( newFile); addNewFileToList( newFile);

View File

@ -23,7 +23,6 @@ package Map;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Frame;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.MouseInfo; import java.awt.MouseInfo;
@ -1637,9 +1636,9 @@ public class MapPanel extends JPanelWithPamKey implements PamObserver, ColorMana
class OverlayOptions implements ActionListener { class OverlayOptions implements ActionListener {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Frame frame = (JFrame) PamController.getMainFrame(); JFrame frame = (JFrame) PamController.getMainFrame();
if (mapController.getPamView() != null) { if (mapController.getPamView() != null) {
frame = mapController.getGuiFrame(); frame = mapController.getPamView().getGuiFrame();
} }
MapDetectionsParameters newParams = MapDetectionsDialog.showDialog(frame, MapDetectionsParameters newParams = MapDetectionsDialog.showDialog(frame,

View File

@ -198,7 +198,6 @@ public class PSFXReadWriter {
BinaryHeader bh = new BinaryHeader(); BinaryHeader bh = new BinaryHeader();
bh.readHeader(dis); bh.readHeader(dis);
PamSettingsGroup psg = new PamSettingsGroup(bh.getDataDate()); PamSettingsGroup psg = new PamSettingsGroup(bh.getDataDate());
ArrayList<ModuleNameObject> moduleNames = new ArrayList<ModuleNameObject>();
/* /*
* *
dos.writeInt(totalLen); dos.writeInt(totalLen);
@ -218,7 +217,6 @@ public class PSFXReadWriter {
dis.read(data); dis.read(data);
if (objectId == ModuleNameObject.typeId) { if (objectId == ModuleNameObject.typeId) {
ModuleNameObject mno = new ModuleNameObject(data); ModuleNameObject mno = new ModuleNameObject(data);
moduleNames.add(mno);
} }
else if (objectId == 2) { else if (objectId == 2) {
PamControlledUnitSettings pcsu = PamControlledUnitSettings.createFromNamedByteArray(data); PamControlledUnitSettings pcsu = PamControlledUnitSettings.createFromNamedByteArray(data);

View File

@ -1,549 +0,0 @@
package PamController;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import Array.ArrayManager;
import PamController.settings.output.xml.PamguardXMLWriter;
import PamDetection.PamDetection;
import PamDetection.RawDataUnit;
import PamView.GeneralProjector;
import PamView.PanelOverlayDraw;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import PamguardMVC.PamProcess;
import PamguardMVC.PamRawDataBlock;
import binaryFileStorage.BinaryStore;
import fftManager.FFTDataBlock;
import fftManager.FFTDataUnit;
import offlineProcessing.OfflineTask;
import offlineProcessing.OfflineTaskGroup;
/**
* Class to take all of the configuration information out of PamController. This
* is because PamController is a singleton class, so there can only every be one of
* them, but for some of the batch processing control, we need to be able to load and
* manipulate a second set of modules, which do nothing within the running
* configuration, but are there to allow us to set up a configuration to send to
* other batch processes in viewer mode. This is also being used in an improved module import system.
* @author dg50
*
*/
public class PamConfiguration {
/**
* List of the current controlled units (PAMGuard modules)
*/
private ArrayList<PamControlledUnit> pamControlledUnits;
public PamConfiguration() {
super();
// create the array list to hold multiple views
pamControlledUnits = new ArrayList<PamControlledUnit>();
}
/**
* Call setupControlledUnit() on all modules.
*/
public void setupProcesses() {
for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).setupControlledUnit();
}
}
/**
* Can PAMGUARD shut down. This question is asked in turn to
* every module. Each module should attempt to make sure it can
* answer true, e.g. by closing files, but if any module
* returns false, then canClose() will return false;
* @return whether it's possible to close PAMGUARD
* without corrupting or losing data.
*/
public boolean canClose() {
for (int i = 0; i < pamControlledUnits.size(); i++) {
if (pamControlledUnits.get(i).canClose() == false) {
return false;
}
}
return true;
}
/**
* Called after canClose has returned true to finally tell
* all modules that PAMGUARD is definitely closing down.so they
* can free any resources, etc.
*/
public void pamClose() {
for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).pamClose();
}
}
/**
* @return the pamControlledUnits
*/
public ArrayList<PamControlledUnit> getPamControlledUnits() {
return pamControlledUnits;
}
/**
* Add a PamControlledUnit to the main list.
* @param controlledUnit
*/
public void addControlledUnit(PamControlledUnit controlledUnit) {
pamControlledUnits.add(controlledUnit);
}
public boolean removeControlledUnt(PamControlledUnit controlledUnit) {
boolean removed = false;
while (pamControlledUnits.contains(controlledUnit)) {
pamControlledUnits.remove(controlledUnit);
removed = true;
}
return removed;
// getMainFrame().revalidate(); //handled inside the GUIFrameManager by notify model changed. The controller should have
//as few direct GUI calls as possible.
}
/**
* re-order the modules according to the given list.
* @param newOrder
* @return
*/
public boolean reOrderModules(int[] newOrder) {
if (pamControlledUnits.size() != newOrder.length) return false;
ArrayList<PamControlledUnit> newList = new ArrayList<PamControlledUnit>();
for (int i = 0; i < newOrder.length; i++) {
newList.add(pamControlledUnits.get(newOrder[i]));
}
pamControlledUnits = newList;
return true;
}
public PamControlledUnit getControlledUnit(int iUnit) {
if (iUnit < getNumControlledUnits()) {
return pamControlledUnits.get(iUnit);
}
return null;
}
public PamControlledUnit findControlledUnit(String unitType) {
for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType)) {
return pamControlledUnits.get(i);
}
}
return null;
}
public int getNumControlledUnits() {
return pamControlledUnits.size();
}
public PamRawDataBlock getRawDataBlock(int id) {
return (PamRawDataBlock) getDataBlock(RawDataUnit.class, id);
}
public PamRawDataBlock getRawDataBlock(String name) {
return (PamRawDataBlock) getDataBlock(RawDataUnit.class, name);
}
/**
* Find a block of a given type with the given name, or null if it
* doesn't exist.
* @param blockType -- RAW, FFT, DETECTOR, null, etc.
* @param name -- the block name
* @return block, which you may want to cast to a subtype
*/
public PamDataBlock getDataBlock(Class blockType, String name) {
if (name == null) return null;
ArrayList<PamDataBlock> blocks = getDataBlocks(blockType, true);
for (PamDataBlock dataBlock:blocks) {
if (name.equals(dataBlock.getLongDataName())) { // check for a long name match first
return dataBlock;
}
if (dataBlock instanceof FFTDataBlock) {
FFTDataBlock fb = (FFTDataBlock) dataBlock;
if (name.equals(fb.getOldLongDataName())) {
return dataBlock;
}
}
if (name.equals(dataBlock.toString())) {
return dataBlock;
}
}
return null;
}
public ArrayList<PamDataBlock> getDataBlocks(Class blockType, boolean includeSubClasses) {
return makeDataBlockList(blockType, includeSubClasses);
}
public ArrayList<PamDataBlock> getDetectorDataBlocks() {
return makeDataBlockList(PamDetection.class, true);
}
public ArrayList<PamDataBlock> getFFTDataBlocks() {
return makeDataBlockList(FFTDataUnit.class, true);
}
public PamDataBlock getFFTDataBlock(int id) {
return getDataBlock(FFTDataUnit.class, id);
}
public PamDataBlock getFFTDataBlock(String name) {
return getDataBlock(FFTDataUnit.class, name);
}
/**
* Find a block of a given type with the id number, or null if the number
* is out of range.
*
* @param blockType
* @param id -- the block id number
* @return block, which you may want to cast to a subtype
*/
public PamDataBlock getDataBlock(Class blockType, int id) {
ArrayList<PamDataBlock> blocks = getDataBlocks(blockType, true);
if (id >= 0 && id < blocks.size()) return blocks.get(id);
return null;
}
public ArrayList<PamDataBlock> getRawDataBlocks() {
return makeDataBlockList(RawDataUnit.class, true);
}
/**
* Find a block with the given long name, or null if it doesn't exist.
* @param longName the long name of the PamDataBlock
* @return block
*/
public PamDataBlock getDataBlockByLongName(String longName) {
if (longName == null) return null;
ArrayList<PamDataBlock> allBlocks = getDataBlocks();
for (PamDataBlock dataBlock:allBlocks) {
if (longName.equals(dataBlock.getLongDataName())) {
return dataBlock;
}
if (dataBlock instanceof FFTDataBlock) {
FFTDataBlock fb = (FFTDataBlock) dataBlock;
if (longName.equals(fb.getOldLongDataName())) {
return dataBlock;
}
}
}
return null;
}
public ArrayList<PamDataBlock> getDataBlocks() {
return makeDataBlockList(PamDataUnit.class, true);
}
/**
* Get a list of PamControlledUnit units of a given type
* @param unitType Controlled unit type
* @return list of units.
*/
public ArrayList<PamControlledUnit> findControlledUnits(String unitType) {
ArrayList<PamControlledUnit> l = new ArrayList<PamControlledUnit>();
int n = getNumControlledUnits();
PamControlledUnit pcu;
for (int i = 0; i < n; i++) {
pcu = getControlledUnit(i);
if (pcu.getUnitType().equals(unitType)) {
l.add(pcu);
}
}
return l;
}
/**
* Get a list of PamControlledUnit units of a given type and name, allowing for nulls.
* @param unitType Controlled unit type, can be null for all units of name
* @param unitName Controlled unit name, can be null for all units of type
* @return list of units.
*/
public ArrayList<PamControlledUnit> findControlledUnits(String unitType, String unitName) {
ArrayList<PamControlledUnit> l = new ArrayList<PamControlledUnit>();
int n = getNumControlledUnits();
PamControlledUnit pcu;
for (int i = 0; i < n; i++) {
pcu = getControlledUnit(i);
if (unitType != null && !unitType.equals(pcu.getUnitType())) {
continue;
}
if (unitName != null && !unitName.equals(pcu.getUnitName())) {
continue;
}
l.add(pcu);
}
return l;
}
/**
* find the first controlled unit with the given type and name.
* @param unitType
* @param unitName
* @return
*/
public PamControlledUnit findControlledUnit(String unitType, String unitName) {
for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType) &&
pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName)) {
return pamControlledUnits.get(i);
}
}
return null;
}
/**
* Find the first instance of a module with a given class type and name.
* <p>Name can be null in which case the first module with the correct class
* will be returned
* @param unitClass Module class (sub class of PamControlledUnit)
* @param unitName Module Name
* @return Existing module with that class and name.
*/
public PamControlledUnit findControlledUnit(Class unitClass, String unitName) {
for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getClass() == unitClass && (unitName == null ||
pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName))) {
return pamControlledUnits.get(i);
}
}
return null;
}
/**
* Get an Array list of PamControlledUnits of a particular class (exact matches only).
* @param unitClass PamControlledUnit class
* @return List of current instances of this class.
*/
public ArrayList<PamControlledUnit> findControlledUnits(Class unitClass) {
ArrayList<PamControlledUnit> foundUnits = new ArrayList<>();
for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getClass() == unitClass) {
foundUnits.add(pamControlledUnits.get(i));
}
}
return foundUnits;
}
/**
* Get an Array list of PamControlledUnits of a particular class (exact matches only).
* @param unitClass PamControlledUnit class
* @return List of current instances of this class.
*/
public ArrayList<PamControlledUnit> findControlledUnits(Class unitClass, boolean includeSubClasses) {
if (includeSubClasses == false) {
return findControlledUnits(unitClass);
}
ArrayList<PamControlledUnit> foundUnits = new ArrayList<>();
for (int i = 0; i < getNumControlledUnits(); i++) {
if (unitClass.isAssignableFrom(pamControlledUnits.get(i).getClass())) {
foundUnits.add(pamControlledUnits.get(i));
}
}
return foundUnits;
}
/**
* Check whether a controlled unit exists based on it's name.
* @param the controlled unit name e.g. "my crazy click detector", not the default name.
*/
public boolean isControlledUnit(String controlName) {
for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(controlName)) {
return true;
}
}
return false;
}
/**
* Gets called in pamStart and may / will attempt to store all
* PAMGUARD settings via the database and binary storage modules.
*/
public void saveSettings(long timeNow) {
PamControlledUnit pcu;
PamSettingsSource settingsSource;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pcu = pamControlledUnits.get(iU);
if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
settingsSource = (PamSettingsSource) pcu;
settingsSource.saveStartSettings(timeNow);
}
}
PamguardXMLWriter.getXMLWriter().writeStartSettings(timeNow);
}
/**
*
* @return a list of PamControlledUnits which implements the
* PamSettingsSource interface
* @see PamSettingsSource
*/
public ArrayList<PamSettingsSource> findSettingsSources() {
ArrayList<PamSettingsSource> settingsSources = new ArrayList<PamSettingsSource>();
PamControlledUnit pcu;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pcu = pamControlledUnits.get(iU);
if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
settingsSources.add((PamSettingsSource) pcu);
}
}
return settingsSources;
}
public ArrayList<PamDataBlock> getPlottableDataBlocks(GeneralProjector generalProjector) {
ArrayList<PamDataBlock> blockList = new ArrayList<PamDataBlock>();
PamProcess pP;
Class unitClass;
PanelOverlayDraw panelOverlayDraw;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
for (int iP = 0; iP < pamControlledUnits.get(iU)
.getNumPamProcesses(); iP++) {
pP = pamControlledUnits.get(iU).getPamProcess(iP);
for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
if(pP.getOutputDataBlock(j).canDraw(generalProjector)) {
blockList.add(pP.getOutputDataBlock(j));
}
}
}
}
return blockList;
}
public ArrayList<PamDataBlock> makeDataBlockList(Class classType, boolean includSubClasses) {
ArrayList<PamDataBlock> blockList = new ArrayList<PamDataBlock>();
PamProcess pP;
Class unitClass;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
for (int iP = 0; iP < pamControlledUnits.get(iU)
.getNumPamProcesses(); iP++) {
pP = pamControlledUnits.get(iU).getPamProcess(iP);
for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
//System.out.println("Comparing "+pP.getOutputDataBlock(j).getUnitClass().getCanonicalName()+" to "+classType.getCanonicalName());
if ((unitClass = pP.getOutputDataBlock(j).getUnitClass()) == classType) {
blockList.add(pP.getOutputDataBlock(j));
}
else if (includSubClasses) {
if (classType != null && classType.isAssignableFrom(unitClass)) {
blockList.add(pP.getOutputDataBlock(j));
}
// while ((unitClass = unitClass.getSuperclass()) != null) {
// if (unitClass == classType) {
// blockList.add(pP.getOutputDataBlock(j));
// break;
// }
// }
}
}
}
}
return blockList;
}
public void notifyModelChanged(int changeType) {
// also tell all PamControlledUnits since they may want to find their data source
// it that was created after they were - i.e. dependencies have got all muddled
for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).notifyModelChanged(changeType);
}
}
public Serializable getSettingsReference() {
ArrayList<UsedModuleInfo> usedModules = new ArrayList<UsedModuleInfo>();
for (int i = 0; i < pamControlledUnits.size(); i++) {
usedModules.add(new UsedModuleInfo(pamControlledUnits.get(i).getClass().getName(),
pamControlledUnits.get(i).getUnitType(),
pamControlledUnits.get(i).getUnitName()));
}
return usedModules;
}
public void destroyModel() {
for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).notifyModelChanged(PamController.DESTROY_EVERYTHING);
}
pamControlledUnits.clear();
}
/**
* Get the index of a PamControlledUnit
* @param unit
* @return
*/
public int getControlledUnitIndex(PamControlledUnit unit) {
return pamControlledUnits.indexOf(unit);
}
/**
* Find the path to the binary store ....
* @return path to the binary store.
*/
public String findBinaryStorePath() {
BinaryStore binaryStore = (BinaryStore) findControlledUnit(BinaryStore.getBinaryUnitType());
if (binaryStore == null) {
return null;
}
String storeLoc = binaryStore.getBinaryStoreSettings().getStoreLocation();
if (storeLoc == null) {
return "";
}
if (storeLoc.endsWith(File.separator) == false) {
storeLoc += File.separator;
}
return storeLoc;
}
/**
* Get a list of all offline task groups in this configuration
* @return task group list
*/
public ArrayList<OfflineTaskGroup> getAllOfflineTaskGroups() {
ArrayList<OfflineTaskGroup> tgs = new ArrayList<OfflineTaskGroup>();
for (PamControlledUnit unit : pamControlledUnits){
int numGroups = unit.getNumOfflineTaskGroups();
for (int iGp=0;iGp<numGroups;iGp++){
tgs.add( unit.getOfflineTaskGroup(iGp));
}
}
return tgs;
}
/**
* Get a list of all offline tasks in the configuration
* @return offline task list
*/
public ArrayList<OfflineTask> getAllOfflineTasks() {
ArrayList<OfflineTask> ots = new ArrayList<OfflineTask>();
ArrayList<OfflineTaskGroup> groups = getAllOfflineTaskGroups();
for (OfflineTaskGroup group : groups) {
int nTasks = group.getNTasks();
for (int i = 0; i < nTasks; i++) {
ots.add(group.getTask(i));
}
}
return ots;
}
}

View File

@ -141,8 +141,6 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
private ModuleStatusManager moduleStatusManager; private ModuleStatusManager moduleStatusManager;
private PamConfiguration pamConfiguration;
// private ArrayList<OfflineTask> offlineTasks = new ArrayList<>(); // private ArrayList<OfflineTask> offlineTasks = new ArrayList<>();
/** /**
@ -157,17 +155,8 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
* name of unit * name of unit
*/ */
public PamControlledUnit(String unitType, String unitName) { public PamControlledUnit(String unitType, String unitName) {
this(null, unitType, unitName);
}
public PamControlledUnit(PamConfiguration pamConfiguration, String unitType, String unitName) {
this.unitType = unitType; this.unitType = unitType;
this.unitName = unitName; this.unitName = unitName;
this.pamConfiguration = pamConfiguration;
if (this.pamConfiguration == null) {
this.pamConfiguration = PamController.getInstance().getPamConfiguration();
}
pamProcesses = new ArrayList<PamProcess>(); pamProcesses = new ArrayList<PamProcess>();
isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW; isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW;
@ -508,12 +497,6 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
return true; return true;
} }
/**
* Get the GUI associated with this module. However, this may return null, so if you want a frame
* to use for a dialog, better to use PamController.getGuiFrame() which handles null automatically.
* @return
*/
@Deprecated
public PamView getPamView() { public PamView getPamView() {
return pamView; return pamView;
} }
@ -691,11 +674,11 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
* @param offlineTaskGroup * @param offlineTaskGroup
*/ */
public void addOfflineTaskGroup(OfflineTaskGroup offlineTaskGroup) { public void addOfflineTaskGroup(OfflineTaskGroup offlineTaskGroup) {
// if (isViewer){ if (isViewer){
offlineTaskGroups.add(offlineTaskGroup); offlineTaskGroups.add(offlineTaskGroup);
// }else{ }else{
// System.out.println("OfflineTaskGroup cannot be added as is not viewer mode"); System.out.println("OfflineTaskGroup cannot be added as is not viewer mode");
// } }
} }
@ -881,34 +864,4 @@ public abstract class PamControlledUnit implements SettingsNameProvider {
return instanceIndex; return instanceIndex;
} }
/**
* The PamConfiguration holds the master list of modules which form part of a
* configuration. It should be accessed to find list of datablocks, etc. rather than
* doing everything through PAMController whenever possible.
* @return the pamConfiguration
*/
public PamConfiguration getPamConfiguration() {
if (pamConfiguration == null) {
pamConfiguration = PamController.getInstance().getPamConfiguration();
}
return pamConfiguration;
}
/**
* Is this module in the main configuration. If it isn't then it's probably a dummy config
* used in the batch processor or for importing / exporting configs, so it should be stopped from
* doing too much !
* @return
*/
public boolean isInMainConfiguration() {
return pamConfiguration == PamController.getInstance().getPamConfiguration();
}
/**
* @param pamConfiguration the pamConfiguration to set
*/
public void setPamConfiguration(PamConfiguration pamConfiguration) {
this.pamConfiguration = pamConfiguration;
}
} }

View File

@ -34,9 +34,6 @@ import javax.swing.SwingUtilities;
import javax.swing.Timer; import javax.swing.Timer;
import javax.swing.ToolTipManager; import javax.swing.ToolTipManager;
import com.jcraft.jsch.ConfigRepository.Config;
import com.sun.xml.bind.v2.TODO;
import Acquisition.AcquisitionProcess; import Acquisition.AcquisitionProcess;
//import com.sun.org.apache.xerces.internal.dom.DocumentImpl; //import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
@ -70,6 +67,7 @@ import PamController.soundMedium.GlobalMediumManager;
import PamDetection.PamDetection; import PamDetection.PamDetection;
import PamDetection.RawDataUnit; import PamDetection.RawDataUnit;
import PamModel.PamModel; import PamModel.PamModel;
import PamModel.PamModelInterface;
import PamModel.PamModelSettings; import PamModel.PamModelSettings;
import PamModel.PamModuleInfo; import PamModel.PamModuleInfo;
import PamModel.SMRUEnable; import PamModel.SMRUEnable;
@ -141,18 +139,16 @@ public class PamController implements PamControllerInterface, PamSettings {
// flag used in main() to indicate that pamguard should exit as soon as processing ends. // flag used in main() to indicate that pamguard should exit as soon as processing ends.
public static final String AUTOEXIT = "-autoexit"; public static final String AUTOEXIT = "-autoexit";
/**
* Never changed. Needed to identify settings for list of modules in prfx files.
*/
public static final String unitName = "Pamguard Controller";
public static final String unitType = "PamController";
/** /**
* The pam model. * The pam model.
*/ */
private PamModel pamModelInterface; private PamModel pamModelInterface;
private PamConfiguration pamConfiguration; /**
* List of the current controlled units (PAMGuard modules)
*/
private ArrayList<PamControlledUnit> pamControlledUnits;
/** /**
* The current PAM status * The current PAM status
*/ */
@ -239,8 +235,6 @@ public class PamController implements PamControllerInterface, PamSettings {
private PamController(int runMode, Object object) { private PamController(int runMode, Object object) {
uniqueController = this; uniqueController = this;
pamConfiguration = new PamConfiguration();
this.runMode = runMode; this.runMode = runMode;
@ -359,6 +353,10 @@ public class PamController implements PamControllerInterface, PamSettings {
*/ */
public void setupPamguard() { public void setupPamguard() {
// create the array list to hold multiple views
pamControlledUnits = new ArrayList<PamControlledUnit>();
/** /**
* Set Locale to English so that formated writes to text fields * Set Locale to English so that formated writes to text fields
* in dialogs use . and not , for the decimal. * in dialogs use . and not , for the decimal.
@ -663,10 +661,9 @@ public class PamController implements PamControllerInterface, PamSettings {
// } // }
void setupProcesses() { void setupProcesses() {
// for (int i = 0; i < pamControlledUnits.size(); i++) { for (int i = 0; i < pamControlledUnits.size(); i++) {
// pamControlledUnits.get(i).setupControlledUnit(); pamControlledUnits.get(i).setupControlledUnit();
// } }
pamConfiguration.setupProcesses();
} }
/** /**
@ -678,7 +675,12 @@ public class PamController implements PamControllerInterface, PamSettings {
* without corrupting or losing data. * without corrupting or losing data.
*/ */
public boolean canClose() { public boolean canClose() {
return pamConfiguration.canClose(); for (int i = 0; i < pamControlledUnits.size(); i++) {
if (pamControlledUnits.get(i).canClose() == false) {
return false;
}
}
return true;
} }
@ -692,7 +694,9 @@ public class PamController implements PamControllerInterface, PamSettings {
getUidManager().runShutDownOps(); getUidManager().runShutDownOps();
pamConfiguration.pamClose(); for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).pamClose();
}
} }
/** /**
@ -712,7 +716,6 @@ public class PamController implements PamControllerInterface, PamSettings {
* it to be easy to override this for specific modules / processes / data blocks. * it to be easy to override this for specific modules / processes / data blocks.
*/ */
public void saveViewerData() { public void saveViewerData() {
ArrayList<PamControlledUnit> pamControlledUnits = pamConfiguration.getPamControlledUnits();
for (int i = 0; i < pamControlledUnits.size(); i++) { for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).saveViewerData(); pamControlledUnits.get(i).saveViewerData();
} }
@ -725,8 +728,7 @@ public class PamController implements PamControllerInterface, PamSettings {
@Override @Override
public void addControlledUnit(PamControlledUnit controlledUnit) { public void addControlledUnit(PamControlledUnit controlledUnit) {
pamControlledUnits.add(controlledUnit);
pamConfiguration.addControlledUnit(controlledUnit);
guiFrameManager.addControlledUnit(controlledUnit); guiFrameManager.addControlledUnit(controlledUnit);
@ -852,8 +854,8 @@ public class PamController implements PamControllerInterface, PamSettings {
guiFrameManager.removeControlledUnit(controlledUnit); guiFrameManager.removeControlledUnit(controlledUnit);
boolean removed = pamConfiguration.removeControlledUnt(controlledUnit); while (pamControlledUnits.contains(controlledUnit)) {
if (removed) { pamControlledUnits.remove(controlledUnit);
notifyModelChanged(PamControllerInterface.REMOVE_CONTROLLEDUNIT); notifyModelChanged(PamControllerInterface.REMOVE_CONTROLLEDUNIT);
} }
// getMainFrame().revalidate(); //handled inside the GUIFrameManager by notify model changed. The controller should have // getMainFrame().revalidate(); //handled inside the GUIFrameManager by notify model changed. The controller should have
@ -869,7 +871,7 @@ public class PamController implements PamControllerInterface, PamSettings {
int[] newOrder = ModuleOrderDialog.showDialog(this, parentFrame); int[] newOrder = ModuleOrderDialog.showDialog(this, parentFrame);
if (newOrder != null) { if (newOrder != null) {
// re-order the modules according the new list. // re-order the modules according the new list.
pamConfiguration.reOrderModules(newOrder); reOrderModules(newOrder);
notifyModelChanged(PamControllerInterface.REORDER_CONTROLLEDUNITS); notifyModelChanged(PamControllerInterface.REORDER_CONTROLLEDUNITS);
@ -879,22 +881,22 @@ public class PamController implements PamControllerInterface, PamSettings {
return false; return false;
} }
// private boolean reOrderModules(int[] newOrder) { private boolean reOrderModules(int[] newOrder) {
//
// if (pamControlledUnits.size() != newOrder.length) return false; if (pamControlledUnits.size() != newOrder.length) return false;
//
// ArrayList<PamControlledUnit> newList = new ArrayList<PamControlledUnit>(); ArrayList<PamControlledUnit> newList = new ArrayList<PamControlledUnit>();
//
// for (int i = 0; i < newOrder.length; i++) { for (int i = 0; i < newOrder.length; i++) {
//
// newList.add(pamControlledUnits.get(newOrder[i])); newList.add(pamControlledUnits.get(newOrder[i]));
//
// } }
//
// pamControlledUnits = newList; pamControlledUnits = newList;
//
// return true; return true;
// } }
/** /**
* Swaps the positions of two modules in the main list of modules and * Swaps the positions of two modules in the main list of modules and
@ -920,12 +922,20 @@ public class PamController implements PamControllerInterface, PamSettings {
@Override @Override
public PamControlledUnit getControlledUnit(int iUnit) { public PamControlledUnit getControlledUnit(int iUnit) {
return pamConfiguration.getControlledUnit(iUnit); if (iUnit < getNumControlledUnits()) {
return pamControlledUnits.get(iUnit);
}
return null;
} }
@Override @Override
public PamControlledUnit findControlledUnit(String unitType) { public PamControlledUnit findControlledUnit(String unitType) {
return pamConfiguration.findControlledUnit(unitType); for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType)) {
return pamControlledUnits.get(i);
}
}
return null;
} }
/** /**
@ -934,7 +944,17 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return list of units. * @return list of units.
*/ */
public ArrayList<PamControlledUnit> findControlledUnits(String unitType) { public ArrayList<PamControlledUnit> findControlledUnits(String unitType) {
return pamConfiguration.findControlledUnits(unitType); ArrayList<PamControlledUnit> l = new ArrayList<PamControlledUnit>();
int n = getNumControlledUnits();
PamControlledUnit pcu;
for (int i = 0; i < n; i++) {
pcu = getControlledUnit(i);
if (pcu.getUnitType().equals(unitType)) {
l.add(pcu);
}
}
return l;
} }
/** /**
* Get a list of PamControlledUnit units of a given type and name, allowing for nulls. * Get a list of PamControlledUnit units of a given type and name, allowing for nulls.
@ -943,12 +963,32 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return list of units. * @return list of units.
*/ */
public ArrayList<PamControlledUnit> findControlledUnits(String unitType, String unitName) { public ArrayList<PamControlledUnit> findControlledUnits(String unitType, String unitName) {
return pamConfiguration.findControlledUnits(unitType, unitName); ArrayList<PamControlledUnit> l = new ArrayList<PamControlledUnit>();
int n = getNumControlledUnits();
PamControlledUnit pcu;
for (int i = 0; i < n; i++) {
pcu = getControlledUnit(i);
if (unitType != null && !unitType.equals(pcu.getUnitType())) {
continue;
}
if (unitName != null && !unitName.equals(pcu.getUnitName())) {
continue;
}
l.add(pcu);
}
return l;
} }
@Override @Override
public PamControlledUnit findControlledUnit(String unitType, String unitName) { public PamControlledUnit findControlledUnit(String unitType, String unitName) {
return pamConfiguration.findControlledUnit(unitType, unitName); for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getUnitType().equalsIgnoreCase(unitType) &&
pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName)) {
return pamControlledUnits.get(i);
}
}
return null;
} }
/** /**
@ -960,7 +1000,13 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return Existing module with that class and name. * @return Existing module with that class and name.
*/ */
public PamControlledUnit findControlledUnit(Class unitClass, String unitName) { public PamControlledUnit findControlledUnit(Class unitClass, String unitName) {
return pamConfiguration.findControlledUnit(unitClass, unitName); for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getClass() == unitClass && (unitName == null ||
pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(unitName))) {
return pamControlledUnits.get(i);
}
}
return null;
} }
/** /**
@ -969,7 +1015,13 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return List of current instances of this class. * @return List of current instances of this class.
*/ */
public ArrayList<PamControlledUnit> findControlledUnits(Class unitClass) { public ArrayList<PamControlledUnit> findControlledUnits(Class unitClass) {
return pamConfiguration.findControlledUnits(unitClass); ArrayList<PamControlledUnit> foundUnits = new ArrayList<>();
for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getClass() == unitClass) {
foundUnits.add(pamControlledUnits.get(i));
}
}
return foundUnits;
} }
/** /**
@ -978,7 +1030,16 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return List of current instances of this class. * @return List of current instances of this class.
*/ */
public ArrayList<PamControlledUnit> findControlledUnits(Class unitClass, boolean includeSubClasses) { public ArrayList<PamControlledUnit> findControlledUnits(Class unitClass, boolean includeSubClasses) {
return pamConfiguration.findControlledUnits(unitClass, includeSubClasses); if (includeSubClasses == false) {
return findControlledUnits(unitClass);
}
ArrayList<PamControlledUnit> foundUnits = new ArrayList<>();
for (int i = 0; i < getNumControlledUnits(); i++) {
if (unitClass.isAssignableFrom(pamControlledUnits.get(i).getClass())) {
foundUnits.add(pamControlledUnits.get(i));
}
}
return foundUnits;
} }
/** /**
@ -986,19 +1047,28 @@ public class PamController implements PamControllerInterface, PamSettings {
* @param the controlled unit name e.g. "my crazy click detector", not the default name. * @param the controlled unit name e.g. "my crazy click detector", not the default name.
*/ */
public boolean isControlledUnit(String controlName) { public boolean isControlledUnit(String controlName) {
return pamConfiguration.isControlledUnit(controlName); for (int i = 0; i < getNumControlledUnits(); i++) {
if (pamControlledUnits.get(i).getUnitName().equalsIgnoreCase(controlName)) {
return true;
}
}
return false;
} }
@Override @Override
public int getNumControlledUnits() { public int getNumControlledUnits() {
return pamConfiguration.getNumControlledUnits(); if (pamControlledUnits == null) {
return 0;
}
return pamControlledUnits.size();
} }
static public PamController getInstance() { static public PamController getInstance() {
return uniqueController; return uniqueController;
} }
public PamModel getModelInterface() { @Override
public PamModelInterface getModelInterface() {
return pamModelInterface; return pamModelInterface;
} }
@ -1115,8 +1185,6 @@ public class PamController implements PamControllerInterface, PamSettings {
globalTimeManager.getGlobalTimeParameters().getStartupDelay()); globalTimeManager.getGlobalTimeParameters().getStartupDelay());
manualStop = false; manualStop = false;
ArrayList<PamControlledUnit> pamControlledUnits = pamConfiguration.getPamControlledUnits();
PamCalendar.setSessionStartTime(startTime); PamCalendar.setSessionStartTime(startTime);
setPamStatus(PAM_RUNNING); setPamStatus(PAM_RUNNING);
@ -1215,7 +1283,6 @@ public class PamController implements PamControllerInterface, PamSettings {
// actually stopped // actually stopped
// statusCheckThread = new Thread(new StatusTimer()); // statusCheckThread = new Thread(new StatusTimer());
// statusCheckThread.start(); // statusCheckThread.start();
ArrayList<PamControlledUnit> pamControlledUnits = pamConfiguration.getPamControlledUnits();
// tell all controlled units to stop // tell all controlled units to stop
for (int iU = 0; iU < pamControlledUnits.size(); iU++) { for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
@ -1291,8 +1358,6 @@ public class PamController implements PamControllerInterface, PamSettings {
* it is necessary to make sure that all internal datablock * it is necessary to make sure that all internal datablock
* buffers have had time to empty. * buffers have had time to empty.
*/ */
ArrayList<PamControlledUnit> pamControlledUnits = pamConfiguration.getPamControlledUnits();
if (PamModel.getPamModel().isMultiThread()) { if (PamModel.getPamModel().isMultiThread()) {
for (int iU = 0; iU < pamControlledUnits.size(); iU++) { for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pamControlledUnits.get(iU).flushDataBlockBuffers(2000); pamControlledUnits.get(iU).flushDataBlockBuffers(2000);
@ -1410,8 +1475,6 @@ public class PamController implements PamControllerInterface, PamSettings {
// } // }
// Debug.out.println(" Are we finished? " + areWeFinished); // Debug.out.println(" Are we finished? " + areWeFinished);
// return areWeFinished; // return areWeFinished;
ArrayList<PamControlledUnit> pamControlledUnits = pamConfiguration.getPamControlledUnits();
boolean running = false; boolean running = false;
for (PamControlledUnit aUnit : pamControlledUnits) { for (PamControlledUnit aUnit : pamControlledUnits) {
int numProcesses = aUnit.getNumPamProcesses(); int numProcesses = aUnit.getNumPamProcesses();
@ -1434,7 +1497,16 @@ public class PamController implements PamControllerInterface, PamSettings {
* PAMGUARD settings via the database and binary storage modules. * PAMGUARD settings via the database and binary storage modules.
*/ */
private void saveSettings(long timeNow) { private void saveSettings(long timeNow) {
pamConfiguration.saveSettings(timeNow); PamControlledUnit pcu;
PamSettingsSource settingsSource;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pcu = pamControlledUnits.get(iU);
if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
settingsSource = (PamSettingsSource) pcu;
settingsSource.saveStartSettings(timeNow);
}
}
PamguardXMLWriter.getXMLWriter().writeStartSettings(timeNow);
} }
/** /**
@ -1451,20 +1523,18 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return path to the binary store. * @return path to the binary store.
*/ */
public String findBinaryStorePath() { public String findBinaryStorePath() {
// TODO get rid of the singleton binary store control and do from the Config.class BinaryStore binaryControl = BinaryStore.findBinaryStoreControl();
// BinaryStore binaryControl = BinaryStore.findBinaryStoreControl(); if (binaryControl == null) {
// if (binaryControl == null) { return null;
// return null; }
// } String storeLoc = binaryControl.getBinaryStoreSettings().getStoreLocation();
// String storeLoc = binaryControl.getBinaryStoreSettings().getStoreLocation(); if (storeLoc == null) {
// if (storeLoc == null) { return "";
// return ""; }
// } if (storeLoc.endsWith(File.separator) == false) {
// if (storeLoc.endsWith(File.separator) == false) { storeLoc += File.separator;
// storeLoc += File.separator; }
// } return storeLoc;
// return storeLoc;
return pamConfiguration.findBinaryStorePath();
} }
/** /**
@ -1474,7 +1544,15 @@ public class PamController implements PamControllerInterface, PamSettings {
* @see PamSettingsSource * @see PamSettingsSource
*/ */
public ArrayList<PamSettingsSource> findSettingsSources() { public ArrayList<PamSettingsSource> findSettingsSources() {
return pamConfiguration.findSettingsSources(); ArrayList<PamSettingsSource> settingsSources = new ArrayList<PamSettingsSource>();
PamControlledUnit pcu;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pcu = pamControlledUnits.get(iU);
if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
settingsSources.add((PamSettingsSource) pcu);
}
}
return settingsSources;
} }
@Override @Override
@ -1503,37 +1581,37 @@ public class PamController implements PamControllerInterface, PamSettings {
*/ */
@Override @Override
public ArrayList<PamDataBlock> getFFTDataBlocks() { public ArrayList<PamDataBlock> getFFTDataBlocks() {
return pamConfiguration.getFFTDataBlocks(); return makeDataBlockList(FFTDataUnit.class, true);
} }
@Override @Override
public PamDataBlock getFFTDataBlock(int id) { public PamDataBlock getFFTDataBlock(int id) {
return pamConfiguration.getDataBlock(FFTDataUnit.class, id); return getDataBlock(FFTDataUnit.class, id);
} }
@Override @Override
public PamDataBlock getFFTDataBlock(String name) { public PamDataBlock getFFTDataBlock(String name) {
return pamConfiguration.getDataBlock(FFTDataUnit.class, name); return getDataBlock(FFTDataUnit.class, name);
} }
@Override @Override
public ArrayList<PamDataBlock> getRawDataBlocks() { public ArrayList<PamDataBlock> getRawDataBlocks() {
return pamConfiguration.makeDataBlockList(RawDataUnit.class, true); return makeDataBlockList(RawDataUnit.class, true);
} }
@Override @Override
public PamRawDataBlock getRawDataBlock(int id) { public PamRawDataBlock getRawDataBlock(int id) {
return (PamRawDataBlock) pamConfiguration.getDataBlock(RawDataUnit.class, id); return (PamRawDataBlock) getDataBlock(RawDataUnit.class, id);
} }
@Override @Override
public PamRawDataBlock getRawDataBlock(String name) { public PamRawDataBlock getRawDataBlock(String name) {
return pamConfiguration.getRawDataBlock(name); return (PamRawDataBlock) getDataBlock(RawDataUnit.class, name);
} }
@Override @Override
public ArrayList<PamDataBlock> getDetectorDataBlocks() { public ArrayList<PamDataBlock> getDetectorDataBlocks() {
return pamConfiguration.getDetectorDataBlocks(); return makeDataBlockList(PamDetection.class, true);
} }
@Override @Override
@ -1571,16 +1649,33 @@ public class PamController implements PamControllerInterface, PamSettings {
* true. * true.
*/ */
public ArrayList<PamDataBlock> getDataBlocks(Class blockType, boolean includeSubClasses) { public ArrayList<PamDataBlock> getDataBlocks(Class blockType, boolean includeSubClasses) {
return pamConfiguration.getDataBlocks(blockType, includeSubClasses); return makeDataBlockList(blockType, includeSubClasses);
} }
@Override @Override
public ArrayList<PamDataBlock> getDataBlocks() { public ArrayList<PamDataBlock> getDataBlocks() {
return pamConfiguration.getDataBlocks(); return makeDataBlockList(PamDataUnit.class, true);
} }
public ArrayList<PamDataBlock> getPlottableDataBlocks(GeneralProjector generalProjector) { public ArrayList<PamDataBlock> getPlottableDataBlocks(GeneralProjector generalProjector) {
return pamConfiguration.getPlottableDataBlocks(generalProjector);
ArrayList<PamDataBlock> blockList = new ArrayList<PamDataBlock>();
PamProcess pP;
Class unitClass;
PanelOverlayDraw panelOverlayDraw;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
for (int iP = 0; iP < pamControlledUnits.get(iU)
.getNumPamProcesses(); iP++) {
pP = pamControlledUnits.get(iU).getPamProcess(iP);
for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
if(pP.getOutputDataBlock(j).canDraw(generalProjector)) {
blockList.add(pP.getOutputDataBlock(j));
}
}
}
}
return blockList;
} }
/** /**
@ -1607,9 +1702,38 @@ public class PamController implements PamControllerInterface, PamSettings {
// } // }
// } // }
// } // }
// private ArrayList<PamDataBlock> makeDataBlockList(Class classType, boolean includSubClasses) { private ArrayList<PamDataBlock> makeDataBlockList(Class classType, boolean includSubClasses) {
// return pamConfiguration.makeDataBlockList(classType, includSubClasses);
// } ArrayList<PamDataBlock> blockList = new ArrayList<PamDataBlock>();
PamProcess pP;
Class unitClass;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
for (int iP = 0; iP < pamControlledUnits.get(iU)
.getNumPamProcesses(); iP++) {
pP = pamControlledUnits.get(iU).getPamProcess(iP);
for (int j = 0; j < pP.getNumOutputDataBlocks(); j++) {
//System.out.println("Comparing "+pP.getOutputDataBlock(j).getUnitClass().getCanonicalName()+" to "+classType.getCanonicalName());
if ((unitClass = pP.getOutputDataBlock(j).getUnitClass()) == classType) {
blockList.add(pP.getOutputDataBlock(j));
}
else if (includSubClasses) {
if (classType != null && classType.isAssignableFrom(unitClass)) {
blockList.add(pP.getOutputDataBlock(j));
}
// while ((unitClass = unitClass.getSuperclass()) != null) {
// if (unitClass == classType) {
// blockList.add(pP.getOutputDataBlock(j));
// break;
// }
// }
}
}
}
}
return blockList;
}
/** /**
* Find a block of a given type with the id number, or null if the number * Find a block of a given type with the id number, or null if the number
@ -1621,7 +1745,10 @@ public class PamController implements PamControllerInterface, PamSettings {
*/ */
@Override @Override
public PamDataBlock getDataBlock(Class blockType, int id) { public PamDataBlock getDataBlock(Class blockType, int id) {
return pamConfiguration.getDataBlock(blockType, id);
ArrayList<PamDataBlock> blocks = getDataBlocks(blockType, true);
if (id >= 0 && id < blocks.size()) return blocks.get(id);
return null;
} }
/** /**
@ -1633,7 +1760,23 @@ public class PamController implements PamControllerInterface, PamSettings {
*/ */
@Override @Override
public PamDataBlock getDataBlock(Class blockType, String name) { public PamDataBlock getDataBlock(Class blockType, String name) {
return pamConfiguration.getDataBlock(blockType, name); if (name == null) return null;
ArrayList<PamDataBlock> blocks = getDataBlocks(blockType, true);
for (PamDataBlock dataBlock:blocks) {
if (name.equals(dataBlock.getLongDataName())) { // check for a long name match first
return dataBlock;
}
if (dataBlock instanceof FFTDataBlock) {
FFTDataBlock fb = (FFTDataBlock) dataBlock;
if (name.equals(fb.getOldLongDataName())) {
return dataBlock;
}
}
if (name.equals(dataBlock.toString())) {
return dataBlock;
}
}
return null;
} }
/** /**
@ -1642,7 +1785,20 @@ public class PamController implements PamControllerInterface, PamSettings {
* @return block * @return block
*/ */
public PamDataBlock getDataBlockByLongName(String longName) { public PamDataBlock getDataBlockByLongName(String longName) {
return pamConfiguration.getDataBlockByLongName(longName); if (longName == null) return null;
ArrayList<PamDataBlock> allBlocks = getDataBlocks();
for (PamDataBlock dataBlock:allBlocks) {
if (longName.equals(dataBlock.getLongDataName())) {
return dataBlock;
}
if (dataBlock instanceof FFTDataBlock) {
FFTDataBlock fb = (FFTDataBlock) dataBlock;
if (longName.equals(fb.getOldLongDataName())) {
return dataBlock;
}
}
}
return null;
} }
/** /**
@ -1729,7 +1885,11 @@ public class PamController implements PamControllerInterface, PamSettings {
MasterReferencePoint.notifyModelChanged(changeType); MasterReferencePoint.notifyModelChanged(changeType);
pamConfiguration.notifyModelChanged(changeType); // also tell all PamControlledUnits since they may want to find their data source
// it that was created after they were - i.e. dependencies have got all muddled
for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).notifyModelChanged(changeType);
}
PamSettingManager.getInstance().notifyModelChanged(changeType); PamSettingManager.getInstance().notifyModelChanged(changeType);
@ -1800,7 +1960,6 @@ public class PamController implements PamControllerInterface, PamSettings {
private void changedThreading() { private void changedThreading() {
PamProcess pamProcess; PamProcess pamProcess;
int nP; int nP;
ArrayList<PamControlledUnit> pamControlledUnits = pamConfiguration.getPamControlledUnits();
for (int i = 0; i < pamControlledUnits.size(); i++) { for (int i = 0; i < pamControlledUnits.size(); i++) {
nP = pamControlledUnits.get(i).getNumPamProcesses(); nP = pamControlledUnits.get(i).getNumPamProcesses();
for (int iP = 0; iP < nP; iP++) { for (int iP = 0; iP < nP; iP++) {
@ -1834,22 +1993,28 @@ public class PamController implements PamControllerInterface, PamSettings {
@Override @Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return pamConfiguration.getSettingsReference(); ArrayList<UsedModuleInfo> usedModules = new ArrayList<UsedModuleInfo>();
for (int i = 0; i < pamControlledUnits.size(); i++) {
usedModules.add(new UsedModuleInfo(pamControlledUnits.get(i).getClass().getName(),
pamControlledUnits.get(i).getUnitType(),
pamControlledUnits.get(i).getUnitName()));
}
return usedModules;
} }
@Override @Override
public long getSettingsVersion() { public long getSettingsVersion() {
return 0; return 0;
} }
@Override @Override
public String getUnitName() { public String getUnitName() {
return unitName; return "Pamguard Controller";
} }
@Override @Override
public String getUnitType() { public String getUnitType() {
return unitType; return "PamController";
} }
@Override @Override
@ -1876,7 +2041,10 @@ public class PamController implements PamControllerInterface, PamSettings {
// also tell all PamControlledUnits since they may want to find their data source // also tell all PamControlledUnits since they may want to find their data source
// it that was created after they were - i.e. dependencies have got all muddled // it that was created after they were - i.e. dependencies have got all muddled
pamConfiguration.destroyModel(); for (int i = 0; i < pamControlledUnits.size(); i++) {
pamControlledUnits.get(i).notifyModelChanged(DESTROY_EVERYTHING);
}
pamControlledUnits = null;
PamSettingManager.getInstance().reset(); PamSettingManager.getInstance().reset();
@ -2201,7 +2369,6 @@ public class PamController implements PamControllerInterface, PamSettings {
public void loadOldSettings(PamSettingsGroup settingsGroup) { public void loadOldSettings(PamSettingsGroup settingsGroup) {
loadOldSettings(settingsGroup, true); loadOldSettings(settingsGroup, true);
} }
/** /**
* Called to load a specific set of PAMGUARD settings in * Called to load a specific set of PAMGUARD settings in
* viewer mode, which were previously loaded in from a * viewer mode, which were previously loaded in from a
@ -2306,7 +2473,7 @@ public class PamController implements PamControllerInterface, PamSettings {
continue; continue;
} }
aUnit = findControlledUnit(moduleClass, aModuleInfo.unitName); aUnit = findControlledUnit(moduleClass, aModuleInfo.unitName);
currentPos = pamConfiguration.getControlledUnitIndex(aUnit); currentPos = pamControlledUnits.indexOf(aUnit);
if (currentPos >= 0) { if (currentPos >= 0) {
temp = orderLUT[nFound]; temp = orderLUT[nFound];
orderLUT[nFound] = currentPos; orderLUT[nFound] = currentPos;
@ -2672,12 +2839,4 @@ public class PamController implements PamControllerInterface, PamSettings {
return this.globalMediumManager; return this.globalMediumManager;
} }
/**
* Gt the main PAMGuard configuration (list of connected modules).
* @return the pamConfiguration
*/
public PamConfiguration getPamConfiguration() {
return pamConfiguration;
}
} }

View File

@ -25,7 +25,7 @@ import java.util.ArrayList;
import javax.swing.JFrame; import javax.swing.JFrame;
import PamModel.PamModel; import PamModel.PamModelInterface;
import PamModel.PamModuleInfo; import PamModel.PamModuleInfo;
import PamView.GuiFrameManager; import PamView.GuiFrameManager;
import PamView.PamViewInterface; import PamView.PamViewInterface;
@ -102,7 +102,7 @@ public interface PamControllerInterface {
* *
* @return Reference to the PamGuard model * @return Reference to the PamGuard model
*/ */
public PamModel getModelInterface(); public PamModelInterface getModelInterface();
/** /**
* Instruction to the controller (probably from a menu command inthe view) * Instruction to the controller (probably from a menu command inthe view)

View File

@ -293,7 +293,7 @@ public class PamSettingManager {
* call this for at least one set of settings. Often the PamSettings * call this for at least one set of settings. Often the PamSettings
* is implemented by the class that extends PamControlledunit, but * is implemented by the class that extends PamControlledunit, but
* it's also possible to have multiple sub modules, processes or displays * it's also possible to have multiple sub modules, processes or displays
* implement PamSettings so that different settings for different bits of * implemnt PamSettings so that different settings for different bits of
* a PamControlledUnit are stored separately. * a PamControlledUnit are stored separately.
* @see PamSettings * @see PamSettings
* @see PamControlledUnit * @see PamControlledUnit

View File

@ -33,7 +33,9 @@ public class PamSettingsGroup implements Comparable<PamSettingsGroup> {
* @param settingsTime settings time in milliseconds. * @param settingsTime settings time in milliseconds.
*/ */
public PamSettingsGroup(long settingsTime) { public PamSettingsGroup(long settingsTime) {
this(settingsTime, new ArrayList<PamControlledUnitSettings>()); super();
this.settingsTime = settingsTime;
unitSettings = new ArrayList<PamControlledUnitSettings>();
} }
/** /**

View File

@ -7,8 +7,7 @@ import PamModel.parametermanager.PamParameterSet;
/** /**
* Very simple class used in an ArrayList of used modules that * Very simple class used in an ArrayList of used modules that
* get's saved between runs. This forms the core of the settings system * get's saved between runs.
* so don't f*** with it !
* @author Doug * @author Doug
* *
*/ */

View File

@ -15,12 +15,10 @@ import PamController.PamController;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import PamController.PamSettingsGroup; import PamController.PamSettingsGroup;
import PamController.UsedModuleInfo;
import PamModel.PamModel; import PamModel.PamModel;
import PamModel.PamModuleInfo; import PamModel.PamModuleInfo;
import PamModel.SMRUEnable; import PamModel.SMRUEnable;
import PamView.dialog.PamFileBrowser; import PamView.dialog.PamFileBrowser;
import PamView.dialog.warn.WarnOnce;
/** /**
* Class to handle the import of settings from other psf files. * Class to handle the import of settings from other psf files.
@ -182,16 +180,9 @@ public class SettingsImport {
/** /**
* Now make a new Pamcontrolled unit with the given name ... * Now make a new Pamcontrolled unit with the given name ...
*/ */
// need to find the module information in the PamModel
// PamModel pamModel = PamModel.getPamModel();
// pamModel.
PamModuleInfo moduleInfo = PamModuleInfo.findModuleInfo(importGroup.getUsedModuleInfo().className);
// find the module info for this one // find the module info for this one
// PamModuleInfo moduleInfo = importGroup.getUsedModuleInfo(); PamModuleInfo moduleInfo = importGroup.getModuleInfo();
if (moduleInfo == null) { if (moduleInfo == null) {
String msg = String.format("Unable to find module information for type %s main class %s in model",
importGroup.getUsedModuleInfo().getUnitType(), importGroup.getUsedModuleInfo().className);
WarnOnce.showWarning("Module creating error!", msg, WarnOnce.WARNING_MESSAGE);
return null; return null;
} }
@ -215,7 +206,6 @@ public class SettingsImport {
} }
} }
loadSubUnitSettings(importGroup, unit.getUnitName()); loadSubUnitSettings(importGroup, unit.getUnitName());
unit.setupControlledUnit();
return unit; return unit;
} }
@ -225,64 +215,45 @@ public class SettingsImport {
* @return * @return
*/ */
ArrayList<SettingsImportGroup> organiseSettingsGroups(ArrayList<PamControlledUnitSettings> settings) { ArrayList<SettingsImportGroup> organiseSettingsGroups(ArrayList<PamControlledUnitSettings> settings) {
/**
* this needs rewriting for psfx files which are organised differently. first we need to find
* a list of PAMGuard modules by finding the settings group of the PAMController.
*/
ArrayList<SettingsImportGroup> groupedSettings = new ArrayList<>(); ArrayList<SettingsImportGroup> groupedSettings = new ArrayList<>();
ArrayList<UsedModuleInfo> usedModules = findPamControllerSettings(settings); // first pull out the settings for PamControlledNnits.
// make the group list based on the list of modules.
for (UsedModuleInfo usedModule : usedModules) {
groupedSettings.add(new SettingsImportGroup(usedModule));
}
// // first pull out the settings for PamControlledNnits.
boolean[] used = new boolean[settings.size()]; boolean[] used = new boolean[settings.size()];
// for (int i = 0; i < settings.size(); i++) { for (int i = 0; i < settings.size(); i++) {
// PamControlledUnitSettings aSet = settings.get(i); PamControlledUnitSettings aSet = settings.get(i);
// if (aSet.getOwnerClassName() == null) { if (aSet.getOwnerClassName() == null) {
// continue; continue;
// } }
// Class ownerClass = null; Class ownerClass = null;
// try { try {
// ownerClass = Class.forName(aSet.getOwnerClassName()); ownerClass = Class.forName(aSet.getOwnerClassName());
// } catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block // TODO Auto-generated catch block
//// e.printStackTrace(); // e.printStackTrace();
// // this is happening since the ownerclassname is not set correctly in psfx files // this is happening since the ownerclassname is not set correctly in psfx files
// // so we have to deserialise the data to find the class. // so we have to deserialise the data to find the class.
//// ownerClass = getClassFromData(aSet.getSerialisedByteArray()); // ownerClass = getClassFromData(aSet.getSerialisedByteArray());
//// ownerClass = PamModuleInfo.findModuleClass(aSet.getUnitType()); // ownerClass = PamModuleInfo.findModuleClass(aSet.getUnitType());
// } }
// if (ownerClass == null) { if (ownerClass == null) {
// continue; continue;
// } }
// if (PamControlledUnit.class.isAssignableFrom(ownerClass)) { if (PamControlledUnit.class.isAssignableFrom(ownerClass)) {
// PamModuleInfo moduleInfo = PamModuleInfo.findModuleInfo(aSet.getOwnerClassName()); PamModuleInfo moduleInfo = PamModuleInfo.findModuleInfo(aSet.getOwnerClassName());
// groupedSettings.add(new SettingsImportGroup(moduleInfo)); groupedSettings.add(new SettingsImportGroup(aSet, moduleInfo));
// used[i] = true; used[i] = true;
// } }
// } }
// now match all the remaining settings into the first set based on ModuleName. // now match all the remaining settings into the first set based on ModuleName.
for (int i = 0; i < settings.size(); i++) { for (int i = 0; i < settings.size(); i++) {
PamControlledUnitSettings aSet = settings.get(i); PamControlledUnitSettings aSet = settings.get(i);
// if (used[i]) continue; if (used[i]) continue;
SettingsImportGroup mainGroup = findGroup(groupedSettings, aSet.getUnitName()); SettingsImportGroup mainGroup = findGroup(groupedSettings, aSet.getUnitName());
if (mainGroup != null) { if (mainGroup != null) {
// main settings will have same type as well as same name. mainGroup.addSubSettings(aSet);
boolean mainType = isMainType(mainGroup, aSet);
if (mainType) {
mainGroup.setMainSettings(aSet);
}
else {
mainGroup.addSubSettings(aSet);
}
used[i] = true; used[i] = true;
// System.out.println(String.format("Adding %s-%s to %s-%s group", aSet.getUnitType(), aSet.getUnitName(), System.out.println(String.format("Adding %s-%s to %s-%s group", aSet.getUnitType(), aSet.getUnitName(),
// mainGroup.getMainSettings().getUnitType(), mainGroup.getMainSettings().getUnitName())); mainGroup.getMainSettings().getUnitType(), mainGroup.getMainSettings().getUnitName()));
} }
} }
@ -301,34 +272,6 @@ public class SettingsImport {
return groupedSettings; return groupedSettings;
} }
/**
* IS this the main settings group for this module ? If it is, it should have the same
* type as well as the same name.
* @param mainGroup
* @param aSet
* @return
*/
private boolean isMainType(SettingsImportGroup mainGroup, PamControlledUnitSettings aSet) {
boolean isMain = mainGroup.getUsedModuleInfo().getUnitType().equals(aSet.getUnitType());
return isMain;
}
private ArrayList<UsedModuleInfo> findPamControllerSettings(ArrayList<PamControlledUnitSettings> settings) {
if (settings == null) {
return null;
}
for (PamControlledUnitSettings aSet : settings) {
if (aSet.getUnitName().equals(PamController.unitName) &&
aSet.getUnitType().equals(PamController.unitType)) {
Object sets = aSet.getSettings();
if (sets instanceof ArrayList) {
return (ArrayList<UsedModuleInfo>) sets;
}
}
}
return null;
}
private Class getClassFromData(byte[] data) { private Class getClassFromData(byte[] data) {
try { try {
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data)); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
@ -342,7 +285,7 @@ public class SettingsImport {
private SettingsImportGroup findGroup(ArrayList<SettingsImportGroup> groupedSettings, String unitName) { private SettingsImportGroup findGroup(ArrayList<SettingsImportGroup> groupedSettings, String unitName) {
for (SettingsImportGroup iG:groupedSettings) { for (SettingsImportGroup iG:groupedSettings) {
if (iG.getUsedModuleInfo().unitName.equals(unitName)) { if (iG.getMainSettings().getUnitName().equals(unitName)) {
return iG; return iG;
} }
} }

View File

@ -17,7 +17,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
@ -67,7 +66,6 @@ public class SettingsImportDialog extends PamDialog {
moduleTable.getColumnModel().getColumn(2).setPreferredWidth(200); moduleTable.getColumnModel().getColumn(2).setPreferredWidth(200);
JPanel mainPanel = new JPanel(new BorderLayout()); JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.setBorder(new TitledBorder("Module import selection"));
JScrollPane scrollPanel = new JScrollPane(moduleTable); JScrollPane scrollPanel = new JScrollPane(moduleTable);
mainPanel.add(BorderLayout.CENTER, scrollPanel); mainPanel.add(BorderLayout.CENTER, scrollPanel);
mainPanel.setPreferredSize(new Dimension(600, 250)); mainPanel.setPreferredSize(new Dimension(600, 250));

View File

@ -5,7 +5,6 @@ import java.util.ArrayList;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamController; import PamController.PamController;
import PamController.UsedModuleInfo;
import PamModel.PamModuleInfo; import PamModel.PamModuleInfo;
/** /**
@ -21,26 +20,19 @@ public class SettingsImportGroup {
private ArrayList<PamControlledUnitSettings> subSettings = new ArrayList<>(); private ArrayList<PamControlledUnitSettings> subSettings = new ArrayList<>();
private UsedModuleInfo usedModuleInfo; private PamModuleInfo moduleInfo;
private ArrayList<ImportChoice> importChoices; private ArrayList<ImportChoice> importChoices;
private ImportChoice importChoice; private ImportChoice importChoice;
public SettingsImportGroup(UsedModuleInfo moduleInfo) {
super();
this.usedModuleInfo = moduleInfo;
}
/** /**
* Constructor takes the main settings * Constructor takes the main settings
* @param mainSettings * @param mainSettings
* @param moduleInfo * @param moduleInfo
*/ */
public SettingsImportGroup(PamControlledUnitSettings mainSettings, UsedModuleInfo moduleInfo) { public SettingsImportGroup(PamControlledUnitSettings mainSettings, PamModuleInfo moduleInfo) {
this.mainSettings = mainSettings; this.mainSettings = mainSettings;
this.usedModuleInfo = moduleInfo; this.moduleInfo = moduleInfo;
} }
/** /**
@ -80,7 +72,7 @@ public class SettingsImportGroup {
importChoices.add(importChoice = new ImportChoice(ImportChoice.DONT_IMPORT, null)); importChoices.add(importChoice = new ImportChoice(ImportChoice.DONT_IMPORT, null));
Class ownerClass = null; Class ownerClass = null;
try { try {
ownerClass = Class.forName(usedModuleInfo.className); ownerClass = Class.forName(mainSettings.getOwnerClassName());
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -88,9 +80,8 @@ public class SettingsImportGroup {
ArrayList<PamControlledUnit> existingModules = ArrayList<PamControlledUnit> existingModules =
PamController.getInstance().findControlledUnits(ownerClass); PamController.getInstance().findControlledUnits(ownerClass);
int maxnumber = 1; // this will only ever be used by the Array Manager which doesn't have a moduleInfo. int maxnumber = 1; // this will only ever be used by the Array Manager which doesn't have a moduleInfo.
PamModuleInfo pamModuleInfo = getPamModuleInfo(); if (this.moduleInfo != null) {
if (pamModuleInfo != null) { maxnumber = moduleInfo.getMaxNumber();
maxnumber = pamModuleInfo.getMaxNumber();
} }
if (existingModules != null) { if (existingModules != null) {
for (int i = 0; i < existingModules.size(); i++) { for (int i = 0; i < existingModules.size(); i++) {
@ -120,29 +111,10 @@ public class SettingsImportGroup {
} }
/** /**
* This is the information from an existing module, which may not
* have the full class name, but does have the type and name of the
* module being imported.
* @return the moduleInfo * @return the moduleInfo
*/ */
public UsedModuleInfo getUsedModuleInfo() { public PamModuleInfo getModuleInfo() {
return usedModuleInfo; return moduleInfo;
}
/**
* this is the module information held in the PamModel which
* is used to create a module.
* @return
*/
public PamModuleInfo getPamModuleInfo() {
return PamModuleInfo.findModuleInfo(usedModuleInfo.className);
}
/**
* @param mainSettings the mainSettings to set
*/
public void setMainSettings(PamControlledUnitSettings mainSettings) {
this.mainSettings = mainSettings;
} }

View File

@ -74,7 +74,7 @@ import PamUtils.FileFinder;
* PamController. * PamController.
* *
*/ */
final public class PamModel implements PamSettings { final public class PamModel implements PamModelInterface, PamSettings {
private PamController pamController; private PamController pamController;
@ -982,6 +982,7 @@ final public class PamModel implements PamSettings {
} }
@Override
public boolean modelSettings(JFrame frame) { public boolean modelSettings(JFrame frame) {
PamModelSettings newSettings = ThreadingDialog.showDialog(frame, pamModelSettings); PamModelSettings newSettings = ThreadingDialog.showDialog(frame, pamModelSettings);
if (newSettings != null) { if (newSettings != null) {

View File

@ -29,7 +29,6 @@ import javax.swing.JFrame;
* order that the PamController and the PamView can interface with the * order that the PamController and the PamView can interface with the
* model. * model.
*/ */
@Deprecated
public interface PamModelInterface { public interface PamModelInterface {
/** /**

View File

@ -10,7 +10,6 @@ import javax.swing.JMenu;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamController; import PamController.PamController;
import PamController.PamControllerInterface; import PamController.PamControllerInterface;
@ -35,9 +34,6 @@ public class PamModuleInfo implements PamDependent{
private Class moduleClass; private Class moduleClass;
private String toolTipText; private String toolTipText;
private static final Class[] constrParams1 = {PamConfiguration.class, String.class};
private static final Class[] constrParams2 = {String.class};
/** /**
* A list of possible GUI types the module can have. These are received from flags in PAMGuiManager(); * A list of possible GUI types the module can have. These are received from flags in PAMGuiManager();
*/ */
@ -213,7 +209,7 @@ public class PamModuleInfo implements PamDependent{
dependencyManager.checkDependency(parentFrame, moduleInfo, true); dependencyManager.checkDependency(parentFrame, moduleInfo, true);
} }
// create a new PamControlledUnit and add it to PamGuard ... // create a new PamControlledUnit and add it to PamGuard ...
PamController pamController = PamController.getInstance(); PamControllerInterface pamController = PamController.getInstance();
pamController.addModule(parentFrame, moduleInfo); pamController.addModule(parentFrame, moduleInfo);
} }
@ -223,63 +219,38 @@ public class PamModuleInfo implements PamDependent{
public AddModuleMenuAction getMenuAction(Frame parentFrame) { public AddModuleMenuAction getMenuAction(Frame parentFrame) {
return new AddModuleMenuAction(parentFrame, this); return new AddModuleMenuAction(parentFrame, this);
} }
public PamControlledUnit create(String unitName) {
return create(null, unitName);
}
public PamControlledUnit create(PamConfiguration pamConfiguration, String unitName) { public PamControlledUnit create(String unitName) {
PamControlledUnit newUnit = null; PamControlledUnit newUnit = null;
// Class[] paramList = new Class[1]; Class[] paramList = new Class[1];
// paramList[0] = unitName.getClass(); paramList[0] = unitName.getClass();
boolean error = false;
try { try {
Constructor constructor = moduleClass.getConstructor(constrParams1); Constructor constructor = moduleClass.getConstructor(paramList);
newUnit = (PamControlledUnit) constructor.newInstance(pamConfiguration, unitName); // Debug.out.println("unitName:"+ unitName);
newUnit = (PamControlledUnit) constructor.newInstance(unitName);
newUnit.setPamModuleInfo(this); newUnit.setPamModuleInfo(this);
} }
catch (Exception Ex) { catch (Exception Ex) {
String title = "Error loading module";
String msg = "There was an error trying to load " + unitName + ".<p>" +
"If this is a core Pamguard module, please copy the error message text and email to " +
"support@pamguard.org.<p>" +
"If this is a plug-in, the error may have been caused by an incompatibility between " +
"it and this version of PAMGuard, or a problem with the code. Please check the developer's website for help.<p>" +
"This module will not be loaded.";
String help = null;
int ans = WarnOnce.showWarning(title, msg, WarnOnce.WARNING_MESSAGE, help, Ex);
System.err.println("Exception while loading " + Ex.getMessage());
Ex.printStackTrace();
return null;
} }
if (newUnit == null) {
try {
Constructor constructor = moduleClass.getConstructor(constrParams2);
newUnit = (PamControlledUnit) constructor.newInstance(unitName);
newUnit.setPamModuleInfo(this);
}
catch (Exception Ex) {
String title = "Error loading module";
String msg = "There was an error trying to load " + unitName + ".<p>" +
"If this is a core Pamguard module, please copy the error message text and email to " +
"support@pamguard.org.<p>" +
"If this is a plug-in, the error may have been caused by an incompatibility between " +
"it and this version of PAMGuard, or a problem with the code. Please check the developer's website for help.<p>" +
"This module will not be loaded.";
String help = null;
int ans = WarnOnce.showWarning(title, msg, WarnOnce.WARNING_MESSAGE, help, Ex);
System.err.println("Exception while loading " + Ex.getMessage());
Ex.printStackTrace();
return null;
}
}
setNInstances(nInstances + 1); setNInstances(nInstances + 1);
return newUnit; return newUnit;
} }
private Constructor findConstructor() throws NoSuchMethodException, SecurityException {
Constructor constructor = null;
try {
constructor = moduleClass.getConstructor(constrParams1);
return constructor;
} catch (NoSuchMethodException | SecurityException e1) {
}
constructor = moduleClass.getConstructor(constrParams2);
return constructor;
}
private void moduleRemoved(PamControlledUnit controlledUnit) { private void moduleRemoved(PamControlledUnit controlledUnit) {
setNInstances(nInstances - 1); setNInstances(nInstances - 1);
@ -405,7 +376,7 @@ public class PamModuleInfo implements PamDependent{
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int ans = JOptionPane.showConfirmDialog(pamControlledUnit.getGuiFrame(), int ans = JOptionPane.showConfirmDialog(pamControlledUnit.getPamView().getGuiFrame(),
"Do you really want to remove the module " "Do you really want to remove the module "
+ pamControlledUnit.getUnitName()); + pamControlledUnit.getUnitName());
if (ans == JOptionPane.YES_OPTION) { if (ans == JOptionPane.YES_OPTION) {

View File

@ -87,6 +87,7 @@ import PamController.PamguardVersionInfo;
import PamController.settings.SettingsImport; import PamController.settings.SettingsImport;
import PamModel.CommonPluginInterface; import PamModel.CommonPluginInterface;
import PamModel.PamModel; import PamModel.PamModel;
import PamModel.PamModelInterface;
import PamModel.PamModuleInfo; import PamModel.PamModuleInfo;
import PamModel.PamPluginInterface; import PamModel.PamPluginInterface;
import PamModel.AboutPluginDisplay; import PamModel.AboutPluginDisplay;
@ -132,14 +133,11 @@ public class PamGui extends PamView implements WindowListener, PamSettings {
* Outer layered pane which allows things to be added the GUI. * Outer layered pane which allows things to be added the GUI.
*/ */
private JLayeredPane layeredPane; private JLayeredPane layeredPane;
private PamController pamController;
public PamGui(PamController pamControllerInterface, public PamGui(PamControllerInterface pamControllerInterface,
PamModel pamModelInterface, int frameNumber) PamModelInterface pamModelInterface, int frameNumber)
{ {
super(pamControllerInterface, pamModelInterface, frameNumber); super(pamControllerInterface, pamModelInterface, frameNumber);
this.pamController = pamControllerInterface;
startMenuEnabler = new MenuItemEnabler(); startMenuEnabler = new MenuItemEnabler();
stopMenuEnabler = new MenuItemEnabler(); stopMenuEnabler = new MenuItemEnabler();
@ -1200,7 +1198,7 @@ public class PamGui extends PamView implements WindowListener, PamSettings {
class menuShowObjectDiagram implements ActionListener { class menuShowObjectDiagram implements ActionListener {
public void actionPerformed(ActionEvent ev){ public void actionPerformed(ActionEvent ev){
PamObjectViewer.Show(getGuiFrame(), pamController.getPamConfiguration()); PamObjectViewer.Show(getGuiFrame());
} }
} }

View File

@ -26,7 +26,7 @@ import javax.swing.JMenu;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import PamModel.PamModel; import PamModel.PamModelInterface;
/** /**
* @author dgillespie * @author dgillespie
@ -39,7 +39,7 @@ import PamModel.PamModel;
* *
*/ */
public class PamMenu { public class PamMenu {
static public JMenuBar createBasicMenu(PamModel pamModelInterface, static public JMenuBar createBasicMenu(PamModelInterface pamModelInterface,
ActionListener actionListener) { ActionListener actionListener) {
JMenuBar menuBar = new JMenuBar(); JMenuBar menuBar = new JMenuBar();
@ -52,7 +52,7 @@ public class PamMenu {
return menuBar; return menuBar;
} }
static public JMenu fileMenu(PamModel pamModelInterface, static public JMenu fileMenu(PamModelInterface pamModelInterface,
ActionListener actionListener) { ActionListener actionListener) {
JMenuItem menuItem; JMenuItem menuItem;
JMenu menu = new JMenu("File"); JMenu menu = new JMenu("File");
@ -64,7 +64,7 @@ public class PamMenu {
return menu; return menu;
} }
static public JMenu loggingMenu(PamModel pamModelInterface, static public JMenu loggingMenu(PamModelInterface pamModelInterface,
ActionListener actionListener) { ActionListener actionListener) {
JMenuItem menuItem; JMenuItem menuItem;
JMenu menu = new JMenu("Logging"); JMenu menu = new JMenu("Logging");
@ -76,7 +76,7 @@ public class PamMenu {
return menu; return menu;
} }
static public JMenu detectionMenu(PamModel pamModelInterface, static public JMenu detectionMenu(PamModelInterface pamModelInterface,
ActionListener actionListener) { ActionListener actionListener) {
JMenu menu = new JMenu("Detection"); JMenu menu = new JMenu("Detection");
JMenuItem menuItem; JMenuItem menuItem;
@ -108,7 +108,7 @@ public class PamMenu {
return menu; return menu;
} }
static public JMenu displayMenu(PamModel pamModelInterface, static public JMenu displayMenu(PamModelInterface pamModelInterface,
ActionListener actionListener) { ActionListener actionListener) {
JMenu menu = new JMenu("Display"); JMenu menu = new JMenu("Display");
JMenuItem menuItem; JMenuItem menuItem;

View File

@ -42,7 +42,6 @@ import javax.swing.Timer;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import PamController.NewModuleDialog; import PamController.NewModuleDialog;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamController; import PamController.PamController;
@ -115,11 +114,9 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
private Stroke arrowStroke, instantArrowStroke; private Stroke arrowStroke, instantArrowStroke;
private PamConfiguration pamConfiguration;
// Font controllerFont, processFont, datablockFont; // Font controllerFont, processFont, datablockFont;
private PamObjectViewer(Frame frame) { private PamObjectViewer(JFrame frame) {
arrowStroke = new BasicStroke(1.5f); arrowStroke = new BasicStroke(1.5f);
instantArrowStroke = new BasicStroke(1.5f); instantArrowStroke = new BasicStroke(1.5f);
@ -128,27 +125,23 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
objectFrame = new ObjectFrame(frame); objectFrame = new ObjectFrame(frame);
// MakeDiagram(); MakeDiagram();
PamController.getInstance().addView(this); PamController.getInstance().addView(this);
PamSettingManager.getInstance().registerSettings(this); PamSettingManager.getInstance().registerSettings(this);
} }
static public PamObjectViewer getObjectViewer(Frame frame) { static public PamObjectViewer getObjectViewer(JFrame frame) {
if (singleInstance == null) { if (singleInstance == null) {
singleInstance = new PamObjectViewer(frame); singleInstance = new PamObjectViewer(frame);
} }
return singleInstance; return singleInstance;
} }
static public void Show(Frame frame, PamConfiguration pamConfiguration) { static public void Show(JFrame frame) {
getObjectViewer(frame).setConfiguration(pamConfiguration);
getObjectViewer(frame).objectFrame.setVisible(true); getObjectViewer(frame).objectFrame.setVisible(true);
singleInstance.MakeDiagram();
// Go through all of the processes/datablocks in every view and update button/tooltip text. // Go through all of the processes/datablocks in every view and update button/tooltip text.
// Mostly done for the FFT Engine process because it includes the FFT size in the // Mostly done for the FFT Engine process because it includes the FFT size in the
// process name, and without this code the name would get set the first time you open // process name, and without this code the name would get set the first time you open
@ -171,10 +164,6 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
} }
} }
private void setConfiguration(PamConfiguration pamConfiguration) {
this.pamConfiguration = pamConfiguration;
}
void MakeDiagram() { void MakeDiagram() {
if (pamObjectViewerSettings.viewStyle == PamObjectViewerSettings.VIEWBYPROCESS) { if (pamObjectViewerSettings.viewStyle == PamObjectViewerSettings.VIEWBYPROCESS) {
@ -191,16 +180,12 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
private void makeControllerDiagram() { private void makeControllerDiagram() {
clearDiagram(); clearDiagram();
PamControllerInterface pamController = PamController.getInstance();
if (pamConfiguration == null) {
return;
}
PamControlledUnit pamControlledUnit; PamControlledUnit pamControlledUnit;
PamControllerView pamControllerView; PamControllerView pamControllerView;
controllerList = new ArrayList<PamControllerView>(); controllerList = new ArrayList<PamControllerView>();
for (int iUnit = 0; iUnit < pamConfiguration.getNumControlledUnits(); iUnit++) { for (int iUnit = 0; iUnit < pamController.getNumControlledUnits(); iUnit++) {
pamControlledUnit = pamConfiguration.getControlledUnit(iUnit); pamControlledUnit = pamController.getControlledUnit(iUnit);
if (pamControlledUnit.getNumPamProcesses() == 0 if (pamControlledUnit.getNumPamProcesses() == 0
&& pamObjectViewerSettings.showProcesslessModules == false) { && pamObjectViewerSettings.showProcesslessModules == false) {
continue; continue;
@ -213,6 +198,25 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
} }
// private void makeProcesslessModules() {
// PamControllerInterface pamController = PamController.getInstance();
// PamControlledUnit pamControlledUnit;
// PamControllerView pamControllerView;
// if (controllerList == null)
// controllerList = new ArrayList<PamControllerView>();
// for (int iUnit = 0; iUnit < pamController.getNumControlledUnits();
// iUnit++) {
// pamControlledUnit = pamController.getControlledUnit(iUnit);
// if (pamControlledUnit.getNumPamProcesses() > 0) {
// continue;
// }
// pamControllerView = new PamControllerView(pamControlledUnit);
// controllerList.add(pamControllerView);
// layoutPanel.add(pamControllerView);
// pamControllerView.addComponentListener(this);
// }
//
// }
private void layoutControllerDiagram() { private void layoutControllerDiagram() {
if (controllerList == null) { if (controllerList == null) {
return; return;
@ -281,10 +285,11 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
int x = xStart; int x = xStart;
int y = yStart; int y = yStart;
PamControllerInterface pamController = PamController.getInstance();
PamControlledUnit pamControlledUnit; PamControlledUnit pamControlledUnit;
PamProcess pamProcess; PamProcess pamProcess;
for (int iUnit = 0; iUnit < pamConfiguration.getNumControlledUnits(); iUnit++) { for (int iUnit = 0; iUnit < pamController.getNumControlledUnits(); iUnit++) {
pamControlledUnit = pamConfiguration.getControlledUnit(iUnit); pamControlledUnit = pamController.getControlledUnit(iUnit);
for (int iP = 0; iP < pamControlledUnit.getNumPamProcesses(); iP++) { for (int iP = 0; iP < pamControlledUnit.getNumPamProcesses(); iP++) {
pamProcess = pamControlledUnit.getPamProcess(iP); pamProcess = pamControlledUnit.getPamProcess(iP);
pamProcessView = new PamProcessView(pamControlledUnit, pamProcessView = new PamProcessView(pamControlledUnit,
@ -412,7 +417,7 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
class ObjectFrame extends JFrame implements ActionListener { class ObjectFrame extends JFrame implements ActionListener {
ObjectFrame(Frame frame) { ObjectFrame(JFrame frame) {
setTitle("Pamguard Data Model"); setTitle("Pamguard Data Model");
// fixed case of Resources 17/8/08 DG. // fixed case of Resources 17/8/08 DG.
@ -594,9 +599,6 @@ public class PamObjectViewer implements PamViewInterface, ComponentListener,
int bestYGap; int bestYGap;
Rectangle sourceBounds, destBounds; Rectangle sourceBounds, destBounds;
hasInstant = false; hasInstant = false;
if (controllerList == null) {
return;
}
for (int i = 0; i < controllerList.size(); i++) { for (int i = 0; i < controllerList.size(); i++) {
pamControllerView = controllerList.get(i); pamControllerView = controllerList.get(i);
pamControlledUnit = pamControllerView.pamControlledUnit; pamControlledUnit = pamControllerView.pamControlledUnit;

View File

@ -24,7 +24,7 @@ import javax.swing.JFrame;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControllerInterface; import PamController.PamControllerInterface;
import PamModel.PamModel; import PamModel.PamModelInterface;
import javafx.application.Platform; import javafx.application.Platform;
/** /**
@ -36,7 +36,7 @@ abstract public class PamView implements PamViewInterface {
protected PamControllerInterface pamControllerInterface; protected PamControllerInterface pamControllerInterface;
protected PamModel pamModelInterface; protected PamModelInterface pamModelInterface;
/** /**
* Frame for main window associated with this view (i.e a PamGUI). * Frame for main window associated with this view (i.e a PamGUI).
@ -47,7 +47,7 @@ abstract public class PamView implements PamViewInterface {
public PamView(PamControllerInterface pamControllerInterface, public PamView(PamControllerInterface pamControllerInterface,
PamModel pamModelInterface, int frameNumber) { PamModelInterface pamModelInterface, int frameNumber) {
this.pamControllerInterface = pamControllerInterface; this.pamControllerInterface = pamControllerInterface;
this.pamModelInterface = pamModelInterface; this.pamModelInterface = pamModelInterface;
this.frameNumber = frameNumber; this.frameNumber = frameNumber;

View File

@ -11,7 +11,6 @@ import javax.swing.JComponent;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
@ -129,14 +128,6 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
} }
} }
/**
* Get table. Allows adding of more menu handlers, etc.
* @return the table object.
*/
public JTable getTable() {
return testTable;
}
/** /**
* Set allowing of multiple row selection. * Set allowing of multiple row selection.
* @param allow * @param allow
@ -237,7 +228,7 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
* @param tableRow * @param tableRow
* @return data unit for the table row. * @return data unit for the table row.
*/ */
protected final T getDataUnit(int tableRow) { private final T getDataUnit(int tableRow) {
synchronized (copySynch) { synchronized (copySynch) {
int rowIndex = getDataIndexForRow(tableRow); int rowIndex = getDataIndexForRow(tableRow);
if (rowIndex < 0) return null; if (rowIndex < 0) return null;
@ -386,7 +377,7 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
* so consider changing the row selection * so consider changing the row selection
* @param e * @param e
*/ */
protected void checkRowSelection(MouseEvent e) { private void checkRowSelection(MouseEvent e) {
int tableRow = testTable.rowAtPoint(e.getPoint()); int tableRow = testTable.rowAtPoint(e.getPoint());
int currentRow = testTable.getSelectedRow(); int currentRow = testTable.getSelectedRow();
if (tableRow != currentRow) { if (tableRow != currentRow) {
@ -398,16 +389,6 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
} }
} }
/**
* Put the getColumnName function out here, so that subclasses can
* more easily override it than if it's buried in the table model
* @param column
* @return colum name
*/
public String getColumnName(int column) {
return getColumnNames()[column];
}
private class ViewScrollObserver implements PamScrollObserver { private class ViewScrollObserver implements PamScrollObserver {
@Override @Override
@ -467,7 +448,7 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
*/ */
@Override @Override
public String getColumnName(int column) { public String getColumnName(int column) {
return DataBlockTableView.this.getColumnName(column); return getColumnNames()[column];
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -154,13 +154,9 @@ public class GroupedSourcePanel extends SourcePanel {
public void setChannelGroups(int[] channelGroups) { public void setChannelGroups(int[] channelGroups) {
if (channelGroups == null) return; if (channelGroups == null) return;
for (int i = 0; i < Math.min(channelGroups.length, PamConstants.MAX_CHANNELS); i++) { try { for (int i = 0; i < Math.min(channelGroups.length, PamConstants.MAX_CHANNELS); i++) {
groupList[i].setSelectedIndex(channelGroups[i]); groupList[i].setSelectedIndex(channelGroups[i]);
} }
catch (Exception e) {
}
}
} }
public static void addComponent(JPanel panel, Component p, GridBagConstraints constraints){ public static void addComponent(JPanel panel, Component p, GridBagConstraints constraints){

View File

@ -343,7 +343,7 @@ public class RecorderTabPanel implements PamTabPanel, RecorderView {
class SettingsButtonListener implements ActionListener { class SettingsButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
recorderControl.recordSettingsDialog(recorderControl.getGuiFrame()); recorderControl.recordSettingsDialog(recorderControl.getPamView().getGuiFrame());
} }
} }

View File

@ -107,7 +107,6 @@ import PamView.GeneralProjector;
import PamView.ColourArray.ColourArrayType; import PamView.ColourArray.ColourArrayType;
import PamView.dialog.PamLabel; import PamView.dialog.PamLabel;
import PamView.PamColors; import PamView.PamColors;
import PamView.PamView;
import PamView.hidingpanel.HidingDialogPanel; import PamView.hidingpanel.HidingDialogPanel;
import PamView.panel.CornerLayout; import PamView.panel.CornerLayout;
import PamView.panel.CornerLayoutContraint; import PamView.panel.CornerLayoutContraint;
@ -276,13 +275,11 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
// } // }
if (spectrogramParameters == null) { if (spectrogramParameters == null) {
this.spectrogramParameters = new SpectrogramParameters(); this.spectrogramParameters = new SpectrogramParameters();
PamView view = userDisplayControl.getPamView(); // setSettings(); // force up the dialog.
if (view != null) { SpectrogramParameters newParams = SpectrogramParamsDialog
SpectrogramParameters newParams = SpectrogramParamsDialog .showDialog(userDisplayControl.getPamView().getGuiFrame(), spectrogramPanels, spectrogramParameters);
.showDialog(userDisplayControl.getGuiFrame(), spectrogramPanels, spectrogramParameters); if (newParams != null) {
if (newParams != null) { this.spectrogramParameters = newParams;
this.spectrogramParameters = newParams;
}
} }
} }
@ -1187,7 +1184,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
// SpectrogramParameters newParams = SpectrogramParamsDialog // SpectrogramParameters newParams = SpectrogramParamsDialog
// .showDialog(userDisplayControl.getPamView().getGuiFrame(), this.getOverlayMarker(), spectrogramParameters); // .showDialog(userDisplayControl.getPamView().getGuiFrame(), this.getOverlayMarker(), spectrogramParameters);
SpectrogramParameters newParams = SpectrogramParamsDialog SpectrogramParameters newParams = SpectrogramParamsDialog
.showDialog(userDisplayControl.getGuiFrame(), spectrogramPanels, spectrogramParameters); .showDialog(userDisplayControl.getPamView().getGuiFrame(), spectrogramPanels, spectrogramParameters);
if (newParams == null) return; if (newParams == null) return;

View File

@ -136,9 +136,7 @@ public class UserInputLogger extends SQLLogging {
if (dataUnit != null && dataUnit.getDatabaseIndex() != databaseIndex) { if (dataUnit != null && dataUnit.getDatabaseIndex() != databaseIndex) {
dataUnit.setDatabaseIndex(databaseIndex); dataUnit.setDatabaseIndex(databaseIndex);
dataUnit.setUserString(dataUnit.getUserString() + " " + txt); dataUnit.setUserString(dataUnit.getUserString() + " " + txt);
// don't call this next line, it causes the unit to get relogged. getPamDataBlock().updatePamData(dataUnit, timeMilliseconds);
// getPamDataBlock().updatePamData(dataUnit, timeMilliseconds);
dataUnit.clearUpdateCount();
} }
else { else {
dataUnit = new UserInputDataUnit(timeMilliseconds, txt); dataUnit = new UserInputDataUnit(timeMilliseconds, txt);

View File

@ -17,7 +17,6 @@ import alarm.actions.AlarmAction;
import alarm.actions.email.SendEmailAction; import alarm.actions.email.SendEmailAction;
import alarm.actions.serial.AlarmSerialAction; import alarm.actions.serial.AlarmSerialAction;
import alarm.actions.sound.PlaySound; import alarm.actions.sound.PlaySound;
import alarm.actions.tast.TastAction;
import alarm.actions.udp.AlarmUDPAction; import alarm.actions.udp.AlarmUDPAction;
import userDisplay.UserDisplayComponent; import userDisplay.UserDisplayComponent;
import userDisplay.UserDisplayControl; import userDisplay.UserDisplayControl;
@ -55,7 +54,6 @@ public class AlarmControl extends PamControlledUnit implements PamSettings {
alarmActions.add(new AlarmSerialAction(this)); alarmActions.add(new AlarmSerialAction(this));
alarmActions.add(new SendEmailAction(this)); alarmActions.add(new SendEmailAction(this));
alarmActions.add(new AlarmUDPAction(this)); alarmActions.add(new AlarmUDPAction(this));
// alarmActions.add(new TastAction(this)); // uncomment when alarm action string ready
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -62,7 +62,7 @@ public class AlarmOfflineTask extends OfflineTask<PamDataUnit> {
@Override @Override
public boolean callSettings() { public boolean callSettings() {
Frame frame = alarmControl.getGuiFrame(); Frame frame = alarmControl.getPamView().getGuiFrame();
boolean ok = alarmControl.showAlarmDialog(frame); boolean ok = alarmControl.showAlarmDialog(frame);
if (ok) { if (ok) {
setParentDataBlock(alarmProcess.getSourceDataBlock()); setParentDataBlock(alarmProcess.getSourceDataBlock());

View File

@ -1,26 +0,0 @@
package alarm.actions.tast;
import alarm.AlarmControl;
import alarm.AlarmDataUnit;
import alarm.actions.serial.AlarmSerialAction;
public class TastAction extends AlarmSerialAction {
public TastAction(AlarmControl alarmControl) {
super(alarmControl);
}
@Override
public String getActionName() {
return "TAST Trigger";
}
@Override
protected String createAlarmString(AlarmDataUnit alarmDataUnit) {
// TODO. To define serial string to send to TAST device once we hear back
// from GenusWave.
return null;
}
}

View File

@ -22,7 +22,7 @@ public class AutecPhonesControl extends PamControlledUnit {
} }
public Frame getGuiFrame() { public Frame getGuiFrame() {
return super.getGuiFrame(); return super.getPamView().getGuiFrame();
} }
class AutecProcess extends PamProcess { class AutecProcess extends PamProcess {

View File

@ -923,7 +923,7 @@ PamSettingsSource, DataOutputStore {
protected void process(List<BinaryMapMakeProgress> chunks) { protected void process(List<BinaryMapMakeProgress> chunks) {
if (PamGUIManager.isSwing()) { if (PamGUIManager.isSwing()) {
if (binaryMapDialog == null) { if (binaryMapDialog == null) {
binaryMapDialog = BinaryMapMakingDialog.showDialog(PamController.getMainFrame()); binaryMapDialog = BinaryMapMakingDialog.showDialog(getPamView().getGuiFrame());
} }
super.process(chunks); super.process(chunks);
for (int i = 0; i < chunks.size(); i++) { for (int i = 0; i < chunks.size(); i++) {
@ -2370,7 +2370,7 @@ PamSettingsSource, DataOutputStore {
* Get the unit type for the binary store. * Get the unit type for the binary store.
* @return the binary store unit type. * @return the binary store unit type.
*/ */
public static String getBinaryUnitType() { private static String getBinaryUnitType() {
return defUnitType; return defUnitType;
} }

View File

@ -2771,7 +2771,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
BTDisplayParameters newParameters = BTDisplayParameters newParameters =
ClickDisplayDialog.showDialog(clickControl, ClickDisplayDialog.showDialog(clickControl,
clickControl.getGuiFrame(), btDisplayParameters); clickControl.getPamView().getGuiFrame(), btDisplayParameters);
if (newParameters != null){ if (newParameters != null){
btDisplayParameters = newParameters.clone(); btDisplayParameters = newParameters.clone();
if (getVScaleManager() != null) { if (getVScaleManager() != null) {

View File

@ -44,7 +44,6 @@ import binaryFileStorage.BinaryStore;
import Filters.FilterDialog; import Filters.FilterDialog;
import Filters.FilterParams; import Filters.FilterParams;
import Localiser.detectionGroupLocaliser.GroupDetection; import Localiser.detectionGroupLocaliser.GroupDetection;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI; import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
@ -98,7 +97,6 @@ import dataPlotsFX.data.TDDataProviderRegisterFX;
import detectionPlotFX.data.DDPlotRegister; import detectionPlotFX.data.DDPlotRegister;
import detectionPlotFX.rawDDPlot.ClickDDPlotProvider; import detectionPlotFX.rawDDPlot.ClickDDPlotProvider;
import fftManager.fftorganiser.FFTDataOrganiser; import fftManager.fftorganiser.FFTDataOrganiser;
import offlineProcessing.OfflineTaskGroup;
/** /**
* Main Controller for click detection. * Main Controller for click detection.
@ -209,22 +207,9 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
public static final String UNITTYPE = "Click Detector"; public static final String UNITTYPE = "Click Detector";
/**
* Old style constructor which only gets a name
* @param name
*/
public ClickControl(String name) { public ClickControl(String name) {
this(null, name);
}
/**
* New style constructor which get a configuraiton and a name.
* @param pamConfiguration
* @param name
*/
public ClickControl(PamConfiguration pamConfiguration, String name) {
super(pamConfiguration, UNITTYPE, name); super(UNITTYPE, name);
sortDataBlockPrefix(); sortDataBlockPrefix();
@ -235,6 +220,7 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
// } // }
clickControl = this; clickControl = this;
angleVetoes = new AngleVetoes(this); angleVetoes = new AngleVetoes(this);
offlineToolbar = new OfflineToolbar(this); offlineToolbar = new OfflineToolbar(this);
@ -302,9 +288,6 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
roccaControl = (RoccaControl) PamController.getInstance().findControlledUnit(RoccaControl.unitType); roccaControl = (RoccaControl) PamController.getInstance().findControlledUnit(RoccaControl.unitType);
} }
else {
ClicksOffline.getOfflineTaskGroup(this);
}
if (PamGUIManager.isSwing()) { if (PamGUIManager.isSwing()) {
@ -1005,19 +988,6 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
return clicksOffline; return clicksOffline;
} }
// /**
// * @return the number of offlineTaskGroups
// */
// public int getNumOfflineTaskGroups() {
// return 1;
// }
//
// /**
// * @return the iTH offlineTaskGroup
// */
// public OfflineTaskGroup getOfflineTaskGroup(int i) {
// return offlineTaskGroups.get(i);
// }
/** /**
* @return the latestOfflineEvent * @return the latestOfflineEvent
@ -1217,8 +1187,7 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
* @return * @return
*/ */
public PamRawDataBlock findRawDataBlock() { public PamRawDataBlock findRawDataBlock() {
return getPamConfiguration().getRawDataBlock(clickParameters.getRawDataSource()); return (PamController.getInstance().getRawDataBlock(clickParameters.getRawDataSource()));
// return (PamController.getInstance().getRawDataBlock(clickParameters.getRawDataSource()));
} }

View File

@ -403,7 +403,7 @@ public class ClickDetector extends PamProcess {
// try to connect automatically to the acquisition module ... // try to connect automatically to the acquisition module ...
// ArrayList<PamDataBlock> rawBlocks = // ArrayList<PamDataBlock> rawBlocks =
// PamController.getInstance().getDataBlocks(RawDataUnit.class, false); // PamController.getInstance().getDataBlocks(RawDataUnit.class, false);
AcquisitionControl daq = (AcquisitionControl) clickControl.getPamConfiguration() AcquisitionControl daq = (AcquisitionControl) PamController.getInstance()
.findControlledUnit(AcquisitionControl.unitType); .findControlledUnit(AcquisitionControl.unitType);
if (daq != null) { if (daq != null) {
rawDataSource = daq.getRawDataBlock(); rawDataSource = daq.getRawDataBlock();

View File

@ -841,7 +841,7 @@ public class ClickSpectrum extends ClickDisplay implements PamObserver , PamSett
pt.x += 10; pt.x += 10;
pt.y += 20; pt.y += 20;
ClickSpectrumParams newParams = ClickSpectrumDialog.showDialog( ClickSpectrumParams newParams = ClickSpectrumDialog.showDialog(
clickControl.getGuiFrame(), pt, this, clickSpectrumParams); clickControl.getPamView().getGuiFrame(), pt, this, clickSpectrumParams);
if (newParams != null) { if (newParams != null) {
if (newParams.plotCepstrum) { if (newParams.plotCepstrum) {
newParams.logScale = false; newParams.logScale = false;
@ -859,7 +859,7 @@ public class ClickSpectrum extends ClickDisplay implements PamObserver , PamSett
pt.x += 10; pt.x += 10;
pt.y += 20; pt.y += 20;
ClickSpectrumTemplateParams newTempParams = ClickSpectrumTemplateEditDialog.showDialog( ClickSpectrumTemplateParams newTempParams = ClickSpectrumTemplateEditDialog.showDialog(
clickControl.getGuiFrame(), pt, this, clickTemplateParams,clickControl); clickControl.getPamView().getGuiFrame(), pt, this, clickTemplateParams,clickControl);
if (newTempParams!=null){ if (newTempParams!=null){
clickTemplateParams = newTempParams.clone(); clickTemplateParams = newTempParams.clone();
sortWestAxis(); sortWestAxis();
@ -873,7 +873,7 @@ public class ClickSpectrum extends ClickDisplay implements PamObserver , PamSett
pt.x += 10; pt.x += 10;
pt.y += 20; pt.y += 20;
ClickSpectrumTemplateParams newTempParams = ClickSpectrumTemplateDialog.showDialog( ClickSpectrumTemplateParams newTempParams = ClickSpectrumTemplateDialog.showDialog(
clickControl.getGuiFrame(), pt, this, clickTemplateParams); clickControl.getPamView().getGuiFrame(), pt, this, clickTemplateParams);
if (newTempParams!=null){ if (newTempParams!=null){
clickTemplateParams = newTempParams.clone(); clickTemplateParams = newTempParams.clone();
sortWestAxis(); sortWestAxis();

View File

@ -765,7 +765,7 @@ public class ClickWaveform extends ClickDisplay implements PamObserver {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
ClickParameters newParams = WaveDisplayDialog.showDialog(clickControl.getGuiFrame(), ClickParameters newParams = WaveDisplayDialog.showDialog(clickControl.getPamView().getGuiFrame(),
clickWaveform, clickControl.clickParameters); clickWaveform, clickControl.clickParameters);
if (newParams != null) { if (newParams != null) {
clickControl.clickParameters = newParams.clone(); clickControl.clickParameters = newParams.clone();

View File

@ -975,7 +975,7 @@ public class IDI_Display extends ClickDisplay implements PamObserver, PamSetting
pt.y -= 10; pt.y -= 10;
pt.x += 10; pt.x += 10;
IDI_DisplayParams newParams = IDI_DisplayDialog.showDialog( IDI_DisplayParams newParams = IDI_DisplayDialog.showDialog(
clickControl.getGuiFrame(), pt, idiParams); clickControl.getPamView().getGuiFrame(), pt, idiParams);
if (newParams != null) { if (newParams != null) {
idiParams = newParams.clone(); idiParams = newParams.clone();
setParameters(); setParameters();

View File

@ -248,7 +248,7 @@ public class WignerPlot extends ClickDisplay implements PamSettings {
pt.y -= 10; pt.y -= 10;
pt.x += 10; pt.x += 10;
WignerPlotOptions newoptions = WignerPlotdialog.showDialog( WignerPlotOptions newoptions = WignerPlotdialog.showDialog(
clickControl.getGuiFrame(), pt, wignerPlotOptions); clickControl.getPamView().getGuiFrame(), pt, wignerPlotOptions);
if (newoptions != null) { if (newoptions != null) {
wignerPlotOptions = newoptions.clone(); wignerPlotOptions = newoptions.clone();
clickedOnClick(lastClick); clickedOnClick(lastClick);

View File

@ -123,7 +123,7 @@ public class ClickDelayTask extends OfflineTask<ClickDetection> {
// clickControl.getClickParameters().setDelayMeasurementParams(0, newParams.clone()); // clickControl.getClickParameters().setDelayMeasurementParams(0, newParams.clone());
// return true; // return true;
// } // }
ClickParameters newParams = ClickDelayDialog.showDialog(clickControl.getGuiFrame(), clickControl); ClickParameters newParams = ClickDelayDialog.showDialog(clickControl.getPamView().getGuiFrame(), clickControl);
if (newParams != null) { if (newParams != null) {
clickControl.setClickParameters(newParams); clickControl.setClickParameters(newParams);
return true; return true;

View File

@ -75,7 +75,7 @@ public class ClickReClassifyTask extends OfflineTask<ClickDetection> {
@Override @Override
public boolean callSettings() { public boolean callSettings() {
return clickControl.classificationDialog(clickControl.getGuiFrame()); return clickControl.classificationDialog(clickControl.getPamView().getGuiFrame());
} }

View File

@ -61,6 +61,8 @@ public class ClicksOffline {
private OfflineParameters offlineParameters = new OfflineParameters(); private OfflineParameters offlineParameters = new OfflineParameters();
private OLProcessDialog clickOfflineDialog; private OLProcessDialog clickOfflineDialog;
private OfflineTaskGroup offlineTaskGroup;
public static final String ClickTypeLookupName = "OfflineRCEvents"; public static final String ClickTypeLookupName = "OfflineRCEvents";
@ -543,8 +545,8 @@ public class ClicksOffline {
*/ */
public void reAnalyseClicks() { public void reAnalyseClicks() {
if (clickOfflineDialog == null) { if (clickOfflineDialog == null) {
clickOfflineDialog = new OLProcessDialog(clickControl.getGuiFrame(), clickOfflineDialog = new OLProcessDialog(clickControl.getPamView().getGuiFrame(),
getOfflineTaskGroup(clickControl), "Click Reprocessing"); getOfflineTaskGroup(), "Click Reprocessing");
} }
clickOfflineDialog.setVisible(true); clickOfflineDialog.setVisible(true);
} }
@ -574,9 +576,8 @@ public class ClicksOffline {
* Get / Create an offline task group for click re-processing. * Get / Create an offline task group for click re-processing.
* @return offline task group. Create if necessary * @return offline task group. Create if necessary
*/ */
public static OfflineTaskGroup getOfflineTaskGroup(ClickControl clickControl) { private OfflineTaskGroup getOfflineTaskGroup() {
offlineTaskGroup = new OfflineTaskGroup(clickControl, "Click Reprocessing");
OfflineTaskGroup offlineTaskGroup = new OfflineTaskGroup(clickControl, "Click Reprocessing");
/** /**
* These tasks are not registered - gets too complicated since some of them * These tasks are not registered - gets too complicated since some of them
@ -606,7 +607,7 @@ public class ClicksOffline {
} }
public void labelClicks(OverlayMark overlayMark, List<PamDataUnit> dataList) { public void labelClicks(OverlayMark overlayMark, List<PamDataUnit> dataList) {
Window win = clickControl.getGuiFrame(); Window win = clickControl.getPamView().getGuiFrame();
OfflineEventDataUnit event = LabelClicksDialog.showDialog(win, clickControl, overlayMark, dataList); OfflineEventDataUnit event = LabelClicksDialog.showDialog(win, clickControl, overlayMark, dataList);
if (event != null) { if (event != null) {
notifyEventChanges(event); notifyEventChanges(event);
@ -624,7 +625,7 @@ public class ClicksOffline {
} }
public void newEvent(OverlayMark overlayMark, List<PamDataUnit> markedClicks) { public void newEvent(OverlayMark overlayMark, List<PamDataUnit> markedClicks) {
Window win = clickControl.getGuiFrame(); Window win = clickControl.getPamView().getGuiFrame();
OfflineEventDataBlock offlineEventDataBlock = clickControl.getClickDetector().getOfflineEventDataBlock(); OfflineEventDataBlock offlineEventDataBlock = clickControl.getClickDetector().getOfflineEventDataBlock();
if (markedClicks == null) { if (markedClicks == null) {
return; return;
@ -691,7 +692,7 @@ public class ClicksOffline {
} }
public void labelClick(OverlayMark overlayMark, PamDataUnit singleClick) { public void labelClick(OverlayMark overlayMark, PamDataUnit singleClick) {
Window win = clickControl.getGuiFrame(); Window win = clickControl.getPamView().getGuiFrame();
OfflineEventDataUnit event = LabelClicksDialog.showDialog(win, clickControl, overlayMark, singleClick); OfflineEventDataUnit event = LabelClicksDialog.showDialog(win, clickControl, overlayMark, singleClick);
if (event != null) { if (event != null) {
notifyEventChanges(event); notifyEventChanges(event);

View File

@ -24,7 +24,7 @@ public class EchoDetectionTask extends OfflineTask<ClickDetection> {
this.clickControl = clickControl; this.clickControl = clickControl;
echoDetectionSystem = clickControl.getEchoDetectionSystem(); echoDetectionSystem = clickControl.getEchoDetectionSystem();
setParentDataBlock(clickControl.getClickDataBlock()); setParentDataBlock(clickControl.getClickDataBlock());
addAffectedDataBlock(clickControl.getClickDataBlock()); // addAffectedDataBlock(clickControl.getClickDataBlock());
} }
@Override @Override
@ -90,7 +90,7 @@ public class EchoDetectionTask extends OfflineTask<ClickDetection> {
if (echoDetectionSystem == null) { if (echoDetectionSystem == null) {
return false; return false;
} }
return EchoDialog.showDialog(clickControl.getGuiFrame(), echoDetectionSystem); return EchoDialog.showDialog(clickControl.getPamView().getGuiFrame(), echoDetectionSystem);
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -84,7 +84,7 @@ public class ClickTrainOfflineProcess {
//if null open the dialog- also create a new offlineTask group if the datablock has changed. //if null open the dialog- also create a new offlineTask group if the datablock has changed.
if (clickTrainDialog == null) { if (clickTrainDialog == null) {
clickTrainDialog = new CTProcessDialog(this.clickTrainControl.getGuiFrame(), clickTrainDialog = new CTProcessDialog(this.clickTrainControl.getPamView().getGuiFrame(),
clickTrainOfflineGroup, "Click Train Detection"); clickTrainOfflineGroup, "Click Train Detection");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS); //batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
} }

View File

@ -122,7 +122,7 @@ public class DbHtControl extends PamControlledUnit implements PamSettings {
offlineTaskGroup.addTask(task); offlineTaskGroup.addTask(task);
} }
if (olProcessDialog == null) { if (olProcessDialog == null) {
olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup, "dBHt Data Export"); olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup, "dBHt Data Export");
} }
olProcessDialog.setVisible(true); olProcessDialog.setVisible(true);
} }

View File

@ -455,7 +455,7 @@ public class DifarControl extends PamControlledUnit implements PamSettings {
// offlineTaskGroup.addTask(task); // offlineTaskGroup.addTask(task);
} }
OLProcessDialog olProcessDialog; OLProcessDialog olProcessDialog;
olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup, "DIFAR Data Export"); olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup, "DIFAR Data Export");
olProcessDialog.setVisible(true); olProcessDialog.setVisible(true);
} }

View File

@ -37,7 +37,6 @@ import fftManager.layoutFX.FFTGuiFX;
//import fftManager.layoutFX.FFTGuiFX; //import fftManager.layoutFX.FFTGuiFX;
import fftManager.newSpectrogram.SpectrogramPlotProvider; import fftManager.newSpectrogram.SpectrogramPlotProvider;
import spectrogramNoiseReduction.SpectrogramNoiseProcess; import spectrogramNoiseReduction.SpectrogramNoiseProcess;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI; import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
@ -71,11 +70,7 @@ public class PamFFTControl extends PamControlledUnit implements PamSettings {
private PamControlledGUISwing fftGUISwing; private PamControlledGUISwing fftGUISwing;
public PamFFTControl(String unitName) { public PamFFTControl(String unitName) {
this(null, unitName); super("FFT Engine", unitName);
}
public PamFFTControl(PamConfiguration pamConfiguration, String unitName) {
super(pamConfiguration, "FFT Engine", unitName);
PamRawDataBlock rawDataBlock = PamController.getInstance(). PamRawDataBlock rawDataBlock = PamController.getInstance().
getRawDataBlock(fftParameters.dataSource); getRawDataBlock(fftParameters.dataSource);

View File

@ -144,10 +144,10 @@ public class PamFFTProcess extends PamProcess {
* name has not been set, so if there isn't a name, use the number ! * name has not been set, so if there isn't a name, use the number !
*/ */
if (fftParameters.dataSourceName != null) { if (fftParameters.dataSourceName != null) {
rawDataBlock = (PamRawDataBlock) fftControl.getPamConfiguration().getDataBlock(RawDataUnit.class, fftParameters.dataSourceName); rawDataBlock = (PamRawDataBlock) PamController.getInstance().getDataBlock(RawDataUnit.class, fftParameters.dataSourceName);
} }
else { else {
rawDataBlock = fftControl.getPamConfiguration().getRawDataBlock(fftParameters.dataSource); rawDataBlock = PamController.getInstance().getRawDataBlock(fftParameters.dataSource);
if (rawDataBlock != null) { if (rawDataBlock != null) {
fftParameters.dataSourceName = rawDataBlock.getDataName(); fftParameters.dataSourceName = rawDataBlock.getDataName();
} }

View File

@ -32,7 +32,6 @@ import offlineProcessing.OLProcessDialog;
import offlineProcessing.OfflineTaskGroup; import offlineProcessing.OfflineTaskGroup;
import warnings.PamWarning; import warnings.PamWarning;
import warnings.WarningSystem; import warnings.WarningSystem;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI; import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
@ -110,8 +109,8 @@ PamSettingsSource {
private int lastErrorCount; private int lastErrorCount;
public DBControl(PamConfiguration pamconfiguration, String unitName, int settingsStore, boolean openImmediately) { public DBControl(String unitName, int settingsStore, boolean openImmediately) {
super(pamconfiguration, dbUnitType, unitName); super(dbUnitType, unitName);
THIS = this; THIS = this;
databaseWarning = new PamWarning(getUnitName(), "Database error", 2); databaseWarning = new PamWarning(getUnitName(), "Database error", 2);
@ -158,9 +157,6 @@ PamSettingsSource {
// selectDatabase(null); // selectDatabase(null);
if (isInMainConfiguration() == false) {
openImmediately = false;
}
if (databaseSystem == null){ if (databaseSystem == null){
selectSystem(dbParameters.getDatabaseSystem(), openImmediately); selectSystem(dbParameters.getDatabaseSystem(), openImmediately);
} }
@ -533,7 +529,7 @@ PamSettingsSource {
// offlineTaskGroup.addTask(task); // offlineTaskGroup.addTask(task);
} }
if (olProcessDialog == null) { if (olProcessDialog == null) {
olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup, olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup,
dataBlock.getDataName() + " Export"); dataBlock.getDataName() + " Export");
} }
olProcessDialog.setVisible(true); olProcessDialog.setVisible(true);

View File

@ -18,7 +18,7 @@ public class DBControlSettings extends DBControl {
public DBControlSettings(String unitName) { public DBControlSettings(String unitName) {
super(null, unitName, PamSettingManager.LIST_DATABASESTUFF, false); super(unitName, PamSettingManager.LIST_DATABASESTUFF, false);
// logSettings = new LogSettings(this); // logSettings = new LogSettings(this);

View File

@ -20,7 +20,6 @@ import pamViewFX.pamTask.PamTaskUpdate;
import PamController.AWTScheduler; import PamController.AWTScheduler;
import PamController.DataOutputStore; import PamController.DataOutputStore;
import PamController.OfflineDataStore; import PamController.OfflineDataStore;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamController; import PamController.PamController;
import PamController.PamControllerInterface; import PamController.PamControllerInterface;
@ -52,10 +51,7 @@ public class DBControlUnit extends DBControl implements DataOutputStore {
private BackupInformation backupInformation; private BackupInformation backupInformation;
public DBControlUnit(String unitName) { public DBControlUnit(String unitName) {
this(null, unitName); super(unitName, whichStore(), true);
}
public DBControlUnit(PamConfiguration pamConfiguration, String unitName) {
super(pamConfiguration, unitName, whichStore(), true);
THIS = this; THIS = this;
setFullTablesCheck(true); setFullTablesCheck(true);
// int runMode = PamController.getInstance().getRunMode(); // int runMode = PamController.getInstance().getRunMode();

View File

@ -70,7 +70,7 @@ public class MTOfflineProcess {
//if null open the dialog- also create a new offlineTask group if the datablock has changed. //if null open the dialog- also create a new offlineTask group if the datablock has changed.
if (mtOfflineDialog == null) { if (mtOfflineDialog == null) {
mtOfflineDialog = new OLProcessDialog(this.mtContorl.getGuiFrame(), mtOfflineDialog = new OLProcessDialog(this.mtContorl.getPamView().getGuiFrame(),
mtOfflineGroup, "Match Template Classifier"); mtOfflineGroup, "Match Template Classifier");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS); //batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
} }

View File

@ -62,7 +62,7 @@ public class NoiseBandProcess extends PamProcess {
public void setupProcess() { public void setupProcess() {
super.setupProcess(); super.setupProcess();
PamDataBlock sourceData = noiseBandControl.getPamConfiguration().getDataBlock(RawDataUnit.class, noiseBandControl.noiseBandSettings.rawDataSource); PamDataBlock sourceData = PamController.getInstance().getDataBlock(RawDataUnit.class, noiseBandControl.noiseBandSettings.rawDataSource);
if (sourceData == null) { if (sourceData == null) {
return; return;
} }

View File

@ -129,7 +129,7 @@ public class NoiseProcess extends PamProcess {
} }
private void findDataSource() { private void findDataSource() {
PamDataBlock source = noiseControl.getPamConfiguration().getDataBlock(FFTDataUnit.class, PamDataBlock source = PamController.getInstance().getDataBlock(FFTDataUnit.class,
noiseControl.noiseSettings.dataSource); noiseControl.noiseSettings.dataSource);
daqProcess = null; daqProcess = null;

View File

@ -1189,7 +1189,7 @@ private void setAxisLabels() {
if (mouseMenu == null) { if (mouseMenu == null) {
mouseMenu = new JPopupMenu(); mouseMenu = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Display Options ..."); JMenuItem menuItem = new JMenuItem("Display Options ...");
menuItem.addActionListener(new DisplayOptions(pamControlledUnit.getGuiFrame())); menuItem.addActionListener(new DisplayOptions(pamControlledUnit.getPamView().getGuiFrame()));
mouseMenu.add(menuItem); mouseMenu.add(menuItem);
} }

View File

@ -126,7 +126,7 @@ public class OneBandControl extends PamControlledUnit implements PamSettings {
offlineTaskGroup.addTask(task); offlineTaskGroup.addTask(task);
} }
if (olProcessDialog == null) { if (olProcessDialog == null) {
olProcessDialog = new OLProcessDialog(getGuiFrame(), offlineTaskGroup, "Noise Data Export"); olProcessDialog = new OLProcessDialog(getPamView().getGuiFrame(), offlineTaskGroup, "Noise Data Export");
} }
olProcessDialog.setVisible(true); olProcessDialog.setVisible(true);
} }

View File

@ -301,21 +301,6 @@ public abstract class OfflineTask<T extends PamDataUnit> {
public PamDataBlock getAffectedDataBlock(int iBlock) { public PamDataBlock getAffectedDataBlock(int iBlock) {
return affectedDataBlocks.get(iBlock); return affectedDataBlocks.get(iBlock);
} }
/**
* Get a formatted string list of affected data blocks
* @return
*/
public String getAffectedBlocksList() {
if (affectedDataBlocks == null || affectedDataBlocks.size() == 0) {
return null;
}
String blocks = affectedDataBlocks.get(0).getDataName();
for (int i = 1; i < affectedDataBlocks.size(); i++) {
blocks += "; " + affectedDataBlocks.get(i).getDataName();
}
return blocks;
}
/** /**
* Return whether or not the task SHOULD be run - i.e. if it is selected in * Return whether or not the task SHOULD be run - i.e. if it is selected in

View File

@ -123,7 +123,7 @@ public class RadarDisplay extends UserFramePlots implements PamObserver, PamSett
if (this.radarParameters == null) { if (this.radarParameters == null) {
this.radarParameters = new RadarParameters(); this.radarParameters = new RadarParameters();
RadarParameters newParams = RadarParametersDialog.showDialog(RadarDisplay.this, RadarParameters newParams = RadarParametersDialog.showDialog(RadarDisplay.this,
userDisplayControl.getGuiFrame(), this.radarParameters, radarProjector); userDisplayControl.getPamView().getGuiFrame(), this.radarParameters, radarProjector);
if (newParams != null) { if (newParams != null) {
this.radarParameters = newParams.clone(); this.radarParameters = newParams.clone();
} }
@ -697,7 +697,7 @@ public class RadarDisplay extends UserFramePlots implements PamObserver, PamSett
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
RadarParameters newParams = RadarParametersDialog.showDialog(RadarDisplay.this, RadarParameters newParams = RadarParametersDialog.showDialog(RadarDisplay.this,
userDisplayControl.getGuiFrame(), radarParameters, radarProjector); userDisplayControl.getPamView().getGuiFrame(), radarParameters, radarProjector);
if (newParams != null) { if (newParams != null) {
radarParameters = newParams.clone(); radarParameters = newParams.clone();
newSettings(); newSettings();

View File

@ -56,7 +56,7 @@ public class DLOfflineProcess {
//if null open the dialog- also create a new offlineTask group if the datablock has changed. //if null open the dialog- also create a new offlineTask group if the datablock has changed.
if (mtOfflineDialog == null) { if (mtOfflineDialog == null) {
mtOfflineDialog = new OLProcessDialog(this.dlControl.getGuiFrame(), mtOfflineDialog = new OLProcessDialog(this.dlControl.getPamView().getGuiFrame(),
dlOfflineGroup, "Deep Learning Classifier"); dlOfflineGroup, "Deep Learning Classifier");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS); //batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
} }

View File

@ -6,7 +6,6 @@ import java.awt.event.ActionListener;
import java.io.Serializable; import java.io.Serializable;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamControllerInterface; import PamController.PamControllerInterface;
@ -23,10 +22,7 @@ public class SpectrogramNoiseControl extends PamControlledUnit implements PamSet
protected SpectrogramNoiseProcess spectrogramNoiseProcess; protected SpectrogramNoiseProcess spectrogramNoiseProcess;
public SpectrogramNoiseControl(String unitName) { public SpectrogramNoiseControl(String unitName) {
this(null, unitName); super("Spectrogram Noise Reduction", unitName);
}
public SpectrogramNoiseControl(PamConfiguration pamConfiguration, String unitName) {
super(pamConfiguration, "Spectrogram Noise Reduction", unitName);
spectrogramNoiseProcess = new SpectrogramNoiseProcess(this); spectrogramNoiseProcess = new SpectrogramNoiseProcess(this);
addPamProcess(spectrogramNoiseProcess); addPamProcess(spectrogramNoiseProcess);

View File

@ -15,7 +15,6 @@ import spectrogramNoiseReduction.threshold.ThresholdParams;
import fftManager.FFTDataBlock; import fftManager.FFTDataBlock;
import fftManager.FFTDataUnit; import fftManager.FFTDataUnit;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamController; import PamController.PamController;
import PamUtils.complex.ComplexArray; import PamUtils.complex.ComplexArray;
@ -65,11 +64,7 @@ public class SpectrogramNoiseProcess extends PamProcess {
@Override @Override
public void setupProcess() { public void setupProcess() {
super.setupProcess(); super.setupProcess();
sourceData = (FFTDataBlock) PamController.getInstance().getDataBlock(FFTDataUnit.class,
PamConfiguration mainConfig = PamController.getInstance().getPamConfiguration();
PamConfiguration localConfig = getPamControlledUnit().getPamConfiguration();
sourceData = (FFTDataBlock) getPamControlledUnit().getPamConfiguration().getDataBlock(FFTDataUnit.class,
getNoiseSettings().dataSource); getNoiseSettings().dataSource);
setParentDataBlock(sourceData); setParentDataBlock(sourceData);

View File

@ -64,7 +64,7 @@ public class TargetMotionLocaliser<T extends PamDataUnit> extends AbstractLocali
// public boolean showTMDialog(T dataUnit) { // public boolean showTMDialog(T dataUnit) {
// if (targetMotionMainPanel == null) { // if (targetMotionMainPanel == null) {
////targetMotionDialog = new TargetMotionMainPanel<T>(pamControlledUnit.getGuiFrame(), this); ////targetMotionDialog = new TargetMotionMainPanel<T>(pamControlledUnit.getPamView().getGuiFrame(), this);
// } // }
// targetMotionMainPanel.updateCurrentControlPanel(); // targetMotionMainPanel.updateCurrentControlPanel();
// return true; // return true;

View File

@ -54,7 +54,7 @@ public class TMOfflineFunctions {
//when we change datablock the taks group is going to stay the same- need to make sure it changes //when we change datablock the taks group is going to stay the same- need to make sure it changes
if (batchLocaliseDialog == null || currentDataBlock!=targetMotionControl.getCurrentDataBlock()) { if (batchLocaliseDialog == null || currentDataBlock!=targetMotionControl.getCurrentDataBlock()) {
batchLocaliseDialog = new TMOLProcessDialog(targetMotionControl.getGuiFrame(), batchLocaliseDialog = new TMOLProcessDialog(targetMotionControl.getPamView().getGuiFrame(),
getOfflineTaskGroup(), "Batch Localise"); getOfflineTaskGroup(), "Batch Localise");
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS); //batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
} }

View File

@ -153,7 +153,7 @@ public class TargetMotionLocaliser<T extends GroupDetection> extends AbstractLoc
public boolean showTMDialog(T dataUnit) { public boolean showTMDialog(T dataUnit) {
if (targetMotionDialog == null) { if (targetMotionDialog == null) {
targetMotionDialog = new TargetMotionDialog<T>(pamControlledUnit.getGuiFrame(), this); targetMotionDialog = new TargetMotionDialog<T>(pamControlledUnit.getPamView().getGuiFrame(), this);
} }
targetMotionDialog.updateEventList(); targetMotionDialog.updateEventList();
targetMotionDialog.setDataUnit(dataUnit); targetMotionDialog.setDataUnit(dataUnit);

View File

@ -1,7 +1,6 @@
package videoRangePanel; package videoRangePanel;
import java.util.List; import java.util.List;
import java.awt.Frame;
import java.awt.Point; import java.awt.Point;
import java.io.File; import java.io.File;
import java.io.Serializable; import java.io.Serializable;
@ -362,9 +361,9 @@ public class VRControl extends PamControlledUnit implements PamSettings {
* @param frame * @param frame
* @param tab- the tab to open the settings dialog on. * @param tab- the tab to open the settings dialog on.
*/ */
public void settingsButtonAWT(Frame frame, int tab) { public void settingsButtonAWT(JFrame frame, int tab) {
if (frame == null) { if (frame == null) {
frame = getGuiFrame(); frame = getPamView().getGuiFrame();
} }
VRParameters newParams = VRParametersDialog.showDialog(frame, this, tab); VRParameters newParams = VRParametersDialog.showDialog(frame, this, tab);
if (newParams != null) { if (newParams != null) {

View File

@ -105,7 +105,7 @@ public class TideManager extends DataImport<String> {
// } // }
// else dir=null; // else dir=null;
// //
// String newFile=PamFileBrowser.fileBrowser(vrControl.getGuiFrame(),dir,PamFileBrowser.OPEN_FILE,"txt"); // String newFile=PamFileBrowser.fileBrowser(vrControl.getPamView().getGuiFrame(),dir,PamFileBrowser.OPEN_FILE,"txt");
// //
// return newFile; // return newFile;
// } // }

View File

@ -179,7 +179,7 @@ public class VRSidePanel implements PamSidePanel {
} }
if (vrControl.getVRParams().currentImageFile==null) { if (vrControl.getVRParams().currentImageFile==null) {
PamDialog.showWarning(vrControl.getGuiFrame(), "No image found", "The folder selected did not contain any compatible images"); PamDialog.showWarning(vrControl.getPamView().getGuiFrame(), "No image found", "The folder selected did not contain any compatible images");
return; return;
} }
vrControl.loadFile(vrControl.getVRParams().currentImageFile); vrControl.loadFile(vrControl.getVRParams().currentImageFile);

View File

@ -221,7 +221,7 @@ public class VRDisplayFX extends PamBorderPane implements VRPane {
} }
if (vrControl.getVRParams().currentImageFile==null) { if (vrControl.getVRParams().currentImageFile==null) {
PamDialog.showWarning(vrControl.getGuiFrame(), "No image found", "The folder selected did not contain any compatible images"); PamDialog.showWarning(vrControl.getPamView().getGuiFrame(), "No image found", "The folder selected did not contain any compatible images");
return; return;
} }
//go back up a few levels to load file as update flags etc need to be triggerred. //go back up a few levels to load file as update flags etc need to be triggerred.

View File

@ -19,7 +19,6 @@ import detectionPlotFX.whistleDDPlot.WhistleDDPlotProvider;
import spectrogramNoiseReduction.SpectrogramNoiseProcess; import spectrogramNoiseReduction.SpectrogramNoiseProcess;
import whistlesAndMoans.layoutFX.WhistleMoanGUIFX; import whistlesAndMoans.layoutFX.WhistleMoanGUIFX;
import whistlesAndMoans.plots.WhistlePlotProvider; import whistlesAndMoans.plots.WhistlePlotProvider;
import PamController.PamConfiguration;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI; import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
@ -56,10 +55,7 @@ public class WhistleMoanControl extends PamControlledUnit implements PamSettings
public static final String UNITTYPE = "WhistlesMoans"; public static final String UNITTYPE = "WhistlesMoans";
public WhistleMoanControl(String unitName) { public WhistleMoanControl(String unitName) {
this(null, unitName); super(UNITTYPE, unitName);
}
public WhistleMoanControl(PamConfiguration pamConfiguration, String unitName) {
super(pamConfiguration, UNITTYPE, unitName);
spectrogramNoiseProcess = new SpectrogramNoiseProcess(this); spectrogramNoiseProcess = new SpectrogramNoiseProcess(this);
addPamProcess(spectrogramNoiseProcess); addPamProcess(spectrogramNoiseProcess);

View File

@ -201,20 +201,36 @@ public class WhistleToneConnectProcess extends PamProcess {
@Override @Override
public void setupProcess() { public void setupProcess() {
super.setupProcess(); super.setupProcess();
SpectrogramNoiseProcess snp = whistleMoanControl.getSpectrogramNoiseProcess(); SpectrogramNoiseProcess snp = whistleMoanControl.getSpectrogramNoiseProcess();
setParentDataBlock(snp.getOutputDataBlock()); setParentDataBlock(snp.getOutputDataBlock());
if (whistleMoanControl.whistleToneParameters.getDataSource() == null) { if (whistleMoanControl.whistleToneParameters.getDataSource() == null) {
return; return;
} }
// sourceData = (FFTDataBlock) PamController.getInstance().getDataBlock(FFTDataUnit.class,
// whistleMoanControl.whistleToneParameters.getDataSource());
// snp.setParentDataBlock(sourceData);
sourceData = (FFTDataBlock) getParentDataBlock(); // our source should always be the output of the SpectrogramNoiseProcess sourceData = (FFTDataBlock) getParentDataBlock(); // our source should always be the output of the SpectrogramNoiseProcess
SpectrogramNoiseSettings specnoiseSettings = whistleMoanControl.whistleToneParameters.getSpecNoiseSettings(); SpectrogramNoiseSettings specnoiseSettings = whistleMoanControl.whistleToneParameters.getSpecNoiseSettings();
specnoiseSettings.dataSource = whistleMoanControl.whistleToneParameters.getDataSource(); specnoiseSettings.dataSource = whistleMoanControl.whistleToneParameters.getDataSource();
snp.setNoiseSettings(specnoiseSettings); snp.setNoiseSettings(specnoiseSettings);
chanOrSeqMap = whistleMoanControl.whistleToneParameters.getChanOrSeqBitmap(); // the channelMap in WhistleToneParameters object may be a sequence map or a channel map, depending on source chanOrSeqMap = whistleMoanControl.whistleToneParameters.getChanOrSeqBitmap(); // the channelMap in WhistleToneParameters object may be a sequence map or a channel map, depending on source
// if (sourceData != null) {
//// chanOrSeqMap = getParentDataBlock().getChannelMap() &
// chanOrSeqMap = getParentDataBlock().getSequenceMap() & // use the sequence bitmap instead of the channel bitmap, in case this is beamformer output
// whistleMoanControl.whistleToneParameters.getChanOrSeqBitmap();
// outputData.sortOutputMaps(getParentDataBlock().getChannelMap(), getParentDataBlock().getSequenceMapObject(), chanOrSeqMap);
// outputData.setFftHop(sourceData.getFftHop());
// outputData.setFftLength(sourceData.getFftLength());
//
// // 2017/11/30 set the whistleLocations channelMap properly
// whistleLocations.sortOutputMaps(getParentDataBlock().getChannelMap(), getParentDataBlock().getSequenceMapObject(), chanOrSeqMap);
//
// // smoothingChannelProcessList = new SmoothingChannelProcess[PamUtils.getHighestChannel(chanOrSeqMap)+1];
// // for (int i = 0; i < PamUtils.getHighestChannel(chanOrSeqMap)+1; i++) {
// // smoothingChannelProcessList[i] = new SmoothingChannelProcess();
// // }
// }
// set the localisation information in the two output datablocks. If the source is using sequence numbers, then we cannot localise // set the localisation information in the two output datablocks. If the source is using sequence numbers, then we cannot localise
boolean mayBearings = whistleMoanControl.whistleToneParameters.mayHaveBearings(); boolean mayBearings = whistleMoanControl.whistleToneParameters.mayHaveBearings();
boolean mayRange = whistleMoanControl.whistleToneParameters.mayHaveRange(); boolean mayRange = whistleMoanControl.whistleToneParameters.mayHaveRange();