Package tritechgemini.fileio
Class GeminiFileCatalog<RecordClass extends SonarImageRecordI>
java.lang.Object
tritechgemini.fileio.GeminiFileCatalog<RecordClass>
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ARISFileCatalog,ECDFileCatalog,GLFFileCatalog
public abstract class GeminiFileCatalog<RecordClass extends SonarImageRecordI>
extends Object
implements Serializable
Catalogue of information that's in a single Sonar data file.
Named when we only supported Tritech GLF and ECD formats, but should also be the base class for any other sonar data catalogues.
These objects are serialized into index files for each data file so don't add anything that can't be serialized.
Named when we only supported Tritech GLF and ECD formats, but should also be the base class for any other sonar data catalogues.
These objects are serialized into index files for each data file so don't add anything that can't be serialized.
- Author:
- Doug Gillespie
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidGet the number of sonars, their id's and types, etc.abstract booleanbuildCatalogue(ArrayList<RecordClass> imageRecords) Catalogue the file.static longcDateToMillis(double cDate) protected abstract voidcheckDeserialisedCatalog(String filePath2) Called just after a catalogue object has been deserialised, giving the opportunity to check anything.booleanCatalogue the file.findRecordForIDandTime(int sonarID, long timeMillis) find the closest record to the given time for the sonar IDfindRecordForIndexandTime(int sonarIndex, long timeMillis) find the closest record to the given time for the sonar IndexintfindRecordIndex(long recordTime) Find the index of the closest record to the given time.findRelativeRecord(SonarImageRecordI baseRecord, int recordOffset) Used when scrolling by record number.voidvoidfreeImageData(long currentTime, long timeWinMillis) Free image data from all records, but with a window around the time of interest which gets kept.static StringgetCatalogName(String dataFileName) Get a name for a serialized catalog file.static GeminiFileCataloggetFileCatalog(String filePath, boolean create) Preferred way of getting a file catalogue, since it will automatically handle ECD, GLF and DAT files.longGet the time of the first recordgetFullRecord(int recordIndex) Get a record at given index, loading full data if required.longGet the time of the last recordintintintGet the number of sonars in the catalogue.getRecord(int recordIndex) Get a record.getRecordByIndex(int index) Get record for given index.intgetRecordIndex(SonarRecordI currentRecord) int[]Get the ID's of the sonars in this catalogue.getSonarInfo(int sonarID) Get the summary info for a single sonar.getSonarRecord(int sonarID, int sonarRecord) Get a record for a specified sonarstatic TimeZoneabstract booleanloadFullRecord(RecordClass geminiRecord) fully load a record (if it isn't already).static GeminiFileCatalogreadSerializedCatalog(String filePath) Read a Gemini file catalogue record for the given data fileprotected voidsetImageRecords(ArrayList<RecordClass> imageRecords) static voidsetTimeZone(TimeZone timeZone) abstract voidStop streaming the catalog.abstract CatalogStreamSummarystreamCatalog(CatalogStreamObserver streamObserver) Start a full forwards only read of the catalog from start to end, sending all records through to the streamObserver.booleantimedLoadFullRecord(RecordClass aRecord) static booleanwriteSerializedCatalog(String filePath, GeminiFileCatalog fileCatalog) Write a Gemini file Catalogue
-
Field Details
-
ECDEND
- See Also:
-
GLFEND
- See Also:
-
DATEND
- See Also:
-
ARISEND
- See Also:
-
-
Constructor Details
-
GeminiFileCatalog
-
-
Method Details
-
getFileCatalog
public static GeminiFileCatalog getFileCatalog(String filePath, boolean create) throws CatalogException Preferred way of getting a file catalogue, since it will automatically handle ECD, GLF and DAT files.- Parameters:
filePath-create- build the catalogue for the file immediately.- Returns:
- file catalogue of null if the file doesn't exist or is an unknown type.
- Throws:
CatalogException- if file is null or there is a failure cataloguing it.
-
checkDeserialisedCatalog
Called just after a catalogue object has been deserialised, giving the opportunity to check anything. note that the file path is set elsewhere to allow for the possibility that the absolute path to the file may have changed, so it's probably not necessary to do anything here.- Parameters:
filePath2-
-
readSerializedCatalog
Read a Gemini file catalogue record for the given data file- Parameters:
filePath- path of data (ecd or glf) file- Returns:
- catalog information read from file.
-
writeSerializedCatalog
Write a Gemini file Catalogue- Parameters:
filePath- path of data file (.ecd or .glf)fileCatalog- file catalogue to write- Returns:
- true if successful write.
-
getCatalogName
Get a name for a serialized catalog file. this is just the normal file name with .x on the end.- Parameters:
dataFileName- Data file name.- Returns:
- name of catalog file.
-
buildCatalogue
Catalogue the file. i.e. go through the file and get the times and file positions of every record in the file.- Parameters:
imageRecords-- Returns:
- true if catalog created successfully
- Throws:
Exception
-
createCatalogue
public boolean createCatalogue()Catalogue the file. i.e. go through the file and get the times and file positions of every record in the file.- Returns:
- true if catalog created successfully
-
analyseCatalog
protected void analyseCatalog()Get the number of sonars, their id's and types, etc. -
getFilePath
-
getCatalogException
-
loadFullRecord
fully load a record (if it isn't already). This may involve going back to the file and getting and unpacking the raw data.- Parameters:
geminiRecord-- Returns:
- true if load sucessful.
- Throws:
IOException
-
streamCatalog
public abstract CatalogStreamSummary streamCatalog(CatalogStreamObserver streamObserver) throws CatalogException Start a full forwards only read of the catalog from start to end, sending all records through to the streamObserver.Whatever calls this will almost definitely want to do so in a separate worker thread because the call will block until the read has finished.
- Parameters:
streamObserver- observer to get catalog data.- Returns:
- number of records read.
- Throws:
CatalogException
-
stopCatalogStream
public abstract void stopCatalogStream()Stop streaming the catalog. -
getFirstRecordTime
public long getFirstRecordTime()Get the time of the first record- Returns:
- the time of the first record
-
getLastRecordTime
public long getLastRecordTime()Get the time of the last record- Returns:
- the time of the first record
-
getNumRecords
public int getNumRecords()- Returns:
- total number of records in the file
-
findRecordIndex
public int findRecordIndex(long recordTime) Find the index of the closest record to the given time.- Parameters:
recordTime-- Returns:
- index of closest record to given time.
-
getRecord
Get a record. Note that this does NOT automatically fully load the record. Also note, that this is an overall index and you might be better off using the getSonarRecord functions- Parameters:
recordIndex-- Returns:
- Gemini record.
-
getSonarRecord
Get a record for a specified sonar- Parameters:
sonarID-sonarRecord-- Returns:
-
getFullRecord
Get a record at given index, loading full data if required.- Parameters:
recordIndex-- Returns:
- fully loaded record.
- Throws:
IOException
-
cDateToMillis
public static long cDateToMillis(double cDate) -
getNumSonars
public int getNumSonars()Get the number of sonars in the catalogue.- Returns:
- number of sonars in the catalogue.
-
getMaxSonarFrames
public int getMaxSonarFrames()- Returns:
- The maximum number of frames for any single sonar
-
getSonarInfo
Get the summary info for a single sonar.- Parameters:
sonarID-- Returns:
- summary info for a single conar.
-
getSonarIDs
public int[] getSonarIDs()Get the ID's of the sonars in this catalogue.- Returns:
- array of IDs (these are the things written on the sonar, not their indexes)
-
findRecordForIDandTime
find the closest record to the given time for the sonar ID- Parameters:
sonarID- sonar IDtimeMillis- time in milliseconds- Returns:
- closest record or null
-
findRelativeRecord
Used when scrolling by record number. Allows to take the current time, then move by a small number of records forwards or backwards.- Parameters:
sonarID-timeMillis-recordOffest-- Returns:
- relative image record in list.
-
getRecordIndex
-
getRecordByIndex
Get record for given index.- Parameters:
index-- Returns:
- record index (or -1 if not found)
-
timedLoadFullRecord
- Throws:
IOException
-
findRecordForIndexandTime
find the closest record to the given time for the sonar Index- Parameters:
sonarIndex- sonar Index (1, 2, 3 ...)timeMillis- time in milliseconds- Returns:
- closest record or null
-
freeAllImageData
public void freeAllImageData() -
getTimeZone
- Returns:
- the timeZone
-
setTimeZone
- Parameters:
timeZone- the timeZone to set
-
freeImageData
public void freeImageData(long currentTime, long timeWinMillis) Free image data from all records, but with a window around the time of interest which gets kept.- Parameters:
currentTime- current time (in Viewer ?)timeWinMillis- time window about current time.
-
getImageRecords
- Returns:
- the imageRecords
-
setImageRecords
- Parameters:
imageRecords- the imageRecords to set
-