Class BinaryDataSource

java.lang.Object
binaryFileStorage.BinaryDataSource
Direct Known Subclasses:
AISBinaryDataSource, ClickBinaryDataSource, ClipBinaryDataSource, CPODBinaryStore, DaqStatusBinaryStore, DbHtDataSource, DifarBinaryDataSource, DLDetectionBinarySource, DLResultBinarySource, FormsBinaryIO, GPLBinaryDataSource, GPLStateDataSource, GPSBinaryDataSource, IshBinaryDataSource, IshFnBinarySource, LtsaBinaryDataSource, NoiseBinaryDataSource, OneBandDataSource, RawDataBinaryDataSource, RWEBinaryDataSource, TriggerBackgroundBinarySource, WhistleBinaryDataSource

public abstract class BinaryDataSource extends Object
Not just a source, but also a sink for binary data from the binary store. Every BinaryDataSource is tied to a single PamDataBlock
Author:
Doug Gillespie
See Also:
  • Field Details

    • packSynchObject

      public static final Object packSynchObject
  • Constructor Details

    • BinaryDataSource

      public BinaryDataSource(PamDataBlock sisterDataBlock)
      Create a binary data source. These are used both to store data in binary files, and possibly also to send data to other PAMguard instances over the network.
      Parameters:
      sisterDataBlock - dataBlock for data to store / send
    • BinaryDataSource

      public BinaryDataSource(PamDataBlock sisterDataBlock, boolean doBinaryStore)
      Create a binary data source. These are used both to store data in binary files, and possibly also to send data to other PAMguard instances over the network.
      Parameters:
      sisterDataBlock - dataBlock for data to store / send
      doBinaryStore - true if data to be stored by default, false otherwise.
  • Method Details

    • getModuleType

      public String getModuleType()
      Returns:
      Module type to be stored in the file header
    • getModuleName

      public String getModuleName()
      Returns:
      Module name to be stored in the file header
    • getStreamName

      public abstract String getStreamName()
      Returns:
      Stream name to be stored in the file header
    • getStreamVersion

      public abstract int getStreamVersion()
      Returns:
      Stream version name to be stored in the Module Specific Control structure
    • getModuleVersion

      public abstract int getModuleVersion()
      Get a version number for the module.

      This is different to the version number in the main file header and allows individual modules to update their format and maintain backwards compatibility with old data

      Returns:
      integer module version number
    • getModuleHeaderData

      public abstract byte[] getModuleHeaderData()
      Returns:
      Additional information (e.g. a control structure for a detector) to be stored in the Module Specific Control structure
    • getModuleFooterData

      public byte[] getModuleFooterData()
      Returns:
      data for the binary footer, or null.
    • sinkData

      public abstract PamDataUnit sinkData(BinaryObjectData binaryObjectData, BinaryHeader bh, int moduleVersion)
      Convert data read back in in viewer mode into the correct type of PamDataUnit.

      DO NOT add this unit directly to the datablock, but pass it back to the calling process which will add it to the datablock if necessary.

      Parameters:
      binaryObjectData - Binary data read back from a file.
      bh - binary header from start of file.
      moduleVersion -
      Returns:
      the PamDataUnit created from these data
    • sinkModuleHeader

      public abstract ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData, BinaryHeader bh)
      Do something with module header information
      Parameters:
      binaryObjectData - data for the module header.
      bh - Binary header information
    • sinkModuleFooter

      public abstract ModuleFooter sinkModuleFooter(BinaryObjectData binaryObjectData, BinaryHeader bh, ModuleHeader moduleHeader)
      Do something with module footer information
      Parameters:
      binaryObjectData - data for the module header.
      bh - Binary header information
    • setBinaryStorageStream

      public void setBinaryStorageStream(BinaryOutputStream binaryStorageStream)
      Parameters:
      binaryStorageStream - the binaryStorageStream to set
    • getBinaryStorageStream

      public BinaryOutputStream getBinaryStorageStream()
      Returns:
      the binaryStorageStream
    • createFilenamePrefix

      public String createFilenamePrefix()
      Creates the prefix for the binary store file names. Moved from the BinaryOutputStream class and changed to a public method so that it could be called by the binaryUIDFunctions object when searching for specific files
      Returns:
    • saveData

      public final boolean saveData(PamDataUnit pamDataUnit)
      Save new data into the binary stream
      Parameters:
      pamDataUnit -
    • getPackedData

      public abstract BinaryObjectData getPackedData(PamDataUnit pamDataUnit)
      Get packed binary data for either sending to file or over the network
      Parameters:
      pamDataUnit - data unit to pack
      Returns:
      packed binary data object
    • getSisterDataBlock

      public PamDataBlock getSisterDataBlock()
    • newFileOpened

      public abstract void newFileOpened(File outputFile)
      Called from the BinaryOutputStream whenever a new output file is opened.
      Parameters:
      outputFile - file information.
    • getSpecialDrawing

      public DataMapDrawing getSpecialDrawing()
      REturn a class capable of overriding the normal drawing on the data map
      Returns:
      null if nothign exists.
    • setDoBinaryStore

      public void setDoBinaryStore(boolean doBinaryStore)
      Parameters:
      doBinaryStore - the doBinaryStore to set This flag tells the binary store that this unit is available for binary storage. It's used mostly in raw data blocks which use this same class to write to a network socket but have the ability to wrote to the binary store disabled.
    • isDoBinaryStore

      public boolean isDoBinaryStore()
      Returns:
      the doBinaryStore
    • reset

      public void reset()
      Reset anything needing resetting in the binary data source. This get's called just before PamStart().
    • isStoreData

      public boolean isStoreData()
      Flag to say we want to actually store the data.
      Returns:
      the storeData
    • setStoreData

      public void setStoreData(boolean storeData)
      Flag to say we want to actually store the data.
      Parameters:
      storeData - the storeData to set
    • isSaveUpdates

      public boolean isSaveUpdates()
      Flag to say that updates should also be stored. this will cause a second record to be written to the binary file, so default response is false.
      Returns:
      the saveUpdates
    • setSaveUpdates

      public void setSaveUpdates(boolean saveUpdates)
      Flag to say that updates should also be stored. this will cause a second record to be written to the binary file, so default response is false.
      Parameters:
      saveUpdates - the saveUpdates to set
    • getBackgroundBinaryWriter

      public BackgroundBinaryWriter getBackgroundBinaryWriter()
      Returns:
      the backgroundBinaryWriter