Array
Class ArrayManager

java.lang.Object
  extended by Array.ArrayManager
All Implemented Interfaces:
PamSettings, PamObserver

public class ArrayManager
extends java.lang.Object
implements PamSettings, PamObserver

Manager for different array configurations. Each array configuration is stored in it's own serialised file, which is separate from other Pam Settings so that they can be stored, emailed around, etc. In it' main seriales file controlled by PamSettingsManager, Pamguard keeps a list of recently used arrays.

The dialog ArrayDialog alows the user to load arrays from file, create new arrays, edit arrays, etc.

Author:
Doug Gillespie
See Also:
PamArray

Field Summary
static int ARRAY_TYPE_LINE
          Line array of two or more elements
static int ARRAY_TYPE_NONE
          No array specified
static int ARRAY_TYPE_PLANE
          Three or more Hydrophones all in the same plane
static int ARRAY_TYPE_POINT
          Point array (single phone or multiple phones at same point)
static int ARRAY_TYPE_VOLUME
          Four or more hydrophones not in the same plane.
private static java.lang.String arrayFileType
           
private  DepthControl depthControl
           
(package private)  java.util.ArrayList<PamArray> recentArrays
           
private static ArrayManager singleInstance
           
 
Constructor Summary
private ArrayManager()
           
 
Method Summary
 void addArray(PamArray newArray)
           
private  boolean areInLine(PamVector[] pvs)
          Test to see if a load of inter-pair vectors are in line or not.
private  boolean areOnPlane(PamVector[] pvs)
          Check to see if inter pair vectors define a volume or just a plane.
private  void createDefaultArray()
           
 int getArrayCount()
           
 PamVector[] getArrayDirection(int phones)
          Get the principle direction vectors for a sub set of hydrophones within the current array
 PamVector[] getArrayDirections()
          Get the principle direction vectors for the current array
 PamVector[] getArrayDirections(PamArray array)
          Get a set of vectors which define the principle coordinates of an array
 PamVector[] getArrayDirections(PamArray array, int phones)
          Get a set of vectors which define the principle components of an array.
static java.lang.String getArrayFileType()
           
static ArrayManager getArrayManager()
           
 int getArrayType()
           
 int getArrayType(int phones)
           
 int getArrayType(PamArray array)
           
 int getArrayType(PamArray array, int phones)
           
static java.lang.String getArrayTypeString(int arrayType)
           
 PamVector[] getArrayVectors(PamArray array, int phones)
           
 PamArray getCurrentArray()
           
 DepthControl getDepthControl()
           
private  PamVector[] getLineArrayVector(PamVector[] arrayVectors)
           
private  double getMaxVolume(PamVector[] pvs)
           
 java.lang.String getObserverName()
           
 PamObserver getObserverObject()
           
private  PamVector[] getPlaneArrayVectors(PamVector[] arrayVectors)
           
 java.util.ArrayList<PamArray> getRecentArrays()
           
 long getRequiredDataHistory(PamObservable o, java.lang.Object arg)
           
 java.io.Serializable getSettingsReference()
           
 long getSettingsVersion()
           
 int getSpatiallyUniquePhones(PamArray array, int phones)
          Take a list of phones and return a list of ones which are at unique positions.
 java.lang.String getUnitName()
           
 java.lang.String getUnitType()
           
private  PamVector[] getVolumeArrayVectors(PamVector[] arrayVectors)
           
static PamArray loadArrayFromFile(java.lang.String fileName)
           
 void masterClockUpdate(long milliSeconds, long sampleNumber)
           
 void noteNewSettings()
           
 void notifyModelChanged(int changeType)
           
 boolean removeArray(PamArray newArray)
           
 void removeObservable(PamObservable o)
          called when an Observable (PamDataBlock) is removed from the system
 boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
           
static boolean saveArrayToFile(PamArray array)
           
 void setCurrentArray(PamArray array)
           
 void setDepthControl(DepthControl depthControl)
           
 void setSampleRate(float sampleRate, boolean notify)
          New sample rate
static void showArrayDialog(java.awt.Frame parentFrame)
           
 void update(PamObservable o, PamDataUnit arg)
          Informs the PamObserver that new data have been added to the Observable class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARRAY_TYPE_NONE

public static final int ARRAY_TYPE_NONE
No array specified

See Also:
Constant Field Values

ARRAY_TYPE_POINT

public static final int ARRAY_TYPE_POINT
Point array (single phone or multiple phones at same point)

See Also:
Constant Field Values

ARRAY_TYPE_LINE

public static final int ARRAY_TYPE_LINE
Line array of two or more elements

See Also:
Constant Field Values

ARRAY_TYPE_PLANE

public static final int ARRAY_TYPE_PLANE
Three or more Hydrophones all in the same plane

See Also:
Constant Field Values

ARRAY_TYPE_VOLUME

public static final int ARRAY_TYPE_VOLUME
Four or more hydrophones not in the same plane.

See Also:
Constant Field Values

singleInstance

private static ArrayManager singleInstance

arrayFileType

private static final java.lang.String arrayFileType
See Also:
Constant Field Values

recentArrays

java.util.ArrayList<PamArray> recentArrays

depthControl

private DepthControl depthControl
Constructor Detail

ArrayManager

private ArrayManager()
Method Detail

createDefaultArray

private void createDefaultArray()

getObserverObject

public PamObserver getObserverObject()
Specified by:
getObserverObject in interface PamObserver
Returns:
the actual observer. In most cases concrete classes will just return 'this' in response. The exception is the Threaded observer, which will return the single thread observer.

getArrayManager

public static ArrayManager getArrayManager()

notifyModelChanged

public void notifyModelChanged(int changeType)

getArrayFileType

public static java.lang.String getArrayFileType()
Returns:
Returns the arrayFileType.

getRecentArrays

public java.util.ArrayList<PamArray> getRecentArrays()
Returns:
Returns the recentArrays.

getArrayCount

public int getArrayCount()

showArrayDialog

public static void showArrayDialog(java.awt.Frame parentFrame)

addArray

public void addArray(PamArray newArray)

setCurrentArray

public void setCurrentArray(PamArray array)

removeArray

public boolean removeArray(PamArray newArray)

getSettingsReference

public java.io.Serializable getSettingsReference()
Specified by:
getSettingsReference in interface PamSettings
Returns:
The serialisable object that will be stored

getSettingsVersion

public long getSettingsVersion()
Specified by:
getSettingsVersion in interface PamSettings
Returns:
An integer version number for the settings

getUnitName

public java.lang.String getUnitName()
Specified by:
getUnitName in interface PamSettings
Returns:
A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.

getUnitType

public java.lang.String getUnitType()
Specified by:
getUnitType in interface PamSettings
Returns:
A Name specific to the type, e.g. Glick detector

restoreSettings

public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
Specified by:
restoreSettings in interface PamSettings
Returns:
true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required

getCurrentArray

public PamArray getCurrentArray()
Returns:
Returns the currentArray.

loadArrayFromFile

public static PamArray loadArrayFromFile(java.lang.String fileName)

saveArrayToFile

public static boolean saveArrayToFile(PamArray array)

getDepthControl

public DepthControl getDepthControl()
Returns:
the depthControl

setDepthControl

public void setDepthControl(DepthControl depthControl)
Parameters:
depthControl - the depthControl to set

getObserverName

public java.lang.String getObserverName()
Specified by:
getObserverName in interface PamObserver

getRequiredDataHistory

public long getRequiredDataHistory(PamObservable o,
                                   java.lang.Object arg)
Specified by:
getRequiredDataHistory in interface PamObserver
Parameters:
o - PamObservable class requiring the data
arg - optional argument from PamObservable
Returns:
time in milliseconds requried by data held in PamObservable

noteNewSettings

public void noteNewSettings()
Specified by:
noteNewSettings in interface PamObserver

removeObservable

public void removeObservable(PamObservable o)
Description copied from interface: PamObserver
called when an Observable (PamDataBlock) is removed from the system

Specified by:
removeObservable in interface PamObserver

setSampleRate

public void setSampleRate(float sampleRate,
                          boolean notify)
Description copied from interface: PamObserver
New sample rate

Specified by:
setSampleRate in interface PamObserver
notify - Notify other PamObservers and PamObservables in the chain.

masterClockUpdate

public void masterClockUpdate(long milliSeconds,
                              long sampleNumber)
Specified by:
masterClockUpdate in interface PamObserver

update

public void update(PamObservable o,
                   PamDataUnit arg)
Description copied from interface: PamObserver
Informs the PamObserver that new data have been added to the Observable class

Specified by:
update in interface PamObserver
Parameters:
o - Reference to the Observable (a PamDataBlock)
arg - Reference to the new PamDataUnit

getArrayType

public int getArrayType()
Returns:
the type of the current array (point, planar, line, etc)

getArrayType

public int getArrayType(int phones)
Parameters:
phones -
Returns:
the type of a sub array of the current array (point, planar, line, etc)

getArrayType

public int getArrayType(PamArray array)
Parameters:
array - a PAMGUARD array
Returns:
the type of an array (point, plane, etc)

getArrayType

public int getArrayType(PamArray array,
                        int phones)
Parameters:
array - a PAMGUARD array
phones - a sub array of phones in the pam array.
Returns:
the type of an array (point, plane, etc)

getSpatiallyUniquePhones

public int getSpatiallyUniquePhones(PamArray array,
                                    int phones)
Take a list of phones and return a list of ones which are at unique positions.

Parameters:
array - hydrophone array
phones - bitmap of hydrophone numbers
Returns:
bitmap of hydrophones which have a unique position.

getArrayDirections

public PamVector[] getArrayDirections()
Get the principle direction vectors for the current array

Returns:
Array of vectors pointing along the array principle axes.

getArrayDirection

public PamVector[] getArrayDirection(int phones)
Get the principle direction vectors for a sub set of hydrophones within the current array

Parameters:
phones - bitmap of hydrophones
Returns:
Array of vectors pointing along the array principle axes.

getArrayDirections

public PamVector[] getArrayDirections(PamArray array)
Get a set of vectors which define the principle coordinates of an array

Parameters:
array - array
Returns:
array of vectors

getArrayDirections

public PamVector[] getArrayDirections(PamArray array,
                                      int phones)
Get a set of vectors which define the principle components of an array.

For a point array, null is returned

For a line array a vector pointing along the array in the direction closest to the y axis

For a planar array a vector pointing as closely as possible to the y axis and a second vector, perpendicular to the first, obeying a right hand rule, in the plane will be returned.

For a volumetric array, the above + the third vector (vec product of the other two).

Parameters:
array - Pamguard array
phones - phones included in a sub array.
Returns:
up to three vectors defining the components of the array.

getLineArrayVector

private PamVector[] getLineArrayVector(PamVector[] arrayVectors)

getPlaneArrayVectors

private PamVector[] getPlaneArrayVectors(PamVector[] arrayVectors)

getVolumeArrayVectors

private PamVector[] getVolumeArrayVectors(PamVector[] arrayVectors)

getArrayVectors

public PamVector[] getArrayVectors(PamArray array,
                                   int phones)

getArrayTypeString

public static java.lang.String getArrayTypeString(int arrayType)

areInLine

private boolean areInLine(PamVector[] pvs)
Test to see if a load of inter-pair vectors are in line or not.

Parameters:
pvs - inter-hydrophone vectors.
Returns:
true if they all line up.

areOnPlane

private boolean areOnPlane(PamVector[] pvs)
Check to see if inter pair vectors define a volume or just a plane.

Parameters:
pvs - array of inter phone vectors
Returns:
true if there is significant volume.

getMaxVolume

private double getMaxVolume(PamVector[] pvs)