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

#include <uresif.h>

Inheritance diagram for UResIf:
Inheritance graph

Public Member Functions

const char * binName ()
 
bool binNameValid ()
 
void connectionHangUp ()
 
const char * getResID ()
 
virtual bool methodCall (const char *name, const char *paramOrder, char **strings, const double *pars, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
void openConnection (const char *newHost, const int newPort)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
void quitRemoteEnd ()
 
double rxTimeout ()
 
void setBinName (const char *handlerName)
 
void setBinNameValid (bool value)
 
void setHost (const char *newHost)
 
void setPort (const int)
 
virtual bool setReplay (bool value)
 
bool setResource (UResBase *resource, bool remove)
 
virtual const char * snprint (const char *preString, char *buff, int buffCnt)
 
 UResIf (const char *aliasID)
 
virtual ~UResIf ()
 
- Public Member Functions inherited from UClientHandler
unsigned long addDataTrap (const char *key, EVENT_CALL onEvent, void *object)
 
bool addFunction (UClientFuncBase *functionHandler, bool remove=false)
 
void closeConnection ()
 
void delDataTrap (unsigned long serial)
 
bool getNamespaceUse ()
 
const char * getServerNamespaceName ()
 
double getServerToLocalTime ()
 
bool isServerToLocalTimeValid ()
 
bool isThreadRunning ()
 
bool openConnection ()
 
void print (const char *preString)
 
void sendPing ()
 
void setHost (const char *host)
 
void setNamespace (const char *toName, const char *attributeString)
 
void setNamespaceLost ()
 
void setNamespaceUse (bool value)
 
void setPort (const int port)
 
void setVerbose (bool value)
 
const char * snprint (const char *preString, char *buff, const int buffCnt)
 
bool start ()
 
void stop (bool andWait)
 
void threadRunLoop ()
 
 UClientHandler ()
 
virtual ~UClientHandler ()
 
- Public Member Functions inherited from UClientPortSml
virtual const char * getSourceName ()
 
 UClientPortSml ()
 
- Public Member Functions inherited from UClientPort
bool blockSend (const char *buffer, int length)
 
void closeConnection ()
 
int getDataFromLine (char *buffer, int bufferSize, int pollTimeoutMs)
 
const char * getHost ()
 
const char * getHostIP ()
 
int getPort ()
 
bool isConnected ()
 
bool isVerbose ()
 
bool sendMsg (const char *message)
 
bool sendWithLock (const char *message)
 
void setHost (const char *toHost)
 
void setPort (int toPort)
 
void setVerbose (bool value)
 
bool tryConnect ()
 
 UClientPort ()
 
virtual ~UClientPort ()
 
- 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 USmlSource
void allowTagAtStartOfLineOnly ()
 
const char * getErrorBuffer ()
 
virtual int getLineNumber ()
 
virtual int getNBytes (char *buffer, int n, int msTimeout=100)
 
virtual bool getNextTag (USmlTag *tag, int msTimeout=100, USmlTagIn *failEndTag=NULL, char *beforeTagBuffer=NULL, int *beforeTagCnt=NULL)
 
char * getRxDataBuffer ()
 
int getRxDataBufferCnt ()
 
bool getToEndTag (USmlTagIn *tag, char *buffer, const int bufferSize, int msTimeout=100, USmlTagIn *lastTag=NULL)
 
bool isErrorText ()
 
bool isVerbose ()
 
virtual bool logSourceData (const char *, int)
 
void setErrorBuffer (char *buf, const int bufCnt)
 
virtual void setLineNumber (int)
 
int setRxDataBufferCnt (int newMaxLength)
 
virtual bool skipNBytes (int n, int msTimeout=100)
 
virtual bool skipToEndTag (USmlTagIn *tag, int msTimeout=100)
 
virtual void syntaxError (const char *message)
 
 USmlSource ()
 
virtual ~USmlSource ()
 
- 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)
 
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 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)
 
void setParent (UReplay *parent)
 
bool setReplay (bool value)
 
 UReplay ()
 
virtual ~UReplay ()
 
- 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 ()
 

Protected Member Functions

virtual void connectionChange (bool connected)
 
void createBaseVar ()
 
virtual void interfaceAlive ()
 
virtual void interfaceAliveTag (USmlTag *tag)
 
virtual void interfaceTick ()
 
virtual bool replayToTime (UTime untilTime)
 
- Protected Member Functions inherited from UClientHandler
void sendNamespaceCloseTag ()
 
virtual void sendNamespaceOpenTag ()
 
- Protected Member Functions inherited from UClientPortSml
virtual bool doVerboseMessages ()
 
virtual int getMoreData (char *buffer, int bufferSize, int pollTimeoutMs)
 
virtual bool isSourceAvailable ()
 
virtual bool outputData (const char *message)
 
- Protected Member Functions inherited from USmlSource
void clearRxBuffer ()
 
- 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

char aliasResID [MAX_ALIAS_LENGTH]
 
UTime aliveTime
 
UTime aliveTimeSend
 
UTime connectedTime
 time of last connect More...
 
UTime replayTime
 
UTime rxByteSec
 UTime last second. More...
 
int rxBytseSecCnt
 number of bytes at last sec time More...
 
UVariablevarAliveLimit
 
UVariablevarAliveReceived
 
UVariablevarBinaryName
 binary alias name More...
 
UVariablevarBinaryValid
 data handled as binary More...
 
UVariablevarConnected
 
UVariablevarConnectedTime
 length of last connection More...
 
UVariablevarConnectionCnt
 number of successful connections More...
 
UVariablevarExableXml
 
UVariablevarHost
 host name used when next connected More...
 
UVariablevarHostAlive
 
UVariablevarHostLoopAlive
 
UVariablevarPort
 portnumber when nex connected More...
 
UVariablevarQuitOnClose
 send quit on exit More...
 
UVariablevarRxBufSize
 size of receive buffer More...
 
UVariablevarRxBytes
 number of bytes received More...
 
UVariablevarRxBytesPerSec
 number of bytes received each second More...
 
UVariablevarRxTimeout
 time to maximum wait for more data on receive - befor give-up or return. More...
 
- Protected Attributes inherited from UClientHandler
bool binData
 is all data binary More...
 
char binTagName [MAX_BIN_NAME_LENGTH+1]
 
char namespaceAttributes [MAX_NORMAL_MESSAGE_LENGTH]
 
char namespaceName [MAX_SML_NAME_LENGTH]
 
bool namespaceUse
 
int notConnectedLoop
 
int rxTimeoutMs
 rx timeout value in ms More...
 
int serverNamespaceLevel
 
char serverNamespaceName [MAX_SML_NAME_LENGTH]
 
bool tryReConnect
 
- Protected Attributes inherited from UClientPort
enum UClientPort:: { ... }  connectionLostReason
 
UTime connectTime
 
char host [MAX_HOST_LENGTH]
 
char hostIP [MAX_HOST_LENGTH]
 
int port
 
unsigned int readCnt
 
bool verboseMessages
 
- Protected Attributes inherited from USmlSource
int dataCnt
 
char * errorBuffer
 
int errorBufferCnt
 
bool gotFirstTag
 
bool tagStartAtStartOfLineOnly
 
- 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_ALIAS_LENGTH = 30
 
- Static Protected Attributes inherited from UClientHandler
static const int MAX_BIN_NAME_LENGTH = 30
 binary tag name 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...
 

Private Attributes

bool makeUpdateEvent
 flag to make an event a little while after connection is established More...
 

Additional Inherited Members

- Static Public Member Functions inherited from UResVarPool
static const char * getResClassID ()
 
- Public Attributes inherited from UClientHandler
bool showInfo
 
bool showWarnings
 
bool tryHoldConnection
 
- Public Attributes inherited from UClientPort
int rxByteCnt
 
ULock tx
 
- Public Attributes inherited from USmlSource
const char * ifName
 
- Public Attributes inherited from UReplay
bool replayTimeAdvancePending
 
UTime replayTimeNow
 
- Static Public Attributes inherited from UClientHandler
static const int MAX_DATA_TRAPS = 100
 
- Protected Types inherited from UClientPort
enum  { notLost, forReopen, rxError, txError }
 

Detailed Description

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

Author
Christian Andersen

Constructor & Destructor Documentation

UResIf::UResIf ( const char *  aliasID)
UResIf::~UResIf ( )
virtual

Destructor

Member Function Documentation

const char* UResIf::binName ( )
inline

Get name associated to binary data

References UClientHandler::binTagName.

Referenced by UFunctionIf::handleIf().

bool UResIf::binNameValid ( )
inline

Get status of data as binary

References UClientHandler::binData.

Referenced by UFunctionIf::handleIf().

void UResIf::connectionChange ( bool  connected)
protectedvirtual
void UResIf::connectionHangUp ( )
inline
void UResIf::createBaseVar ( )
protected
const char* UResIf::getResID ( )
inline

Fixed name of this resource type

References aliasResID, and print().

Referenced by UFunctionIf::createResources(), and UResIf().

void UResIf::interfaceAlive ( )
protectedvirtual

Alive from other tags

Reimplemented from UClientHandler.

References aliveTime, and UTime::now().

Referenced by connectionHangUp().

void UResIf::interfaceAliveTag ( USmlTag tag)
protectedvirtual

Alive tick from receives data loop

Reimplemented from UClientHandler.

References aliveTime, USmlTagIn::getAttDouble(), UTime::now(), UVariable::setValued(), and varHostLoopAlive.

Referenced by connectionHangUp().

void UResIf::interfaceTick ( )
protectedvirtual
bool UResIf::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 what is needed and return (a double sized) result in 'value' and return true if the method call is allowed. The 'paramOrder' indicates the valid parameters d, s or c for double, string or class that is available as input values for the call. 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).

Reimplemented from UResVarPool.

References UClientPort::sendWithLock().

Referenced by snprint().

void UResIf::openConnection ( const char *  newHost,
const int  newPort 
)
inline
const char * UResIf::print ( const char *  preString,
char *  buff,
int  buffCnt 
)
virtual

print status to a string buffer

Reimplemented from UResVarPool.

References UClientHandler::snprint().

Referenced by getResID(), and snprint().

void UResIf::quitRemoteEnd ( )

Send quit to remote end if this is a connected server that uses a namespace this is assumed to understand a quit command

References UVariable::getBool(), UClientPort::isConnected(), UClientPort::sendWithLock(), UClientHandler::serverNamespaceLevel, varQuitOnClose, and Wait().

Referenced by connectionHangUp(), and UFunctionIf::~UFunctionIf().

bool UResIf::replayToTime ( UTime  untilTime)
protectedvirtual

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 from UReplay.

References UTime::getMicrosec(), UTime::getSec(), UClientPort::isConnected(), UResBase::replay, replayTime, and UClientPort::sendWithLock().

Referenced by connectionHangUp().

double UResIf::rxTimeout ( )
inline

Get timeout value for RX

References UClientHandler::rxTimeoutMs.

void UResIf::setBinName ( const char *  handlerName)
inline

Set name associated to binary data

References UVariable::setValues(), and varBinaryName.

Referenced by UFunctionIf::handleIf().

void UResIf::setBinNameValid ( bool  value)
inline

Set status of data as binary

References UVariable::setValued(), and varBinaryValid.

Referenced by UFunctionIf::handleIf().

void UResIf::setHost ( const char *  newHost)
inline

Set hostname to connect to

References UVariable::setValues(), and varHost.

void UResIf::setPort ( const int  )
inline

Set port number to connect to

References UClientPort::port, UVariable::setInt(), and varPort.

virtual bool UResIf::setReplay ( bool  value)
inlinevirtual

Set replay flag. replay actions is relayed to server in other end, if flag is true.

Parameters
valueif true replay is enabled, and interface will respond to replay actions true

References UTime::clear(), UResBase::replay, and replayTime.

Referenced by UFunctionIf::handleIf().

bool UResIf::setResource ( UResBase resource,
bool  remove 
)
virtual

Called by server core when new resources are available. return true is resouurce is used Save a pointer to the resource as needed.

Reimplemented from UResVarPool.

References UClientHandler::addFunction(), UCmdExe::getResClassID(), UResBase::isAlsoA(), UServerPush::setCmdExe(), and UResVarPool::setResource().

Referenced by snprint().

virtual const char* UResIf::snprint ( const char *  preString,
char *  buff,
int  buffCnt 
)
inlinevirtual

Print status for this resource

References methodCall(), print(), and setResource().

Referenced by UFunctionIf::handleIf().

Member Data Documentation

char UResIf::aliasResID[MAX_ALIAS_LENGTH]
protected

The alias name for this interface.

Referenced by getResID(), interfaceTick(), and UResIf().

UTime UResIf::aliveTime
protected

Time last alive statement were received

Referenced by connectionChange(), interfaceAlive(), interfaceAliveTag(), and interfaceTick().

UTime UResIf::aliveTimeSend
protected

Time last alive statement were received

Referenced by connectionChange(), and interfaceTick().

UTime UResIf::connectedTime
protected

time of last connect

Referenced by connectionChange(), and interfaceTick().

bool UResIf::makeUpdateEvent
private

flag to make an event a little while after connection is established

Referenced by connectionChange(), interfaceTick(), and UResIf().

const int UResIf::MAX_ALIAS_LENGTH = 30
staticprotected

Referenced by UResIf().

UTime UResIf::replayTime
protected

Replay time used

Referenced by replayToTime(), and setReplay().

UTime UResIf::rxByteSec
protected

UTime last second.

Referenced by interfaceTick().

int UResIf::rxBytseSecCnt
protected

number of bytes at last sec time

Referenced by interfaceTick().

UVariable* UResIf::varAliveLimit
protected

how long is the longest allowed pause before deemed dead

Referenced by createBaseVar(), and interfaceTick().

UVariable* UResIf::varAliveReceived
protected

time since last alive message was received

Referenced by createBaseVar(), and interfaceTick().

UVariable* UResIf::varBinaryName
protected

binary alias name

Referenced by createBaseVar(), interfaceTick(), and setBinName().

UVariable* UResIf::varBinaryValid
protected

data handled as binary

Referenced by createBaseVar(), interfaceTick(), and setBinNameValid().

UVariable* UResIf::varConnected
protected

Should interface try hold connection try hold the connection

Referenced by connectionChange(), connectionHangUp(), createBaseVar(), interfaceTick(), and openConnection().

UVariable* UResIf::varConnectedTime
protected

length of last connection

Referenced by connectionChange(), createBaseVar(), and interfaceTick().

UVariable* UResIf::varConnectionCnt
protected

number of successful connections

Referenced by connectionChange(), and createBaseVar().

UVariable* UResIf::varExableXml
protected

sent an alive test every second - if true

Referenced by createBaseVar(), and interfaceTick().

UVariable* UResIf::varHost
protected

host name used when next connected

Referenced by createBaseVar(), openConnection(), and setHost().

UVariable* UResIf::varHostAlive
protected

sent an alive test every second - if true

Referenced by createBaseVar(), and interfaceTick().

UVariable* UResIf::varHostLoopAlive
protected

time since last server loop

Referenced by createBaseVar(), interfaceAliveTag(), and interfaceTick().

UVariable* UResIf::varPort
protected

portnumber when nex connected

Referenced by createBaseVar(), openConnection(), and setPort().

UVariable* UResIf::varQuitOnClose
protected

send quit on exit

Referenced by createBaseVar(), and quitRemoteEnd().

UVariable* UResIf::varRxBufSize
protected

size of receive buffer

Referenced by createBaseVar(), and interfaceTick().

UVariable* UResIf::varRxBytes
protected

number of bytes received

Referenced by createBaseVar(), and interfaceTick().

UVariable* UResIf::varRxBytesPerSec
protected

number of bytes received each second

Referenced by createBaseVar(), and interfaceTick().

UVariable* UResIf::varRxTimeout
protected

time to maximum wait for more data on receive - befor give-up or return.

Referenced by createBaseVar(), and interfaceTick().


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