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

#include <urespoly.h>

Inheritance diagram for UResPoly:
Inheritance graph

Public Member Functions

UPolyItemadd (const char *name)
 
UPolyItemadd (const char *name, const double x, const double y, const double z=0.0)
 
const char * codePolysXml (const char *tagName, char *buf, const int bufCnt, UTime updatedSince)
 
bool codePolyXml (const char *tagName, char *buf, const int bufCnt, UTime updatedSince, int idx)
 
virtual const char * commandList ()
 
virtual void createResources ()
 
bool del (const char *name)
 
UPolyItemgetItem (const char *name)
 
UPolyItemgetItem (int idx)
 
const char * getList (const char *preStr, char *buff, const int buffCnt)
 
UPolyItemgetNext (int p1, int *p2, const char *name)
 
int getPolysCnt ()
 
void gotNewData ()
 
virtual void handleNewData (USmlTag *tag, const char *ifname)
 
virtual bool methodCall (const char *name, const char *paramOrder, char **strings, const double *pars, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
virtual bool methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct=NULL, int *returnStructCnt=NULL)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
 UResPoly ()
 
void UResPolyInit ()
 
virtual ~UResPoly ()
 
- Public Member Functions inherited from UResIfBase
 UResIfBase ()
 
 ~UResIfBase ()
 
- Public Member Functions inherited from UClientFuncBase
virtual void changedNamespace (const char *newNamespace)
 
virtual void doTimeTick ()
 
int getMsgCnt ()
 
bool getVerbose ()
 
virtual const char * name ()
 
bool sendMsg (UClientPortSml *cnn, const char *buff, int buffCnt)
 
bool sendMsg (UClientPortSml *cnn, const char *buff)
 
void setVerbose (bool value)
 
 UClientFuncBase ()
 
virtual ~UClientFuncBase ()
 
- 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 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 ()
 
- Public Member Functions inherited from UVarMethodImplement
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 Attributes

bool verbose
 
- Public Attributes inherited from UClientFuncBase
ULock decodeLock
 
- Public Attributes inherited from UReplay
bool replayTimeAdvancePending
 
UTime replayTimeNow
 

Protected Member Functions

void createBaseVar ()
 
- Protected Member Functions inherited from UClientFuncBase
void handleHelp (USmlTag *tag)
 
void printReply (USmlTagIn *tag, const char *preString)
 
- 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

UPolyItempolys [MAX_POLYS_CNT]
 array of poly handles More...
 
int polysCnt
 Number of polys allocated. More...
 
UVariablevarCallDispOnNewData
 inform a potential display plugin, that new data is available More...
 
UVariablevarPolyCnt
 number of established poly items More...
 
UVariablevarUpdTime
 last update time for polygons More...
 
- Protected Attributes inherited from UClientFuncBase
int msgHandled
 
char serverNamespace [MAX_SML_NAME_LENGTH]
 
int serverNamespaceValue
 
bool verboseMessages
 
- 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_POLYS_CNT = 1000
 maximum number of polys 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

UResPoly::UResPoly ( )
inline

Constructor

UResPoly::~UResPoly ( )
virtual

Destructor

Member Function Documentation

UPolyItem * UResPoly::add ( const char *  name)

Add a new poly item

Parameters
nameis the name of the new item. The name must be unique,
Returns
a pointer to the new item, or null if it exist already, or could not be added.

References UPolygon::getPointsCnt(), ULock::lock(), UPolygon::setAsPolyline(), UPolyItem::setName(), ULock::unlock(), and UPolyItem::UPolyItem().

Referenced by ULineMatch::addToPoly(), UFuncPoly::handleCommand(), UFuncLoca2::handleCommand(), UFuncLocalize::handleLocalize(), UFuncBall::makeDisplayPolygon(), and UFuncImSeg::makeDisplayPolygon().

UPolyItem * UResPoly::add ( const char *  name,
const double  x,
const double  y,
const double  z = 0.0 
)

Add a new poly item

Parameters
nameis the name of a new or existing item. Names are unique,
x,y,zis a position that is added to the end of the item points, z is optional.
Returns
a pointer to the item, or null if it do not exist and could not be added.

References UPolygon::add(), UPolygon::clear(), UPolygon::getPointsCnt(), ULock::lock(), UPolygon::setAsPolyline(), UPolyItem::setName(), UPolyItem::setUpdated(), ULock::unlock(), and UPolyItem::UPolyItem().

const char * UResPoly::codePolysXml ( const char *  tagName,
char *  buf,
const int  bufCnt,
UTime  updatedSince 
)

code all polygons to an XML message into this buffer

Parameters
tagNameis the name to the tag, in wich the polygons are to be listed.
buffis the buffer, where to write the code.
buffCntis the size of the buffer
updatedSinceonly items updated later than this is XML packed
Returns
a pointer to buff

References buf, UPolyItem::codeXML(), and UPolyItem::updateTime.

bool UResPoly::codePolyXml ( const char *  tagName,
char *  buf,
const int  bufCnt,
UTime  updatedSince,
int  idx 
)

code all polygons to an XML message into this buffer

Parameters
tagNameis the name to the tag, in wich the polygons are to be listed.
buffis the buffer, where to write the code.
buffCntis the size of the buffer
updatedSinceonly items updated later than this is XML packed
idxis index to the polygon to code.
Returns
true if the update time is later than updatedSince (else not coded)

References buf, UPolyItem::codeXML(), and UPolyItem::updateTime.

Referenced by UFuncPoly::handleCommand().

virtual const char* UResPoly::commandList ( )
inlinevirtual

Function, that shall return a string with all handled commands, i.e. should return "gmk gmk2d guidemark", if commands starting with any of these three keywords are handled by this function

Reimplemented from UClientFuncBase.

References UPolyItem::name, and UPolyItem::print().

void UResPoly::createBaseVar ( )
protected

Make the variables that will be available to other plugins

void UResPoly::createResources ( )
virtual

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

Reimplemented from UResBase.

bool UResPoly::del ( const char *  name)

Delete a poly, that is, set vertex count to 0 This marks that the polygon is empty and the polygon slot may be reused.

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

References UPolygon::clear(), ULock::lock(), and ULock::unlock().

Referenced by UFuncPoly::handleCommand().

UPolyItem * UResPoly::getItem ( const char *  name)

Get poly item pointer

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

Referenced by ULineMatch::addToPoly(), UFuncLoca2::correlateLines(), UFuncLoca2::handleCommand(), UFuncLocalize::handleLocalize(), UFuncBall::makeDisplayPolygon(), UFuncImSeg::makeDisplayPolygon(), and UNavPaint::paintPolyItems().

UPolyItem* UResPoly::getItem ( int  idx)
inline

get an item by index, NB no range check

Parameters
idxthe index to the items available, should be in the range 0..getPolysCnt()-1.
Returns
a pointer to the iten, NB! the pointer may be NULL

References UPolygon::add().

const char * UResPoly::getList ( const char *  preStr,
char *  buff,
const int  buffCnt 
)

Get list of current polys

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

Referenced by UFuncPoly::handleCommand().

UPolyItem * UResPoly::getNext ( int  p1,
int *  p2,
const char *  name 
)

Get poly item pointer starting at index 'p1'

Parameters
p1is the first polygon to search for the next name that matches 'name'
p2is set (if not NULL) to the next polygon after the found
nameis the name of the poly
Returns
NULL if a poly with this name is not found

References UPolyItem::match().

Referenced by UFuncLocalize::handleAddLine(), UFuncLoca2::handleAddLine(), and UFuncPoly::handleCommand().

int UResPoly::getPolysCnt ( )
inline

Get number of current poly processes

Returns
number of polys, active or not

References buf.

Referenced by UFuncPoly::handleCommand(), and UNavPaint::paintPolyItems().

void UResPoly::gotNewData ( )
void UResPoly::handleNewData ( USmlTag tag,
const char *  ifname 
)
virtual
bool UResPoly::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.

References UPolygon::add(), UPosition::clear(), UPolygon::getPoint(), UPolygon::getPointsCnt(), UPolyItem::isA(), roundi(), and UVariable::set3D().

bool UResPoly::methodCallV ( const char *  name,
const char *  paramOrder,
UVariable params[],
UDataBase **  returnStruct = NULL,
int *  returnStructCnt = NULL 
)
virtual

A varPool method with this class as implementor is called.

Parameters
nameis the name of the called function
paramOrderis a string with one char for each parameter in the call - d is double, s is string, c is class object.
paramsis an array of variable pointers with the actual parameters, in the order specified by order
returnStructis an array of class object pointers that can return values or objects (may be NULL) if no result value is needed (a procedure call)
returnStructCntis the number of objects in the returnStruct buffer
Returns
true if the method is recognised (exists), when false is returned a invalid name or parameter list is detected.

Reimplemented from UVarMethodImplement.

References UPolygon::add(), UPosition::clear(), UPolyItem::cooSys, UPolygon::copyTo(), UVariable::get3D(), UVariable::getInt(), UPolygon::getPoint(), UPolygon::getPointsCnt(), UVariable::getPose(), UPolyItem::isA(), UDataBase::isAlsoA(), UPolygon::isInsideConvex(), UPolygon::remove(), roundi(), UVariable::set3D(), UPolygon::setAsPolygon(), UPolygon::setAsPolyline(), UVariable::setBool(), UPolyItem::setUpdated(), UPosition::x, UPose::x, UPosition::y, UPose::y, and UPosition::z.

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

print status to a string buffer

Reimplemented from UResVarPool.

void UResPoly::UResPolyInit ( )

Initialize resource

Member Data Documentation

const int UResPoly::MAX_POLYS_CNT = 1000
staticprotected

maximum number of polys

UPolyItem* UResPoly::polys[MAX_POLYS_CNT]
protected

array of poly handles

int UResPoly::polysCnt
protected

Number of polys allocated.

UVariable* UResPoly::varCallDispOnNewData
protected

inform a potential display plugin, that new data is available

UVariable* UResPoly::varPolyCnt
protected

number of established poly items

UVariable* UResPoly::varUpdTime
protected

last update time for polygons

bool UResPoly::verbose

Is the resource to output verbose message to console

Referenced by UFuncPoly::handleCommand().


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