public abstract class PamControlledUnit
extends java.lang.Object
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 calculate 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 and Description |
---|
PamControlledUnit(java.lang.String unitType,
java.lang.String unitName)
Constructor for a new PamControlledUnit
|
Modifier and Type | Method and Description |
---|---|
void |
addOfflineTaskGroup(OfflineTaskGroup offlineTaskGroup)
Registers the offlineTaskGroup with the PamControlledUnit on instantiation.
|
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) |
static org.w3c.dom.Element |
addXMLParameter(org.w3c.dom.Document doc,
org.w3c.dom.Element paramsEl,
boolean value,
java.lang.String name,
java.lang.String description,
int accessLevel,
int propagate)
Add a new boolean point XML element.
|
static org.w3c.dom.Element |
addXMLParameter(org.w3c.dom.Document doc,
org.w3c.dom.Element paramsEl,
double value,
java.lang.String name,
java.lang.String description,
int accessLevel,
int propagate)
Add a new floating point XML element.
|
static org.w3c.dom.Element |
addXMLParameter(org.w3c.dom.Document doc,
org.w3c.dom.Element paramsEl,
int value,
java.lang.String name,
java.lang.String description,
int accessLevel,
int propagate)
Add a new integer point XML element.
|
static org.w3c.dom.Element |
addXMLParameter(org.w3c.dom.Document doc,
org.w3c.dom.Element paramsEl,
java.lang.String value,
java.lang.String name,
java.lang.String description,
int accessLevel,
int propagate)
Add a new floating point XML element.
|
boolean |
canClose()
Called before Pamguard shuts down.
|
boolean |
canPlayViewerSound() |
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.
|
boolean |
flushDataBlockBuffers(long maxWait)
Go into a wait state while any buffers in output data blocks flush through
in multithread mode.
|
int |
getFrameNumber()
Get the number of the frame that side and tab panels
for this module should sit on.
|
java.awt.Frame |
getGuiFrame()
Get the main frame for the GUI.
|
java.lang.String |
getModuleSummary()
Get a module summary text string for shorthand output to
summary QC systems.
|
int |
getNumOfflineTaskGroups() |
int |
getNumPamProcesses()
Gets the total number of PamProcesses controlled by this Controller
|
OfflineTaskGroup |
getOfflineTaskGroup(int i) |
PamController |
getPamController() |
PamModuleInfo |
getPamModuleInfo() |
PamProcess |
getPamProcess(int iP) |
PamView |
getPamView() |
java.lang.Object |
getShortUnitType() |
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.awt.Component |
getToolbarComponent()
Sets the toolbar component which will be incorporated into the top toolbar whenever
this controlled unit's display is selected in the main tab panel
|
java.lang.String |
getUnitName()
Returns the name of the unit
|
java.lang.String |
getUnitType() |
int |
getVerboseLevel() |
boolean |
gotoTab() |
boolean |
isViewer() |
void |
notifyModelChanged(int changeType)
General notification when the PAMGAURD model changes.
|
void |
pamClose()
Called when PAMGUARD is finally closing down so that a module
may free any remaining resources (e.g.
|
void |
pamHasStopped()
Called for all controlled units after Pam acquisition has stopped
|
void |
pamToStart()
called just before data acquisition starts.
|
void |
playViewerSound()
Start playing sound in reponse to a call from the viewer top toolbar.
|
void |
removePamProcess(PamProcess pamProcess)
Removes a process.
|
boolean |
removeUnit()
Called to remove a unit.
|
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.
|
void |
stopViewerSound()
Stop playing sound in response to a call from the viewer top toolbar.
|
void |
terminalPrint(java.lang.String string,
int verboseLevel)
Print a line, with line feed, on the terminal if the verbose
level is >= the set level for this module
|
void |
terminalPrintln(java.lang.String string,
int verboseLevel)
Print a line, with linefeed, on the terminal if the verbose
level is >= the set level for this module
|
java.lang.String |
toString() |
public PamControlledUnit(java.lang.String unitType, java.lang.String unitName)
unitName
- name of unitpublic PamProcess getPamProcess(int iP)
iP
- -
The index of the processpublic int getNumPamProcesses()
public void addPamProcess(PamProcess pamProcess)
pamProcess
- Reference to a PamProcesspublic boolean removeUnit()
public void rename(java.lang.String newName)
public void removePamProcess(PamProcess pamProcess)
pamProcess
- process to removepublic void notifyModelChanged(int changeType)
changeType
- type of changepublic PamTabPanel getTabPanel()
PamTabPanel
,
PamSidePanel
public int getFrameNumber()
public void setFrameNumber(int frameNumber)
public PamSidePanel getSidePanel()
It is possible for a PamControlled unit to have a side panel without having a pamTabPanel.
PamSidePanel
,
PamTabPanel
public final java.awt.Component getToolbarComponent()
public javax.swing.JMenuBar getTabSpecificMenuBar(java.awt.Frame parentFrame, javax.swing.JMenuBar standardMenu, PamGui pamGui)
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)
standardMenu
- the standard menu for the Pam GUI.public javax.swing.JMenuItem createDetectionMenu(java.awt.Frame parentFrame)
parentFrame
- The owner frame of the menuNote 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.
public javax.swing.JMenuItem createDisplayMenu(java.awt.Frame parentFrame)
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.
public void setupControlledUnit()
public void pamToStart()
public void pamHasStopped()
public boolean canClose()
public java.lang.String getUnitName()
public java.lang.String getUnitType()
public void addOtherRelatedMenuItems(java.awt.Frame parentFrame, javax.swing.JMenu menu, java.lang.String name)
public int addRelatedMenuItems(java.awt.Frame parentFrame, javax.swing.JMenu menu, java.lang.String name)
public boolean gotoTab()
public PamView getPamView()
public java.awt.Frame getGuiFrame()
public void setPamView(PamView pamView)
pamView
- public javax.swing.JMenuItem createHelpMenu(java.awt.Frame parentFrame)
public javax.swing.JMenuItem createFileMenu(javax.swing.JFrame parentFrame)
parentFrame
- parent frame for the menupublic void setSidePanel(PamSidePanel sidePanel)
Side panels are generally used to display summary information for the PamControlledUnit or to provide quick access controls.
sidePanel
- Reference to a PamSidePanel objectPamSidePanel
public void setTabPanel(PamTabPanel tabPanel)
tabPanel
- public PamModuleInfo getPamModuleInfo()
public void setPamModuleInfo(PamModuleInfo pamModuleInfo)
pamModuleInfo
- The pamModuleInfo to set.public ClipboardCopier getTabClipCopier()
public PamController getPamController()
public void setPamController(PamController pamController)
pamController
- the pamController to setpublic java.lang.String toString()
toString
in class java.lang.Object
public void saveViewerData()
This gets called automatically on system exit and can also be called from the file menu.
public final boolean fillXMLElement(org.w3c.dom.Document doc, org.w3c.dom.Element moduleData)
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.
doc
- moduleData
- XML element to fill.public static org.w3c.dom.Element addXMLParameter(org.w3c.dom.Document doc, org.w3c.dom.Element paramsEl, double value, java.lang.String name, java.lang.String description, int accessLevel, int propagate)
doc
- XML document rootparamsEl
- parent elementvalue
- value for new elementname
- name for new elementdescription
- description for new elementeditable
- will be visible in web interfacepropagate
- determines how setting may propagate to other configuration files.public static org.w3c.dom.Element addXMLParameter(org.w3c.dom.Document doc, org.w3c.dom.Element paramsEl, int value, java.lang.String name, java.lang.String description, int accessLevel, int propagate)
doc
- XML document rootparamsEl
- parent elementvalue
- value for new elementname
- name for new elementdescription
- description for new elementeditable
- will be visible in web interfacepropagate
- determines how setting may propagate to other configuration files.public static org.w3c.dom.Element addXMLParameter(org.w3c.dom.Document doc, org.w3c.dom.Element paramsEl, java.lang.String value, java.lang.String name, java.lang.String description, int accessLevel, int propagate)
doc
- XML document rootparamsEl
- parent elementvalue
- value for new elementname
- name for new elementdescription
- description for new elementeditable
- will be visible in web interfacepropagate
- determines how setting may propagate to other configuration files.public static org.w3c.dom.Element addXMLParameter(org.w3c.dom.Document doc, org.w3c.dom.Element paramsEl, boolean value, java.lang.String name, java.lang.String description, int accessLevel, int propagate)
doc
- XML document rootparamsEl
- parent elementvalue
- value for new elementname
- name for new elementdescription
- description for new elementeditable
- will be visible in web interfacepropagate
- determines how setting may propagate to other configuration files.public boolean flushDataBlockBuffers(long maxWait)
this has been placed in each controlled unit so that it can be overriedden if if necessary.
maxWait
- max wait time in secondspublic boolean canPlayViewerSound()
public void playViewerSound()
public void stopViewerSound()
public void pamClose()
public void addOfflineTaskGroup(OfflineTaskGroup offlineTaskGroup)
offlineTaskGroup
- public int getNumOfflineTaskGroups()
public OfflineTaskGroup getOfflineTaskGroup(int i)
public java.lang.String getModuleSummary()
public java.lang.Object getShortUnitType()
public boolean isViewer()
public void terminalPrintln(java.lang.String string, int verboseLevel)
string
- string t printverboseLevel
- verbose levelpublic void terminalPrint(java.lang.String string, int verboseLevel)
string
- string t printverboseLevel
- verbose levelpublic int getVerboseLevel()