Package com.luciad.format.asterix
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
ILcdInputStreamFactoryon this decoder that can create anInputStreambased on your needs.
Model structure
- This model decoder returns a
model listwith a model for each data type in the input. - All models returned by this model decoder implement
ILcd2DBoundsIndexedModel.
Model descriptor
- Sub-models containing trajectory data have a
track model descriptor - Sub-models containing plots have a
plot model descriptor - Sub-models containing weather picture have a
weather model descriptor - Sub-models containing a radar have a
TLcdASTERIXRadarVideoModelDescriptor
Model reference
- All models returned by this model decoder have an
ILcdGridReferenceor anILcdGeodeticReference.
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.TracksPlotsif a track had no identifying informationWeather picturesRadar video
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 anILcdInputStreamFactory
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 theTLcdModelList(seeTLcdLockUtil). 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
- The decoder supports the categories 1, 8, 10, 11, 21, 30, 48, 62, 240 and 244 of the ASTERIX standard. See the Overview of the ASTERIX specifications for the supported categories for the full list of specifications used to implement the categories. For more information on the ASTERIX standard, see the EUROCONTROL website.
Limitations
- The model will keep the created
InputStreamopen so that it can receive updates. As a consequence, when you are finished with the model, you need to callILcdModel.dispose()so that the model can properly close the createdInputStream.
- Since:
- 2018.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum to choose the strategy on how to decode live data. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringURI's beginning with this constant are recognized by this decoder as a source name for live ASTERIX data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeSource(ILcdDataSource aDataSource) Checks whether this model decoder can decode the specified data source.booleancanDecodeSource(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.decodeSource(ILcdDataSource aDataSource) Creates a new model from the given data source.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.intReturns the history length.Returns the input stream factory that is currently used for creating input streams given source names.Returns the strategy to use for decoding live data.voidsetHistoryLength(int aHistoryLength) Sets the history length to the given length.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory that will be used for creating input streams given source names.voidsetLiveDecodingStrategy(TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy aLiveDecodingStrategy) Sets the strategy to use when decoding live data.Methods inherited from class com.luciad.format.asterix.ALcdASTERIXDecoder
getCategories, getRecordFilter, getReferenceProvider, getScalingFactorProvider, getTransformationProvider, isClassTraceOn, setCategories, setClassTraceOn, setRecordFilter, setReferenceProvider, setScalingFactorProvider, setTransformationProviderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
decodeModelMetadata, decodeModelMetadata, discoverDataSources
-
Field Details
-
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 callsetInputStreamFactory(ILcdInputStreamFactory). See the class javadoc for an example code snippet.
-
-
Method Details
-
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 benull.- See Also:
-
setInputStreamFactory
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:
setInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Parameters:
aInputStreamFactory- the input stream factory to be used.
-
getInputStreamFactory
Returns the input stream factory that is currently used for creating input streams given source names.- Specified by:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- 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, theTLcdASTERIXTrajectorys 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 tosetHistoryLength(int)for details.- Returns:
- the history length.
- See Also:
-
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the displayable name of this
ILcdModelDecoder.
-
canDecodeSource
Checks whether this model decoder can decode the specified data source.
- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be verified; typically a file name or a URL.- Returns:
truewhenaSourceNamerepresents a valid URI, where the scheme starts with "asterixlive+",falseotherwise.- See Also:
-
canDecodeSource
Checks whether this model decoder can decode the specified data source.
- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- The data source to check.- Returns:
trueif the data source is aTLcdASTERIXDataSourcecontaining a single source with a source name accepted bycanDecodeSource(String), or aTLcdDataSourcecontaining a source name accepted bycanDecodeSource(String). Returnsfalsein all other cases.- See Also:
-
decodeSource
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.
By default, this method:
- Throws a
NullPointerExceptionwhen anulldata source is passed. - Delegates to the
ILcdModelDecoder.decode(String)method when aTLcdDataSourceis passed. - Throws an IOException in other case.
- Specified by:
decodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- theILcdDataSourceto be decoded.- Returns:
- a model containing the decoded data. While
nullis 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:
- Throws a
-
decode
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.- Specified by:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
nullis 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:
-