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

#include <uresbase.h>

Inheritance diagram for UResBase:
Inheritance graph

Public Member Functions

void createReplayVar (UVarPool *pool)
 
virtual void createResources ()
 
UCmdExegetCorePointer ()
 
char * getLogFileName (char *fn, const int fnCnt)
 
int getResFuncIdx ()
 
const char * getResID ()
 
int getResVersion ()
 
virtual bool gotAllResources (char *, int)
 
bool isA (const char *idStr)
 
bool isAlsoA (const char *id)
 
virtual void print (const char *preString)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
virtual void saveSettings ()
 
void setCorePointer (UCmdExe *serverCore)
 
void setResFuncIdx (int idx)
 
virtual void setResID (const char *id, const int version)
 
virtual bool setResource (UResBase *, bool)
 
virtual void stop (bool)
 
virtual void updateReplayStatus ()
 
 UResBase ()
 
virtual ~UResBase ()
 
- Public Member Functions inherited from UReplay
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)
 
 UReplay ()
 
virtual ~UReplay ()
 
- Public Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 

Protected Member Functions

UResBasegetStaticResource (const char *resName, bool mayCreate, bool staticOnly=true)
 get a pointer to a static resource. More...
 

Protected Attributes

int resFuncIdx
 
char resID [MAX_RESOURCE_ID_LENGTH]
 
char resIsAlso [MAX_RESOURCE_ISALSO_LENGTH]
 
int resVersion
 
- Protected Attributes inherited from UReplay
bool replay
 
FILE * replayFile
 
char replayFileName [REPLAY_FILE_NAME_LENGTH]
 replay filename More...
 
char replayLine [MAX_LOG_LINE_LENGTH]
 
int replayLogLine
 
UReplayreplayParent
 
UTime replayTimeNext
 

Private Attributes

UCmdExecore
 max length of replay filename More...
 
struct {
   UVariable *   line
 
   UVariable *   replay
 
   UVariable *   time
 
var
 

Additional Inherited Members

- Public Attributes inherited from UReplay
bool replayTimeAdvancePending
 
UTime replayTimeNow
 
- Static Protected Attributes inherited from UReplay
static const int MAX_LOG_LINE_LENGTH = 10000
 
static const int REPLAY_FILE_NAME_LENGTH = 264
 max length of replay filename More...
 

Detailed Description

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

Author
Christian Andersen

Constructor & Destructor Documentation

UResBase::UResBase ( )

Constructor

References core, resID, resIsAlso, setResID(), and var.

UResBase::~UResBase ( )
virtual

Destructor

References UReplay::replayFile.

Member Function Documentation

void UResBase::createReplayVar ( UVarPool pool)

Replay N singles from the logfile.

Parameters
stepsnumber of steps to advance true if N steps were available in replay file. Set replay flag. If replay flag is changed to true, the logfile (odo.log) is attempted opened. If successfull, the current pose history is cleared and the first record read and implemented. If not successfull, the replay flag is set to true, and the pose history is cleared only. Returns true if replay file is opened Set new replay file name. If replay is in progress, then the old file is closed, before assigning the new name.
nameis the new mane. Create local replay variables for status updates

References UVarPool::addVar(), and var.

Referenced by UCamPool::createBaseVar(), and createResources().

virtual void UResBase::createResources ( )
inlinevirtual
UCmdExe* UResBase::getCorePointer ( )
inline

Get current pointer to core (UCmdExe)

References core.

Referenced by UResIfVar::handleVar(), and UResMapObst::sendMapLinesToLocalizer().

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

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) Replay one step in the logfile.

Returns
false if no more steps area available in logfile 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 Is the resource in replay mode 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. 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. Get the full logfile name. This is the data path followed by the resource name and the '.log' extension
fnbuffer for destination filename
fnCntis the length of the provided buffer Returns pointer to fn[] string.

References dataPath, and resID.

Referenced by stop().

int UResBase::getResFuncIdx ( )
inline

Get the function index of the owner of this resource

References resFuncIdx.

Referenced by UResPool::getResFunc(), UCmdExe::getStaticResource(), UCmdExe::isResourceOwner(), and UResPool::removeResourceFunc().

const char* UResBase::getResID ( )
inline
int UResBase::getResVersion ( )
inline
UResBase * UResBase::getStaticResource ( const char *  resName,
bool  mayCreate,
bool  staticOnly = true 
)
protected

get a pointer to a static resource.

Parameters
resNameThe name of the resource to be acquired.
mayCreateif set to true, then the resource will be created if it do not exist already.
staticOnlyif true only a static resource is returned. Should realy only be used for non-static resources if inside the same plugin.
Returns
NULL if not found, else a bointer to an existing type

References core, and UCmdExe::getStaticResource().

Referenced by UResAvoid::copyAvoidObstacles(), UResAvoid::copyCellPolys(), UResAvoid::copyFootprintPolys(), createResources(), UCamPool::decodeReplayLine(), UResPassable::doObstAnalysis(), UResMapObst::getNearObstacles(), ULaserPool::getScan(), UResLocater::locate(), UResLobst::methodCallV(), UResLocater::polygonToPolyPlugin(), UResLobst::sendAsObstacles(), UResMapObst::sendMapLinesToLocalizer(), UResLocater::set_poselast(), UResLocater::set_state(), UResLocater::set_utmstate(), UImagePool::setLogImg(), UResLocater::setUtmPoseToMapPose(), UQtgui::updateImg(), UResObstacle::updateMappedObstacles(), and UQtgui::updateVar().

virtual bool UResBase::gotAllResources ( char *  ,
int   
)
inlinevirtual

Test if all needed resources are loaded. 'missingThese is a buffer where missing resources should be written. 'missingTheseCnt' isthe buffer size not to be resexceeded. Should return true if all resources are available.

Reimplemented in UFunctionBase, UResNavIfMan, UCamPool, UResVarPool, UResDisp, UResLaserIfRoad, ULaserPool, UImagePool, UResLaserIfScan, UResDrivePos, UResRoadDrive, UResCamIf, UResPoseHist, UResCamIfImg, and UResV360.

References isAlsoA().

Referenced by UResPoseHist::gotAllResources(), UResRoadDrive::gotAllResources(), UResDrivePos::gotAllResources(), ULaserPool::gotAllResources(), UResLaserIfRoad::gotAllResources(), and UResVarPool::gotAllResources().

bool UResBase::isA ( const char *  idStr)
bool UResBase::isAlsoA ( const char *  id)
void UResBase::print ( const char *  preString)
virtual

Print the (short) status of resource

Reimplemented in UFunctionBase, UCmdExe, and UCamPool.

Referenced by getResVersion(), and UResPool::print().

const char * UResBase::print ( const char *  preString,
char *  buff,
int  buffCnt 
)
virtual
virtual void UResBase::saveSettings ( )
inlinevirtual

Save settings for this resource as needed This is called after the stop call, so all action should be stopped at this call. but all modules are still loaded.

Reimplemented in UCamPool.

References setResID().

Referenced by UResPool::saveSettings().

void UResBase::setCorePointer ( UCmdExe serverCore)
inline

Set pointer to core (UCmdExe)

References core.

Referenced by UCmdExe::addResource(), and UCmdExe::UCmdExeInit().

void UResBase::setResFuncIdx ( int  idx)
inline

Set reference index to function owning the resource. This is called by server core and should not be changed.

References resFuncIdx.

Referenced by UCmdExe::addResource().

void UResBase::setResID ( const char *  id,
const int  version 
)
virtual

Function to set a resource ID, this should NOT be called after the resource is known to the server.

Parameters
[in]*idis the new name (possibly an alias) for this version of the resource

Reimplemented in UResPoseHist.

References MAX_RESOURCE_ID_LENGTH, MAX_RESOURCE_ISALSO_LENGTH, UReplay::REPLAY_FILE_NAME_LENGTH, UReplay::replayFileName, resID, resIsAlso, and resVersion.

Referenced by UFunctionGps::createResources(), UFuncBin::createResources(), saveSettings(), UFunctionBase::setCommand(), UResPoseHist::setResID(), UCamPool::UCamPool(), UCamPool::UCamPoolInit(), UCmdExe::UCmdExe(), UFunctionBase::UFunctionBase(), UImagePool::UImagePool(), ULaserPool::ULaserPool(), UPoseHistNotUsed::UPoseHistNotUsed(), UResAuEf::UResAuEf(), UResAvoid::UResAvoid(), UResBase(), UResBin::UResBin(), UResCamIf::UResCamIf(), UResCamIfCam::UResCamIfCam(), UResCamIfGmk::UResCamIfGmk(), UResCamIfImg::UResCamIfImg(), UResCamIfPath::UResCamIfPath(), UResDrivePos::UResDrivePos(), UResDummy::UResDummy(), UResIf::UResIf(), UResIfBase::UResIfBase(), UResIfVar::UResIfVar(), UResLaserIf::UResLaserIf(), UResLaserIfObst::UResLaserIfObst(), UResLaserIfScan::UResLaserIfScan(), UResLaserIfSf::UResLaserIfSf(), UResLobst::UResLobst(), UResLocater::UResLocater(), UResMapObst::UResMapObst(), UResObstacle::UResObstacle(), UResPassable::UResPassable(), UResPcp::UResPcp(), UResRhdIf::UResRhdIf(), UResRoadDrive::UResRoadDrive(), UResRoadLine::UResRoadLine(), UResRoseBot::UResRoseBot(), UResSmrCtl::UResSmrCtl(), UResV360::UResV360(), and UResVarPool::UResVarPool().

virtual bool UResBase::setResource ( UResBase ,
bool   
)
inlinevirtual
virtual void UResBase::stop ( bool  )
inlinevirtual
void UResBase::updateReplayStatus ( )
virtual

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

Reimplemented from UReplay.

Reimplemented in UImagePool, and UFuncKinect.

References UReplay::isReplay(), UReplay::replayFile, UReplay::replayLogLine, UReplay::replayTimeNow, and var.

Referenced by createResources().

Member Data Documentation

UCmdExe* UResBase::core
private

max length of replay filename

Is the resource in replay mode - this may trigger an update to time call Next Replay time available in logfile Replay file handlereplay filename Maximum length of a line in the logfile Buffer for latest line (but not used) line from logfile Current line number in logfile replay to time needs an update - set by the replay advance time call and reset by main command thread when serviced. Current replay time, and the time that should be advanced to by all other replaying devices Pointer to server core (UCmdExe), to access static resources

Referenced by getCorePointer(), getStaticResource(), setCorePointer(), and UResBase().

UVariable* UResBase::line
UVariable* UResBase::replay
int UResBase::resFuncIdx
protected

Index to function owner of resource

Referenced by getResFuncIdx(), setResFuncIdx(), and UCmdExe::UCmdExeInit().

char UResBase::resID[MAX_RESOURCE_ID_LENGTH]
protected

Name of resource (identification)

Referenced by getLogFileName(), getResID(), isA(), setResID(), UCmdExe::sysModuleCmd(), and UResBase().

char UResBase::resIsAlso[MAX_RESOURCE_ISALSO_LENGTH]
protected

Name of resource (identification)

Referenced by isAlsoA(), setResID(), and UResBase().

int UResBase::resVersion
protected
UVariable* UResBase::time
struct { ... } UResBase::var

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