Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

LogPlayer Class Reference

A message queue that can record and play logfiles. More...

#include <LogPlayer.h>

Inheritance diagram for LogPlayer:

Inheritance graph
[legend]
Collaboration diagram for LogPlayer:

Collaboration graph
[legend]
List of all members.

Public Types

enum  LogPlayerState {
  initial, recording, paused,
  playing
}
 different states of the logplayer More...


Public Member Functions

 LogPlayer (MessageQueue &targetQueue)
 Constructor.

LogPlayerState getState ()
 Returns the state of the queue.

void _new ()
 Deletes all messages from the queue.

bool open (const char *fileName)
 Opens a log file and reads all messages into the queue.

void play ()
 Playes the queue.

void pause ()
 Pauses playing the queue.

void stop ()
 Stops playing the queue, resets the position in the queue to the first message.

void stepForward ()
 Plays the next message in the queue.

void stepBackward ()
 Plays the previous message in the queue.

void stepRepeat ()
 repeats the current message in the queue

void jumpFrame (int frame)
 jumps to given message-number in the queue

void record ()
 Starts / Stops recording.

void smooth ()
 Activates/deactivates jpeg image smoothing.

bool save (const char *fileName)
 Writes all messages in the log player queue to a log file.

bool saveAMV (const char *fileName)
 Writes all messages in the log player queue to an AIBOVision compatibile movie file.

void saveCSVrow (OutTextRawFile &file, double *row, unsigned int rowLen)
 Writes an row of doubles to an comma separated value file.

bool saveCSV (const char *fileName)
 Writes a couple of message types in the log player queue to an comma separated value file with a common time line.

bool saveImages (const char *fileName)
 Writes all images in the log player queue to a bunch of files (*.bmp or *.jpg).

void setPlaySpeed (double speed)
 Sets the playing speed of the log player.

void handleMessage (InMessage &message)
 Adds the message to the queue depending on isRecording.

void onIdle ()
 If playing a log file, that function checks if it is time to release the next message dependend on the time stamp.

int getNumberOfMessages () const
 Returns the number of stored messages.

int getCurrentMessageNumber () const
 Returns the number of the current message.

MessageID getCurrentMessageID () const
 Returns the type of the current message.

bool isSmoothingEnabled () const
 Returns the status of the smoothing flag.


Protected Attributes

int currentMessageNumber
 The number of the current message.


Private Member Functions

void convertIntString (char *str, int value)
 little routine to convert an integer into C style string

unsigned long getTimeStamp (int message)
 Returns the time stamp of a given message.


Private Attributes

LogPlayerState state
 the state of the log player

MessageQueuetargetQueue
double playSpeed
 A factor, how fast the messages are played.

unsigned long timeWhenFirstMessageWasPlayed
 The time when the first message was played.

unsigned long timeOfFirstPlayedMessage
 The time stamp of the first played message.

bool smoothingEnabled
 Flag which triggers smoothing of jpeg compressed images.


Detailed Description

A message queue that can record and play logfiles.

The messages are played in the same time sequence as they were recorded.

Author:
Martin Lötzsch

Definition at line 22 of file LogPlayer.h.


Member Enumeration Documentation

enum LogPlayer::LogPlayerState
 

different states of the logplayer

Enumeration values:
initial 
recording 
paused 
playing 

Definition at line 32 of file LogPlayer.h.

Referenced by getState().


Constructor & Destructor Documentation

LogPlayer::LogPlayer MessageQueue targetQueue  ) 
 

Constructor.

Parameters:
targetQueue The queue into that messages from played logfiles shall be stored.

Definition at line 21 of file LogPlayer.cpp.

References _new().

Here is the call graph for this function:


Member Function Documentation

LogPlayer::LogPlayerState LogPlayer::getState  ) 
 

Returns the state of the queue.

Definition at line 414 of file LogPlayer.cpp.

References LogPlayerState, and state.

void LogPlayer::_new  ) 
 

Deletes all messages from the queue.

Definition at line 29 of file LogPlayer.cpp.

References MessageQueue::clear(), initial, state, and stop().

Referenced by LogPlayer().

Here is the call graph for this function:

bool LogPlayer::open const char *  fileName  ) 
 

Opens a log file and reads all messages into the queue.

Parameters:
fileName the name of the file to open
Returns:
if the reading was successful

Definition at line 36 of file LogPlayer.cpp.

References MessageQueue::clear(), InFile::exists(), and stop().

Here is the call graph for this function:

void LogPlayer::play  ) 
 

Playes the queue.

Note that you have to call onIdle() regularely if you want to use that function

Definition at line 49 of file LogPlayer.cpp.

References pause(), playing, and state.

Here is the call graph for this function:

void LogPlayer::pause  ) 
 

Pauses playing the queue.

Definition at line 61 of file LogPlayer.cpp.

References getNumberOfMessages(), initial, paused, state, timeOfFirstPlayedMessage, and timeWhenFirstMessageWasPlayed.

Referenced by jumpFrame(), play(), record(), stepBackward(), stepForward(), stepRepeat(), and stop().

Here is the call graph for this function:

void LogPlayer::stop  ) 
 

Stops playing the queue, resets the position in the queue to the first message.

Definition at line 55 of file LogPlayer.cpp.

References currentMessageNumber, and pause().

Referenced by _new(), onIdle(), open(), saveAMV(), saveCSV(), and saveImages().

Here is the call graph for this function:

void LogPlayer::stepForward  ) 
 

Plays the next message in the queue.

Definition at line 78 of file LogPlayer.cpp.

References MessageQueue::copyMessage(), currentMessageNumber, getNumberOfMessages(), pause(), paused, state, and targetQueue.

Here is the call graph for this function:

void LogPlayer::stepBackward  ) 
 

Plays the previous message in the queue.

Definition at line 70 of file LogPlayer.cpp.

References MessageQueue::copyMessage(), currentMessageNumber, pause(), paused, state, and targetQueue.

Here is the call graph for this function:

void LogPlayer::stepRepeat  ) 
 

repeats the current message in the queue

Definition at line 86 of file LogPlayer.cpp.

References MessageQueue::copyMessage(), currentMessageNumber, pause(), paused, state, and targetQueue.

Here is the call graph for this function:

void LogPlayer::jumpFrame int  frame  ) 
 

jumps to given message-number in the queue

Definition at line 94 of file LogPlayer.cpp.

References MessageQueue::copyMessage(), currentMessageNumber, getNumberOfMessages(), pause(), paused, state, and targetQueue.

Here is the call graph for this function:

void LogPlayer::record  ) 
 

Starts / Stops recording.

Note that you have to notify the queue on new messages with handleMessage().

Definition at line 379 of file LogPlayer.cpp.

References initial, pause(), paused, playing, recording, and state.

Here is the call graph for this function:

void LogPlayer::smooth  ) 
 

Activates/deactivates jpeg image smoothing.

Definition at line 394 of file LogPlayer.cpp.

References smoothingEnabled.

bool LogPlayer::save const char *  fileName  ) 
 

Writes all messages in the log player queue to a log file.

Parameters:
fileName the name of the file to write
Returns:
if the writing was successful

Definition at line 102 of file LogPlayer.cpp.

References OutFile::exists(), and getNumberOfMessages().

Here is the call graph for this function:

bool LogPlayer::saveAMV const char *  fileName  ) 
 

Writes all messages in the log player queue to an AIBOVision compatibile movie file.

Images are encoded in a raw YUV format.

Parameters:
fileName the name of the file to write
Returns:
if the writing was successful

Definition at line 130 of file LogPlayer.cpp.

References InMessage::bin, Image::cameraInfo, convertIntString(), currentMessageNumber, OutFile::exists(), getCurrentMessageID(), getNumberOfMessages(), idImage, idJPEGImage, Image::image, CameraInfo::resolutionHeight, CameraInfo::resolutionWidth, MessageQueueBase::setSelectedMessageForReading(), stop(), JPEGImage::toImage(), and OutStream< OutFile, OutBinary >::write().

Here is the call graph for this function:

void LogPlayer::saveCSVrow OutTextRawFile file,
double *  row,
unsigned int  rowLen
 

Writes an row of doubles to an comma separated value file.

Parameters:
file the open file to write to
row a row containing the doubles to be written
rowLen number of entries in row

Definition at line 198 of file LogPlayer.cpp.

Referenced by saveCSV().

bool LogPlayer::saveCSV const char *  fileName  ) 
 

Writes a couple of message types in the log player queue to an comma separated value file with a common time line.

Parameters:
fileName the name of the file to write
Returns:
if the writing was successful

Definition at line 219 of file LogPlayer.cpp.

References InMessage::bin, SpecialPercept::checkerPose, currentMessageNumber, OutFile::exists(), RobotPose::frameNumber, SpecialPercept::frameNumber, getCurrentMessageID(), getNumberOfMessages(), idSpecialPercept, idWorldState, RECEIVE_WORLDSTATE, Pose2D::rotation, saveCSVrow(), MessageQueueBase::setSelectedMessageForReading(), stop(), Pose2D::translation, SpecialPercept::type, Vector2< double >::x, and Vector2< double >::y.

Here is the call graph for this function:

bool LogPlayer::saveImages const char *  fileName  ) 
 

Writes all images in the log player queue to a bunch of files (*.bmp or *.jpg).

Parameters:
fileName the name of one file to write, all files will be enumerated by appending a 3 digit number to the filename.
Returns:
if the writing of all files was successful

Definition at line 290 of file LogPlayer.cpp.

References InMessage::bin, Image::cameraInfo, Image::convertFromYUVToRGB(), currentMessageNumber, OutFile::exists(), getCurrentMessageID(), getNumberOfMessages(), idImage, idJPEGImage, Image::image, CameraInfo::resolutionHeight, CameraInfo::resolutionWidth, MessageQueueBase::setSelectedMessageForReading(), stop(), JPEGImage::toImage(), and OutStream< OutFile, OutBinary >::write().

Here is the call graph for this function:

void LogPlayer::setPlaySpeed double  speed  ) 
 

Sets the playing speed of the log player.

"2" playes the messages double as fast as they were recorded, "0.5" plays the messages with the half speed.

Definition at line 402 of file LogPlayer.cpp.

References playSpeed, and timeWhenFirstMessageWasPlayed.

void LogPlayer::handleMessage InMessage message  ) 
 

Adds the message to the queue depending on isRecording.

That function should be called for every message in the queue that the log player shall work on.

Definition at line 408 of file LogPlayer.cpp.

References recording, and state.

void LogPlayer::onIdle  ) 
 

If playing a log file, that function checks if it is time to release the next message dependend on the time stamp.

Call that function whenever there is some processing time left.

Definition at line 419 of file LogPlayer.cpp.

References MessageQueue::copyMessage(), currentMessageNumber, SystemCall::getCurrentSystemTime(), getNumberOfMessages(), SystemCall::getTimeSince(), getTimeStamp(), playing, playSpeed, state, stop(), targetQueue, timeOfFirstPlayedMessage, and timeWhenFirstMessageWasPlayed.

Here is the call graph for this function:

int LogPlayer::getNumberOfMessages  )  const
 

Returns the number of stored messages.

Definition at line 462 of file LogPlayer.cpp.

References MessageQueueBase::getNumberOfMessages().

Referenced by jumpFrame(), onIdle(), pause(), save(), saveAMV(), saveCSV(), saveImages(), and stepForward().

Here is the call graph for this function:

int LogPlayer::getCurrentMessageNumber  )  const
 

Returns the number of the current message.

Definition at line 467 of file LogPlayer.cpp.

References currentMessageNumber.

MessageID LogPlayer::getCurrentMessageID  )  const
 

Returns the type of the current message.

Definition at line 472 of file LogPlayer.cpp.

References currentMessageNumber, MessageQueueBase::getMessageID(), and MessageID.

Referenced by saveAMV(), saveCSV(), and saveImages().

Here is the call graph for this function:

bool LogPlayer::isSmoothingEnabled  )  const [inline]
 

Returns the status of the smoothing flag.

Definition at line 151 of file LogPlayer.h.

References smoothingEnabled.

void LogPlayer::convertIntString char *  str,
int  value
[private]
 

little routine to convert an integer into C style string

Definition at line 116 of file LogPlayer.cpp.

Referenced by saveAMV().

unsigned long LogPlayer::getTimeStamp int  message  )  [private]
 

Returns the time stamp of a given message.

Parameters:
message The number of the message
Returns:
The time stamp

Definition at line 457 of file LogPlayer.cpp.

References MessageQueueBase::getTimeStamp().

Referenced by onIdle().

Here is the call graph for this function:


Member Data Documentation

LogPlayerState LogPlayer::state [private]
 

the state of the log player

Definition at line 159 of file LogPlayer.h.

Referenced by _new(), getState(), handleMessage(), jumpFrame(), onIdle(), pause(), play(), record(), stepBackward(), stepForward(), and stepRepeat().

MessageQueue& LogPlayer::targetQueue [private]
 

Definition at line 162 of file LogPlayer.h.

Referenced by jumpFrame(), onIdle(), stepBackward(), stepForward(), and stepRepeat().

double LogPlayer::playSpeed [private]
 

A factor, how fast the messages are played.

"2" playes the messages double as fast as they were recorded, "0.5" plays the messages with the half speed.

Definition at line 172 of file LogPlayer.h.

Referenced by onIdle(), and setPlaySpeed().

int LogPlayer::currentMessageNumber [protected]
 

The number of the current message.

Definition at line 183 of file LogPlayer.h.

Referenced by getCurrentMessageID(), getCurrentMessageNumber(), jumpFrame(), onIdle(), saveAMV(), saveCSV(), saveImages(), stepBackward(), stepForward(), stepRepeat(), and stop().

unsigned long LogPlayer::timeWhenFirstMessageWasPlayed [private]
 

The time when the first message was played.

Definition at line 187 of file LogPlayer.h.

Referenced by onIdle(), pause(), and setPlaySpeed().

unsigned long LogPlayer::timeOfFirstPlayedMessage [private]
 

The time stamp of the first played message.

Definition at line 190 of file LogPlayer.h.

Referenced by onIdle(), and pause().

bool LogPlayer::smoothingEnabled [private]
 

Flag which triggers smoothing of jpeg compressed images.

Definition at line 193 of file LogPlayer.h.

Referenced by isSmoothingEnabled(), and smooth().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:09:29 2004 for GT2004 by doxygen 1.3.6