Class TLcdASTERIXLiveDecoder

java.lang.Object
com.luciad.format.asterix.ALcdASTERIXDecoder
com.luciad.format.asterix.TLcdASTERIXLiveDecoder
All Implemented Interfaces:
Closeable, AutoCloseable

public class TLcdASTERIXLiveDecoder extends ALcdASTERIXDecoder implements Closeable
This decoder reads ASTERIX data from a live stream, and updates a given TLcdModelList with it. For each encountered category/ UAP/datatype combination, a new sub ILcdModel is added to the TLcdModelList. The datatype can either be tracks, plots or ILcdDataObject for radars or service messages.

The current implementation of TLcdASTERIXLiveDecoder will add tracks, plots or ILcdDataObject for radars or service messages to the sub models. The domain object depends on the incoming messages. Messages without ID's will be generated as plots, other messages will be generated as tracks, radars or service messages.

Sub-models containing trajectory data will have a track model descriptor, sub-models containing plots will have a plot model descriptor, sub-models containing a radar will have a TLcdASTERIXRadarVideoModelDescriptor, while sub-models containing service messages will have a TLcdASTERIXRadarServiceMessageModelDescriptor.

Whenever this decoder adds a sub model to the given TLcdModelList, it takes a write lock on the TLcdModelList (see TLcdLockUtil). Whenever it makes a modification to one of the elements of a sub model, it takes a lock on the sub model. Users of the live decoder should also take the appropriate read (or write) locks to avoid threading problems.

This decoder can also be used to replay recorded ASTERIX data, provided it is in the ASTERIX Final format or the PCAP format. The input stream given to the decodeSFCT(InputStream, int, ILcdModelContainer) decodeSFCT} or initDecode methods should be a TLcdASTERIXFinalReplayInputStream to achieve this. The format of the stream needs to be explicitly specified to the replay stream if not ASTERIX final (e.g PCAP).

Supported versions

See Also:
  • Constructor Details

    • TLcdASTERIXLiveDecoder

      public TLcdASTERIXLiveDecoder()
  • Method Details

    • setHistoryLength

      public void setHistoryLength(int aHistoryLength)
      Sets the history length to the given length. This will limit the amount of points in the history to the given length. For example, if the history length is set to five, the TLcdASTERIXTrajectorys preserve only the last five track locations.

      For some ASTERIX categories (e.g. Category 240) no history is kept, as such this parameter will have no effect.

      Parameters:
      aHistoryLength - The maximum amount of points that are be kept in the history.
    • getHistoryLength

      public int getHistoryLength()
      Returns the history length. Please refer to setHistoryLength(int) for details.
      Returns:
      the history length.
      See Also:
    • decodeSFCT

      public void decodeSFCT(InputStream aStream, int aFireEventMode, ILcdModelContainer aModelSFCT) throws IOException
      Modifies the given ILcdModelContainer to contain new blocks of ASTERIX data that are read from the given InputStream. For each data block, the applicable model in the model container is updated or created if it does not yet exists. This method does not return until all data is read. To stop the decoding process, use Thread.interrupt(). Because this method does not return until all data is handled, it is advised to call it from a dedicated thread.
      Parameters:
      aStream - The stream to read data blocks from.
      aFireEventMode - One of ILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT. It allows to specify when and if any model events need to be fired when the model container and its models are changed by this decoder. If FIRE_NOW is used, changes are immediately propagated after each decoded data block, and the user of this method does not need to do anything else. If FIRE_LATER is used, the events are collected. It is then up to the user of this method to fire those collected changes once in a while using ILcdModel.fireCollectedModelChanges() on aModelSFCT. If NO_EVENT is used, no events are collected nor fired.
      aModelSFCT - The model to modify.
      Throws:
      IOException - In case of I/O failure.
    • initDecode

      public void initDecode(InputStream aInputStream)
      Prepares this decoder to read live ASTERIX data from the given InputStream.

      This method may only be called once. If this method is called, you need to call decodeBlockSFCT to decode the live data block by block. You should not use the decodeSFCT method anymore after calling this method.

      If you are finished with the live decoder, you should call the close() method.

      Parameters:
      aInputStream - The InputStream from which decodeBlockSFCT should read the live data.
      See Also:
    • decodeBlockSFCT

      public void decodeBlockSFCT(int aFireEventMode, ILcdModelContainer aModelSFCT) throws IOException
      Reads a single ASTERIX block from the InputStream that was given to initDecode(java.io.InputStream).

      initDecode should have been called once before calling this method.

      Parameters:
      aFireEventMode - One of ILcdModel.FIRE_NOW, ILcdModel.FIRE_LATER or ILcdModel.NO_EVENT. It allows to specify when and if any model events need to be fired when the model is changed by this decoder. If FIRE_NOW is used, changes are immediately propagated, and the user of this method does not need to do anything else. If for example FIRE_LATER is used, the events are collected. It is than up the the user of this method to fire those collected changes once in a while using ILcdModel.fireCollectedModelChanges() on aModelSFCT.
      aModelSFCT - The model to modify.
      Throws:
      EOFException - when no more live data can be received.
      IOException - In case of I/O failure.
      See Also:
    • blockAvailable

      public boolean blockAvailable() throws IOException
      Returns true if the next ASTERIX block can be read without blocking on I/O. This method is useful when you don't want your UI thread (for instance, the AWT Event Dispatch Thread) to be blocked on the InputStream.
      Returns:
      true if the next ASTERIX block can be read without blocking on I/O. false otherwise.
      Throws:
      IOException - In case of an I/O exception.
    • close

      public void close() throws IOException
      Closes this live decoder, signaling decodeBlockSFCT(int, com.luciad.model.ILcdModelContainer) will not be called anymore.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - If there is an I/O error while closing the live decoder.