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

#include <ureskeep.h>

Inheritance diagram for UResKeep:
Inheritance graph

Public Member Functions

UKeepItemadd (const char *name)
 
virtual void createResources ()
 
bool deleteKeep (const char *name)
 
UKeepItemgetKeepItem (const char *name)
 
const char * getKeepList (const char *preStr, char *buff, const int buffCnt)
 
int getKeepsCnt ()
 
UServerPushgetPushHandle (const char *process, bool eventOn)
 
virtual bool methodCall (const char *name, const char *paramOrder, char **strings, const double *pars, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
void run ()
 
void setWait (bool value)
 
 UResKeep ()
 
void UResKeepInit ()
 
virtual ~UResKeep ()
 
- Public Member Functions inherited from UResVarPool
int addMethod (const char *formalName, const char *paramTypes, const char *comment)
 
int addMethodV (const char *formalName, const char *paramTypes, const char *comment)
 
UVarPooladdStruct (const char *name, const char *comment, bool copy=false)
 
UVariableaddVar (const char *name, const double initialValue, const char *type, const char *comment)
 
UVariableaddVar (const char *name, const char *initialValue, const char *type, const char *comment)
 
UVariableaddVarA (const char *name, const char *initialValue, const char *type, const char *comment)
 
bool callGlobal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
bool callGlobalV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt)
 Call a method from the root var pool scope It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More...
 
bool callLocal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
bool callVS (const char *function, const char *stringParam)
 
int callVSCD (const char *function, const char *strPar, UDataBase *data, int cooSys)
 
void createBaseVar ()
 
virtual bool createVarSpace (const int varCnt, const int structCnt, const int methCnt, const char *note, bool copy=false)
 
bool getGlobalString (const char *name, const char **value)
 
bool getGlobalValue (const char *name, double *value)
 
bool getGlobalValue (const char *name, const char **value)
 
bool getGlobalValue (const char *name, bool *value)
 
bool getGlobalValue (const char *name, UTime *value)
 
bool getLocalValue (const char *name, double *value)
 get a value in this variable tree More...
 
bool getLocalValue (const char *name, bool *value)
 
bool getLocalValue (const char *name, UTime *value)
 
double getLocalValue (int idx)
 
UPosition getLocalValue3D (int idx)
 
UPosRot getLocalValue6D (int idx)
 
bool getLocalValueBool (int idx)
 
int getLocalValueInt (int idx)
 
UTime getLocalValueTime (int idx)
 
const char * getLogFileName ()
 
const char * getVarDescription (int idx)
 
UVarCalcgetVarPool ()
 
virtual bool gotAllResources (char *missingThese, int missingTheseCnt)
 
bool isLogFileOpen ()
 
bool isLogFileOpen (const char *structName)
 
bool isVarPoolUpdated (int lastCnt, int *newCnt)
 
void logFileClose ()
 
bool logFileOpen ()
 
void logFileStart (const char *structName, bool open)
 
bool setGlobalVar (const char *name, const double value, bool mayAdd)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar (int idx, double value, const int element)
 
bool setLocalVar (const char *name, const double value, bool mayAdd)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar3D (int idx, UPosition *value)
 
bool setLocalVar6D (int idx, UPosRot *value)
 
bool setLocalVarAdd (int idx, double value, const int element)
 
bool setLocalVarPose (int idx, UPose *value)
 
virtual bool setResource (UResBase *resource, bool remove)
 
void setVarPool (UVarCalc *sharedVarPool)
 
int updateQTvars (int structIdx)
 
 UResVarPool ()
 
virtual ~UResVarPool ()
 
- Public Member Functions inherited from UResBase
void createReplayVar (UVarPool *pool)
 
UCmdExegetCorePointer ()
 
char * getLogFileName (char *fn, const int fnCnt)
 
int getResFuncIdx ()
 
const char * getResID ()
 
int getResVersion ()
 
bool isA (const char *idStr)
 
bool isAlsoA (const char *id)
 
virtual void print (const char *preString)
 
virtual void saveSettings ()
 
void setCorePointer (UCmdExe *serverCore)
 
void setResFuncIdx (int idx)
 
virtual void setResID (const char *id, const int version)
 
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 ()
 
- Public Member Functions inherited from UVarMethodImplement
virtual bool methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt)
 
virtual ~UVarMethodImplement ()
 
- Public Member Functions inherited from ULogFile
void closeLog ()
 
void doFlush ()
 
FILE * getF ()
 
const char * getLogFileName ()
 
const char * getLogName ()
 
bool isLogOpen ()
 
bool isOpen ()
 
void logLock ()
 
bool logRename (const char *name)
 
void logUnlock ()
 
bool openLog ()
 
bool openLog (bool doOpen)
 
bool openLog (const char *resName)
 
void setLogFlush (bool doFlush)
 
void setLogName (const char *resName, const char *ext="log")
 
void setLogNameNumber (int number)
 add a number to the logfile name, That is if the logName is 'svs' and number is 2 (and logPath is '/rhome/demo'), then logfilename is set to '/rhome/demo/svs_2.log'. The purpose is to have an alternative, if the file renaming fails (if the file system is locked or something). More...
 
void setLogTime (UTime timestamp)
 
void toLog (const char *logString)
 
void toLog (const char *s1, const char *s2)
 
void toLog (const int num, const char *s1, const char *s2)
 
void toLog (const char *s1, const int num, const char *s2)
 
void toLog (const char *s1, const int n1, const int n2, const char *s2)
 
void toLog (const char *s1, const int num, const char *s2, const char *s3)
 
void toLog (const char *s1, const int n1, const int n2, const char *s2, const char *s3)
 
 ULogFile ()
 
void useLogTime (bool value)
 
 ~ULogFile ()
 
- Public Member Functions inherited from UServerPush
int addPushCommand (UServerInMsg *msg)
 
virtual void callGotNewDataWithObject ()
 
bool doPushCall (UServerPushElement *pe, const char *value)
 
void flushClientCmds (int clientIdx)
 
UServerPushImplementgetImplementor ()
 
int getPushCmdCnt (int *cmdCnt, int *callCnt)
 
UServerPushQueuegetPushQueue ()
 
bool gotCmdExe ()
 
void gotNewData (void *pData)
 
bool isUpdated (int lastCnt, int *newCnt)
 
bool needNewData ()
 
void print (const char *preString)
 
void print (const char *preString, char *buff, int buffCnt)
 
void servicePendingPushCmds ()
 
void setCmdExe (UServerPushImplement *executor)
 
void setImplementor (UServerPushImplement *executor)
 
bool setResource (UResBase *resource, bool remove)
 
bool setUpdated (const char *value)
 Add watch object if needed. An image or other object is updated. set object as updated, with an extra qualifier, that may be used as a parameter in a push call. this push list is then added to the to the push list examined by the server thread. when server thread reach this push list it will call to get a possible associated data structure by a call to needNewData() whish is expected to call gotNewData(void * data_structure) - but now in the server thread. More...
 
 UServerPush ()
 
virtual ~UServerPush ()
 

Public Attributes

bool verbose
 
- Public Attributes inherited from UReplay
bool replayTimeAdvancePending
 
UTime replayTimeNow
 

Protected Member Functions

void createBaseVar ()
 
bool start ()
 
void stop (bool andWait)
 
- Protected Member Functions inherited from UResVarPool
void setDescription (const char *note, bool copy=false)
 
- Protected Member Functions inherited from UResBase
UResBasegetStaticResource (const char *resName, bool mayCreate, bool staticOnly=true)
 get a pointer to a static resource. More...
 

Protected Attributes

UServerPusheventOff
 handle to push event handler, when any keep process goes off More...
 
UKeepItemkeeps [MAX_KEEPS_CNT]
 array of keep handles More...
 
int keepsCnt
 Number of keeps allocated. More...
 
pthread_t threadHandle
 
bool threadRunning
 
bool threadStop
 
UVariablevarErrCnt
 number of commands that returned error More...
 
UVariablevarIdleCnt
 idle count More...
 
UVariablevarKeepTime
 sample period time for keep thread More...
 
UVariablevarWait
 pointer to wait for all keep items More...
 
- Protected Attributes inherited from UResBase
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
 
- Protected Attributes inherited from ULogFile
int failCnt
 
FILE * logFile
 
ULock logFileLock
 
char logFileName [MAX_FILENAME_SIZE]
 
bool logFlush
 
char logName [MAX_FILENAME_SIZE]
 
UTime logTime
 
bool logTimeUse
 

Static Protected Attributes

static const int MAX_KEEPS_CNT = 100
 maximum number of keeps More...
 
- 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from UResVarPool
static const char * getResClassID ()
 

Detailed Description

This is the shared resource class. It must enherit from the resource base class (or one of its decendents) as shown.

Author
Christian Andersen

Constructor & Destructor Documentation

UResKeep::UResKeep ( )
inline
UResKeep::~UResKeep ( )
virtual

Destructor

References UKeepItem::eventOff.

Member Function Documentation

UKeepItem * UResKeep::add ( const char *  name)
void UResKeep::createBaseVar ( )
protected

Make the variables that will be available to other plugins

References UVarPool::addVar(), and UKeepItem::varWait.

void UResKeep::createResources ( )
virtual

Create any resources that this modules needs This method is called after the resource is registred by the server.

Reimplemented from UResBase.

References UKeepItem::core, UKeepItem::eventOff, UServerPush::setCmdExe(), and UServerPush::UServerPush().

bool UResKeep::deleteKeep ( const char *  name)

Delete a keep, and stop any monitoring related to this keep

Parameters
nameis the name of the keep
Returns
true if deleted keep, false if not existed.

References UVarPool::deleteStruct(), ULock::lock(), and ULock::unlock().

Referenced by UFuncKeep::handleKeep().

UKeepItem * UResKeep::getKeepItem ( const char *  name)

Get keep item pointer

Parameters
nameis the name of the keep
Returns
NULL if a keep with this name is not found

Referenced by UFuncKeep::handleKeep(), and UFuncKeep::handleKeepPush().

const char * UResKeep::getKeepList ( const char *  preStr,
char *  buff,
const int  buffCnt 
)

Get list of current keeps

Parameters
preStris a short string, that is added at the start of the buffer.
buffis the buffer, where to write the list.
buffCntis the size of the buffer
Returns
a pointer to buff

References bool2str(), UVariable::getBool(), and UKeepItem::varWait.

Referenced by UFuncKeep::handleKeep().

int UResKeep::getKeepsCnt ( )
inline

Get number of current keep processes

Returns
number of keeps, active or not

References UKeepItem::createBaseVar(), and UKeepItem::setWait().

Referenced by UFuncKeep::handleKeep().

UServerPush * UResKeep::getPushHandle ( const char *  process,
bool  eventOn 
)

Get handle to relevant push handler

Parameters
processif empty, the full resource handler is requested else process is expected to be the name of the process.
eventOnif false, then the eventOff handler is returned.
Returns
the requested event handler, or NULL if not found.

References UKeepItem::eventOff.

bool UResKeep::methodCall ( const char *  name,
const char *  paramOrder,
char **  strings,
const double *  pars,
double *  value,
UDataBase **  returnStruct,
int *  returnStructCnt 
)
virtual

The varPool has methods, and a call to one of these is needed. Do the call now and return (a double sized) result in 'value' and return true if the method call is allowed. If the returnStruct and returnStructCnt is not NULL, then a number (no more than initial value of returnStructCnt) of structures based on UDataBase may be returned into returnStruct array of pointers. The returnStructCnt should be modified to the actual number of used pointers (if needed). If the call is allowed, but the result is invalid for some reason, the return value 'value' can be set to som agreed value, (e.g. 0.0 (false) and 1.0 for true).

Reimplemented from UResVarPool.

const char * UResKeep::print ( const char *  preString,
char *  buff,
int  buffCnt 
)
virtual

print status to a string buffer

Reimplemented from UResVarPool.

void UResKeep::run ( )

Run the time loop to test for jobs to be activated. This call do not return until the threadStop flag is set true.

References UVariable::getBool(), ULock::lock(), mind(), UTime::Now(), UKeepItem::tick(), ULock::unlock(), UKeepItem::varWait, and Wait().

Referenced by startKeepLoopThread().

void UResKeep::setWait ( bool  value)

Set the wait flag. If waiting, then the monitoring of all keep items are off (and no action taken) When the flag is switched on, then the monitoring of (non waiting) keep items are restarted.

Parameters
valueis the new value for the wait flag.

References UVariable::setBool(), and UKeepItem::varWait.

Referenced by UFuncKeep::handleKeep().

bool UResKeep::start ( )
protected

Start read thread

Returns
Returns true if the read thread started.

References startKeepLoopThread().

void UResKeep::stop ( bool  andWait)
protectedvirtual

Stop read thread - and wait for thread join

Parameters
andWaitwait for thread to finish (ignored, waits always)

Reimplemented from UResBase.

void UResKeep::UResKeepInit ( )

Initialize resource

References UKeepItem::createBaseVar(), UKeepItem::eventOff, and UVarPool::verbose.

Member Data Documentation

UServerPush* UResKeep::eventOff
protected

handle to push event handler, when any keep process goes off

UKeepItem* UResKeep::keeps[MAX_KEEPS_CNT]
protected

array of keep handles

int UResKeep::keepsCnt
protected

Number of keeps allocated.

const int UResKeep::MAX_KEEPS_CNT = 100
staticprotected

maximum number of keeps

pthread_t UResKeep::threadHandle
protected

Thread handle for frame read thread.

bool UResKeep::threadRunning
protected

Is thread actually running

bool UResKeep::threadStop
protected

Should thread stop - terminate

UVariable* UResKeep::varErrCnt
protected

number of commands that returned error

UVariable* UResKeep::varIdleCnt
protected

idle count

UVariable* UResKeep::varKeepTime
protected

sample period time for keep thread

UVariable* UResKeep::varWait
protected

pointer to wait for all keep items

bool UResKeep::verbose

Is the resource to output verbose message to console

Referenced by UFuncKeep::handleKeep().


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