|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.io.DataInputStream
net.sf.jaer.eventio.AEFileInputStream
public class AEFileInputStream
Class to stream in packets of events from binary input stream from a file recorded by AEViewer.
The file format is simple, it consists of an arbitrary number of timestamped AEs:
int32 address int32 timestamp int32 address int32 timestamp
(Prior to version 2.0 data files, the address was a 16 bit short value.)
An optional ASCII header consisting of lines starting with '#' is skipped when opening the file and may be retrieved. No later comment lines are allowed because the rest ot the file must be pure binary data.
The first line of the header specifies the file format (for later versions). Files lacking a header are assumed to be of int16 address form.
The first line of the header has a value like "#!AER-DAT2.0". The 2.0 is the version number.
AEFileInputStream has PropertyChangeSupport via getSupport(). PropertyChangeListeners will get informed of the following events
AEDataFile
Nested Class Summary | |
---|---|
class |
AEFileInputStream.NonMonotonicTimeException
class used to signal a backwards read from input stream |
class |
AEFileInputStream.WrappedTimeException
Indicates that timestamp has wrapped around from most positive to most negative signed value. |
Field Summary | |
---|---|
static int |
EVENT16_SIZE
With new 32bits adressses, use EVENT32_SIZE, but use EVENT16_SIZE for backward compatibility with 16 bit addresses |
static int |
EVENT32_SIZE
(new style) int addr, int timestamp |
protected java.util.ArrayList<java.lang.String> |
header
|
static int |
MAX_BUFFER_SIZE_EVENTS
|
int |
MAX_NONMONOTONIC_TIME_EXCEPTIONS_TO_PRINT
|
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
AEFileInputStream(java.io.File f)
Creates a new instance of AEInputStream |
|
AEFileInputStream(java.io.FileInputStream in)
Deprecated. use the constructor with a File object so that users of this can more easily get file information |
Method Summary | |
---|---|
void |
close()
|
AEFileInputStream |
copy()
copies out the part of the stream from IN to OUT markers and returns it as a new AEInputStream |
AEFileInputStream |
cut()
cuts out the part of the stream from IN to OUT and returns it as a new AEInputStream |
long |
getAbsoluteStartingTimeMs()
When the file is opened, the filename is parsed to try to extract the date and time the file was created from the filename. |
int |
getCurrentStartTimestamp()
|
int |
getDurationUs()
|
java.io.File |
getFile()
Returns the File that is being read, or null if the instance is constructed from a FileInputStream |
int |
getFirstTimestamp()
returns the first timestamp in the stream |
float |
getFractionalPosition()
Returns the position as a fraction of the total number of events |
java.util.ArrayList<java.lang.String> |
getHeader()
Gets the header strings from the file |
int |
getLastTimestamp()
|
int |
getMostRecentTimestamp()
|
java.beans.PropertyChangeSupport |
getSupport()
AEFileInputStream has PropertyChangeSupport. |
boolean |
isNonMonotonicTimeExceptionsChecked()
Checking for wrapped time exceptions can be disabled for reasons of speed or corrupted data files. |
void |
mark()
mark the current position. |
void |
markIn()
mark the current position as the IN point for editing. |
void |
markOut()
mark the current position as the OUT position for editing. |
protected void |
parseFileFormatVersion(java.lang.String s)
parses the file format version given a string with the header comment character stripped off. |
void |
paste(AEFileInputStream in)
pastes the in stream at the IN marker into this stream |
int |
position()
gets the current position (in events) for reading forwards, i.e., readEventForwards will read this event number. |
void |
position(int event)
set position in events from start of file |
protected void |
readHeader(java.io.FileInputStream fileInputStream)
reads the header comment lines. |
AEPacketRaw |
readPacketByNumber(int n)
Uesd to read fixed size packets either forwards or backwards. |
AEPacketRaw |
readPacketByTime(int dt)
returns an AEPacketRaw at least dt long up to the max size of the buffer or until end-of-file. |
void |
rewind()
rewind to the start, or to the marked position, if it has been set. |
void |
setAbsoluteStartingTimeMs(long absoluteStartingTimeMs)
|
void |
setCurrentStartTimestamp(int currentStartTimestamp)
|
void |
setFile(java.io.File f)
Sets the File reference but doesn't open the file |
void |
setFractionalPosition(float frac)
Sets fractional position in events |
void |
setMostRecentTimestamp(int mostRecentTimestamp)
|
void |
setNonMonotonicTimeExceptionsChecked(boolean yes)
Sets whether the input stream is checked for timestamp nonmonotonicity. |
long |
size()
gets the size of the stream in events |
protected void |
skipHeader()
skips the header lines (if any) |
java.lang.String |
toString()
|
void |
unmark()
clear any marked position |
Methods inherited from class java.io.DataInputStream |
---|
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes |
Methods inherited from class java.io.FilterInputStream |
---|
available, mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final int MAX_NONMONOTONIC_TIME_EXCEPTIONS_TO_PRINT
public static final int MAX_BUFFER_SIZE_EVENTS
public static final int EVENT16_SIZE
public static final int EVENT32_SIZE
protected java.util.ArrayList<java.lang.String> header
Constructor Detail |
---|
public AEFileInputStream(java.io.FileInputStream in) throws java.io.IOException
java.io.IOException
public AEFileInputStream(java.io.File f) throws java.io.IOException
f
- the file to open
java.io.FileNotFoundException
- if file doesn't exist or can't be read
java.io.IOException
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public AEPacketRaw readPacketByNumber(int n) throws java.io.IOException
readPacketByNumber
in interface AEFileInputStreamInterface
n
- the number of events to read
java.io.IOException
- if there is a problem, e.g. end of filepublic AEPacketRaw readPacketByTime(int dt) throws java.io.IOException
Non-monotonic timestamps cause warning messages to be printed (up to MAX_NONMONOTONIC_TIME_EXCEPTIONS_TO_PRINT) and packet reading is aborted when the non-monotonic timestamp is encountered. Nornally this does not cause problems except that the packet is storter in duration that called for. But when sychronized playback is enabled it causes the differnt threads to desychronize. Therefore the data files should not contain non-monotonic timestamps when sychronized playback is desired.
readPacketByTime
in interface AEFileInputStreamInterface
dt
- the timestamp different in units of the timestamp (usually us)
java.io.IOException
- if there is any problemMAX_BUFFER_SIZE_EVENTS
public void rewind() throws java.io.IOException
rewind
in interface InputDataFileInterface
java.io.IOException
public long size()
size
in interface InputDataFileInterface
public void position(int event)
position
in interface InputDataFileInterface
event
- the number of the event, starting with 0public int position()
position
in interface InputDataFileInterface
public float getFractionalPosition()
getFractionalPosition
in interface InputDataFileInterface
public void setFractionalPosition(float frac)
setFractionalPosition
in interface InputDataFileInterface
frac
- 0-1 float range, 0 at start, 1 at endpublic java.beans.PropertyChangeSupport getSupport()
public void mark() throws java.io.IOException
mark
in interface InputDataFileInterface
java.io.IOException
- if there is some error in reading the datapublic void markIn() throws java.io.IOException
java.io.IOException
- if there is some error in reading the datapublic void markOut() throws java.io.IOException
java.io.IOException
- if there is some error in reading the datapublic void unmark()
unmark
in interface InputDataFileInterface
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.FilterInputStream
java.io.IOException
public int getFirstTimestamp()
public int getLastTimestamp()
public int getDurationUs()
Assumes data file is timestamped in us. This method fails to provide a sensible value if the timestamp wwaps.
public int getCurrentStartTimestamp()
public void setCurrentStartTimestamp(int currentStartTimestamp)
public int getMostRecentTimestamp()
public void setMostRecentTimestamp(int mostRecentTimestamp)
public AEFileInputStream cut()
public AEFileInputStream copy()
public void paste(AEFileInputStream in)
in
- the stream to pasteprotected void skipHeader() throws java.io.IOException
java.io.IOException
protected void readHeader(java.io.FileInputStream fileInputStream) throws java.io.IOException
java.io.IOException
protected void parseFileFormatVersion(java.lang.String s)
AEDataFile
public java.util.ArrayList<java.lang.String> getHeader()
public java.io.File getFile()
public void setFile(java.io.File f)
public long getAbsoluteStartingTimeMs()
public void setAbsoluteStartingTimeMs(long absoluteStartingTimeMs)
public boolean isNonMonotonicTimeExceptionsChecked()
AEFileInputStreamInterface
isNonMonotonicTimeExceptionsChecked
in interface AEFileInputStreamInterface
public void setNonMonotonicTimeExceptionsChecked(boolean yes)
AEFileInputStreamInterface
setNonMonotonicTimeExceptionsChecked
in interface AEFileInputStreamInterface
yes
- true to check (default).
|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |