PamController
Class PamControlledUnit

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

public abstract class PamControlledUnit
extends 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.


Constructor Summary
PamControlledUnit(String unitType, String unitName)
          Constructor for a new PamControlledUnit
 
Method Summary
 void addOtherRelatedMenuItems(Frame parentFrame, JMenu menu, String name)
           
 void addPamProcess(PamProcess pamProcess)
          Adds a PamProcess to the ControlledUnit
 int addRelatedMenuItems(Frame parentFrame, JMenu menu, String name)
           
 boolean canClose()
          Called before Pamguard shuts down.
 JMenuItem createDetectionMenu(Frame parentFrame)
          Create a JMenu object containing MenuItems associated with PamProcesses
 JMenuItem createDisplayMenu(Frame parentFrame)
          Create a JMenu object containing MenuItems associated with the view
 JMenuItem createFileMenu(JFrame parentFrame)
           
 JMenuItem createHelpMenu(Frame parentFrame)
           
 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
 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.
 PamTabPanel getTabPanel()
          Gets a reference to a panel to be added to a view
 JMenuBar getTabSpecificMenuBar(Frame parentFrame, JMenuBar standardMenu, PamGui pamGui)
          Create a tab specific menu to go with this PamControlledUnit.
 String getUnitName()
          Returns the name of the unit
 String getUnitType()
           
 boolean gotoTab()
           
 void notifyModelChanged(int changeType)
           
 void pamHasStopped()
          Called for all contorlled 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(String newName)
           
 void setFrameNumber(int frameNumber)
           
 void setPamModuleInfo(PamModuleInfo pamModuleInfo)
           
 void setPamView(PamView pamView)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PamControlledUnit

public PamControlledUnit(String unitType,
                         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(String newName)

removePamProcess

public void removePamProcess(PamProcess pamProcess)
Removes a process.

Parameters:
pamProcess - process to remove

notifyModelChanged

public void notifyModelChanged(int changeType)

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 JMenuBar getTabSpecificMenuBar(Frame parentFrame,
                                      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 JMenuItem createDetectionMenu(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 JMenuItem createDisplayMenu(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 contorlled 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 String getUnitName()
Returns the name of the unit

Returns:
the name of the unit

getUnitType

public String getUnitType()

addOtherRelatedMenuItems

public void addOtherRelatedMenuItems(Frame parentFrame,
                                     JMenu menu,
                                     String name)

addRelatedMenuItems

public int addRelatedMenuItems(Frame parentFrame,
                               JMenu menu,
                               String name)

gotoTab

public boolean gotoTab()

getPamView

public PamView getPamView()

setPamView

public void setPamView(PamView pamView)

createHelpMenu

public JMenuItem createHelpMenu(Frame parentFrame)

createFileMenu

public JMenuItem createFileMenu(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.