Class PamDataBlock<Tunit extends PamDataUnit>
- Direct Known Subclasses:
AcousticDataBlock
,AISDataBlock
,AlarmDataBlock
,AnalogArraySensorDataBlock
,AngleDataBlock
,ArrayAccelDataBlock
,AutecDataBlock
,BackgroundDataBlock
,BearingDataBlock
,BFLDataOutput
,BuoyStatusDataBlock
,CalibrationDataBlock
,ClickTrainTempBlock
,ClipSpectrogramMarkDataBlock
,D3DataBlock
,DaqStatusDataBlock
,DbHtDataBlock
,DepthDataBlock
,DLModelDataBlock
,EffortDataBlock
,FormsDataBlock
,FormsMasterDataBlock
,GPLStateDataBlock
,GPSDataBlock
,GridDataBlock
,HydrophoneDataBlock
,IMUDataBlock
,IshDataBlock
,LandmarkDataBlock
,LinePlotDataBlock
,MapCommentDataBlock
,MarkDataBlock
,MeygenDataBlock
,NMEADataBlock
,NoiseDataBlock
,NoiseDataBlock
,OneBandDataBlock
,PrintScreenDataBlock
,QAOpsDataBlock
,QASoundDataBlock
,QueuedDataBlock
,QueuedTaskDataBlock
,RavenDataBlock
,RoccaContourDataBlock
,RoccaLoggingDataBlock
,RoccaSightingDataBlock
,RockBlockDataBlock
,SegmenterDataBlock
,SegmenterGroupDataBlock
,SimObjectsDataBlock
,SimpleClickDataBlock
,SimSoundDataBlock
,SingletonDataBlock
,StreamerDataBlock
,SuperDetDataBlock
,TargetMotionDataBlock
,TaskLoggingDataBlock
,TethysLogDataBlock
,TideDataBlock
,TrackedGroupDataBlock
,TriggerBackgroundDataBlock
,VRDataBlock
,WhistleClasificationDataBlock
,WhistleLocationDataBlock
- Author:
- Doug Gillespie
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.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
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 final int
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 final int
Only accept an iterator for a unit that matches the time exactlystatic final int
static final int
static final int
static final int
static final int
static final int
Set the iterator so that a call to next() will give the first wanted elementstatic final int
Set the iterator so that a call to previous() will give the first wanted elementstatic final int
When getting a DataUnit from the Datablock, get the absolute data unit, i.e.static final int
When getting a DataUnit from the Datablock, get the current data unit, i.e.static final int
Data loaded for requested time period.static final int
Data partially loaded for requested time periodstatic final int
The request threw an exception of some sort.static final int
The request was interrupted (in multi thread load)static final int
No data available for offline loading.static final int
this is exactly the same data as requested last time. -
Constructor Summary
ConstructorDescriptionPamDataBlock
(Class unitClass, String dataName, PamProcess parentProcess, int channelMap) Standard PamDataBlock constructor.PamDataBlock
(Class unitClass, String dataName, PamProcess parentProcess, int channelMap, boolean isOffline) PamDataBlock constructor that allows bespoke setting of isOffline flag. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataAnnotationType
(DataAnnotationType annotationType) Keep for backwards compatibilityvoid
addLocalisationContents
(int localisationContents) Add a single flag indicating what localisation information might be available for the data in this block.void
Adds a PamObserver, which will then receive notifications when data is added.void
addObserver
(PamObserver o, boolean reThread) void
addOfflineDataMap
(OfflineDataMap offlineDataMap) Adds a new offline datamap to the data blockvoid
addOldPamData
(Tunit pamDataUnit) Add early PAM data to a datablock.void
addPamData
(Tunit pamDataUnit) Adds a new PamDataUnit to the PamDataBlock.void
addPamData
(Tunit pamDataUnit, Long uid) Adds a new PamDataUnit to the PamDataBlock and force the UID to a specific value.Auto generate an effort provider.void
void
Cancel the current offline data ordervoid
cancelDataOrder
(boolean quedItems) Cancel the current offline data ordervoid
Check offline datablock UID's, taking the maximum uid from all available data maps.void
clearAll()
Clears all PamDataUnits from memoryvoid
Clears list of both channel and sequence iteratorsvoid
boolean
Clear all data units on viewer load.Make a soft copy of all of the data in the datablock.int
createProcessAnnotations
(PamDataBlock sourceData, ProcessAnnotator newAnnotations) Copies all annotations over from the source DataBlock, then adds in the new ones from the new datablock.int
createProcessAnnotations
(PamDataBlock sourceData, ProcessAnnotator newAnnotations, boolean notifyDownstream) Copies all annotations over from the source DataBlock, then adds in the new ones from the new datablock.void
dispose()
clean up datablock when it's no longer neededvoid
void
dumpBufferStatus
(String message, boolean sayEmpties) Look in every data block, particularly threaded ones, and dump the buffer status.findAnnotation
(String type, String name) Finds an annotation with the given type and namefindAnnotation
(ProcessAnnotation template) Finds an annotation with the same type and name as the template annotationfindByDatabaseIndex
(int databaseIndex) Find a dataunit based on it's database index.findDataUnit
(long timeMS, int channels) Find a data unit.findDataUnit
(long timeMS, int channels, int absStartPos) Find a unit that starts at a specific time.findFirstUnitAfter
(long timems, DataSelector dataSelector) findLastUnitBefore
(long timems, DataSelector dataSelector) find the first data unit that is at or before the given time.findUnitByUIDandUTC
(long unitUID, long utc) find a data unit based on it's UID AND on it's timestamp to deal with problems of UID's occasionally resetting and therefore not being quite as unique as we'd like them to be.findUnitsinInterval
(long startTime, long endTime) Find a group of data units within a time window.int
getARealChannel
(int chanOrSeqNum) There are times when a module doesn't know whether the channel it is using is really a channel, or whether it is actually a sequence number.final boolean
getChannelIterator
(int channelMap, int whereFrom) Get an iterator which can iterator through only data units with data from particular channels in a databock.int
Get the number of stored channel/sequence iterators for a datablock.int
int
getChannelsForSequenceMap
(int sequenceMap) Given a sequenceMap, this method returns the associated channelMap.getClosestUnitMillis
(long startTime) Find the closest data unit to a given time.getClosestUnitMillis
(long startTime, int channelMap) Find the closest data unit to a given time.getClosestUnitMillisUsingSeq
(long startTime, int chanOrSeqMap) Find the closest data unit to a given time.Get any information from the data block about cross referencing in database tables.double
getCumulativeGain
(int iChan) Get the total gain of this data block and all upstream datablocks.long
long
Get the level of automation employed by the generation of these data.Get information about species types that may occur within this data block.getDataBlockXML
(Document doc) Get a brief summary of datablock to include in XML descriptions.Get a complete copy of the data.getDataCopy
(long startTimeMillis, int channels, int match, int position) copy the data using an iterator, positioned at the given startTime.getDataCopy
(long t1, long t2, boolean assumeOrder) Get a temporary copy of all data between two times (inclusive)getDataCopy
(long t1, long t2, boolean assumeOrder, DataSelector dataSelector) Get a temporary copy of all data between two times (inclusive) using a data selectorgetDataCopyFromEnd
(long startTimeMillis, int channels, int match, int position) copy the data using an iterator, positioned at the given startTime.getDataCopyFromStart
(long startTimeMillis, int channels, int match, int position) copy the data using an iterator, positioned at the given startTime.double
getDataGain
(int iChan) Return the gain applied to any data created into this datablock.Get a data map which has a datagramgetDataSelector
(String selectorName, boolean allowScores) Convenience method to save programmer from having to call into the creator all the time.getDataSelector
(String selectorName, boolean allowScores, String selectorType) Convenience method to save programmer from having to call into the creator all the time.getDataSelector
(String selectorName, boolean allowScores, String selectorType, boolean includeAnnotations, boolean includeSuperDetections) Convenience method to save programmer from having to call into the creator all the time.getDataUnit
(int ref, int refType) Gets a reference to a data unit.getDataUnitMenuItems
(DataMenuParent menuParent, Point mousePosition, PamDataUnit... dataUnits) Get menu items pertinent to one or more data units.getDataUnitPopupMenu
(DataMenuParent menuParent, Point mousePosition, PamDataUnit... dataUnits) Get a standard popup menu (or null) using items from getDataUnitMenuItemsdouble[]
Get the nominal range of durations of sounds that might be detected by this detector (if applicable).Get the first raw data block in the chain.Gets the first data unit storedgetFirstUnit
(int channelMap) Get the first unit for a specific channel map (any match of channels allowed).getFirstUnitAfter
(long timems) Return the first DataUnit that is on or after the given timelong
double[]
Get the range of frequencies over which the data in the data block are likely to be present.int
There may not be a 1:1 mapping of channels to hydrophonesGet the data source for exporting as a JSON-formatted stringGets the last data unit storedgetLastUnit
(int channelMap) Get the last unit for a specific channel map (any match of channels allowed).long
long
getListIterator
(int whereFrom) Get a list iterator through the data from a given position.getListIterator
(long startTimeMillis, int channels, int match, int position) Get an iterator, positioned at the given startTime.getListIteratorFromEnd
(long startTime, int channels, int match, int position) Get an iterator, positioned at the given startTime.getListIteratorFromStart
(long startTime, int channels, int match, int position) Get an iterator, positioned at the given startTime.Find localisation algorithm for this data.Get Information indicating what localisation information might be available for the data in this block.Get a slightly longer data name that also contains the module nameint
getMyDataUnits
(List<PamDataUnit> randomDataUnits) From a whole load of data units, e.g.int
Get the natural lifetime in secondsint
Get the natural lifetime in millisecondslong
getNextDataStart
(long timeMillis) Get the next data start point.getNextUnit
(long startTime, int channelMap) Simple function to find the data unit at or following the given start time that has a given channel bitmapgetNextUnit
(ListIterator<Tunit> listIterator, long startTime, int channelMap) Finds the data unit after the given start time that has the same channel map.int
int
Get the number of pam data units that are required prior to the load times that get sent to loadViewerData.int
getOfflineData
(OfflineDataLoadInfo offlineLoadInfo) Gets data for offline display, playback, etc.getOfflineDataMap
(int iMap) getOfflineDataMap
(OfflineDataStore dataSource) getPreceedingUnit
(long startTime) Simple function to find the data unit at or before the given start time.getPreceedingUnit
(long startTime, int channelMap) Simple function to find the data unit at or before the given start time that has a given channel bitmapgetPreceedingUnit
(ListIterator<Tunit> listIterator, long startTime) Finds the data unit before the given start time.getPreceedingUnit
(ListIterator<Tunit> listIterator, long startTime, int channelMap) Finds the data unit before the given start time that has the same channel map.getPreceedingUnitFromSeq
(long startTime, int chanOrSeqMap) Simple function to find the data unit at or before the given start time that has a given channel OR sequence bitmapgetPreceedingUnitFromSeq
(ListIterator<Tunit> listIterator, long startTime, int chanOrSeqMap) Finds the data unit before the given start time that has the same channel/sequence map.long
getPrevDataEnd
(long timeMillis) Get the previous data end point.New plan - always use the binary store if it has any data at all.int
Quick integer datablock id which is based on the datanameint
Make a better quickId that is more resilient to changes at any point in the string, i.e.Tries to find the raw data block source of the current data block.Gets a recycled data unit if one is available.int
getReverseChannelIterator
(int channelMap) Get an iterator which can go backwards through a datablock, but only selects dataunits that have a channel map that overlaps with channelMap.float
getSaveRequirements
(OfflineDataStore dataStore) Work out some basic information about the elements that need saving from these data.int
Get the number of separate channel sequences in the data.getSequenceIterator
(int sequenceMap, int whereFrom) Get an iterator which can iterator through only data units with data from particular sequence numbers in a databock.int
As described in dataunit, this is a slightly different map to channelmap to be used when beamforming, where the map of available outputs may be quite different to the number of available input channels.As described in dataunit, this is a slightly different map to channelmap to be used when beamforming, where the map of available outputs may be quite different to the number of available input channels.boolean
getShouldBinary
(PamDataUnit pamDataUnit) Get flag to say whether data should be stored in the binary storeboolean
In general, should the data block try to log to the database?boolean
getShouldLog
(PamDataUnit pamDataUnit) Should log the data unit to the database ?Class<?>
The synchronisation lock is a synchronisation object that must be used to synch all iterators using the data unit list and any function that puts data into or out of them.getTethysDataProvider
(TethysControl tethysControl) Gets a data provider for Tethys.getUniqueParentList
(List<PamDataUnit> pamDataUnits) Get a list of unique super detections for a load of data unitsint
getUnitIndex
(Tunit dataUnit) int
int
getUnitsCountFromTime
(long countStart) boolean
hasDataRange
(long startMillis, long endMillis) Do data exist which cover the given time range ?boolean
boolean
Flag to say that data should be cleared every time PAMGuard starts.boolean
boolean
boolean
boolean
loadViewerData
(long dataStart, long dataEnd, ViewLoadObserver loadObserver) Instruction from the viewer scroll manager to load new data.boolean
loadViewerData
(OfflineDataLoadInfo offlineDataLoadInfo, ViewLoadObserver loadObserver) Instruction from the viewer scroll manager to load new data.void
masterClockUpdate
(long milliSeconds, long clockSample) boolean
needViewerDataLoad
(OfflineDataLoadInfo offlineDataLoadInfo) Do we need to reload offline data ? Default behaviour is to reurn true if the time periods of the data load have changed, false otherwise.void
Tell all observers of this datablock that some control parameters have changed.void
notifyModelChanged
(int changeType) Receive notifications from the main PamController.void
orderOfflineData
(OfflineDataLoadInfo offlineDataLoadInfo) Similar functionality to getOfflineData, but this will launch a separate worker thread to do the actual work getting the data.void
orderOfflineData
(PamObserver dataObserver, LoadObserver loadObserver, long startMillis, long endMillis, int loadKeepLayers, int interrupt) Similar functionality to getOfflineData, but this will launch a separate worker thread to do the actual work getting the data.void
orderOfflineData
(PamObserver dataObserver, LoadObserver loadObserver, long startMillis, long endMillis, int loadKeepLayers, int interrupt, boolean allowRepeats) Similar functionality to getOfflineData, but this will launch a separate worker thread to do the actual work getting the data.void
pamStart
(long startTime) Need this notification at startup time to perform a few standard actions.void
pamStop
(long stopTime) Need this notification at stop time to perform a few standard actions.void
remove()
boolean
Remove a data unit from a data block, but NOT from the database.boolean
Remove a data unit from a data block and optionally remove it's entry from the database.void
removeOfflineDataMap
(OfflineDataStore dataSource) remove a no longer needed offline data map.void
reset()
Reset a datablock.boolean
Saves data in this data block in offline viewer mode.void
setAnnotationHandler
(AnnotationHandler annotationHandler) void
setBackgroundManager
(BackgroundManager backgroundManager) void
setBinaryDataSource
(BinaryDataSource binaryDataSource) void
setCanClipGenerate
(boolean canClipGenerate) void
setChannelMap
(int channelMap) Set the software channel map for the data block.void
setClearAtStart
(boolean clearAtStart) Flag to say that data should be cleared every time PAMGuard starts.void
setDatagramProvider
(DatagramProvider datagramProvider) void
setDataName
(String dataName) void
setDataSelectCreator
(DataSelectorCreator dataSelectorCreator) void
setJSONDataSource
(JSONObjectDataSource jsonDataSource) Set the data source for exporting as a JSON-formatted stringvoid
setLinkGpsData
(boolean linkGpsData) void
setLocalisationContents
(int localisationContents) Set a bitmap of flags indicating what localisation information might be available for the data in this block.void
SetLogging
(SQLLogging logging) void
setMixedDirection
(int mixedDirection) void
setNanoTimeCalculator
(NanoTimeCalculator nanoTimeCalculator) void
setNaturalLifetime
(int naturalLifetime) Set the natural lifetime in seconds of the data if there are no observers asking to keep it for longervoid
setNaturalLifetimeMillis
(int naturalLifetime) Set the natural lifetime in millisecondsvoid
setPamSymbolManager
(PamSymbolManager pamSymbolManager) void
setParentProcess
(PamProcess newProcess) void
setRecordingTrigger
(RecorderTrigger recorderTrigger) void
setRecycling
(boolean recycling) void
setRecyclingStoreLength
(int recyclingStoreLength) void
setSampleRate
(float sampleRate, boolean notify) Sets the sample rate for the block (e.g.void
setSequenceMap
(Integer sequenceMap) As described in dataunit, this is a slightly different map to channelmap to be used when beamforming, where the map of available outputs may be quite different to the number of available input channels.void
setShouldBinary
(boolean shouldBinary) Set flag to say if data should be stored in the binary store.final void
setShouldLog
(boolean shouldLog) Set if data should be logged to the database.void
setSynchLock
(Object synchLock) The synchronisation lock is a synchronisation object that must be used to synch all iterators using the data unit list and any function that puts data into or out of them.void
setUidHandler
(DataBlockUIDHandler uidHandler) Set the UID handler - very occasionally it's necessary to set this to null.boolean
void
sortData()
Sorts all the data units in the data block in order of time (unless a a data unit class chooses to overwrite the compareTo function.void
sortOutputMaps
(int sourceChanMap, Integer sourceSeqMap, int localSubsetMap) This method will sort out this PamDataBlock's channel map and sequence map, depending on the source PamDataBlock that it's getting it's information from.void
Had some issues with the Timer holding a reference to the underlying PamDataBlock (RoccaContourDataBlock, in this case) and not releasing it for garbage collection.toString()
void
updatePamData
(Tunit pamDataUnit, long updateTimeMillis) update a dataunit.Methods inherited from class PamguardMVC.PamObservable
addInstantObserver, canDraw, canDraw, clearchanged, countObservers, createKeyItem, deleteObserver, deleteObservers, drawDataUnit, findThreadedObserver, getCPUPercent, getCPUPercent, getHoverText, getLongestObserver, getMaxThreadJitter, getOverlayDraw, getPamObserver, getRequiredHistory, isInstantObserver, notifyInstantObservers, notifyNornalObservers, notifyObservers, notifyObservers, setChanged, setOverlayDraw, updateObservers, waitForThreadedObservers
-
Field Details
-
REFERENCE_ABSOLUTE
public static final int REFERENCE_ABSOLUTEWhen getting a DataUnit from the Datablock, get the absolute data unit, i.e. the unit number as would be if none had ever been deleted- See Also:
-
REFERENCE_CURRENT
public static final int REFERENCE_CURRENTWhen getting a DataUnit from the Datablock, get the current data unit, i.e. the unit number in the current ArrayList- See Also:
-
MIX_DONOTHING
public static final int MIX_DONOTHING- See Also:
-
MIX_OUTOFDATABASE
public static final int MIX_OUTOFDATABASE- See Also:
-
MIX_INTODATABASE
public static final int MIX_INTODATABASE- See Also:
-
REQUEST_NO_DATA
public static final int REQUEST_NO_DATANo data available for offline loading.- See Also:
-
REQUEST_DATA_LOADED
public static final int REQUEST_DATA_LOADEDData loaded for requested time period.- See Also:
-
REQUEST_DATA_PARTIAL_LOAD
public static final int REQUEST_DATA_PARTIAL_LOADData partially loaded for requested time period- See Also:
-
REQUEST_SAME_REQUEST
public static final int REQUEST_SAME_REQUESTthis is exactly the same data as requested last time.This flag will be used with one of the other three.
- See Also:
-
REQUEST_INTERRUPTED
public static final int REQUEST_INTERRUPTEDThe request was interrupted (in multi thread load)- See Also:
-
REQUEST_EXCEPTION
public static final int REQUEST_EXCEPTIONThe request threw an exception of some sort.- See Also:
-
NOTIFY_NEW_DATA
public static final int NOTIFY_NEW_DATA- See Also:
-
NOTIFY_UPDATE_DATA
public static final int NOTIFY_UPDATE_DATA- See Also:
-
ITERATOR_END
public static final int ITERATOR_END- See Also:
-
MATCH_EXACT
public static final int MATCH_EXACTOnly accept an iterator for a unit that matches the time exactly- See Also:
-
MATCH_BEFORE
public static final int MATCH_BEFOREIf there is not exact time match, set the iterator so that the first element it returns will be the element before the requested time.- See Also:
-
MATCH_AFTER
public static final int MATCH_AFTERIf there is not exact time match, set the iterator so that the first element it returns will be the element after the requested time.- See Also:
-
POSITION_BEFORE
public static final int POSITION_BEFORESet the iterator so that a call to previous() will give the first wanted element- See Also:
-
POSITION_AFTER
public static final int POSITION_AFTERSet the iterator so that a call to next() will give the first wanted element- See Also:
-
-
Constructor Details
-
PamDataBlock
Standard PamDataBlock constructor.- Parameters:
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.
-
PamDataBlock
public PamDataBlock(Class unitClass, String dataName, PamProcess parentProcess, int channelMap, boolean isOffline) PamDataBlock constructor that allows bespoke setting of isOffline flag.- Parameters:
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.isOffline
- datablock is offline, so normal data deleting doesn't apply
-
-
Method Details
-
remove
public void remove() -
getUnitsCount
public int getUnitsCount()- Returns:
- The total number of PamDataUnits in the block
-
getUnitsCountFromTime
public int getUnitsCountFromTime(long countStart) -
getRemovedItems
- Returns:
- the removedItems list
-
getFirstUnitAfter
Return the first DataUnit that is on or after the given time- Parameters:
timems
- Milliseconds - UTC in standard Java epoch- Returns:
- a PamDataUnit or null if no data were found
-
findDataUnit
Find a unit that starts at a specific time. searchStart may help to speed things up, however, now that a LinkedList is used in place of a vector, it's likely that this speed increase will be small.Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
- Parameters:
timeMS
- start time of data unitchannels
- channel bitmap of data unit, or 0 for any data unitabsStartPos
- start position for search, -1 if you want to start searching backwards from the end.- Returns:
- data unit (or null if nothing found)
-
getReverseChannelIterator
Get an iterator which can go backwards through a datablock, but only selects dataunits that have a channel map that overlaps with channelMap. Note that only hasPrevious() and previous() work and that you cannot add, delete, or move forwards through this iterator.- Parameters:
channelMap
- channel map for search- Returns:
- a reverese iterator to go backwards through the data.
-
findDataUnit
Find a data unit. By default, the search starts at the end of the list and works backwards on the assumption that we'll be more interested in more recent data.- Parameters:
timeMS
- start time of PamDataUnitchannels
- channel bitmap of PamDataUnit- Returns:
- found data unit, or null.
-
getUnitIndex
-
findByDatabaseIndex
Find a dataunit based on it's database index. If there have been no updates, then database indexes should be in order and a fast find can be used. If however, there have been updates, then things will not be in order so it's necessary to go through everything from start to end.- Parameters:
databaseIndex
- Index to search for.- Returns:
- found unit or null.
-
findUnitByUIDandUTC
find a data unit based on it's UID AND on it's timestamp to deal with problems of UID's occasionally resetting and therefore not being quite as unique as we'd like them to be.Allow a two second jitter on the time match to allow for some database systems not writing times to better than one second accuracy which won't match to binary file times which will remain accurate to milliseconds.
- Parameters:
unitUID
-utc
-- Returns:
- found data unit or null;
-
findFirstUnitAfter
-
findLastUnitBefore
find the first data unit that is at or before the given time.- Parameters:
timems
- time in milliseconds.dataSelector
- optional data selector- Returns:
- unit or null.
-
findUnitsinInterval
Find a group of data units within a time window.- Parameters:
startTime
- time to search from in millisendTime
- time to search to in millis- Returns:
- An ArrayList of units between startTime and endTime. If no units are present in this time window an empty array will be returned.
-
hasDataRange
public boolean hasDataRange(long startMillis, long endMillis) Do data exist which cover the given time range ?- Parameters:
startMillis
-endMillis
-- Returns:
- true if data exist covering that time range.
-
clearAll
public void clearAll()Clears all PamDataUnits from memoryIn viewer mode, data are also re-saved.
-
reset
public void reset()Reset a datablock. This is called at PamStart from PamController It's been added in mostly to help with some issues surrounding sample numbering and timing when receiving Network data in which case the PamCalendar.getSessionStartTime may have been initialised when the sample count is already up in the zillions, in which case a lot of the timing functions won't work. -
getCurrentViewDataStart
public long getCurrentViewDataStart()- Returns:
- the start time of data currently loaded by the viewer.
-
getCurrentViewDataEnd
public long getCurrentViewDataEnd()- Returns:
- the end time of data currently loaded by the viewer.
-
loadViewerData
Instruction from the viewer scroll manager to load new data.This just calls through to loadViewerData(OfflineDataLoadInfo ...) so this should not be overridden. Override the other function instead.
- Parameters:
dataStart
- data start time in millisdataEnd
- data end time in millis.loadObserver
- - the load obsever. Can be used as a callback for load progress.
-
needViewerDataLoad
Do we need to reload offline data ? Default behaviour is to reurn true if the time periods of the data load have changed, false otherwise.- Parameters:
offlineDataLoadInfo
-- Returns:
- true if we need to reload offline data.
-
clearOnViewerLoad
public boolean clearOnViewerLoad()Clear all data units on viewer load.- Returns:
- true for normal operations, may be overridded for some types of super detection
-
loadViewerData
public boolean loadViewerData(OfflineDataLoadInfo offlineDataLoadInfo, ViewLoadObserver loadObserver) Instruction from the viewer scroll manager to load new data.- Parameters:
offlineDataLoadInfo
- - the load object which contains all info on the data to be loaded.loadObserver
- - the load observer. Can be used as a callback for load progress.
-
saveViewerData
public boolean saveViewerData()Saves data in this data block in offline viewer mode.- Returns:
- true if data found and saved.
-
getNumRequiredBeforeLoadTime
public int getNumRequiredBeforeLoadTime()Get the number of pam data units that are required prior to the load times that get sent to loadViewerData. This can be used for things like hydrophone data where it may be necessary to load up a few earlier points to complete a trackline, etc.- Returns:
- number of units required.
-
addPamData
Adds a new PamDataUnit to the PamDataBlock. When the data unit is added, PamObservers that have subscribed to the block will be notified.
If the data unit already has a UID, it will be left as is.- Parameters:
pamDataUnit
- Reference to a PamDataUnit
-
addOldPamData
Add early PAM data to a datablock. this can be used in normal mode as well as viewer mode. UID's are not changed, and no notifications are sent out.- Parameters:
pamDataUnit
-
-
addPamData
Adds a new PamDataUnit to the PamDataBlock and force the UID to a specific value. This should only be used in very specific circumstances - nromally, programmers should call addPamData(Tunit pamDataUnit) and let PAMGuard handle the UID's.- Parameters:
pamDataUnit
- Reference to a PamDataUnituid
- Unique identifier for data unit.
-
getLastUnitMillis
public long getLastUnitMillis() -
updatePamData
update a dataunit. Does little except flag that the data unit is updated (so it will get saved), and sends notifications to other modules.- Parameters:
pamDataUnit
-updateTimeMillis
-
-
shouldNotify
public boolean shouldNotify() -
remove
Remove a data unit from a data block, but NOT from the database. To also remove from database, call remove(datUnit, true);- Parameters:
aDataUnit
-- Returns:
-
remove
Remove a data unit from a data block and optionally remove it's entry from the database.- Parameters:
aDataUnit
- data unit to remove from the working list.clearDatabase
- entry immediately remove the data unit entry from the database- Returns:
- true if removed successfully (false if it didn't exit).
-
getRecycledUnit
Gets a recycled data unit if one is available.- Returns:
- recycled unit, or null
-
getSourceDataBlock
-
getDataUnit
Gets a reference to a data unit.- Parameters:
ref
- number of the data unitrefType
- REFERENCE_ABSOLUTE or REFERENCE_CURRENT- Returns:
- DataUnit \n If refType is REFERENCE_ABSOLUTE then the data unit with the absolute position ref is returned (if it has not yet been deleted). This might be used to re-access a specific unit or to access the unit coming directly before or after a previously accessed unit. \n If refType is REFERENCE_CURRENT then the data unit at that position in the current ArrayList is returned.
-
getLastUnit
Gets the last data unit stored- Returns:
- data unit or null
-
getLastUnit
Get the last unit for a specific channel map (any match of channels allowed).Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
- Parameters:
channelMap
- channel map- Returns:
- last data unit with at least one channel matching, or null.
-
getFirstUnit
Gets the first data unit stored- Returns:
- data unit or null
-
getFirstUnit
Get the first unit for a specific channel map (any match of channels allowed).Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
- Parameters:
channelMap
- channel map- Returns:
- last data unit with at least one channel matching, or null.
-
getPreceedingUnit
Finds the data unit before the given start time.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.
- Parameters:
listIterator
- pre initialised ListIteratorstartTime
- search time in milliseconds- Returns:
- data unit at or following the given time.
- See Also:
-
getPreceedingUnit
Finds the data unit before the given start time that has the same channel map.Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, getPreceedingUnitFromSeq should be used instead.
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.
- Parameters:
listIterator
- pre initialised ListIteratorstartTime
- search time in millisecondschannelMap
- Channel bitmap- Returns:
- data unit at or following the given time.
- See Also:
-
getPreceedingUnitFromSeq
public Tunit getPreceedingUnitFromSeq(ListIterator<Tunit> listIterator, long startTime, int chanOrSeqMap) Finds the data unit before the given start time that has the same channel/sequence map.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.
- Parameters:
listIterator
- pre initialised ListIteratorstartTime
- search time in millisecondschanOrSeqMap
- Channel bitmap- Returns:
- data unit at or following the given time.
- See Also:
-
getPreceedingUnit
Simple function to find the data unit at or before the given start time.- Parameters:
startTime
- search time in milliseconds- Returns:
- data unit at or following the given time.
-
getPreceedingUnit
Simple function to find the data unit at or before the given start time that has a given channel bitmap- Parameters:
startTime
- search time in millisecondschannelMap
- Channel bitmap- Returns:
- data unit at or following the given time.
-
getPreceedingUnitFromSeq
Simple function to find the data unit at or before the given start time that has a given channel OR sequence bitmap- Parameters:
startTime
- search time in millisecondschanOrSeqMap
- Channel or Sequence bitmap- Returns:
- data unit at or following the given time.
-
getNextUnit
Finds the data unit after the given start time that has the same channel map.Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
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.
- Parameters:
listIterator
- pre initialised ListIteratorstartTime
- search time in millisecondschannelMap
- Channel bitmap- Returns:
- data unit at or following the given time.
- See Also:
-
getNextUnit
Simple function to find the data unit at or following the given start time that has a given channel bitmap- Parameters:
startTime
- search time in millisecondschannelMap
- Channel bitmap- Returns:
- data unit at or following the given time.
-
getClosestUnitMillis
Find the closest data unit to a given time.- Parameters:
startTime
- Start time of data unit (milliseconds)- Returns:
- closest data unit
-
getClosestUnitMillis
Find the closest data unit to a given time. Note that this method works specifically with the channelMap. If you need to use either channel map or sequence map, call getClosestUnitMillisUsingSeq instead.- Parameters:
startTime
- Start time of data unit (milliseconds)channelMap
- Channel map - must be some overlap, not an exact match.- Returns:
- closest data unit
-
getClosestUnitMillisUsingSeq
Find the closest data unit to a given time. This method tries to check the data units for sequence number first, and if there is no sequence number will try the channel number- Parameters:
startTime
- Start time of data unit (milliseconds)chanOrSeqMap
- Channel/Sequence map - must be some overlap, not an exact match.- Returns:
- closest data unit
-
getSampleRate
public float getSampleRate()- Returns:
- The sample rate of the data contained in the block
-
getFrequencyRange
public double[] getFrequencyRange()Get the range of frequencies over which the data in the data block are likely to be present. Note that this is pretty crude and may not reflect the true range, for example, the click detector will return the limits of it's trigger filter, and there are plenty of sounds outside of that range which may have most of their energy well outside of the trigger range of the detector.- Returns:
- Nominal frequency range for data in this block.
-
getDurationRange
public double[] getDurationRange()Get the nominal range of durations of sounds that might be detected by this detector (if applicable). This is pretty crude, but will give an indication of which detectors might work with which types of sound.
can return null, 0 and Double.Infinity are also acceptable values.- Returns:
- duration range in seconds of sounds this detector can sensibly detect
-
getDataName
- Returns:
- Name of the data in the block.
-
getLongDataName
Get a slightly longer data name that also contains the module name- Returns:
- longer data name including module name.
-
setSampleRate
public void setSampleRate(float sampleRate, boolean notify) Sets the sample rate for the block (e.g. call this after opening a sound file and reading the sample rate from the file header or after altering sound card settings). All observers of this block (PamProcesses and some views) are notified, they in turn should tell their own output PamDataBlocks about the change.- Parameters:
sampleRate
- The new sample rate in Hz.notify
- set true if Observers should be notified
-
masterClockUpdate
public void masterClockUpdate(long milliSeconds, long clockSample) -
noteNewSettings
public void noteNewSettings()Tell all observers of this datablock that some control parameters have changed. Modified July 09 to make sure it doesn't loop through itself when using threaded observers. -
toString
-
getNaturalLifetime
public int getNaturalLifetime()Get the natural lifetime in seconds- Returns:
- lifetime in seconds
-
setNaturalLifetimeMillis
public void setNaturalLifetimeMillis(int naturalLifetime) Set the natural lifetime in milliseconds- Parameters:
naturalLifetime
-
-
getNaturalLifetimeMillis
public int getNaturalLifetimeMillis()Get the natural lifetime in milliseconds- Returns:
-
setNaturalLifetime
public void setNaturalLifetime(int naturalLifetime) Set the natural lifetime in seconds of the data if there are no observers asking to keep it for longer- Parameters:
naturalLifetime
- in seconds (NOT milliseconds)
-
isLinkGpsData
public boolean isLinkGpsData() -
setLinkGpsData
public void setLinkGpsData(boolean linkGpsData) -
getChannelMap
public int getChannelMap()- Returns:
- Software channel map for the data block.
-
setChannelMap
public void setChannelMap(int channelMap) Set the software channel map for the data block.- Parameters:
channelMap
- channel bitmap
-
getSequenceCount
public int getSequenceCount()Get the number of separate channel sequences in the data. For nearly all data this will be the number of bits in the channel map. For beam formed data, or data derived from beam formed data this will generally be the total number of beams.This should be used to set numbers of display channels, etc.
- Returns:
- number of separate sequences of data in the stream.
-
getHydrophoneMap
public int getHydrophoneMap()There may not be a 1:1 mapping of channels to hydrophones- Returns:
- Hydrophone bit map
-
getDataGain
public double getDataGain(int iChan) Return the gain applied to any data created into this datablock.Example 1: The amplifier module will just return it's gain
Example 2: The FFT module will return the loss due to windowing the data.
To convert to dB use 20*log10(Math.abs(getDataGain()));
- Parameters:
iChan
- channel number- Returns:
- gain as a factor (to allow for negative gains)
-
getCumulativeGain
public double getCumulativeGain(int iChan) Get the total gain of this data block and all upstream datablocks.- Parameters:
iChan
- channel- Returns:
- total gain.
-
setDataName
- Parameters:
dataName
- The dataName to set.
-
getLoggingName
-
getParentProcess
- Returns:
- Returns the parentProcess.
-
setParentProcess
-
getSourceProcess
- Returns:
- Returns the sourceProcess.
-
getRawSourceDataBlock
-
getFirstRawSourceDataBlock
Get the first raw data block in the chain. This is useful for finding decimator datablocks.- Returns:
- the first raw data block in the chain
-
getRawSourceDataBlock2
Tries to find the raw data block source of the current data block. It does this by bouncing back and forth from ParentProcess to ParentDataBlock and back again, until it finds a PamRawDataBlock or either the ParentProcess or the ParentDataBlock is null.- Returns:
- the PamRawDataBlock that serves as the source data, or null if no data block is found
-
addObserver
Description copied from class:PamObservable
Adds a PamObserver, which will then receive notifications when data is added. This is for single thread ops only- Overrides:
addObserver
in classPamObservable
- Parameters:
o
- Reference to the observer
-
addObserver
- Overrides:
addObserver
in classPamObservable
-
getUnitClass
- Returns:
- Class type for the sotred data units in this data block.
-
dispose
public void dispose()clean up datablock when it's no longer needed -
stopTimer
public void stopTimer()Had some issues with the Timer holding a reference to the underlying PamDataBlock (RoccaContourDataBlock, in this case) and not releasing it for garbage collection. Added in this method to force the timer to stop and release it's hold.- Overrides:
stopTimer
in classPamObservable
-
autoSetDataBlockMixMode
public void autoSetDataBlockMixMode() -
getMixedDirection
public int getMixedDirection() -
setMixedDirection
public void setMixedDirection(int mixedDirection) -
getLocalisationContents
Get Information indicating what localisation information might be available for the data in this block. Note that a flag being set here is no guarantee that the data units will have a particular type of localisation data, since localisation may have failed on individual units.- Returns:
- localisation flags
-
setLocalisationContents
public void setLocalisationContents(int localisationContents) Set a bitmap of flags indicating what localisation information might be available for the data in this block. Note that a flag being set here is no guarantee that the data units will have a particular type of localisation data, since localisation may have failed on individual units.- Parameters:
localisationContents
- bitmap of localisation contents
-
addLocalisationContents
public void addLocalisationContents(int localisationContents) Add a single flag indicating what localisation information might be available for the data in this block. Note that a flag being set here is no guarantee that the data units will have a particular type of localisation data, since localisation may have failed on individual units.- Parameters:
localisationContents
- bitmap of localisation contents
-
getLocalisationAlgorithm
Find localisation algorithm for this data. This may be within the owning module, or a downstream algorithm.- Returns:
- first found localisation algorithm or null;
-
getListIterator
Get a list iterator through the data from a given position. the user of the iterator will then have to work out if they go fowards or backwards through the data.- Parameters:
whereFrom
- index in data, or ITERATOR_END (-1) to go to end- Returns:
- iterator through data
-
getListIterator
public ListIterator<Tunit> getListIterator(long startTimeMillis, int channels, int match, int position) Get an iterator, positioned at the given startTime.- Parameters:
channels
- map of channels of interest.match
- match criteria = MATCH_EXACT, MATCH_BEFORE, MATCH_AFTERposition
- where to position the cursor: POSITION_BEFORE, POSITION_AFTERstartTime
- Start time in milliseconds.- Returns:
- a list iterator ...
-
getDataCopy
copy the data using an iterator, positioned at the given startTime.- Parameters:
startTimeMillis
-channels
- map of channels of interest.match
- match criteria = MATCH_EXACT, MATCH_BEFORE, MATCH_AFTERposition
- where to position the cursor: POSITION_BEFORE, POSITION_AFTERstartTime
- Start time in milliseconds.channels
-match
-position
-- Returns:
- temporary copy of the data
-
getListIteratorFromStart
public ListIterator<Tunit> getListIteratorFromStart(long startTime, int channels, int match, int position) Get an iterator, positioned at the given startTime.Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
- Parameters:
startTime
- Start time in milliseconds.channels
- map of channels of interest.match
- match criteria = MATCH_EXACT, MATCH_BEFORE, MATCH_AFTERposition
- where to position the cursor: POSITION_BEFORE, POSITION_AFTER- Returns:
- a list iterator ...
-
getDataCopyFromStart
public ArrayList<Tunit> getDataCopyFromStart(long startTimeMillis, int channels, int match, int position) copy the data using an iterator, positioned at the given startTime.Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
- Parameters:
startTimeMillis
-channels
- map of channels of interest.match
- match criteria = MATCH_EXACT, MATCH_BEFORE, MATCH_AFTERposition
- where to position the cursor: POSITION_BEFORE, POSITION_AFTERstartTime
- Start time in milliseconds.channels
-match
-position
-- Returns:
- temporary copy of the data
-
getListIteratorFromEnd
public ListIterator<Tunit> getListIteratorFromEnd(long startTime, int channels, int match, int position) Get an iterator, positioned at the given startTime.Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
- Parameters:
startTime
- Start time in milliseconds.channels
- map of channels of interest.match
- match criteria = MATCH_EXACT, MATCH_BEFORE, MATCH_AFTERposition
- where to position the cursor: POSITION_BEFORE, POSITION_AFTER- Returns:
- a list iterator ...
-
getDataCopyFromEnd
public ArrayList<Tunit> getDataCopyFromEnd(long startTimeMillis, int channels, int match, int position) copy the data using an iterator, positioned at the given startTime.Note that this method works specifically on the Channel Map. If this data block may have sequence numbers or channels, a new method needs to be created using the getSequenceBitmap call instead of getChannelBitmap.
- Parameters:
startTimeMillis
-channels
- map of channels of interest.match
- match criteria = MATCH_EXACT, MATCH_BEFORE, MATCH_AFTERposition
- where to position the cursor: POSITION_BEFORE, POSITION_AFTERstartTime
- Start time in milliseconds.channels
-match
-position
-- Returns:
- temporary copy of the data
-
dumpBlockContents
public void dumpBlockContents() -
getDataCopy
Get a complete copy of the data. Using this is often safer than using internal iterators to go through the data for plotting, etc., since this copy of the data will not need to be synchronized, so will not cause thread lockouts. Generally copying the array will be faster than doing anything with the data within the array.- Returns:
- temporary complete copy of the data in a new array.
-
getDataCopy
Get a temporary copy of all data between two times (inclusive)- Parameters:
t1
- first timet2
- last timeassumeOrder
- Assume units are in order, so can break as soon as a unit after t2 is reached- Returns:
- temporary copy of the data
-
getDataCopy
public ArrayList<Tunit> getDataCopy(long t1, long t2, boolean assumeOrder, DataSelector dataSelector) Get a temporary copy of all data between two times (inclusive) using a data selector- Parameters:
t1
- first timet2
- last timeassumeOrder
- Assume units are in order, so can break as soon as a unit after t2 is reacheddataSelector
- data selector (can be null)- Returns:
- temporary copy of the data
-
getProcessAnnotations
-
createProcessAnnotations
Copies all annotations over from the source DataBlock, then adds in the new ones from the new datablock.- Parameters:
sourceData
- source DatablocknewAnnotations
- source of new annotations- Returns:
- total number of annotations
-
createProcessAnnotations
public int createProcessAnnotations(PamDataBlock sourceData, ProcessAnnotator newAnnotations, boolean notifyDownstream) Copies all annotations over from the source DataBlock, then adds in the new ones from the new datablock.- Parameters:
sourceData
- source DatablocknewAnnotations
- source of new annotationsnotifydownstream
- notify downstream modules.- Returns:
- total number of annotations
-
findAnnotation
Finds an annotation with the given type and name- Parameters:
type
- annotation typename
- annotation name- Returns:
- annotation object
-
findAnnotation
Finds an annotation with the same type and name as the template annotation- Parameters:
template
- template annotation- Returns:
- annotation object
-
setRecycling
public void setRecycling(boolean recycling) - Parameters:
recycling
- the recycling to set
-
isRecycling
public boolean isRecycling()- Returns:
- the recycling
-
setRecyclingStoreLength
public void setRecyclingStoreLength(int recyclingStoreLength) - Parameters:
recyclingStoreLength
- the recyclingStoreLength to set
-
getRecyclingStoreLength
public int getRecyclingStoreLength()- Returns:
- the recyclingStoreLength
-
notifyModelChanged
public void notifyModelChanged(int changeType) Receive notifications from the main PamController.- Parameters:
changeType
-
-
setBinaryDataSource
- Parameters:
BinaryDataSource
- the BinaryDataSource to set
-
getBinaryDataSource
- Returns:
- the BinaryDataSource
-
setJSONDataSource
Set the data source for exporting as a JSON-formatted string- Parameters:
jsonDataSource
-
-
getJSONDataSource
Get the data source for exporting as a JSON-formatted string- Returns:
-
SetLogging
-
getLogging
-
getTethysDataProvider
Gets a data provider for Tethys. These will probably need to be bespoke, but for now will autogenerate based on the SQLLogging information.- Returns:
- the tethysDataProvider
-
getDataAutomationInfo
Get the level of automation employed by the generation of these data. Should ideally be completed for everything providing data to Tethys.- Returns:
- level of automation for this data block.
-
getDatablockSpeciesManager
Get information about species types that may occur within this data block. Primarily for conversion into Tethys compatible data, but may prove to have other uses.- Returns:
- Types of species information available within this datablock.
-
getCanLog
public final boolean getCanLog() -
getUIDRepairLogging
-
getShouldLog
Should log the data unit to the database ?- Parameters:
pamDataUnit
- dataunit to consider- Returns:
- true if data should be logged.
-
getShouldLog
public boolean getShouldLog()In general, should the data block try to log to the database?- Returns:
- true if data should be logged.
-
setShouldLog
public final void setShouldLog(boolean shouldLog) Set if data should be logged to the database.- Parameters:
shouldLog
- flag to log data.
-
getShouldBinary
Get flag to say whether data should be stored in the binary store- Parameters:
pamDataUnit
- data unit- Returns:
- true if the data unit shoule be saved.
-
setShouldBinary
public void setShouldBinary(boolean shouldBinary) Set flag to say if data should be stored in the binary store.- Parameters:
shouldBinary
- flag to say data shoule be stored.
-
addOfflineDataMap
Adds a new offline datamap to the data blockNote that there may be several maps from different types of storage (although only one should have anything in it in a sensible world).
It's also possible that these will be recreated during a run, and we don't want two of the same type in the same datablock, so check that there isn't already one and remove it
- Parameters:
offlineDataMap
-
-
getNumOfflineDataMaps
public int getNumOfflineDataMaps()- Returns:
- the number of different offline data maps
-
getOfflineDataMap
- Parameters:
iMap
- index of map (see getNumOfflineDataMaps)- Returns:
- an OfflineDataMap from that index in the list.
-
getOfflineDataMap
- Parameters:
dataSource
- an offline data source (e.g. binaray storage, database storage, etc.- Returns:
- the offline data map for a specific OfflineDataSource or null
-
getPrimaryDataMap
New plan - always use the binary store if it has any data at all. If the binary store doesn't exist or is empty, only then use the database.- Returns:
- a data map
-
getDatagrammedMap
Get a data map which has a datagram- Returns:
-
removeOfflineDataMap
remove a no longer needed offline data map.- Parameters:
dataSource
- data source (e.g. binary, database, raw data, etc.
-
getSaveRequirements
Work out some basic information about the elements that need saving from these data.- Parameters:
dataStore
- data source that want's to save the data.- Returns:
- an object of information
-
orderOfflineData
public void orderOfflineData(PamObserver dataObserver, LoadObserver loadObserver, long startMillis, long endMillis, int loadKeepLayers, int interrupt) Similar functionality to getOfflineData, but this will launch a separate worker thread to do the actual work getting the data. The worker thread will call getOfflineData.getOfflineData will probably (if not overridden) be sending data to the update member function of the observer, but from the worker thread. Once it's complete, it will send a message to say that data are loaded.
It's possible that the user will do something which causes this to be called again before the previous thread completed execution, in which case there are three options:
OFFLINE_DATA_INTERRUPT - previous thread will be terminated
OFFLINE_DATA_WAIT - wait for previous thread to terminate, then start this load
OFFLINE_DATA_CANCEL - give up and return
- Parameters:
dataObserver
- observer of the loaded dataloadObserver
- observer to get status information on the load.startMillis
- data start time in millisecondsendMillis
- data end time in milliseconds.loadKeepLayers
- number of layers of data to keep in the datablocks.interrupt
- interrupt options.
-
orderOfflineData
Similar functionality to getOfflineData, but this will launch a separate worker thread to do the actual work getting the data. The worker thread will call getOfflineData.getOfflineData will probably (if not overridden) be sending data to the update member function of the observer, but from the worker thread. Once it's complete, it will send a message to say that data are loaded.
It's possible that the user will do something which causes this to be called again before the previous thread completed execution, in which case there are three options:
OFFLINE_DATA_INTERRUPT - previous thread will be terminated
OFFLINE_DATA_WAIT - wait for previous thread to terminate, then start this load
OFFLINE_DATA_CANCEL - give up and return
- Parameters:
offlineDataLoadInfo
- objerct whihc contains all info needed to load data.
-
orderOfflineData
public void orderOfflineData(PamObserver dataObserver, LoadObserver loadObserver, long startMillis, long endMillis, int loadKeepLayers, int interrupt, boolean allowRepeats) Similar functionality to getOfflineData, but this will launch a separate worker thread to do the actual work getting the data. The worker thread will call getOfflineData.getOfflineData will probably (if not overridden) be sending data to the update member function of the observer, but from the worker thread. Once it's complete, it will send a message to say that data are loaded.
It's possible that the user will do something which causes this to be called again before the previous thread completed execution, in which case there are three options:
OFFLINE_DATA_INTERRUPT - previous thread will be terminated
OFFLINE_DATA_WAIT - wait for previous thread to terminate, then start this load
OFFLINE_DATA_CANCEL - give up and return
- Parameters:
dataObserver
- observer of the loaded dataloadObserver
- observer to get status information on the load.startMillis
- data start time in millisecondsendMillis
- data end time in milliseconds.loadKeepLayers
- Number of layers of datablock which should hang on to loaded data rather than delete it immediately.interrupt
- interrupt options.allowRepeats
- allow repeated loads of exactly the same data.
-
getOfflineData
Gets data for offline display, playback, etc.This is used to get data from some upstream process which is quite different to the function loadViewerData(...) which loads data directly associated with this data block.
For example, this might be called in the FFT data block by the spectrogram which wants some data to display. The FFT data block does not have this data, so it passes the request up to it's process which will in turn pass the request on until it reaches a module which is capable of loading data into data units and sending them back down the line.
- Parameters:
observer
- data observer which will receive the datacancellationObject
-
-
cancelDataOrder
public void cancelDataOrder()Cancel the current offline data order -
cancelDataOrder
public void cancelDataOrder(boolean quedItems) Cancel the current offline data order- Parameters:
quedItems
- - true to cancel all low priority threads in the wait que
-
clearDeletedList
public void clearDeletedList() -
getNextDataStart
public long getNextDataStart(long timeMillis) Get the next data start point. i.e. the time of the start of a map point which is > timeMillis- Parameters:
timeMillis
- current time in milliseconds- Returns:
- start time of the next data start.
-
getPrevDataEnd
public long getPrevDataEnd(long timeMillis) Get the previous data end point. i.e. the time of the end of a map point which is invalid input: '<' timeMillis- Parameters:
timeMillis
- current time in milliseconds- Returns:
- start time of the next data start.
-
setDatagramProvider
-
getDatagramProvider
-
isCanClipGenerate
public boolean isCanClipGenerate()- Returns:
- the canClipGenerate
-
setCanClipGenerate
public void setCanClipGenerate(boolean canClipGenerate) - Parameters:
canClipGenerate
- the canClipGenerate to set
-
getQuickId
public int getQuickId()Quick integer datablock id which is based on the dataname- Returns:
-
getQuickId2
public int getQuickId2()Make a better quickId that is more resilient to changes at any point in the string, i.e. checksum all four bytes.- Returns:
- and integer made up of exclusive OR's of all bytes making up the long data name
-
sortData
public void sortData()Sorts all the data units in the data block in order of time (unless a a data unit class chooses to overwrite the compareTo function. -
setRecordingTrigger
-
getRecordingTrigger
-
getChannelIterator
Get an iterator which can iterator through only data units with data from particular channels in a databock.In viewer mode, channel iterators are saved for reuse but will be deleted / cleared if data are removed or added to the datablock to avoid concurrency exceptions.
- Parameters:
channelMap
- channel mapwhereFrom
- 0, start at start,- Returns:
- a channel iterator
-
getSequenceIterator
Get an iterator which can iterator through only data units with data from particular sequence numbers in a databock. Note that if the sequenceMap == null, this will simply default to the channelMap (but will still be classed as a SequenceIterator)In viewer mode, sequence iterators are saved for reuse but will be deleted / cleared if data are removed or added to the datablock to avoid concurrency exceptions.
- Parameters:
sequenceMap
- sequence mapwhereFrom
- 0, start at start,- Returns:
- a sequence iterator
-
clearChannelIterators
public void clearChannelIterators()Clears list of both channel and sequence iterators -
getChannelIteratorCount
public int getChannelIteratorCount()Get the number of stored channel/sequence iterators for a datablock.- Returns:
- the number of channel invalid input: '&' sequence iterators currently associated with this data block.
-
isClearAtStart
public boolean isClearAtStart()Flag to say that data should be cleared every time PAMGuard starts. Is true by default, but some modules may want to set this false for some streams.- Returns:
- the clearAtStart
-
setClearAtStart
public void setClearAtStart(boolean clearAtStart) Flag to say that data should be cleared every time PAMGuard starts. Is true by default, but some modules may want to set this false for some streams.- Parameters:
clearAtStart
- the clearAtStart to set
-
setDataSelectCreator
-
getDataSelectCreator
- Returns:
- an object that can create data selectors to sub select data from within this type of data block.
-
getDataSelector
Convenience method to save programmer from having to call into the creator all the time.- Parameters:
selectorName
-allowScores
-- Returns:
- null or a DataSelector
-
getDataSelector
Convenience method to save programmer from having to call into the creator all the time.- Parameters:
selectorName
-allowScores
-selectorType
- Type of selector, generally a ModuleType name, e.g. Map, so that options can be tailored to specific needs- Returns:
- null or a DataSelector
-
getDataSelector
public DataSelector getDataSelector(String selectorName, boolean allowScores, String selectorType, boolean includeAnnotations, boolean includeSuperDetections) Convenience method to save programmer from having to call into the creator all the time.- Parameters:
selectorName
-allowScores
-selectorType
- Type of selector, generally a ModuleType name, e.g. Map, so that options can be tailored to specific needsincludeAnnotations
- include options from any annotators of this data streamincludeSuperDetections
- include any possible super detection data selectors.- Returns:
- null or a DataSelector
-
getCrossReferenceInformation
Get any information from the data block about cross referencing in database tables.This gets used when importing databases, whereby Id's will change, so may need to be rewritten in related tables. Does not (currently) handle issues with UID's.
- Returns:
- null or cross reference information.
-
getNanoTimeCalculator
- Returns:
- the nanoTimeCalculator
-
setNanoTimeCalculator
- Parameters:
nanoTimeCalculator
- the nanoTimeCalculator to set
-
getUidHandler
- Returns:
- the uidHandler
-
setUidHandler
Set the UID handler - very occasionally it's necessary to set this to null.- Parameters:
uidHandler
-
-
getAnnotationHandler
- Returns:
- the annotationHandler
-
addDataAnnotationType
Keep for backwards compatibility- Parameters:
annotationType
-
-
setAnnotationHandler
- Parameters:
annotationHandler
- the annotationHandler to set
-
getPamSymbolManager
- Returns:
- aSymbol Manager which manages all symbol shapes and colours for this data block.
-
setPamSymbolManager
- Parameters:
pamSymbolManager
- the pamSymbolManager to set
-
checkOfflineDataUIDs
public void checkOfflineDataUIDs()Check offline datablock UID's, taking the maximum uid from all available data maps. -
getSequenceMap
public int getSequenceMap()As described in dataunit, this is a slightly different map to channelmap to be used when beamforming, where the map of available outputs may be quite different to the number of available input channels.e.g. if a beam former had 4 input channels and made 6 beams then thechannelMap would be 0xF, but the sequenceMap would be 0x3F.
Always defaults to the channel map if it's not been set.
- Returns:
- the sequenceMap
-
setSequenceMap
As described in dataunit, this is a slightly different map to channelmap to be used when beamforming, where the map of available outputs may be quite different to the number of available input channels.e.g. if a beam former had 4 input channels and made 6 beams then thechannelMap would be 0xF, but the sequenceMap would be 0x3F.
- Parameters:
sequenceMap
- the sequenceMap to set
-
getSequenceMapObject
As described in dataunit, this is a slightly different map to channelmap to be used when beamforming, where the map of available outputs may be quite different to the number of available input channels.e.g. if a beam former had 4 input channels and made 6 beams then thechannelMap would be 0xF, but the sequenceMap would be 0x3F.
As opposed to the getSequenceMap method, this method will return the sequenceMap object even if it is null
- Returns:
-
sortOutputMaps
This method will sort out this PamDataBlock's channel map and sequence map, depending on the source PamDataBlock that it's getting it's information from. It should typically be called when created, especially if the channel/sequence information is a subset of the source data block (such as when selected in a GroupSourcePanel object).
There are 3 passed parameters: the source channel map, the source sequence map, and the subset map that this data block should reference. The local subset map may be the same as the source channel/sequence map, or it may only be a few of the source's channels or sequences.
If the source data block has no sequence map (sourceSeqMap==null) then it's a normal FFT data block, and this PamDataBlock should be storing the local subset map in it's channelMap field and keeping it's sequenceMap field = null.
If the source data block does have a sequence map (i.e. the source is the output of a Beamformer), then this PamDataBlock should be storing the local subset map in it's sequenceMap field and storing the source channel map in it's channelMap field.- Parameters:
sourceChanMap
-sourceSeqMap
-localSubsetMap
-
-
getChannelsForSequenceMap
public int getChannelsForSequenceMap(int sequenceMap) Given a sequenceMap, this method returns the associated channelMap. By default, this simply returns passed parameter. For the majority of the PamDataBlocks this is correct because there won't be a sequenceMap. This method should be used when the calling function is given a channel but it does not know whether that is truly a channel, or actually a sequence number. It can pass the channel to this method; if the PamDataBlock doesn't have sequence numbers then the number really was a channel and the calling function will get the same number returned.This method MUST BE OVERRIDDEN in any module that actually uses sequences (e.g. the Beamformer module) to properly map the sequenceMap to the channelMap.
- Parameters:
sequenceMap
-- Returns:
- the associated channelMap
-
getARealChannel
public int getARealChannel(int chanOrSeqNum) There are times when a module doesn't know whether the channel it is using is really a channel, or whether it is actually a sequence number. In such a case, this method should be called on the source data block, and the channel/sequence number in question should be passed to it. If there is no sequenceMap, the variable passed into this method really is a channel and it is simply passed back. If there is a sequenceMap, however, then the value passed back will be the lowest channel in the channelMap.- Parameters:
chanOrSeqNum
- The channel or sequence number in question- Returns:
- an actual channel number
-
getTOADCalculator
- Returns:
- A calculator for Time of Arrival Difference Calculations
-
getFirstViewerUID
public long getFirstViewerUID()- Returns:
- the firstViewerUID
-
getLastViewerUID
public long getLastViewerUID()- Returns:
- the lastViewerUID
-
getSynchLock
The synchronisation lock is a synchronisation object that must be used to synch all iterators using the data unit list and any function that puts data into or out of them. 99% of the time it is set to be a reference to the data block (this) but just occasionally it may be necessary to set it to something else. It must never be null.- Returns:
- the synchronisation lock
-
setSynchLock
The synchronisation lock is a synchronisation object that must be used to synch all iterators using the data unit list and any function that puts data into or out of them. 99% of the time it is set to be a reference to the data block (this) but just occasionally it may be necessary to set it to something else. It must never be null.- Parameters:
synchronizationLock
- the synchronisation lock to set
-
getSuperDetectionClass
- Returns:
- the superDetectionClass
-
copyDataList
Make a soft copy of all of the data in the datablock. Note that this doesn't copy ANY of the data, just the references into a new list. This can be used when there is an operation running in a separate thread which is going to take a long time to get through all the data and can't handle the data list updating, but at the same time can't lock the list for the amount of time it may need to operator on the data.- Returns:
- Array list copy of all data units.
-
getBespokeDataMapGraphic
-
getMyDataUnits
From a whole load of data units, e.g. as selected by a mark on a display, get a list of the ones that belong just to this data block.- Parameters:
randomDataUnits
- data units which may be of any type- Returns:
- list of input units that belong to this data block.
-
getUniqueParentList
Get a list of unique super detections for a load of data units- Parameters:
pamDataUnits
- list of data units.- Returns:
- list of unique parents.
-
isOffline
public boolean isOffline()- Returns:
- the isOffline
-
getBackgroundManager
- Returns:
- the backgroundManager
-
setBackgroundManager
- Parameters:
backgroundManager
- the backgroundManager to set
-
getDataBlockXML
Get a brief summary of datablock to include in XML descriptions. Basic output is very simple. Expect other datablock to extend this by adding additional attributes.- Parameters:
doc
-- Returns:
- XML element with description of data.
-
dumpBufferStatus
Look in every data block, particularly threaded ones, and dump the buffer status. This will have to go via PamProcess so that additional information can be added from any processes that hold additional data in other internal buffers.- Parameters:
message
- Message to print prior to dumping buffers for debug.sayEmpties
- dump info even if a buffer is empty (otherwise, only ones that have stuff still)
-
getEffortProvider
- Returns:
- the effort provider.
-
autoEffortProvider
Auto generate an effort provider. This may get called many times for blocks without effort, but that doesn't really matter since its only going to happen when opening dialogs, etc.- Returns:
-
pamStart
public void pamStart(long startTime) Need this notification at startup time to perform a few standard actions.- Parameters:
startTime
-
-
pamStop
public void pamStop(long stopTime) Need this notification at stop time to perform a few standard actions.- Parameters:
startTime
-
-