Package com.luciad.format.asterix
Class TLcdASTERIXLiveDecoder
java.lang.Object
com.luciad.format.asterix.ALcdASTERIXDecoder
com.luciad.format.asterix.TLcdASTERIXLiveDecoder
- All Implemented Interfaces:
Closeable
,AutoCloseable
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
- The decoder supports the categories 1, 8, 10, 11, 21, 30, 34, 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.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the next ASTERIX block can be read without blocking on I/O.void
close()
Closes this live decoder, signalingdecodeBlockSFCT(int, com.luciad.model.ILcdModelContainer)
will not be called anymore.void
decodeBlockSFCT
(int aFireEventMode, ILcdModelContainer aModelSFCT) Reads a single ASTERIX block from theInputStream
that was given to initDecode(java.io.InputStream).void
decodeSFCT
(InputStream aStream, int aFireEventMode, ILcdModelContainer aModelSFCT) Modifies the givenILcdModelContainer
to contain new blocks of ASTERIX data that are read from the givenInputStream
.int
Returns the history length.void
initDecode
(InputStream aInputStream) Prepares this decoder to read live ASTERIX data from the givenInputStream
.void
setHistoryLength
(int aHistoryLength) Sets the history length to the given length.Methods inherited from class com.luciad.format.asterix.ALcdASTERIXDecoder
getCategories, getRecordFilter, getReferenceProvider, getScalingFactorProvider, getTransformationProvider, isClassTraceOn, setCategories, setClassTraceOn, setRecordFilter, setReferenceProvider, setScalingFactorProvider, setTransformationProvider
-
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, theTLcdASTERIXTrajectory
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.
- 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:
-
decodeSFCT
public void decodeSFCT(InputStream aStream, int aFireEventMode, ILcdModelContainer aModelSFCT) throws IOException Modifies the givenILcdModelContainer
to contain new blocks of ASTERIX data that are read from the givenInputStream
. 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, useThread.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 ofILcdFireEventMode.FIRE_NOW
,ILcdFireEventMode.FIRE_LATER
orILcdFireEventMode.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. IfFIRE_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. IfFIRE_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 usingILcdModel.fireCollectedModelChanges()
onaModelSFCT
. IfNO_EVENT
is used, no events are collected nor fired.aModelSFCT
- The model to modify.- Throws:
IOException
- In case of I/O failure.
-
initDecode
Prepares this decoder to read live ASTERIX data from the givenInputStream
.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 thedecodeSFCT
method anymore after calling this method.If you are finished with the live decoder, you should call the
close()
method.- Parameters:
aInputStream
- TheInputStream
from whichdecodeBlockSFCT
should read the live data.- See Also:
-
decodeBlockSFCT
Reads a single ASTERIX block from theInputStream
that was given to initDecode(java.io.InputStream).initDecode
should have been called once before calling this method.- Parameters:
aFireEventMode
- One ofILcdModel.FIRE_NOW
,ILcdModel.FIRE_LATER
orILcdModel.NO_EVENT
. It allows to specify when and if any model events need to be fired when the model is changed by this decoder. IfFIRE_NOW
is used, changes are immediately propagated, and the user of this method does not need to do anything else. If for exampleFIRE_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 usingILcdModel.fireCollectedModelChanges()
onaModelSFCT
.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
Returnstrue
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 theInputStream
.- 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
Closes this live decoder, signalingdecodeBlockSFCT(int, com.luciad.model.ILcdModelContainer)
will not be called anymore.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- If there is an I/O error while closing the live decoder.
-