lcm :: EventLog :: Class EventLog
[hide private]
[frames] | no frames]

Class EventLog

object --+
         |
        EventLog

EventLog is a class for reading and writing LCM log files in Python.

An EventLog opened for reading supports the iterator protocol, with each call to next() returning the next Event in the log.

Instance Methods [hide private]
 
__init__(self, path, mode='r', overwrite=False)
Initializer
 
seek(self, filepos)
Positions the internal file pointer at the next event that starts at or is after byte offset filepos.
 
seek_to_timestamp(self, timestamp)
Seek (approximately) to a particular timestamp.
int
size(self)
Returns: the total size of the log file, in bytes
 
close(self)
Closes the log file.
 
write_event(self, utime, channel, data)
Writes an event to the log file.
Event
read_next_event(self)
Returns: the next Event in the log file.
Event
__next__(self)
Python 2.6 - 3.x version for iterators
Event
next(self)
int
tell(self)
Returns: the current position of the internal file pointer, in bytes

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, path, mode='r', overwrite=False)
(Constructor)

 

Initializer

Parameters:
  • path - Path to the logfile to open
  • mode - Open the log for reading ('r') or writing ('w')
  • overwrite - If mode is 'w', and the filename at path already exists, then EventLog will truncate and overwrite the file if this parameter is set to True. Otherwise, EventLog refuses to overwrite existing files and raises a ValueError.
Overrides: object.__init__

seek(self, filepos)

 

Positions the internal file pointer at the next event that starts at or is after byte offset filepos.

Parameters:
  • filepos - byte offset from start of log
Returns:
None

seek_to_timestamp(self, timestamp)

 

Seek (approximately) to a particular timestamp.

@param eventlog The log file object @param ts Timestamp of the target event in the log file.

Returns:
None

size(self)

 
Returns: int
the total size of the log file, in bytes

close(self)

 

Closes the log file. After an EventLog is closed, it is essentially useless

Returns:
None

write_event(self, utime, channel, data)

 

Writes an event to the log file. Log file must be openeed in write mode.

Parameters:
  • utime - Microseconds since 00:00:00 Jan 1, 1970 UTC
  • channel - Channel name corresponding to the event
  • data - data bytes
Returns:
None

read_next_event(self)

 
Returns: Event
the next Event in the log file.

tell(self)

 
Returns: int
the current position of the internal file pointer, in bytes