Class TLcdASTERIXLiveModelDecoder

java.lang.Object
com.luciad.format.asterix.ALcdASTERIXDecoder
com.luciad.format.asterix.TLcdASTERIXLiveModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder

@LcdService(service=ILcdModelDecoder.class, priority=20000) public final class TLcdASTERIXLiveModelDecoder extends ALcdASTERIXDecoder implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This decoder reads live ASTERIX data from an InputStream and represents it in a ILcdModelContainer. For each of the specified categories/ UAP/datatype combination, a new sub ILcdModel is added to the ILcdModelContainer. The datatype can either be trajectories, plots or weather pictures.

This class offers the functionality of the TLcdASTERIXLiveDecoder as an ILcdModelDecoder. This is useful when your application uses the TLcdServiceLoader to find all model decoders, or when you have another centralized list of model decoders.

Input files

File Required Entry point Description
*.astfin x x ASTERIX Final file containing a sequence of ASTERIX blocks within a header and footer
*.pcap x x ASTERIX blocks captured from the network in a PCAP file

Supported file transfer protocols

  • Since there are no standard protocols for live ASTERIX data, you need to set your own ILcdInputStreamFactory on this decoder that can create an InputStream based on your needs.

Model structure

Model descriptor

Model reference

Model elements

All domain objects decoded with this decoder implement the ILcdDataObject interface. This interface allows you to retrieve information on each of the domain models of ASTERIX in a uniform way. The data models and types can be obtained from either the domain objects or from the TLcdASTERIXDataTypes class. The current implementation of this decoder creates models with the following domain objects based on the incoming messages.

Sample code

This model decoder recognizes valid URIs where the scheme starts with "asterixlive+" as ASTERIX data streams. It is the responsibility of the user of this class to configure an ILcdInputStreamFactory on this decoder which can create input streams for such a URI:

   TLcdASTERIXLiveModelDecoder decoder = new TLcdASTERIXLiveModelDecoder();

   //Define and configure an ILcdInputStreamFactory which can create an InputStream to your ASTERIX live data stream
   ILcdInputStreamFactory isf = new ILcdInputStreamFactory{
     public InputStream createInputStream(String aSource) throws IOException{
       if("asterixlive+myprotocol://my_asterix_stream".equals(aSource)){
         return asterixDataStream;// <- an InputStream to your ASTERIX live data
       }
       throw new IOException("Cannot create an InputStream for " + aSource);
     }
   }
   decoder.setInputStreamFactory(isf);

   //Configure the decoder if needed
   //For example configure which categories you want to decode, set a reference provider, ...
   decoder.setCategories(new ALcdASTERIXCategory[]{new TLcdASTERIXCategory240()});

   //Actual decoding of the model
   //Note how the source name matches the source name supported by the ILcdInputStreamFactory
   ILcdModel asterixLiveModel = decoder.decode("asterixlive+myprotocol://my_asterix_stream");
 

Performance tips

Thread safety

  • 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.

Supported versions

Limitations

  • The model will keep the created InputStream open so that it can receive updates. As a consequence, when you are finished with the model, you need to call ILcdModel.dispose() so that the model can properly close the created InputStream.
Since:
2018.0
  • Field Details

    • ASTERIX_LIVE_SCHEME_PREFIX

      public static final String ASTERIX_LIVE_SCHEME_PREFIX
      URI's beginning with this constant are recognized by this decoder as a source name for live ASTERIX data. See the class javadoc for more information.
      See Also:
  • Constructor Details

    • TLcdASTERIXLiveModelDecoder

      public TLcdASTERIXLiveModelDecoder()
      Default constructor. Before you can decode any model, you still need to call setInputStreamFactory(ILcdInputStreamFactory). See the class javadoc for an example code snippet.
  • Method Details

    • getLiveDecodingStrategy

      public TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy getLiveDecodingStrategy()
      Returns the strategy to use for decoding live data.

      The default strategy is is ON_EDT

      Returns:
      The strategy to use when decoding live data. Never null.
    • setLiveDecodingStrategy

      public void setLiveDecodingStrategy(TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy aLiveDecodingStrategy)
      Sets the strategy to use when decoding live data.
      Parameters:
      aLiveDecodingStrategy - The strategy to use when decoding live data. Should not be null.
      See Also:
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory that will be used for creating input streams given source names. The factory should be able to create input streams for sources starting with "asterixlive+".
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the input stream factory that is currently used for creating input streams given source names.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is currently used.
    • 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:
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)

      Checks whether this model decoder can decode the specified data source.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be verified; typically a file name or a URL.
      Returns:
      true when aSourceName represents a valid URI, where the scheme starts with "asterixlive+", false otherwise.
      See Also:
    • canDecodeSource

      public boolean canDecodeSource(ILcdDataSource aDataSource)

      Checks whether this model decoder can decode the specified data source.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - The data source to check.
      Returns:
      true if the data source is a TLcdASTERIXDataSource containing a single source with a source name accepted by canDecodeSource(String), or a TLcdDataSource containing a source name accepted by canDecodeSource(String). Returns false in all other cases.
      See Also:
    • decodeSource

      public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
      Description copied from interface: ILcdModelDecoder

      Creates a new model from the given data source.

      By default, this method:

      Specified by:
      decodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the ILcdDataSource to be decoded.
      Returns:
      a model containing the decoded data. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.
      
       public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException {
         try {
           // Perform decoding ...
         } catch (RuntimeException e) {
           throw new IOException(e);
         }
       }
       
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be decoded; typically a file name or a URL.
      Returns:
      A model containing the decoded data. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.
      
         public ILcdModel decode( String aSourceName ) throws IOException {
            try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
               // Perform decoding ...
            } catch (RuntimeException e) {
               throw new IOException(e);
            }
         }
       
      See Also: