PamguardMVC
Class PamDataUnit

java.lang.Object
  extended by PamguardMVC.PamDataUnit
All Implemented Interfaces:
java.lang.Comparable<PamDataUnit>
Direct Known Subclasses:
AcousticDataUnit, AISDataUnit, AngleDataUnit, BeakedDataUnit, BeakedExperimentData, DaqStatusDataUnit, DepthDataUnit, GpsDataUnit, IshmaelDataUnit, LandmarkDataUnit, ListeningEffortData, LogModules.ModulesDataUnit, LogSettings.SettingsDataUnit, MapComment, NMEADataUnit, RecorderDataUnit, ShoreStationDataUnit, SimObjectDataUnit, TerrellaStandardDataSetUnit, ThingHeard, UserInputDataUnit, VRDataUnit

public abstract class PamDataUnit
extends java.lang.Object
implements java.lang.Comparable<PamDataUnit>

Author:
Doug Gillespie

Class for units of PAM data.

PamDataUnit's are held in ArrayLists within PamDataBlocks.

When a PamDataUnit is added to a PamDataBlock any PamProcesses that subscribe to that PamDataBlock receive a notification and can retrieve the PamDataUnits from the block.

Any data derived from acoustic data should subclass from AcousticDataUnit

See Also:
PamDataBlock, AcousticDataUnit

Field Summary
protected  int absBlockIndex
          Absolute block index, needed for searches once NPDU's start getting deleted off the front of the storage
protected  int channelBitmap
          map of channels used in the data.
private  int databaseIndex
          Index of last entry into database - what will happen if the data are written into > 1 column ?
private  int databaseUpdateOf
          Index of any database unit that this updated.
private  DataUnitFileInformation dataUnitFileInformation
           
private  long lastUpdateTime
          time of the last update
protected  AbstractLocalisation localisation
          Localisation information
protected  LatLong oLL
           
private  double[] pairAngles
           
private  PamDataBlock parentDataBlock
          Reference to parent data block
protected  long timeMilliseconds
          time the NewPamDataUnit was created based using standard Java time
private  int updateCount
          Counter which increases if the data are altered and re-sent around PAMGUARD
 
Constructor Summary
PamDataUnit(long timeMilliseconds)
           
 
Method Summary
private  void calcOandAngles()
           
 void clearUpdateCount()
          Do a clear of update count after a database save.
 int compareTo(PamDataUnit o)
           
 int getAbsBlockIndex()
           
 int getChannelBitmap()
           
 int getDatabaseIndex()
           
 int getDatabaseUpdateOf()
           
 DataUnitFileInformation getDataUnitFileInformation()
           
protected  GpsData getGpsPosition()
          Used when no hydrophone information is specified to get the nearest ships GPS position.
 long getLastUpdateTime()
           
 AbstractLocalisation getLocalisation()
           
 LatLong getOriginLatLong(boolean recalculate)
          Get the latlongof the mean hydrophone position at the time of this detection.
 double getPairAngle(int pair, boolean recalculate)
          Return the angle between pairs of hydorphones.
 PamDataBlock getParentDataBlock()
           
 long getTimeMilliseconds()
           
 int getUpdateCount()
           
 void setAbsBlockIndex(int absBlockIndex)
           
 void setChannelBitmap(int channelBitmap)
           
 void setDatabaseIndex(int databaseIndex)
           
 void setDatabaseUpdateOf(int databaseUpdateOf)
           
 void setDataUnitFileInformation(DataUnitFileInformation dataUnitFileInformation)
           
 void setLastUpdateTime(long lastUpdateTime)
           
 void setLocalisation(AbstractLocalisation localisation)
           
 void setOriginLatLong(LatLong oll)
           
 void setParentDataBlock(PamDataBlock parentDataBlock)
           
 void setTimeMilliseconds(long timeMilliseconds)
           
 void updateDataUnit(long updateTime)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeMilliseconds

protected long timeMilliseconds
time the NewPamDataUnit was created based using standard Java time


absBlockIndex

protected int absBlockIndex
Absolute block index, needed for searches once NPDU's start getting deleted off the front of the storage


parentDataBlock

private PamDataBlock parentDataBlock
Reference to parent data block


channelBitmap

protected int channelBitmap
map of channels used in the data.

N.B the PamDataBlock also has a channelBitmap. The channelBitmap in a PamDataBlock is a list of channels that might be present in the data units. The channelBitmap in the data unit represents channels that are actually present in that data unit. For instance, if sampling 2 channels (ch0 and ch1) of raw audio data, the channelBitmap in the data block would equal 3, but the channel maps in the data units (which contain one channel of data each) will alternate between 1 and 2.

note that these are the software channels and that there may not be a 1:1 relationship between software channels and hydrophones.

This parameter is included in PamDataUnit and not in the subclass AcousticDataUnit since it is sometimes needed by non acoustic data.


updateCount

private int updateCount
Counter which increases if the data are altered and re-sent around PAMGUARD


lastUpdateTime

private long lastUpdateTime
time of the last update


databaseIndex

private int databaseIndex
Index of last entry into database - what will happen if the data are written into > 1 column ?


databaseUpdateOf

private int databaseUpdateOf
Index of any database unit that this updated.


dataUnitFileInformation

private DataUnitFileInformation dataUnitFileInformation

localisation

protected AbstractLocalisation localisation
Localisation information


oLL

protected LatLong oLL

pairAngles

private double[] pairAngles
Constructor Detail

PamDataUnit

public PamDataUnit(long timeMilliseconds)
Method Detail

setAbsBlockIndex

public void setAbsBlockIndex(int absBlockIndex)

setParentDataBlock

public void setParentDataBlock(PamDataBlock parentDataBlock)

setTimeMilliseconds

public void setTimeMilliseconds(long timeMilliseconds)

getAbsBlockIndex

public int getAbsBlockIndex()

getParentDataBlock

public PamDataBlock getParentDataBlock()

getTimeMilliseconds

public long getTimeMilliseconds()

updateDataUnit

public void updateDataUnit(long updateTime)

clearUpdateCount

public void clearUpdateCount()
Do a clear of update count after a database save.


getUpdateCount

public int getUpdateCount()
Returns:
the number of times the data unit has been updated.

getChannelBitmap

public int getChannelBitmap()

setChannelBitmap

public void setChannelBitmap(int channelBitmap)

getLocalisation

public AbstractLocalisation getLocalisation()
Returns:
Returns the localisation.

setLocalisation

public void setLocalisation(AbstractLocalisation localisation)
Parameters:
localisation - The localisation to set.

getOriginLatLong

public LatLong getOriginLatLong(boolean recalculate)
Get the latlongof the mean hydrophone position at the time of this detection.

Parameters:
recalculate -
Returns:
Lat long of detectin origin (usually the position of the reference hydrophone at time of detection)

setOriginLatLong

public void setOriginLatLong(LatLong oll)

getPairAngle

public double getPairAngle(int pair,
                           boolean recalculate)
Return the angle between pairs of hydorphones. For a n channel detection, n-1 pair angles are calulcated, each being the bearing, realtive to north, from the pair+1th hydrophone TO the 0th hydropone (i.e. for a 2 channel array, there is one pair calculated and it's from channel 1 to channel 0, which is the most useful. If other inter pair angles are required, then it should easy to calculate them from these values.

Parameters:
pair -
recalculate -
Returns:
angle clockwise from North in degrees.

calcOandAngles

private void calcOandAngles()

getGpsPosition

protected GpsData getGpsPosition()
Used when no hydrophone information is specified to get the nearest ships GPS position.

Returns:
GPS data closest to the time of the detection

getLastUpdateTime

public long getLastUpdateTime()

setLastUpdateTime

public void setLastUpdateTime(long lastUpdateTime)

getDatabaseIndex

public int getDatabaseIndex()

setDatabaseIndex

public void setDatabaseIndex(int databaseIndex)

getDatabaseUpdateOf

public int getDatabaseUpdateOf()

setDatabaseUpdateOf

public void setDatabaseUpdateOf(int databaseUpdateOf)

getDataUnitFileInformation

public DataUnitFileInformation getDataUnitFileInformation()

setDataUnitFileInformation

public void setDataUnitFileInformation(DataUnitFileInformation dataUnitFileInformation)

compareTo

public int compareTo(PamDataUnit o)
Specified by:
compareTo in interface java.lang.Comparable<PamDataUnit>