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

#include <uresrhdif.h>

Inheritance diagram for UResRhdIf:
Inheritance graph

Public Member Functions

const char * getHost ()
 
int getPort ()
 
bool isConnected ()
 
bool isWriteGranted ()
 
bool isWriteRequested ()
 
void run ()
 
void setHost (const char *hostName)
 
void setPort (int port)
 
void setWriteable (bool value)
 
bool tryConnect (bool aConnect, bool keep)
 
 UResRhdIf ()
 
void UResRhdIfInit ()
 
virtual ~UResRhdIf ()
 
- 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)
 
virtual bool methodCall (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct=NULL, int *returnStructCnt=NULL)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
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)
 
virtual void createResources ()
 
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 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

int keepsCnt
 Number of keeps allocated. More...
 
pthread_t threadHandle
 
bool threadRunning
 
bool threadStop
 
UVariablevarConnected
 is RHD connected */ More...
 
UVariablevarHost
 current host name More...
 
UVariablevarKeep
 should connection be reestablished if not connected More...
 
UVariablevarPort
 current port number More...
 
UVariablevars [MAX_VARS_CNT]
 array of variables for RHD variables More...
 
UVariablevarSampleTime
 sample time of the RHD More...
 
int varsCnt
 
UVariablevarWriteAccess
 
UVariablevarWriteGranted
 
- 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
 

Static Protected Attributes

static const int MAX_VARS_CNT = 500
 max number of RHD variables 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

UResRhdIf::UResRhdIf ( )
inline

Constructor

References UResBase::setResID(), UResRhdIfInit(), and ~UResRhdIf().

UResRhdIf::~UResRhdIf ( )
virtual

Destructor

References stop(), and tryConnect().

Referenced by UResRhdIf().

Member Function Documentation

void UResRhdIf::createBaseVar ( )
protected

Make the variables that will be available to other plugins

References UResVarPool::addVar(), UResVarPool::getVarPool(), varConnected, varHost, varKeep, varPort, varSampleTime, varWriteAccess, and varWriteGranted.

Referenced by isWriteGranted(), and UResRhdIfInit().

const char* UResRhdIf::getHost ( )
inline

Get current host name

References UVariable::getValues(), and varHost.

Referenced by UFuncRhdIf::handleRhd().

int UResRhdIf::getPort ( )
inline

Get current port number

Returns
the current selected port number (connected or not)

References UVariable::getInt(), and varPort.

Referenced by UFuncRhdIf::handleRhd().

bool UResRhdIf::isConnected ( )
inline

Is RDH connected

Returns
true if connected, else false.

References UVariable::getBool(), tryConnect(), and varConnected.

Referenced by UFuncRhdIf::handleRhd(), and tryConnect().

bool UResRhdIf::isWriteGranted ( )
inline

is write request granted.

Returns
true, if write granted flag is set.

References createBaseVar(), UVariable::getBool(), start(), stop(), and varWriteGranted.

Referenced by UFuncRhdIf::handleRhd().

bool UResRhdIf::isWriteRequested ( )
inline

is write request flag (for next connect) set - not the same as write granted.

Returns
true, if write request flag is set.

References UVariable::getBool(), and varWriteAccess.

Referenced by UFuncRhdIf::handleRhd().

void UResRhdIf::run ( )
void UResRhdIf::setHost ( const char *  hostName)
inline

Set host name

Parameters
hostNameis a c-string with new host name

References UVariable::setValues(), and varHost.

Referenced by UFuncRhdIf::handleRhd().

void UResRhdIf::setPort ( int  port)
inline

Set host name

Parameters
hostNameis a c-string with new host name

References run(), UVariable::setInt(), and varPort.

Referenced by UFuncRhdIf::handleRhd().

void UResRhdIf::setWriteable ( bool  value)
inline

Set write request flag (for next connect)

Parameters
valueif true, then a write request will be made.

References UVariable::setBool(), and varWriteAccess.

Referenced by UFuncRhdIf::handleRhd().

bool UResRhdIf::start ( )
protected

Start read thread

Returns
Returns true if the read thread started.

References startRhdLoopThread(), threadHandle, threadRunning, and threadStop.

Referenced by isWriteGranted(), and UResRhdIfInit().

void UResRhdIf::stop ( bool  andWait)
protectedvirtual

Stop read thread - and wait for thread join

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

Reimplemented from UResBase.

References threadHandle, threadRunning, and threadStop.

Referenced by isWriteGranted(), and ~UResRhdIf().

bool UResRhdIf::tryConnect ( bool  aConnect,
bool  keep 
)

Connect or stop connection to RHD

Parameters
valueif true, try to connect, if connected already, then do nothing
valueif false, then stop connection (hang-up) if not already stopped.
keeptry to reconnect if connection is lost
Returns
true if successful

References UVariable::getBool(), UVariable::getInt(), UVariable::getValues(), isConnected(), UVariable::setBool(), UServerPush::setUpdated(), varConnected, varHost, varKeep, varPort, varWriteAccess, and varWriteGranted.

Referenced by UFuncRhdIf::handleRhd(), isConnected(), run(), and ~UResRhdIf().

void UResRhdIf::UResRhdIfInit ( )

Initialize resource

References createBaseVar(), MAX_VARS_CNT, start(), threadRunning, vars, varsCnt, and verbose.

Referenced by UResRhdIf().

Member Data Documentation

int UResRhdIf::keepsCnt
protected

Number of keeps allocated.

const int UResRhdIf::MAX_VARS_CNT = 500
staticprotected

max number of RHD variables

Referenced by run(), and UResRhdIfInit().

pthread_t UResRhdIf::threadHandle
protected

Thread handle for frame read thread.

Referenced by start(), and stop().

bool UResRhdIf::threadRunning
protected

Is thread actually running

Referenced by run(), start(), stop(), and UResRhdIfInit().

bool UResRhdIf::threadStop
protected

Should thread stop - terminate

Referenced by run(), start(), and stop().

UVariable* UResRhdIf::varConnected
protected

is RHD connected */

Referenced by createBaseVar(), isConnected(), run(), and tryConnect().

UVariable* UResRhdIf::varHost
protected

current host name

Referenced by createBaseVar(), getHost(), setHost(), and tryConnect().

UVariable* UResRhdIf::varKeep
protected

should connection be reestablished if not connected

Referenced by createBaseVar(), run(), and tryConnect().

UVariable* UResRhdIf::varPort
protected

current port number

Referenced by createBaseVar(), getPort(), setPort(), and tryConnect().

UVariable* UResRhdIf::vars[MAX_VARS_CNT]
protected

array of variables for RHD variables

Referenced by run(), and UResRhdIfInit().

UVariable* UResRhdIf::varSampleTime
protected

sample time of the RHD

Referenced by createBaseVar(), and run().

int UResRhdIf::varsCnt
protected

number of used pointers in varRHD

Referenced by run(), and UResRhdIfInit().

UVariable* UResRhdIf::varWriteAccess
protected
UVariable* UResRhdIf::varWriteGranted
protected
bool UResRhdIf::verbose

Is the resource to output verbose message to console

Referenced by UResRhdIfInit().


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