public class TLcdASTERIXLiveDecoder extends ALcdASTERIXDecoder implements Closeable
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).
TLcdLockUtil
Constructor and Description |
---|
TLcdASTERIXLiveDecoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
blockAvailable()
Returns
true if the next ASTERIX block can be read without blocking on I/O. |
void |
close()
Closes this live decoder, signaling
decodeBlockSFCT(int, com.luciad.model.ILcdModelContainer) will not be called anymore. |
void |
decodeBlockSFCT(int aFireEventMode,
ILcdModelContainer aModelSFCT)
Reads a single ASTERIX block from the
InputStream that was given to initDecode(java.io.InputStream). |
void |
decodeSFCT(InputStream aStream,
int aFireEventMode,
ILcdModelContainer aModelSFCT)
Modifies the given
ILcdModelContainer to contain new blocks of ASTERIX data that are read
from the given InputStream . |
int |
getHistoryLength()
Returns the history length.
|
void |
initDecode(InputStream aInputStream)
Prepares this decoder to read live ASTERIX data from the given
InputStream . |
void |
setHistoryLength(int aHistoryLength)
Sets the history length to the given length.
|
getCategories, getRecordFilter, getReferenceProvider, getScalingFactorProvider, getTransformationProvider, isClassTraceOn, setCategories, setClassTraceOn, setRecordFilter, setReferenceProvider, setScalingFactorProvider, setTransformationProvider
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 void decodeSFCT(InputStream aStream, int aFireEventMode, ILcdModelContainer aModelSFCT) throws IOException
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.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.IOException
- In case of I/O failure.public void initDecode(InputStream aInputStream)
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.
aInputStream
- The InputStream
from which decodeBlockSFCT
should read the live data.decodeBlockSFCT(int, ILcdModelContainer)
public void decodeBlockSFCT(int aFireEventMode, ILcdModelContainer aModelSFCT) throws IOException
InputStream
that was given to initDecode(java.io.InputStream).
initDecode
should have been called once before calling this method.
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.EOFException
- when no more live data can be received.IOException
- In case of I/O failure.initDecode(java.io.InputStream)
public boolean blockAvailable() throws IOException
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
.true
if the next ASTERIX block can be read without blocking on I/O. false
otherwise.IOException
- In case of an I/O exception.public void close() throws IOException
decodeBlockSFCT(int, com.luciad.model.ILcdModelContainer)
will not be called anymore.close
in interface Closeable
close
in interface AutoCloseable
IOException
- If there is an I/O error while closing the live decoder.