@LcdService(service=ILcdModelDecoder.class, priority=20000) public final class TLcdASTERIXLiveModelDecoder extends ALcdASTERIXDecoder implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
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.
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 |
ILcdInputStreamFactory
on this decoder that can create an InputStream
based on your needs.model list
with a model
for each data type in the input.ILcd2DBoundsIndexedModel
.track model descriptor
plot model descriptor
weather model descriptor
TLcdASTERIXRadarVideoModelDescriptor
ILcdGridReference
or
an ILcdGeodeticReference
.Tracks
Plots
if a track had no identifying informationWeather pictures
Radar video
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");
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.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
.Modifier and Type | Class and Description |
---|---|
static class |
TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy
Enum to choose the strategy on how to decode live data.
|
Modifier and Type | Field and Description |
---|---|
static String |
ASTERIX_LIVE_SCHEME_PREFIX
URI's beginning with this constant are recognized by this decoder as
a source name for live ASTERIX data.
|
Constructor and Description |
---|
TLcdASTERIXLiveModelDecoder()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(ILcdDataSource aDataSource)
Checks whether this model decoder can decode the specified data source.
|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Creates a new model from the given data source.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
int |
getHistoryLength()
Returns the history length.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is currently used for creating input streams
given source names.
|
TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy |
getLiveDecodingStrategy()
Returns the strategy to use for decoding live data.
|
void |
setHistoryLength(int aHistoryLength)
Sets the history length to the given length.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory that will be used for creating input streams
given source names.
|
void |
setLiveDecodingStrategy(TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy aLiveDecodingStrategy)
Sets the strategy to use when decoding live data.
|
getCategories, getRecordFilter, getReferenceProvider, getScalingFactorProvider, getTransformationProvider, isClassTraceOn, setCategories, setClassTraceOn, setRecordFilter, setReferenceProvider, setScalingFactorProvider, setTransformationProvider
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decodeModelMetadata, decodeModelMetadata, discoverDataSources
public static final String ASTERIX_LIVE_SCHEME_PREFIX
public TLcdASTERIXLiveModelDecoder()
setInputStreamFactory(ILcdInputStreamFactory)
.
See the class javadoc for an example code snippet.public TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy getLiveDecodingStrategy()
The default strategy is is ON_EDT
null
.public void setLiveDecodingStrategy(TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy aLiveDecodingStrategy)
aLiveDecodingStrategy
- The strategy to use when decoding live data. Should not be null
.TLcdASTERIXLiveModelDecoder.LiveDecodingStrategy
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public void setHistoryLength(int aHistoryLength)
TLcdASTERIXTrajectory
s 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.
aHistoryLength
- The maximum amount of points that are be kept in the history.public int getHistoryLength()
setHistoryLength(int)
for details.setHistoryLength(int)
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
when aSourceName
represents a valid URI, where the scheme starts with "asterixlive+",
false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public boolean canDecodeSource(ILcdDataSource aDataSource)
Checks whether this model decoder can decode the specified data source.
canDecodeSource
in interface ILcdModelDecoder
aDataSource
- The data source to check.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.ILcdModelDecoder.decodeSource(ILcdDataSource)
,
ILcdModelDecoder.decodeModelMetadata(ILcdDataSource)
public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
NullPointerException
when a null
data source is passed.ILcdModelDecoder.decode(String)
method when a TLcdDataSource
is passed.decodeSource
in interface ILcdModelDecoder
aDataSource
- the ILcdDataSource
to be decoded.null
is allowed, implementors are advised to throw an error instead.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);
}
}
ILcdModelDecoder.canDecodeSource(ILcdDataSource)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.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);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)