Documentation
¶
Index ¶
- Variables
- func ReadOSIFile(filename string, msgType MessageType) ([]proto.Message, error)
- type MessageType
- type OSIFileReader
- func (r *OSIFileReader) Close() error
- func (r *OSIFileReader) GetMessageIndex() int
- func (r *OSIFileReader) JumpTo(messageIndex int) error
- func (r *OSIFileReader) Open() error
- func (r *OSIFileReader) ReadAll() ([]proto.Message, error)
- func (r *OSIFileReader) ReadNext() (proto.Message, error)
- func (r *OSIFileReader) ReadRest() ([]proto.Message, error)
- func (r *OSIFileReader) Reset() error
- func (r *OSIFileReader) Size() (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrFileAlreadyOpened = errors.New("file already opened")
ErrFileAlreadyOpened occurs when trying to open a file that is currently open
var ErrReaderClosed = errors.New("reader closed")
ErrReaderClosed occurs when trying to read data using a bufio reader that has already been closed
var ErrUnsupportedMessageType = errors.New("unsupported message type")
ErrUnsupportedMessageType indicates the given MessageType isn't supported. This shouldn't happen.
Functions ¶
func ReadOSIFile ¶
func ReadOSIFile(filename string, msgType MessageType) ([]proto.Message, error)
ReadOSIFile reads an OSI trace file and returns all messages matching the msgType. It assumes messages are length-prefixed with uint32 (little endian).
Types ¶
type MessageType ¶
type MessageType string
MessageType represents the type of OSI message.
const ( GroundTruth MessageType = "GroundTruth" SensorData MessageType = "SensorData" SensorView MessageType = "SensorView" SensorViewConfiguration MessageType = "SensorViewConfiguration" HostVehicleData MessageType = "HostVehicleData" TrafficCommand MessageType = "TrafficCommand" TrafficCommandUpdate MessageType = "TrafficCommandUpdate" TrafficUpdate MessageType = "TrafficUpdate" MotionRequest MessageType = "MotionRequest" )
type OSIFileReader ¶
type OSIFileReader struct {
// contains filtered or unexported fields
}
OSIFileReader provides a struct-like interface to read OSI messages from a file.
func NewOSIFileReader ¶
func NewOSIFileReader(filename string, msgType MessageType) (*OSIFileReader, error)
NewOSIFileReader opens the file and prepares the reader for the given message type.
func (*OSIFileReader) Close ¶
func (r *OSIFileReader) Close() error
Close closes the underlying file.
func (*OSIFileReader) GetMessageIndex ¶
func (r *OSIFileReader) GetMessageIndex() int
GetMessageIndex returns the current index
func (*OSIFileReader) JumpTo ¶
func (r *OSIFileReader) JumpTo(messageIndex int) error
JumpTo seeks to the beginning of the specified message (0-indexed). After calling JumpTo(n), ReadNext() will return the (n+1)th message.
func (*OSIFileReader) Open ¶
func (r *OSIFileReader) Open() error
Open reopens the file if it was previously closed.
func (*OSIFileReader) ReadAll ¶
func (r *OSIFileReader) ReadAll() ([]proto.Message, error)
ReadAll resets the reader and reads all messages of the specified type from the start.
func (*OSIFileReader) ReadNext ¶
func (r *OSIFileReader) ReadNext() (proto.Message, error)
ReadNext reads the next message of the specified type from the file. Returns io.EOF if no more messages are available.
func (*OSIFileReader) ReadRest ¶
func (r *OSIFileReader) ReadRest() ([]proto.Message, error)
ReadRest reads all remaining messages of the specified type from the current position.
func (*OSIFileReader) Reset ¶
func (r *OSIFileReader) Reset() error
Reset seeks back to the beginning of the file and resets the buffered reader.
func (*OSIFileReader) Size ¶
func (r *OSIFileReader) Size() (int64, error)
Size returns the current file size in bytes.