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

#include <usmltag.h>

Inheritance diagram for USmlTag:
Inheritance graph

Public Member Functions

bool cnnVerbose ()
 
bool codeLineSegment (ULineSegment *seg, char *s, const unsigned int bufferLength, const char *name, const char *extra=NULL)
 
char * codeManoeuvre (UManoeuvre *man, char *buf, int bufCnt, char *name)
 
bool codeManPPSeq (UManPPSeq *manseq, char *buf, int bufCnt, char *name)
 
const char * codeObstacle (UObstacle *obst, char *buf, int bufCnt, char *name)
 
const char * codePolygon (UPolygon *poly, char *buf, int bufCnt, char *name, const char *extra)
 
char * codePose (UPose pose, char *buf, int bufCnt, const char *name, const char *extraAtt=NULL)
 
char * codePoseTime (UPoseTime pt, char *buf, int bufCnt, const char *name)
 
char * codePoseTime1 (UPoseTime pt, char *buf, int bufCnt, const char *name, const char *extraAtt=NULL)
 
char * codePoseV (UPoseV pv, char *buf, int bufCnt, const char *name)
 
const char * codePosition (UPosition *pos, char *s, const unsigned int bufferLength, const char *name, const char *extra=NULL)
 
const char * codePosition (UPosition pos, char *s, const unsigned int bufferLength, const char *name, const char *extra=NULL)
 
const char * codeRotation (URotation *rot, char *s, const unsigned int bufferLength, const char *name)
 
const char * codeRotation (URotation rot, char *s, const unsigned int bufferLength, const char *name)
 
const char * codeTime (const UTime time, char *s, const unsigned int bufferLength, const char *name)
 
bool getGmk (UGmk *gmk)
 
const char * getIfName ()
 
bool getLineSegment (ULineSegment *seg)
 
bool getManSeq (UManSeq *man)
 
int getNBytes (char *buffer, int n, int msTimeout)
 
bool getNextTag (USmlTag *tag, int msTimeout, USmlTagIn *failEndTag=NULL, char *beforeTagBuffer=NULL, int *beforeTagCnt=NULL)
 
bool getObstacle (UObstacle *obst, char *name)
 
bool getObstacleGroup (UObstacleGroup *oGrp, char *name)
 
bool getPolygon (UPolygon *poly, char *name)
 
bool getPose (UPose *pose)
 
bool getPoseT (UPoseTime *pose)
 
bool getPoseTime (UPoseTime *pose, char *name)
 
bool getPoseTVQ (UPoseTVQ *pose)
 
bool getPoseV (UPoseV *pose)
 
bool getPosition (UPosition *pos)
 
bool getProbPoly (UProbPoly *poly)
 
bool getRotation (URotation *rot)
 
bool getTimeofday (UTime *time, char *name)
 
bool outputData (const char *message)
 
bool sendProbPoly (UProbPoly *poly, UServerInMsg *msg, const char *name, const char *extraAtt, UCmdExe *exe)
 
void setCnn (USmlSource *connection)
 
bool skipNBytes (int n, int msTimeout)
 
bool skipToEndTag (int msTimeout)
 
 USmlTag ()
 
- Public Member Functions inherited from USmlTagIn
void allowTagEndInString ()
 
int findEndTag (const char *data, const int dataCnt)
 
bool getAttBool (const char *name, bool *value, bool defaultValue=true)
 
int getAttCnt ()
 
bool getAttDouble (const char *name, double *value, double defaultValue=0.0)
 
bool getAttInteger (const char *name, int *value, int defaultValue=0)
 
bool getAttTime (const char *name, UTime *value)
 
bool getAttTime (const char *name, UTime *value, double defaultValue)
 
bool getAttTime (const char *name, UTime *value, UTime defaultValue)
 
bool getAttUnsignedLong (const char *name, unsigned long *value, unsigned long defaultValue=0)
 
bool getAttValue (const char *name, char *value, const int bufLength)
 
bool getAttValueBool (const char *name, bool *value, bool defValue)
 
bool getAttValueD (const char *name, double *value)
 
bool getAttValueInt (const char *name, int *value)
 
const char * getNext ()
 
bool getNextAttribute (char *name, char *value, const int valBufLength, const int nameMaxCnt=MAX_SML_NAME_LENGTH, bool *overflow=NULL)
 
int getTagCnt ()
 
const char * getTagName ()
 
const char * getTagStart ()
 
bool getTime (UTime *time)
 
const char * getToEnd ()
 
bool isAFullTag ()
 
bool isAnEndTag ()
 
bool isAPhonyTag ()
 
bool isAStartTag ()
 
bool isTagA (const char *tag)
 
bool isTagAnEnd (const char *tag)
 
bool isTagEndFound ()
 
bool isValid ()
 
void print (const char *preString)
 
bool reset ()
 
void setBinaryTag (const char *name, const char *data, int dataCnt)
 
bool setTag (const char *tagString)
 
bool setTag (const char *tagString, int tagStringCnt)
 
void setValid (bool value)
 
 USmlTagIn ()
 
 ~USmlTagIn ()
 

Protected Attributes

USmlSourcecnn
 
- Protected Attributes inherited from USmlTagIn
bool ignoreTagEndInString
 
bool isEndTag
 
bool isFullTag
 
bool isStartTag
 
const char * next
 
const char * tag
 
int tagCnt
 
bool tagEndFound
 
char tagName [MAX_SML_NAME_LENGTH]
 
const char * toEnd
 
bool valid
 

Detailed Description

Class that codes and decodes more complex structores to and from the SML format

Constructor & Destructor Documentation

USmlTag::USmlTag ( )
inline

Constructor

References cnn.

Member Function Documentation

bool USmlTag::cnnVerbose ( )
inline
bool USmlTag::codeLineSegment ( ULineSegment seg,
char *  s,
const unsigned int  bufferLength,
const char *  name,
const char *  extra = NULL 
)

Code the line segment to in a XML like text of the form <lineSeg name="name" legngth=1.234 extra/> <pos3d name="start" x=1.0e12 y=2.0 z=2.0/> <pos3d name="vec" x=9.9 y=9.9 z=9.9/> </lineSeg>. If extra is not NULL, then the extra string info is inserted as 'extra' into start tag. Returns true if data is fitted into buffer.

References codePosition(), ULineSegment::length, ULine::pos, and ULine::vec.

Referenced by codeRotation(), UFunctionPassable::handlePass(), UFunctionAvoid::sendCurrentAvoidPath(), UFunctionPassable::sendRoadLines(), and testSmlEncoding().

char * USmlTag::codeManoeuvre ( UManoeuvre man,
char *  buf,
int  bufCnt,
char *  name 
)
bool USmlTag::codeManPPSeq ( UManPPSeq manseq,
char *  buf,
int  bufCnt,
char *  name 
)
const char * USmlTag::codeObstacle ( UObstacle obst,
char *  buf,
int  bufCnt,
char *  name 
)

Code an obstacle polygon including start and end pose etc. Requires approc 90 bytes per vertice plus about 400 characters for other values

References buf, codePolygon(), codePoseTime(), UObstacle::codeXmlAttributes(), UObstacle::getDataType(), UObstacle::getPoseFirst(), UObstacle::getPoseLast(), and mini().

Referenced by codeRotation(), UFuncObj3d::sendObjects(), and UFunctionPassable::sendObstacles().

const char * USmlTag::codePolygon ( UPolygon poly,
char *  buf,
int  bufCnt,
char *  name,
const char *  extra 
)

Code a polygon using the tagname 'polygon'. Handles any number of vertices, but require a buffer of about 90 characters per vertice (+ about 50 for frame)

Parameters
polyis the polygon to code,
bufis the buffer to code to,
bufCntis the length of the buffer,
nameis an optional extra name attribute value - is added as name value in quotes.
extrais a full string of extra attributes (assumed to be coded to legal xml standard, i.e. aaa="bbb" ccc="555" ....
Returns
pointer to buffer

References UPolygon::codeXml().

Referenced by codeObstacle(), codeRotation(), and UPolyItem::codeXML().

char * USmlTag::codePose ( UPose  pose,
char *  buf,
int  bufCnt,
const char *  name,
const char *  extraAtt = NULL 
)

Code a pose to this string, and include a name attribute, if name holds a name. Additional attributes (like time, velocity may be placed in 'extraAtt'

References buf, UPose::h, UPose::x, and UPose::y.

Referenced by codePoseTime(), codePoseTime1(), codeRotation(), UFunctionPassable::handlePass(), UFunctionAvoid::sendCurrentPath(), UFunctionPassable::sendFullScan(), UFuncEfLine::sendRobotPoseAndSensorPosition(), and UFunctionLaser::sendScan().

char * USmlTag::codePoseTime ( UPoseTime  pt,
char *  buf,
int  bufCnt,
const char *  name 
)

Code a pose-time structure as a combination of pose and time tags

References buf, codePose(), codeTime(), UPoseTime::getPose(), and UPoseTime::t.

Referenced by codeObstacle(), codeRotation(), UFuncObj3d::sendObjects(), and UFunctionPassable::sendObstacles().

char * USmlTag::codePoseTime1 ( UPoseTime  pt,
char *  buf,
int  bufCnt,
const char *  name,
const char *  extraAtt = NULL 
)

Code pose time as one tag. Extra attributes may be added in 'extraAtt'

References codePose(), UTime::getMicrosec(), UPoseTime::getPose(), UTime::getSec(), and UPoseTime::t.

Referenced by codeRotation(), and UFunctionPoseHist::handlePoseHistCommand().

char * USmlTag::codePoseV ( UPoseV  pv,
char *  buf,
int  bufCnt,
const char *  name 
)

Code a robot pose including velocity. All is in metric units, meter and radians Returns a pointer to the coded string (buf).

References buf, UPoseV::getVel(), UPose::h, UPose::x, and UPose::y.

Referenced by codeManPPSeq(), codeRotation(), and UFunctionRoadDrive::handleCommand().

const char * USmlTag::codePosition ( UPosition pos,
char *  s,
const unsigned int  bufferLength,
const char *  name,
const char *  extra = NULL 
)

Make position to SML string <pos3d name="name" x="123.456" y="123.456" z="123.2"/ [extra]> Returns pointer to the buffer string 's', if buffer is too short the message will be truncated. If name is NULL or an empty string, the name attribute will be omitted. The 'extra' is extra attributes appended before the '/>' close tag.

References UPosition::codeXml().

Referenced by cnnVerbose(), codeLineSegment(), codePosition(), UFuncBall_improved::handleCommand(), UFuncBall::handleCommand(), UFunctionPassable::handlePass(), UFunctionPassable::sendFullScan(), UFunctionCamGmk::sendGmk(), UFuncEfLine::sendRobotPoseAndSensorPosition(), UFunctionLaser::sendScan(), and testSmlEncoding().

const char* USmlTag::codePosition ( UPosition  pos,
char *  s,
const unsigned int  bufferLength,
const char *  name,
const char *  extra = NULL 
)
inline

Slight variation of the main function with the same name

References codePosition(), and codeRotation().

const char * USmlTag::codeRotation ( URotation rot,
char *  s,
const unsigned int  bufferLength,
const char *  name 
)

Code a rotation structore into string s of length 'buffer length. Returns a pointer to s, if buffer length is sufficient, else NULL is returned

References URotation::Kappa, URotation::Omega, and URotation::Phi.

Referenced by codePosition(), codeRotation(), UFunctionPassable::handlePass(), UFunctionPassable::sendFullScan(), UFunctionCamGmk::sendGmk(), UFuncEfLine::sendRobotPoseAndSensorPosition(), and UFunctionLaser::sendScan().

const char* USmlTag::codeRotation ( URotation  rot,
char *  s,
const unsigned int  bufferLength,
const char *  name 
)
inline
const char * USmlTag::codeTime ( const UTime  time,
char *  s,
const unsigned int  bufferLength,
const char *  name 
)

Code a time of dat as a single tag. Returns a pointer to s, if buffer length is sufficient, else NULL is returned

References UTime::getMicrosec(), and UTime::getSec().

Referenced by codePoseTime(), codeRotation(), and UFunctionCamGmk::sendGmk().

bool USmlTag::getGmk ( UGmk gmk)
const char* USmlTag::getIfName ( )
inline

Get interface name - if set

References cnn, getPoseTVQ(), and USmlSource::ifName.

Referenced by UResLaserIfScan::handleLaserScan().

bool USmlTag::getLineSegment ( ULineSegment seg)
bool USmlTag::getManSeq ( UManSeq man)
int USmlTag::getNBytes ( char *  buffer,
int  n,
int  msTimeout 
)
inline
bool USmlTag::getNextTag ( USmlTag tag,
int  msTimeout,
USmlTagIn failEndTag = NULL,
char *  beforeTagBuffer = NULL,
int *  beforeTagCnt = NULL 
)

Shortcut to cnn (UClientPortSml) function Read the next available tag into the provided buffer.

Parameters
tag,Thefound tag is loaded into the 'tag' buffer.
inttimeout in ms
failEndTagThe search is also stopped if an end-tag is found matching the 'failEndTag' (makes the function return false).
beforeTagBufferis (if != NULL) filled with the data before the next tag.
beforeTagCntis on entry the buffer size. The number of bytes filled into the buffer returned into 'beforeTagCnt'. If there is more data before the next tag than the space in 'beforeTagBuffer' then the function returns with 'beforeTagBuffer' equal to the buffer size and the function returnes true. Note the buffer is NOT nul-terminated (to allow binary data), so the user must add a nul at the 'beforeTagCnt' position if the result is used as a string. true if tag is valid (and the beforeTagBuffer has no overflow).

References cnn, and USmlSource::getNextTag().

Referenced by UClientFuncLaser::handleGetComplexData(), UClientFuncGmk::handleGmkGet(), UClientFuncBase::handleHelp(), UClientFuncImage::handleImages(), UClientFuncSimScan::handleLaserScan(), UResLaserIfScan::handleLaserScan(), UClientFuncLaser::handleLaserScan(), UResNavIfMan::handleManData(), UResPcp::handleNewData(), UResPoly::handleNewData(), UClientFuncObstGrp::handleObst(), UResLaserIfObst::handleObst(), UClientFuncLaser::handleOdo(), UResIfVar::handleOther(), UClientFuncSF::handlePass(), UResLaserIfSf::handlePass(), UClientFuncLaser::handlePath(), UClientFuncPath::handlePathGetMsg(), UClientFuncPath::handlePathPolygonData(), UClientFuncLaser::handlePlan(), UResIfVar::handlePoseHist(), UClientFuncSF::handleRoad(), UResLaserIfSf::handleRoad(), UResLaserIfRoad::handleRoad(), UClientFuncSF::handleSF(), UResLaserIfSf::handleSF(), UClientFuncLaser::handleVarData(), UClientFuncLaser::handleWpc(), UClientManSeq::setFromTag(), ULaserPathResult::setFromTag(), and skipToEndTag().

bool USmlTag::getObstacle ( UObstacle obst,
char *  name 
)
bool USmlTag::getObstacleGroup ( UObstacleGroup oGrp,
char *  name 
)
bool USmlTag::getPolygon ( UPolygon poly,
char *  name 
)
bool USmlTag::getPose ( UPose pose)
bool USmlTag::getPoseT ( UPoseTime pose)

Get pose time in compact form. <pt od="1234567890.123456" x=0.123 y="1.234" th="0.0123"/>. Returns true if all needed attributes were present.

References USmlTagIn::getAttValue(), getPose(), UTime::setTimeU(), and UPoseTime::t.

Referenced by codeRotation(), getPoseTVQ(), and UResIfVar::handlePoseHist().

bool USmlTag::getPoseTime ( UPoseTime pose,
char *  name 
)

Get a pose-time structure. If there is a name attribute, then set it to the name structure (name buffer must be able to hold 30 characters).

References cnn, USmlTagIn::getAttValue(), USmlSource::getNextTag(), getPose(), USmlTagIn::getTagName(), getTimeofday(), USmlTagIn::isAStartTag(), USmlTagIn::isTagA(), USmlTagIn::isTagAnEnd(), USmlSource::isVerbose(), USmlTagIn::print(), USmlTagIn::reset(), USmlSource::skipToEndTag(), and UPoseTime::t.

Referenced by codeRotation(), getObstacle(), and getObstacleGroup().

bool USmlTag::getPoseTVQ ( UPoseTVQ pose)

DEcode a pose with time and potentiallt velocity and quality figure.

Returns
true if at least x,y,th and time is available.

References USmlTagIn::getAttValue(), getPoseT(), UPoseTVQ::q, and UPoseTVQ::vel.

Referenced by getIfName(), and UServerClient::trapMessage().

bool USmlTag::getPoseV ( UPoseV pose)

Get a pose-velocity structure from this tag. Returns true if all fields (x,y,h,v) were present.

References USmlTagIn::getNextAttribute(), UPose::h, MAX_SML_NAME_LENGTH, USmlTagIn::reset(), UPoseV::setVel(), UPose::x, and UPose::y.

Referenced by codeRotation(), and getManSeq().

bool USmlTag::getPosition ( UPosition pos)
bool USmlTag::getProbPoly ( UProbPoly poly)
bool USmlTag::getRotation ( URotation rot)
bool USmlTag::getTimeofday ( UTime time,
char *  name 
)

Get time value from this tag.

References USmlTagIn::getAttValue(), USmlTagIn::reset(), and UTime::setTime().

Referenced by codeRotation(), and getPoseTime().

bool USmlTag::outputData ( const char *  message)
inline

Shortcut to cnn (UClientPortSml) function Shortcut to cnn (UClientPortSml) function

References cnn, and USmlSource::outputData().

Referenced by UResCamIfImg::gotNewImage().

bool USmlTag::sendProbPoly ( UProbPoly poly,
UServerInMsg msg,
const char *  name,
const char *  extraAtt,
UCmdExe exe 
)

Send an UProbPoly structure. Add some extra attributes in start tag if extraAtt is not NULL (or empty).

Parameters
polyis the polygon to be send,
msgis the message reference for client number etc.
nameis an optional value for a name attribute
extraAttan additional (optional) string with more attributes for the polygon start tag
exeis a server core pointer that implements the send functions Returns true if send.

References bool2str(), UPose::getAsSml(), UTime::getAsSml(), UProbPoly::getCromaSD(), UProbPoly::getIsObst(), UPolygon::getPoints(), UPolygon::getPointsCnt(), UProbPoly::getPoseOrg(), UProbPoly::getPoseTime(), USmlTagIn::getTagName(), UCmdExe::sendMsg(), UServerInMsg::tag, UPosition::x, and UPosition::y.

Referenced by codeRotation(), UFuncImgPoly::findAreaFromSeedRGB(), and UFunctionCamPath::findPath().

void USmlTag::setCnn ( USmlSource connection)
inline

Set connection pointer

References cnn.

Referenced by USmlSource::getNextTag().

bool USmlTag::skipNBytes ( int  n,
int  msTimeout 
)
inline

Shortcut to cnn (UClientPortSml) function

References cnn, and USmlSource::skipNBytes().

bool USmlTag::skipToEndTag ( int  msTimeout)
inline

Member Data Documentation

USmlSource* USmlTag::cnn
protected

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