AURobotServers  4
Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
UReplay Class Reference

#include <ureplay.h>

Inheritance diagram for UReplay:
Inheritance graph

Public Member Functions

void addChild (UReplay *child)
 
virtual bool decodeReplayLine (char *)
 
char * getLogFileName (char *fn, const int fnCnt)
 
char * getReplayFileName (char *fn, const int fnCnt)
 
int getReplayLogLine ()
 
bool isReplay ()
 
bool isReplayFileOpen ()
 
void removeChild (UReplay *child)
 
virtual void replayAdvanceTime (UTime untilTime)
 
void replaySetBaseFileName (const char *name, const char *preName="")
 
void replaySetFileName (const char *name)
 
virtual bool replayStep ()
 
int replayStep (int steps)
 
virtual bool replayToTime (UTime untilTime)
 
void setParent (UReplay *parent)
 
bool setReplay (bool value)
 
virtual void updateReplayStatus ()
 
 UReplay ()
 
virtual ~UReplay ()
 

Public Attributes

bool replayTimeAdvancePending
 
UTime replayTimeNow
 

Protected Attributes

bool replay
 
FILE * replayFile
 
char replayFileName [REPLAY_FILE_NAME_LENGTH]
 replay filename More...
 
char replayLine [MAX_LOG_LINE_LENGTH]
 
int replayLogLine
 
UReplayreplayParent
 
UTime replayTimeNext
 

Static Protected Attributes

static const int MAX_LOG_LINE_LENGTH = 10000
 
static const int REPLAY_FILE_NAME_LENGTH = 264
 max length of replay filename More...
 

Private Attributes

UReplay ** childs
 list of childs that needs to be informed of replay steps. More...
 
int childsCnt
 number of childs in the child list. More...
 

Detailed Description

Base class for a shared resource. Includes commen handling of replay.

Author
Christian Andersen

Constructor & Destructor Documentation

UReplay::UReplay ( )
UReplay::~UReplay ( )
virtual

Destructor

References replayFile.

Member Function Documentation

void UReplay::addChild ( UReplay child)

Add a child to this replay structure.

References childs, and childsCnt.

Referenced by setParent(), and updateReplayStatus().

virtual bool UReplay::decodeReplayLine ( char *  )
inlinevirtual

Decode this replay line, that is assumed to be valid.

Parameters
lineis a pointer to the line.
Returns
true if the line is valid and used (step is successfull).
false if line is not a valid step.

Reimplemented in UResGps, UCamPool, UVarHist, UImagePool, and UFuncKinect.

References getLogFileName(), getReplayFileName(), replaySetBaseFileName(), replaySetFileName(), replayStep(), and setReplay().

Referenced by replayStep().

char* UReplay::getLogFileName ( char *  fn,
const int  fnCnt 
)

Get the full logfile name. This is the data path followed by the resource name and the '.log' extension

Parameters
fnbuffer for destination filename
fnCntis the length of the provided buffer Returns pointer to fn[] string.

Referenced by decodeReplayLine().

char * UReplay::getReplayFileName ( char *  fn,
const int  fnCnt 
)

Get the full replay logfile name. This is the replay path followed by the resource name and the '.log' extension

Parameters
fnbuffer for destination filename
fnCntis the length of the provided buffer Returns pointer to fn[] string.

References replayFileName, and replayPath.

Referenced by decodeReplayLine(), UFunctionImgPool::handleImageSetCommand(), UFuncKinect::handleKinect(), UFunctionVarPool::handleVarValues(), UFunctionVarPool::sendVar(), and setReplay().

int UReplay::getReplayLogLine ( )
inline

Get current replay log linenumber

Referenced by UFunctionVarPool::sendVar().

bool UReplay::isReplay ( )
inline
bool UReplay::isReplayFileOpen ( )
inline

Is the resource in replay mode

References replayFile.

Referenced by UFunctionVarPool::sendVar(), and UFunctionVarPool::sendVarList().

void UReplay::removeChild ( UReplay child)

Remove this child from replay list

Parameters
childis a pointer to the replay structure of the child to be removed. The child pointer is removed and the cound of children is decreased. If child is not found, then nothing happends.

References childs, and childsCnt.

Referenced by updateReplayStatus().

void UReplay::replayAdvanceTime ( UTime  untilTime)
virtual

Advance replay for all resources in replay mode until just before this time The function sets a flag and the steps are performed in main command thread as soon as possible (before next user queue, and before push events)

Reimplemented in ULaserPool.

References replayAdvanceTime(), replayParent, replayTimeAdvancePending, and replayTimeNow.

Referenced by UCmdExe::handleServerCommand(), replayAdvanceTime(), ULaserPool::replayAdvanceTime(), replayStep(), UReplayDevice::replayStep(), UResPoseHist::replayStep(), and UReplayDevice::replayStepToScan().

void UReplay::replaySetBaseFileName ( const char *  name,
const char *  preName = "" 
)

Set basename for replay file, this is preceded by the replay path and a '.log' is added.

Parameters
namelogfile name (excluding replay path and .log extension)
preNameoptional additional string inserted just in front of name (no '/' or '.' added)

References REPLAY_FILE_NAME_LENGTH, replayFile, and replayFileName.

Referenced by UFunctionImgPool::createResources(), UFunctionGps::createResources(), UFuncPiCam::createResources(), UFuncKinect::createResources(), and decodeReplayLine().

void UReplay::replaySetFileName ( const char *  name)

Set new replay file name (fully qualified filename). If replay is in progress, then the old file is closed, before assigning the new name.

Parameters
nameis the new mane.

References REPLAY_FILE_NAME_LENGTH, replayFile, and replayFileName.

Referenced by decodeReplayLine(), and UCamPool::UCamPoolInit().

bool UReplay::replayStep ( )
virtual
int UReplay::replayStep ( int  steps)

Replay N singles from the logfile.

Parameters
stepsnumber of steps to advance the line number reached in the replay file and -1 if no usable file.

References replay, replayAdvanceTime(), replayLogLine, replayStep(), and replayTimeNow.

bool UReplay::replayToTime ( UTime  untilTime)
virtual

Advance replay for this resources - if in replay mode - until just before this time

Parameters
untilTimeadvance with steps in logfile until this time is reached
Returns
true if advanced

Reimplemented in UResIf, and ULaserPool.

References childs, childsCnt, replay, replayStep(), replayTimeNext, and replayToTime().

Referenced by UFunctionPoseHist::handlePoseHistCommand(), UResPool::handleReplay(), and replayToTime().

void UReplay::setParent ( UReplay parent)

Set replay parent

Parameters
pointerto parent, parent has to be informed on steps, and if this child is deleted, then parent will inform if other childs has advanced.

References addChild(), and replayParent.

Referenced by updateReplayStatus().

bool UReplay::setReplay ( bool  value)

Set replay flag.

Parameters
valueif true, then the logfile (name.log) is attempted opened. If not successfull, the replay flag is still set to true, and attemped opened at next step true if replay file is opened or not

References getReplayFileName(), MAX_LOG_LINE_LENGTH, replay, replayFile, replayLine, replayLogLine, replayTimeNext, UTime::setTimeTod(), updateReplayStatus(), and UTime::valid.

Referenced by decodeReplayLine(), UVarLog::getUpdTime(), UFunctionCam::handleCamSetCommand(), UFunctionGps::handleCommand(), UFunctionImgPool::handleImageSetCommand(), UFuncKinect::handleKinect(), UFunctionVarPool::handleVarValues(), and replayStep().

virtual void UReplay::updateReplayStatus ( )
inlinevirtual

If replay status is maintained in global vars, then it is time to update

Reimplemented in UResBase, UImagePool, and UFuncKinect.

References addChild(), removeChild(), and setParent().

Referenced by replayStep(), and setReplay().

Member Data Documentation

UReplay** UReplay::childs
private

list of childs that needs to be informed of replay steps.

Referenced by addChild(), removeChild(), replayToTime(), and UReplay().

int UReplay::childsCnt
private

number of childs in the child list.

Referenced by addChild(), removeChild(), replayToTime(), and UReplay().

const int UReplay::MAX_LOG_LINE_LENGTH = 10000
staticprotected

Maximum length of a line in the logfile

Referenced by replayStep(), and setReplay().

bool UReplay::replay
protected

Is the resource in replay mode - this may trigger an update to time call

Referenced by isReplay(), replayStep(), replayToTime(), setReplay(), and UReplay().

const int UReplay::REPLAY_FILE_NAME_LENGTH = 264
staticprotected

max length of replay filename

Referenced by replaySetBaseFileName(), replaySetFileName(), and UResBase::setResID().

FILE* UReplay::replayFile
protected
char UReplay::replayFileName[REPLAY_FILE_NAME_LENGTH]
protected
char UReplay::replayLine[MAX_LOG_LINE_LENGTH]
protected

Buffer for latest line (but not used) line from logfile

Referenced by UCamPool::decodeReplayLine(), replayStep(), setReplay(), and UReplay().

int UReplay::replayLogLine
protected

Current line number in logfile

Referenced by replayStep(), setReplay(), UResBase::updateReplayStatus(), and UReplay().

UReplay* UReplay::replayParent
protected

if not a resource itself, then set pointer to parent resource, to handle the replay of other foles

Referenced by UVarLog::getUpdTime(), replayAdvanceTime(), setParent(), and UReplay().

bool UReplay::replayTimeAdvancePending

replay to time needs an update - set by the replay advance time call and reset by main command thread when serviced.

Referenced by UResPool::handleReplay(), replayAdvanceTime(), and UReplay().

UTime UReplay::replayTimeNext
protected
UTime UReplay::replayTimeNow

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