public class LsfIndex
extends java.lang.Object
Constructor and Description |
---|
LsfIndex(java.io.File lsfFile) |
LsfIndex(java.io.File lsfFile,
IMCDefinition defs)
Class constructor.
|
LsfIndex(java.io.File lsfFile,
IMCDefinition defs,
LsfIndexListener listener) |
Modifier and Type | Method and Description |
---|---|
int |
advanceToTime(int startIndex,
double timestamp) |
void |
cleanup()
This must be called to break the mapping and free memory.
|
boolean |
containsMessagesOfType(java.lang.String... messageTypes) |
java.util.Collection<java.lang.Integer> |
entitiesOfMessage(java.lang.String message)
Retrieve all the entities generating the given message
|
java.lang.String |
entityNameOf(int messageNumber) |
int |
entityOf(int messageNumber) |
int |
fieldIdOf(int messageNumber) |
java.util.Collection<Announce> |
getAvailableSystems() |
IMCDefinition |
getDefinitions()
Retrieve the IMC definitions used by this LsfIndex object
|
double |
getEndTime() |
int |
getEntityId(java.lang.String entityName)
Look for an entity name in this log
|
java.lang.String |
getEntityName(int entityId)
This method uses the EntityInfo messages present in the log to calculate
the name the of the given entity id.
This method should be used only for single vehicle logs. |
java.lang.String |
getEntityName(int src,
int src_ent)
Retrieve the name of an entity for a specific vehicle.
This method uses the EntityInfo messages in the log to calculate this value. |
<T> T |
getFirst(java.lang.Class<T> clazz) |
int |
getFirstMessageAtOrAfter(double timestamp) |
int |
getFirstMessageOfType(int type) |
int |
getFirstMessageOfType(java.lang.String abbrev) |
<T> LsfIterator<T> |
getIterator(java.lang.Class<T> msgType) |
<T> LsfIterator<T> |
getIterator(java.lang.Class<T> msgType,
int fromIndex) |
<T> LsfIterator<T> |
getIterator(java.lang.Class<T> msgType,
long millisBetweenMessages) |
java.lang.Iterable<IMCMessage> |
getIterator(java.lang.String msgType) |
java.lang.Iterable<IMCMessage> |
getIterator(java.lang.String msgType,
int fromIndex) |
java.lang.Iterable<IMCMessage> |
getIterator(java.lang.String msgType,
int fromIndex,
long timestepMillis) |
<T> T |
getLast(java.lang.Class<T> clazz) |
int |
getLastMessageOfType(int type) |
int |
getLastMessageOfType(java.lang.String abbrev) |
java.io.File |
getLsfFile() |
IMCMessage |
getMessage(int messageNumber)
Deserializes and retrieves the message at given index
|
<T> T |
getMessage(int messageNumber,
java.lang.Class<T> clazz) |
IMCMessage |
getMessageAt(java.lang.String type,
double timestamp) |
int |
getMessageAtOrAfer(int type,
int entity,
int startIndex,
double timestamp) |
IMCMessage |
getMessageAtOrAfter(java.lang.String type,
int startIndex,
double timestamp) |
IMCMessage |
getMessageAtOrAfter(java.lang.String type,
int startIndex,
int entity,
double timestamp) |
IMCMessage |
getMessageAtOrAfter(java.lang.String type,
java.lang.String entity,
int startIndex,
double timestamp) |
byte[] |
getMessageBytes(int ind)
This method retrieves the bytes associated with the message at given
index
|
int |
getMsgIndexAt(java.lang.String type,
double timestamp) |
<T> T |
getNext(double timestamp,
java.lang.Class<T> clazz) |
int |
getNextMessageOfEntity(int type,
int entity,
int startIndex)
This method returns the index of the next message with given type and
source entity
|
int |
getNextMessageOfEntity(java.lang.String entity,
int startIndex)
Retrieves the next message in the index that matches the given entity
name
|
int |
getNextMessageOfType(int type,
int startIndex) |
int |
getNextMessageOfType(java.lang.String abbrev,
int startIndex) |
int |
getNumberOfMessages() |
int |
getPreviousMessageOfType(int type,
int startIndex) |
double |
getStartTime() |
java.lang.String |
getSystemName(int sysId) |
java.util.Vector<Announce> |
getSystemsOfType(Announce.SYS_TYPE type) |
int |
hashOf(int i)
This method calculates an hashcode based on source and entity of the
message at index i
|
boolean |
hasMultipleVehicles() |
boolean |
isBigEndian(int messageNumber) |
java.lang.Iterable<IMCMessage> |
iterateEntityMessages(java.lang.String entityName)
Get an iterator to traverse all messages in the log from a selected
entity name
|
void |
load(java.io.File lsfFile,
IMCDefinition defs) |
static void |
main(java.lang.String[] args) |
java.lang.Iterable<IMCMessage> |
messagesOfType(int type) |
java.lang.Iterable<IMCMessage> |
messagesOfType(java.lang.String abbrev) |
<T extends IMCMessage> |
nextMessageOfType(java.lang.Class<T> type,
int startIndex) |
long |
positionOf(int messageNumber)
Retrieve the offset in the lsf File for message at given index
|
int |
sizeOf(int messageNumber) |
java.lang.String |
sourceNameOf(int messageNumber) |
int |
sourceOf(int messageNumber) |
void |
startReplay()
Same as
startReplay(1) |
void |
startReplay(long timeMultiplier,
java.lang.String host,
int port)
Just for testing purposes.
|
double |
timeOf(int messageNumber)
Retrieve the time, in seconds since January 1st 1970 UTC of the given
message
|
int |
typeOf(int messageNumber)
Retrieve the type of message at given index
|
public LsfIndex(java.io.File lsfFile, IMCDefinition defs, LsfIndexListener listener) throws java.lang.Exception
java.lang.Exception
public LsfIndex(java.io.File lsfFile, IMCDefinition defs) throws java.lang.Exception
lsfFile
- The file, in lsf format with the messages logdefs
- The IMC definitions for that logjava.lang.Exception
- If the log file is not valid / cannot be read.public LsfIndex(java.io.File lsfFile) throws java.lang.Exception
java.lang.Exception
public int hashOf(int i)
i
- The index of the message to calculate hashcodepublic int advanceToTime(int startIndex, double timestamp)
public void load(java.io.File lsfFile, IMCDefinition defs) throws java.lang.Exception
java.lang.Exception
public byte[] getMessageBytes(int ind)
ind
- The index of the messagepublic int typeOf(int messageNumber)
messageNumber
- The index of the messagepublic double timeOf(int messageNumber)
messageNumber
- The index of the message in the logpublic boolean isBigEndian(int messageNumber)
public java.lang.String sourceNameOf(int messageNumber)
public java.lang.String entityNameOf(int messageNumber)
public int sizeOf(int messageNumber)
public int sourceOf(int messageNumber)
public int entityOf(int messageNumber)
public int fieldIdOf(int messageNumber)
public long positionOf(int messageNumber)
messageNumber
- The index of the messagepublic <T> T getMessage(int messageNumber, java.lang.Class<T> clazz) throws java.lang.Exception
java.lang.Exception
public java.lang.Iterable<IMCMessage> iterateEntityMessages(java.lang.String entityName)
entityName
- The entity to be iteratedpublic java.lang.Iterable<IMCMessage> getIterator(java.lang.String msgType)
public java.lang.Iterable<IMCMessage> getIterator(java.lang.String msgType, int fromIndex)
public java.lang.Iterable<IMCMessage> getIterator(java.lang.String msgType, int fromIndex, long timestepMillis)
public <T> LsfIterator<T> getIterator(java.lang.Class<T> msgType)
public <T> LsfIterator<T> getIterator(java.lang.Class<T> msgType, int fromIndex)
public <T> LsfIterator<T> getIterator(java.lang.Class<T> msgType, long millisBetweenMessages)
public IMCMessage getMessage(int messageNumber)
messageNumber
- The message indexpublic int getNumberOfMessages()
public void startReplay()
startReplay(1)
public void startReplay(long timeMultiplier, java.lang.String host, int port)
timeMultiplier
- If 1.0 is used, the separation between messages will be
approximately the same as real-time. If this value is higher,
the replay will be done faster in the same proportion.public int getFirstMessageOfType(java.lang.String abbrev)
public <T> T getFirst(java.lang.Class<T> clazz)
public <T> T getLast(java.lang.Class<T> clazz)
public int getFirstMessageOfType(int type)
public int getLastMessageOfType(java.lang.String abbrev)
public int getLastMessageOfType(int type)
public int getNextMessageOfType(int type, int startIndex)
public int getNextMessageOfEntity(java.lang.String entity, int startIndex)
entity
- The entity to look forstartIndex
- Only messages after this index will be testedindex > startIndex
that has
a matching entity name.public int getNextMessageOfEntity(int type, int entity, int startIndex)
type
- The type of the message to look forentity
- The source entity (src_ent field in the header) to look forstartIndex
- The index exactly before the index from where to start lookingpublic java.util.Collection<java.lang.Integer> entitiesOfMessage(java.lang.String message)
message
- The messagepublic int getPreviousMessageOfType(int type, int startIndex)
public int getNextMessageOfType(java.lang.String abbrev, int startIndex)
public java.lang.Iterable<IMCMessage> messagesOfType(int type)
public java.lang.Iterable<IMCMessage> messagesOfType(java.lang.String abbrev)
public IMCDefinition getDefinitions()
public boolean hasMultipleVehicles()
public boolean containsMessagesOfType(java.lang.String... messageTypes)
public java.lang.String getEntityName(int src, int src_ent)
src
- The IMC id of the systemsrc_ent
- The id of the entity to be resolvedpublic java.lang.String getSystemName(int sysId)
public java.lang.String getEntityName(int entityId)
#getEntityName(Integer, Integer)
should be used instead.entityId
- The (numeric) id of the entity to resolvepublic int getEntityId(java.lang.String entityName)
entityName
- The name of the entity to look for255
if the entity was not foundpublic void cleanup()
public java.util.Collection<Announce> getAvailableSystems()
public <T> T getNext(double timestamp, java.lang.Class<T> clazz)
public java.util.Vector<Announce> getSystemsOfType(Announce.SYS_TYPE type)
public int getMessageAtOrAfer(int type, int entity, int startIndex, double timestamp)
public double getStartTime()
public double getEndTime()
public IMCMessage getMessageAtOrAfter(java.lang.String type, java.lang.String entity, int startIndex, double timestamp)
public int getMsgIndexAt(java.lang.String type, double timestamp)
public int getFirstMessageAtOrAfter(double timestamp)
public IMCMessage getMessageAt(java.lang.String type, double timestamp)
public <T extends IMCMessage> T nextMessageOfType(java.lang.Class<T> type, int startIndex)
public IMCMessage getMessageAtOrAfter(java.lang.String type, int startIndex, double timestamp)
public IMCMessage getMessageAtOrAfter(java.lang.String type, int startIndex, int entity, double timestamp)
public java.io.File getLsfFile()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception