|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectPamguardMVC.PamObservable
PamguardMVC.PamDataBlock<Tunit>
public class PamDataBlock<Tunit extends PamDataUnit>
PamDataBlocks manage the data from PamProcesses.
New data, either from external sources (sound cards, GPS, etc.) or detector output (clicks or whistles, etc.) are placed in PamDataUnits. The job of a PamDataBlock is to manage those PamDataUnits.
Processes that require the data from a PamDataBlock must implement PamObserver and subscribe as listeners to the PamDataBlock. When a new PamDataUnit is added to a data block, all listeners will be notified and sent references both to the data block and the data unit.
Each PamDatablock is also responsible for deleting old data. Since only the observers of PamDataBlocks know how much historical data is required, before deleting any data each PamDataBlock asks all the PamObservers for their required data history in milliseconds and takes the maximum value returned by all observers. The PamDataBlock will then calculate the time of the first required data unit and delete all preceding units. This operation takes place approximately once per second.
For example, a whistle detector, while searching for whistles, may only require the last two or three data units from the data block containing FFT data, but when it's found a complete whistle, it may need to go back and look at the FFT data from other channels in order to calculate a location, or it may require the raw data in order to look at the original waveform. As another example, the map panel may want to hold several hours of data in memory for display purposes.
It is essential that PamProcesses are realistic about how much data they can ask a PamDataBlock to hold - if they consistently ask for too much data to be stored, the computer will run out of memory.
PamDataUnit,
PamProcess| Field Summary | |
|---|---|
protected String |
dataName
|
static int |
ITERATOR_END
|
static int |
MATCH_AFTER
If there is not exact time match, set the iterator so that the first element it returns will be the element after the requested time. |
static int |
MATCH_BEFORE
If there is not exact time match, set the iterator so that the first element it returns will be the element before the requested time. |
static int |
MATCH_EXACT
Only accept an iterator for a unit that matches the time exactly |
static int |
MIX_DONOTHING
|
static int |
MIX_INTODATABASE
|
static int |
MIX_OUTOFDATABASE
|
protected int |
naturalLifetime
Natural lifetime of data in seconds. |
static int |
NOTIFY_NEW_DATA
|
static int |
NOTIFY_UPDATE_DATA
|
protected List<Tunit> |
pamDataUnits
|
protected PamProcess |
parentProcess
|
static int |
POSITION_AFTER
Set the iterator so that a call to next() will give the first wanted element |
static int |
POSITION_BEFORE
Set the iterator so that a call to previous() will give the first wanted element |
static int |
REFERENCE_ABSOLUTE
When getting a DataUnit from the Datablock, get the abosulte data unit, i.e. |
static int |
REFERENCE_CURRENT
When getting a DataUnit from the Datablock, get the current data unit, i.e. |
protected int |
unitsAdded
|
protected int |
unitsRemoved
|
protected int |
unitsUpdated
|
| Fields inherited from class PamguardMVC.PamObservable |
|---|
logging, masterClockSample, objectChanged, overlayDraw, pamObservers, pamProfiler |
| Constructor Summary | |
|---|---|
PamDataBlock(Class unitClass,
String dataName,
PamProcess parentProcess,
int channelMap)
PamDataBlock constructor. |
|
| Method Summary | |
|---|---|
void |
addLocalisationContents(int localisationContents)
|
void |
addObserver(PamObserver o)
Adds a PamObserver, which will then receive notifications when data is added |
void |
addObserver(PamObserver o,
boolean reThread)
|
void |
addPamData(Tunit pamDataUnit)
Adds a new PamDataUnit to the PamDataBlock. |
void |
autoSetDataBlockMixMode()
|
void |
clearAll()
Clears all PamDataUnits from memory |
void |
dumpBlockContents()
|
Tunit |
findByDatabaseIndex(int databaseIndex)
Find a dataunit based on it's database index. |
Tunit |
findDataUnit(long timeMS,
int channels)
Find a data unit. |
Tunit |
findDataUnit(long timeMS,
int channels,
int absStartPos)
Find a unit that starts at a specific time. |
protected Tunit |
getAbsoluteDataUnit(int absReference)
Gets a specific data unit using an absolute reference system which keeps track of data units that have been removed. |
int |
getChannelMap()
|
Tunit |
getClosestUnitMillis(long startTime)
Find the closest data unit to a given time. |
String |
getDataName()
|
Tunit |
getDataUnit(int ref,
int refType)
Gets a reference to a data unit. |
Tunit |
getFirstUnit()
Gets the first data unit stored |
Tunit |
getFirstUnitAfter(long timems)
Return the first DataUnit that is on or after the given time |
Tunit |
getLastUnit()
Gets the last data unit stored |
ListIterator<Tunit> |
getListIterator(int whereFrom)
|
ListIterator<Tunit> |
getListIterator(long startTimeMillis,
int channels,
int match,
int position)
|
ListIterator<Tunit> |
getListIteratorFromEnd(long startTime,
int channels,
int match,
int position)
|
ListIterator<Tunit> |
getListIteratorFromStart(long startTime,
int channels,
int match,
int position)
|
int |
getLocalisationContents()
|
String |
getLoggingName()
|
String |
getLongDataName()
|
int |
getMixedDirection()
|
int |
getNaturalLifetime()
|
PamProcess |
getParentProcess()
|
Tunit |
getPreceedingUnit(ListIterator<Tunit> listIterator,
long startTime)
Finds the data unit before the given start time. |
Tunit |
getPreceedingUnit(ListIterator<Tunit> listIterator,
long startTime,
int channelMap)
Finds the data unit before the given start time that has the same channel map. |
Tunit |
getPreceedingUnit(long startTime)
Simple function to find the data unit at or before the given start time. |
Tunit |
getPreceedingUnit(long startTime,
int channelMap)
Simple function to find the data unit at or before the given start time that has a given channel bitmap |
PamRawDataBlock |
getRawSourceDataBlock()
|
float |
getSampleRate()
|
PamDataBlock |
getSourceDataBlock()
|
PamProcess |
getSourceProcess()
|
Class |
getUnitClass()
|
int |
getUnitIndex(Tunit dataUnit)
|
int |
getUnitsCount()
|
int |
getUnitsCountFromTime(long countStart)
|
boolean |
isLinkGpsData()
|
void |
loadViewData(PamViewParameters pamViewParameters)
if possible, loads old data back in from a database or other storage space. |
void |
masterClockUpdate(long milliSeconds,
long clockSample)
|
void |
noteNewSettings()
Tell all observers of this datablock that some control parameters have changed. |
void |
remove()
|
boolean |
remove(PamDataUnit aDataUnit)
|
protected int |
removeOldUnitsS(long mastrClockSample)
|
protected int |
removeOldUnitsT(long currentTimeMS)
Removes olderPamDataUnits from memory, starting at the first unit and continuing until if finds one with data coming earlier than the given time in milliseconds. |
void |
setChannelMap(int channelMap)
|
void |
setDataName(String dataName)
|
void |
setLinkGpsData(boolean linkGpsData)
|
void |
setLocalisationContents(int localisationContents)
|
void |
setMixedDirection(int mixedDirection)
|
void |
setNaturalLifetime(int naturalLifetime)
Set the natural lifetime of the data if there are no observers asking to keep it for longer |
void |
setSampleRate(float sampleRate,
boolean notify)
Sets the sample rate for the block (e.g. |
boolean |
shouldNotify()
|
String |
toString()
|
void |
updatePamData(Tunit pamDataUnit,
long timeMillis)
|
| Methods inherited from class PamguardMVC.PamObservable |
|---|
canDraw, clearchanged, countObservers, createKeyItem, deleteObserver, deleteObservers, drawDataUnit, findThreadedObserver, getCanLog, getCPUPercent, getCPUPercent, getHoverText, getLogging, getLongestObserver, getPamObservers, getRequiredHistory, getShouldLog, notifyObservers, notifyObservers, setChanged, SetLogging, setOverlayDraw, setShouldLog, waitForThreadedObservers |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int REFERENCE_ABSOLUTE
public static final int REFERENCE_CURRENT
public static final int MIX_DONOTHING
public static final int MIX_OUTOFDATABASE
public static final int MIX_INTODATABASE
protected String dataName
protected List<Tunit extends PamDataUnit> pamDataUnits
protected PamProcess parentProcess
protected int naturalLifetime
protected int unitsRemoved
protected int unitsAdded
protected int unitsUpdated
public static final int NOTIFY_NEW_DATA
public static final int NOTIFY_UPDATE_DATA
public static final int ITERATOR_END
public static final int MATCH_EXACT
public static final int MATCH_BEFORE
public static final int MATCH_AFTER
public static final int POSITION_BEFORE
public static final int POSITION_AFTER
| Constructor Detail |
|---|
public PamDataBlock(Class unitClass,
String dataName,
PamProcess parentProcess,
int channelMap)
unitClass - class of data unit to hold in this data blockdataName - name of data blockparentProcess - parent PamProcesschannelMap - bitmap of channels which may be represented in data units in this data block.| Method Detail |
|---|
public void remove()
public int getUnitsCount()
public int getUnitsCountFromTime(long countStart)
public Tunit getFirstUnitAfter(long timems)
timems - Milliseconds - UTC in standard Java epoch
public Tunit findDataUnit(long timeMS,
int channels,
int absStartPos)
timeMS - start time of data unitchannels - channel bitmap of data unitabsStartPos - start position for search, -1 if you
want to start searching backwards from the end.
public Tunit findDataUnit(long timeMS,
int channels)
timeMS - start time of PamDataUnitchannels - channel bitmap of PamDataUnit
public int getUnitIndex(Tunit dataUnit)
public Tunit findByDatabaseIndex(int databaseIndex)
databaseIndex - Index to search for.
public void clearAll()
public void loadViewData(PamViewParameters pamViewParameters)
public void addPamData(Tunit pamDataUnit)
pamDataUnit - Reference to a PamDataUnit
public void updatePamData(Tunit pamDataUnit,
long timeMillis)
public boolean shouldNotify()
public boolean remove(PamDataUnit aDataUnit)
protected int removeOldUnitsT(long currentTimeMS)
If the data are acoustic, it trys to find the data source and looks to see how much data has been placed in the source data unit and does the calculation in samples.
currentTimeMS - Time in milliseconds of the first data which must be kept
protected int removeOldUnitsS(long mastrClockSample)
public PamDataBlock getSourceDataBlock()
public PamRawDataBlock getRawSourceDataBlock()
public Tunit getDataUnit(int ref,
int refType)
ref - number of the data unitrefType - REFERENCE_ABSOLUTE or REFERENCE_CURRENT
protected Tunit getAbsoluteDataUnit(int absReference)
absReference - Absolute reference to the data unit
public Tunit getLastUnit()
public Tunit getFirstUnit()
public Tunit getPreceedingUnit(ListIterator<Tunit> listIterator,
long startTime)
This implementation is passed an iterator which has already been initialised to be at the END of the list. In this way, the calling function has access to the iterator and can access nearby elements.
listIterator - pre initialised ListIteratorstartTime - search time in milliseconds
ListIterator
public Tunit getPreceedingUnit(ListIterator<Tunit> listIterator,
long startTime,
int channelMap)
This implementation is passed an iterator which has already been initialised to be at the END of the list. In this way, the calling function has access to the iterator and can access nearby elements.
listIterator - pre initialised ListIteratorstartTime - search time in millisecondschannelMap - Channel bitmap
ListIteratorpublic Tunit getPreceedingUnit(long startTime)
startTime - search time in milliseconds
public Tunit getPreceedingUnit(long startTime,
int channelMap)
startTime - search time in millisecondschannelMap - Channel bitmap
public Tunit getClosestUnitMillis(long startTime)
startTime - Start time of data unit (milliseconds)
public float getSampleRate()
public String getDataName()
public String getLongDataName()
public void setSampleRate(float sampleRate,
boolean notify)
sampleRate - The new sample rate in Hz.notify - set true if Observers should be notified
public void masterClockUpdate(long milliSeconds,
long clockSample)
public void noteNewSettings()
public String toString()
toString in class Objectpublic int getNaturalLifetime()
public void setNaturalLifetime(int naturalLifetime)
naturalLifetime - in seconds (NOT milliseconds)public boolean isLinkGpsData()
public void setLinkGpsData(boolean linkGpsData)
public int getChannelMap()
public void setChannelMap(int channelMap)
public void setDataName(String dataName)
dataName - The dataName to set.public String getLoggingName()
public PamProcess getParentProcess()
public PamProcess getSourceProcess()
public void addObserver(PamObserver o)
PamObservable
addObserver in class PamObservableo - Reference to the observer
public void addObserver(PamObserver o,
boolean reThread)
addObserver in class PamObservablepublic Class getUnitClass()
public void autoSetDataBlockMixMode()
public int getMixedDirection()
public void setMixedDirection(int mixedDirection)
public int getLocalisationContents()
public void setLocalisationContents(int localisationContents)
public void addLocalisationContents(int localisationContents)
public ListIterator<Tunit> getListIterator(int whereFrom)
public ListIterator<Tunit> getListIterator(long startTimeMillis,
int channels,
int match,
int position)
public ListIterator<Tunit> getListIteratorFromStart(long startTime,
int channels,
int match,
int position)
public void dumpBlockContents()
public ListIterator<Tunit> getListIteratorFromEnd(long startTime,
int channels,
int match,
int position)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||