PamController
Class PamControlledUnit

java.lang.Object
  extended by PamController.PamControlledUnit
Direct Known Subclasses:
AcquisitionControl, AirgunControl, AISControl, AmpControl, AngleControl, BeakedControl, BinaryStore, ClickControl, ClipControl, DataMapControl, DBControl, DecimatorControl, DepthControl, EdgeControl, FilterControl, GPSControl, IshDetControl, IshLocControl, IshmaelDataControl, KernelSmoothingControl, LandmarkControl, LikelihoodDetectionUnit, LikelihoodFFTController, ListeningControl, MapController, NMEAControl, NoiseControl, PamFFTControl, PatchPanelControl, PlaybackControl, RecorderControl, RoccaControl, SpectrogramNoiseControl, TerrellaControl, TowedArray3DController, UserDisplayControl, UserInputController, VetoController, VRControl, WhistleClassifierControl, WhistleControl, WhistleMoanControl, WhitesWhistleControl, WorkshopController

public abstract class PamControlledUnit
extends java.lang.Object

Author:
Doug Gillespie

PamControlledUnit is an abstract class that is used to contain all the information required for an actual detector, sub detection process or display within Pamguard.

See the how to make Pamguard plug-ins overview.

Each unit will probably have a PamProcess, which will do something like caclulate FFT's, look for whistles, read a sound card, etc. Associated with each process there may or may not be a display or a display component (e.g. a toolbar window for controlling file playback speed, a panel to be added to a GUI, menu's for controlling the algorithm and / or the various bits of the display).

Each PamControlledUnit along with one or more PamProcesses and display units comprises a kind of mini MVC, the PamControlledUnit being the Controller, the PamProcesses and their associated data blocks the model and the display comonents the view.

Each PamProcess requires a reference to a PamControllerUnit in it's constructor, so PamProcesses can only exist within this framework.

Subclasses of PamControlledUnit should handle menu commands associated with any menu's they are responsible for and send those commands on to their processes and other display comonents as necessary.

A View in the Pamguard MVC can query for a list of PamControlledUnits, the view can then see which have a display, etc and add them to the view.


Field Summary
private  int frameNumber
           
protected  boolean isViewer
           
private  PamController pamController
           
private  PamModuleInfo pamModuleInfo
           
private  java.util.ArrayList<PamProcess> pamProcesses
          List of PamProcesses in this unit
private  PamView pamView
           
private  PamSidePanel sidePanel
          Optional additional graphics component to be displayed to the left of the main tab panel control.
private  ClipboardCopier tabClipCopier
          clipboard copier to go with tabPanel;
private  PamTabPanel tabPanel
          Reference to a PamTabPanel containing informaton on how to set up a display relevant to the processes in this unit.
private  java.lang.String unitName
          unitName and unitType are used to identify each PamControlledUnit.
private  java.lang.String unitType
          unitName and unitType are used to identify each PamControlledUnit.
 
Constructor Summary
PamControlledUnit(java.lang.String unitType, java.lang.String unitName)
          Constructor for a new PamControlledUnit
 
Method Summary
 void addOtherRelatedMenuItems(java.awt.Frame parentFrame, javax.swing.JMenu menu, java.lang.String name)
           
 void addPamProcess(PamProcess pamProcess)
          Adds a PamProcess to the ControlledUnit
 int addRelatedMenuItems(java.awt.Frame parentFrame, javax.swing.JMenu menu, java.lang.String name)
           
 boolean canClose()
          Called before Pamguard shuts down.
 javax.swing.JMenuItem createDetectionMenu(java.awt.Frame parentFrame)
          Create a JMenu object containing MenuItems associated with PamProcesses
 javax.swing.JMenuItem createDisplayMenu(java.awt.Frame parentFrame)
          Create a JMenu object containing MenuItems associated with the view
 javax.swing.JMenuItem createFileMenu(javax.swing.JFrame parentFrame)
           
 javax.swing.JMenuItem createHelpMenu(java.awt.Frame parentFrame)
           
 boolean fillXMLElement(org.w3c.dom.Document doc, org.w3c.dom.Element moduleData)
          Fill an XML element with data about this module.
protected  boolean fillXMLParameters(org.w3c.dom.Document doc, org.w3c.dom.Element paramsEl)
          Add Module specific XML data.
 int getFrameNumber()
          Get the number of the frame that side and tab panels for this module should sit on.
 int getNumPamProcesses()
          Gets the total number of PamProcesses controlled by this Controller
 PamController getPamController()
           
 PamModuleInfo getPamModuleInfo()
           
 PamProcess getPamProcess(int iP)
           
 PamView getPamView()
           
 PamSidePanel getSidePanel()
          Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel.
 ClipboardCopier getTabClipCopier()
           
 PamTabPanel getTabPanel()
          Gets a reference to a panel to be added to a view
 javax.swing.JMenuBar getTabSpecificMenuBar(java.awt.Frame parentFrame, javax.swing.JMenuBar standardMenu, PamGui pamGui)
          Create a tab specific menu to go with this PamControlledUnit.
 java.lang.String getUnitName()
          Returns the name of the unit
 java.lang.String getUnitType()
           
 boolean gotoTab()
           
 void notifyArrayChanged()
          Called whenever the array configuration dialog has been called.
 void notifyModelChanged(int changeType)
          General notification when the PAMGAURD model changes.
 void pamHasStopped()
          Called for all controlled units after Pam acquisition has stopped
 void pamToStart()
          called just before data acquisition starts.
 void removePamProcess(PamProcess pamProcess)
          Removes a process.
 boolean removeUnit()
           
 void rename(java.lang.String newName)
           
 void saveViewerData()
          Save data (to binary files and to database) in viewer mode.
 void setFrameNumber(int frameNumber)
           
 void setPamController(PamController pamController)
           
 void setPamModuleInfo(PamModuleInfo pamModuleInfo)
           
 void setPamView(PamView pamView)
          Called whenever the frme of a PamControlledunit changes (including at program startup).
 void setSidePanel(PamSidePanel sidePanel)
          Sets the side panel for the PamControlledUnit Side panels are shown down the left hand side of the main Pamguard GUI and are always visible, irrespective of which tab is being viewed on the main tabbed display.
 void setTabPanel(PamTabPanel tabPanel)
          Sets the tab panel for the PamControlledUnit.
 void setupControlledUnit()
          called for all PamControlledUnits after all units have been created.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pamController

private PamController pamController

pamProcesses

private java.util.ArrayList<PamProcess> pamProcesses
List of PamProcesses in this unit


tabPanel

private PamTabPanel tabPanel
Reference to a PamTabPanel containing informaton on how to set up a display relevant to the processes in this unit.


tabClipCopier

private ClipboardCopier tabClipCopier
clipboard copier to go with tabPanel;


sidePanel

private PamSidePanel sidePanel
Optional additional graphics component to be displayed to the left of the main tab panel control.


unitType

private java.lang.String unitType
unitName and unitType are used to identify each PamControlledUnit. \n the unitType is general for a particular concrete class of PamControlledUnit such as a click or whistle detector or a fft machine. \n The unitName should be specific to each instance of the class, e.g. Sperm whale detector, Beaked Whale detector, etc.


unitName

private java.lang.String unitName
unitName and unitType are used to identify each PamControlledUnit. \n the unitType is general for a particular concrete class of PamControlledUnit such as a click or whistle detector or a fft machine. \n The unitName should be specific to each instance of the class, e.g. Sperm whale detector, Beaked Whale detector, etc.


pamView

private PamView pamView

pamModuleInfo

private PamModuleInfo pamModuleInfo

isViewer

protected boolean isViewer

frameNumber

private int frameNumber
Constructor Detail

PamControlledUnit

public PamControlledUnit(java.lang.String unitType,
                         java.lang.String unitName)
Constructor for a new PamControlledUnit

Parameters:
unitName - name of unit
Method Detail

getPamProcess

public PamProcess getPamProcess(int iP)
Parameters:
iP - - The index of the process
Returns:
Reference to a PamProcess or null if iP is invalid

getNumPamProcesses

public int getNumPamProcesses()
Gets the total number of PamProcesses controlled by this Controller

Returns:
The total number of PamProcesses

addPamProcess

public void addPamProcess(PamProcess pamProcess)
Adds a PamProcess to the ControlledUnit

Parameters:
pamProcess - Reference to a PamProcess

removeUnit

public boolean removeUnit()

rename

public void rename(java.lang.String newName)

removePamProcess

public void removePamProcess(PamProcess pamProcess)
Removes a process.

Parameters:
pamProcess - process to remove

notifyModelChanged

public void notifyModelChanged(int changeType)
General notification when the PAMGAURD model changes.

Parameters:
changeType - type of change

notifyArrayChanged

public void notifyArrayChanged()
Called whenever the array configuration dialog has been called.


getTabPanel

public PamTabPanel getTabPanel()
Gets a reference to a panel to be added to a view

Returns:
reference to a PamTabPanel object
See Also:
PamTabPanel, PamSidePanel

getFrameNumber

public int getFrameNumber()
Get the number of the frame that side and tab panels for this module should sit on.

Returns:
frame number.

setFrameNumber

public void setFrameNumber(int frameNumber)

getSidePanel

public PamSidePanel getSidePanel()
Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel. Side panels should be small since they are always visible and any space they take will be taken from the main tab panel.

It is possible for a PamControlled unit to have a side panel without having a pamTabPanel.

Returns:
a pamSidePanel object.
See Also:
PamSidePanel, PamTabPanel

getTabSpecificMenuBar

public javax.swing.JMenuBar getTabSpecificMenuBar(java.awt.Frame parentFrame,
                                                  javax.swing.JMenuBar standardMenu,
                                                  PamGui pamGui)
Create a tab specific menu to go with this PamControlledUnit.

Default is to throw back the standard menu to be used. This function should clone the standard menu and then modify the clone (usually by replacing the Display sub menu)

Parameters:
standardMenu - the standard menu for the Pam GUI.
Returns:
a complete menu bar to be shown while a particular tab is selected

createDetectionMenu

public javax.swing.JMenuItem createDetectionMenu(java.awt.Frame parentFrame)
Create a JMenu object containing MenuItems associated with PamProcesses

Parameters:
parentFrame - The owner frame of the menu
Returns:
reference to a JMenu which can be added to an existing menu or menu bar

Note that if multiple views are to use the same menu, then they should each create a new menu (by setting Create to true) the first time they call this method.


createDisplayMenu

public javax.swing.JMenuItem createDisplayMenu(java.awt.Frame parentFrame)
Create a JMenu object containing MenuItems associated with the view

Returns:
reference to a JMenu which can be added to an existing menu or menu bar

Note that if multiple views are to use the same menu, then they should each create a new menu (by setting Create to true) the first time they call this method.


setupControlledUnit

public void setupControlledUnit()
called for all PamControlledUnits after all units have been created. This is a good time for the controlled units and processes to find and check their source data and the configuration generally since most onjects (i.e. output data blocks) should be in place


pamToStart

public void pamToStart()
called just before data acquisition starts. Note that PamObservers get a call to setSampleRate anyway so this mainly needs to be used for display elements that may need their scales adjusted before startup.


pamHasStopped

public void pamHasStopped()
Called for all controlled units after Pam acquisition has stopped


canClose

public boolean canClose()
Called before Pamguard shuts down. Rather than returning false, this function can be used as a final oportunity to save settings, write to the database, etc.

Returns:
true if OK for Pamguard to shut down, false otherwise.

getUnitName

public java.lang.String getUnitName()
Returns the name of the unit

Returns:
the name of the unit

getUnitType

public java.lang.String getUnitType()

addOtherRelatedMenuItems

public void addOtherRelatedMenuItems(java.awt.Frame parentFrame,
                                     javax.swing.JMenu menu,
                                     java.lang.String name)

addRelatedMenuItems

public int addRelatedMenuItems(java.awt.Frame parentFrame,
                               javax.swing.JMenu menu,
                               java.lang.String name)

gotoTab

public boolean gotoTab()

getPamView

public PamView getPamView()

setPamView

public void setPamView(PamView pamView)
Called whenever the frme of a PamControlledunit changes (including at program startup).

Parameters:
pamView -

createHelpMenu

public javax.swing.JMenuItem createHelpMenu(java.awt.Frame parentFrame)

createFileMenu

public javax.swing.JMenuItem createFileMenu(javax.swing.JFrame parentFrame)
Parameters:
parentFrame - parent frame for the menu
Returns:
the file menu item

setSidePanel

public void setSidePanel(PamSidePanel sidePanel)
Sets the side panel for the PamControlledUnit Side panels are shown down the left hand side of the main Pamguard GUI and are always visible, irrespective of which tab is being viewed on the main tabbed display.

Side panels are generally used to display summary information for the PamControlledUnit or to provide quick access controls.

Parameters:
sidePanel - Reference to a PamSidePanel object
See Also:
PamSidePanel

setTabPanel

public void setTabPanel(PamTabPanel tabPanel)
Sets the tab panel for the PamControlledUnit. A tab panel may contain graphics or tables to display information of any type.

Parameters:
tabPanel -

getPamModuleInfo

public PamModuleInfo getPamModuleInfo()
Returns:
Returns the pamModuleInfo.

setPamModuleInfo

public void setPamModuleInfo(PamModuleInfo pamModuleInfo)
Parameters:
pamModuleInfo - The pamModuleInfo to set.

getTabClipCopier

public ClipboardCopier getTabClipCopier()

getPamController

public PamController getPamController()
Returns:
the pamController

setPamController

public void setPamController(PamController pamController)
Parameters:
pamController - the pamController to set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

saveViewerData

public void saveViewerData()
Save data (to binary files and to database) in viewer mode.

This gets called automatically on system exit and can also be called from the file menu.


fillXMLElement

public final boolean fillXMLElement(org.w3c.dom.Document doc,
                                    org.w3c.dom.Element moduleData)
Fill an XML element with data about this module.

this is expected to only include parameters which are required for real time data collection on remote platforms using a stand alone, no GUI pamguard version.

Parameters:
doc -
moduleData - XML element to fill.
Returns:
false if this module has no data of interest, otherwise just add data to the element.

fillXMLParameters

protected boolean fillXMLParameters(org.w3c.dom.Document doc,
                                    org.w3c.dom.Element paramsEl)
Add Module specific XML data.

this will generally be the place where most modules set their xml settings data.

Parameters:
doc -
paramsEl -
Returns: