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:

[legend]
Collaboration diagram for LogPlayer:

[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 | saveSynchronized (const char *fileName)
| Synchronizes the RemoteCamWorldstates with the robots timestamps and writes a resorted version of the logfile.
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.
void | keep (MessageID *messageIDs)
| The functions filters the message queue.
void | remove (MessageID *messageIDs)
| The functions filters the message queue.
void | statistics (int frequency[numOfMessageIDs])
| The function creates a histogram on the message ids contained in the log file.
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
MessageQueue & | targetQueue
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.
## Friends
class | CRemoteCamToolBar
class | CLogAnalyzerBase

## 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 22 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 578 of file LogPlayer.cpp. References LogPlayerState.

void LogPlayer::_new | ( |  | ) |

| Deletes all messages from the queue. Definition at line 30 of file LogPlayer.cpp. References MessageQueue::clear(), initial, 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 37 of file LogPlayer.cpp. References MessageQueue::clear(), InFile::exists(), and stop(). Referenced by CLogAnalyzerBase::openLogfile().

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 50 of file LogPlayer.cpp. References pause(), and playing.

Here is the call graph for this function:

void LogPlayer::pause | ( |  | ) |

| Pauses playing the queue. Definition at line 62 of file LogPlayer.cpp. References getNumberOfMessages(), initial, paused, 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 56 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 79 of file LogPlayer.cpp. References MessageQueue::copyMessage(), currentMessageNumber, getNumberOfMessages(), pause(), paused, and targetQueue.

Here is the call graph for this function:

void LogPlayer::stepBackward | ( |  | ) |

| Plays the previous message in the queue. Definition at line 71 of file LogPlayer.cpp. References MessageQueue::copyMessage(), currentMessageNumber, pause(), paused, and targetQueue.

Here is the call graph for this function:

void LogPlayer::stepRepeat | ( |  | ) |

| repeats the current message in the queue Definition at line 87 of file LogPlayer.cpp. References MessageQueue::copyMessage(), currentMessageNumber, pause(), paused, and targetQueue. Referenced by keep(), and remove().

Here is the call graph for this function:

void LogPlayer::jumpFrame | ( | int | frame | ) |

| jumps to given message-number in the queue Definition at line 95 of file LogPlayer.cpp. References MessageQueue::copyMessage(), currentMessageNumber, getNumberOfMessages(), pause(), paused, 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 543 of file LogPlayer.cpp. References initial, pause(), paused, playing, and recording.

Here is the call graph for this function:

void LogPlayer::smooth | ( |  | ) |

| Activates/deactivates jpeg image smoothing. Definition at line 558 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 103 of file LogPlayer.cpp. References OutFile::exists(), and getNumberOfMessages(). Referenced by saveSynchronized().

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 131 of file LogPlayer.cpp. References InMessage::bin, Image::cameraInfo, convertIntString(), currentMessageNumber, OutFile::exists(), getCurrentMessageID(), getNumberOfMessages(), idImage, idJPEGImage, Image::image, MessageQueue::in, 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 199 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 220 of file LogPlayer.cpp. References InMessage::bin, SpecialPercept::checkerPose, currentMessageNumber, OutFile::exists(), RobotPose::frameNumber, SpecialPercept::frameNumber, getCurrentMessageID(), getNumberOfMessages(), idRemoteCamWorldState, idSpecialPercept, idWorldState, MessageQueue::in, RECEIVE_WORLDSTATE, Pose2D::rotation, saveCSVrow(), MessageQueueBase::setSelectedMessageForReading(), stop(), RobotPose::timestamp, Pose2D::translation, SpecialPercept::type, Vector2< double >::x, and Vector2< double >::y.

Here is the call graph for this function:

bool LogPlayer::saveSynchronized | ( | const char * | fileName | ) |

  | Synchronizes the RemoteCamWorldstates with the robots timestamps and writes a resorted version of the logfile. Condition: Logfile must contain TimeSynchronziation Messages from robot and remoteCam. Parameters:
  fileName | the name of the file to write
Returns: if the writing was successful Definition at line 309 of file LogPlayer.cpp. References OutMessage::bin, InMessage::bin, MessageQueue::copyMessage(), currentMessageNumber, OutMessage::finishMessage(), getCurrentMessageID(), MessageQueueBase::getData(), MessageQueueBase::getMessageID(), MessageQueueBase::getMessageSize(), MessageQueueBase::getMessageWasSentFromAPhysicalRobot(), MessageQueueBase::getNumberOfMessages(), getNumberOfMessages(), PlayerPoseCollection::getOpponentPlayerPose(), PlayerPoseCollection::getOwnPlayerPose(), MessageQueueBase::getPlayerNumber(), MessageQueueBase::getTeamColor(), MessageQueueBase::getTimeStamp(), RobotPose::getValidity(), idRemoteCamWorldState, idSyncTimestampRemoteCam, idSyncTimestampRobot, MessageQueue::in, PlayerPoseCollection::numberOfOpponentPlayers, PlayerPoseCollection::numberOfOwnPlayers, MessageQueue::out, MessageQueue::queue, RECEIVE_WORLDSTATE, save(), BallModel::seen, SEND_WORLD_STATE, PlayerPose::setFrameNumber(), BallModel::setFrameNumber(), RobotPose::setFrameNumber(), PlayerPoseCollection::setOpponentPlayerPose(), PlayerPoseCollection::setOwnPlayerPose(), MessageQueueBase::setSelectedMessageForReading(), RobotPose::setTimestamp(), RobotPose::timestamp, SeenBallState::timeWhenLastSeen, and OutStream< OutMessageQueue, OutBinary >::write().

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 454 of file LogPlayer.cpp. References InMessage::bin, Image::cameraInfo, Image::convertFromYCbCrToRGB(), currentMessageNumber, OutFile::exists(), getCurrentMessageID(), getNumberOfMessages(), idImage, idJPEGImage, Image::image, MessageQueue::in, 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 566 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 572 of file LogPlayer.cpp. References recording.

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 583 of file LogPlayer.cpp. References MessageQueue::copyMessage(), currentMessageNumber, SystemCall::getCurrentSystemTime(), getNumberOfMessages(), SystemCall::getTimeSince(), getTimeStamp(), playing, playSpeed, MessageQueue::removeRepetitions(), 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 627 of file LogPlayer.cpp. References MessageQueueBase::getNumberOfMessages(). Referenced by jumpFrame(), keep(), onIdle(), pause(), CLogAnalyzerBase::readLogfile(), remove(), save(), saveAMV(), saveCSV(), saveImages(), saveSynchronized(), statistics(), and stepForward().

Here is the call graph for this function:

int LogPlayer::getCurrentMessageNumber | ( |  | ) | const

| Returns the number of the current message. Definition at line 632 of file LogPlayer.cpp. References currentMessageNumber.

MessageID LogPlayer::getCurrentMessageID | ( |  | ) | const

| Returns the type of the current message. Definition at line 637 of file LogPlayer.cpp. References currentMessageNumber, MessageQueueBase::getMessageID(), and MessageID. Referenced by keep(), CLogAnalyzerBase::readLogfile(), remove(), saveAMV(), saveCSV(), saveImages(), and saveSynchronized().

Here is the call graph for this function:

void LogPlayer::keep | ( | MessageID * | messageIDs | ) |

  | The functions filters the message queue. Parameters:
  messageIDs | An null-terminated array of message ids that should be kept.
Definition at line 643 of file LogPlayer.cpp. References currentMessageNumber, getCurrentMessageID(), getNumberOfMessages(), MessageID, MessageQueue::moveAllMessages(), MessageQueue::queue, MessageQueueBase::setSelectedMessageForReading(), and stepRepeat().

Here is the call graph for this function:

void LogPlayer::remove | ( | MessageID * | messageIDs | ) |

  | The functions filters the message queue. Parameters:
  messageIDs | An null-terminated array of message ids that should be removed.
Definition at line 663 of file LogPlayer.cpp. References currentMessageNumber, getCurrentMessageID(), getNumberOfMessages(), MessageID, MessageQueue::moveAllMessages(), MessageQueue::queue, MessageQueueBase::setSelectedMessageForReading(), and stepRepeat().

Here is the call graph for this function:

void LogPlayer::statistics | ( | int | frequency[numOfMessageIDs] | ) |

  | The function creates a histogram on the message ids contained in the log file. Parameters:
  frequency | An array that is filled with the frequency of message ids.
Definition at line 682 of file LogPlayer.cpp. References ASSERT, MessageQueueBase::getMessageID(), getNumberOfMessages(), numOfMessageIDs, and MessageQueueBase::setSelectedMessageForReading().

Here is the call graph for this function:

bool LogPlayer::isSmoothingEnabled | ( |  | ) | const`[inline]`

| Returns the status of the smoothing flag. Definition at line 178 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 117 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 622 of file LogPlayer.cpp. References MessageQueueBase::getTimeStamp(). Referenced by onIdle().

Here is the call graph for this function:

## Friends And Related Function Documentation

friend class CRemoteCamToolBar`[friend]`

| Reimplemented from MessageQueue. Definition at line 212 of file LogPlayer.h.

friend class CLogAnalyzerBase`[friend]`

| Definition at line 213 of file LogPlayer.h.

## Member Data Documentation

LogPlayerState LogPlayer::state`[private]`

| the state of the log player Definition at line 186 of file LogPlayer.h.

MessageQueue& LogPlayer::targetQueue`[private]`

| Definition at line 189 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 199 of file LogPlayer.h. Referenced by onIdle(), and setPlaySpeed().

int LogPlayer::currentMessageNumber`[protected]`

| The number of the current message. Definition at line 210 of file LogPlayer.h. Referenced by getCurrentMessageID(), getCurrentMessageNumber(), jumpFrame(), keep(), onIdle(), CLogAnalyzerBase::readLogfile(), remove(), saveAMV(), saveCSV(), saveImages(), saveSynchronized(), stepBackward(), stepForward(), stepRepeat(), and stop().

unsigned long LogPlayer::timeWhenFirstMessageWasPlayed`[private]`

| The time when the first message was played. Definition at line 217 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 220 of file LogPlayer.h. Referenced by onIdle(), and pause().

bool LogPlayer::smoothingEnabled`[private]`

| Flag which triggers smoothing of jpeg compressed images. Definition at line 223 of file LogPlayer.h. Referenced by isSmoothingEnabled(), and smooth().

The documentation for this class was generated from the following files:

- Tools/MessageQueue/LogPlayer.h
- Tools/MessageQueue/LogPlayer.cpp