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

#include <urule.h>

Inheritance diagram for UMisRule:
Inheritance graph

Public Member Functions

void addIniLine (UMisItem *newLine)
 
void addMainLine (UMisItem *newLine)
 
void addPostLine (UMisItem *newLine)
 
virtual const char * getDataType ()
 
const char * getFileName ()
 
UMisItemgetIniLines ()
 
int getIniLinesCnt ()
 
UMisItemgetMainLines ()
 
int getMainLinesCnt ()
 
const char * getName ()
 
UMisItemgetPostLines ()
 
int getPostLinesCnt ()
 
virtual bool isEdit ()
 
virtual const char * print (const char *preStr, char *buf, const int bufCnt)
 
virtual int setBusyCnt (int delta)
 
void setCalc (UVarCalc *calculator)
 
void setLogFile (ULogFile *logFile)
 
void setName (const char *toName)
 
 UMisRule ()
 
bool unpackRule (USmlSource *cnn, USmlTag *tag)
 
virtual ~UMisRule ()
 
- Public Member Functions inherited from UMisItem
virtual ResultValue execute (UVarCalc *calc, int state)
 
const char * findStopChar (const char *source, char stop)
 
int getLineNumber ()
 
bool isA (const char *matchType)
 
virtual bool setLine (const int lineNum, const char *value, UVarCalc *calc)
 
void setLineNumber (const int line)
 
 UMisItem ()
 
virtual ~UMisItem ()
 
- Public Member Functions inherited from UDataBase
bool isA (const char *typeString)
 
virtual bool isAlsoA (const char *typeString)
 
virtual void snprint (const char *preString, char *buff, const int buffCnt)
 
 UDataBase ()
 
virtual ~UDataBase ()
 

Public Attributes

char * condition
 
string dependPlugin
 
string description
 
char * destination
 
bool isFull
 
bool isLoop
 
bool isRule
 
bool isRun
 
bool isSwitch
 
bool isTop
 
ULogFilelogm
 
int order
 Priority order of this plan - relative to other (sub) plans. This value controls in wich order the list of (sub) plans are assigned processing time, i.e. if a number of sub-plans evaluate some value - e.g. the robot pose - then thise can be assigned to be evaluated before another subplan, that combines or selects the usable results from the others. A priority with a low number is executed first. The value range is 1..100, where 1 is executed before the others. if two plans have the same priority order, then the order is un-determined. Default value is 50. More...
 
char * parameters
 
int parametersCnt
 
int switchValue
 
- Public Attributes inherited from UMisItem
UMisItemnext
 

Protected Types

enum  MisPart { MP_INIT, MP_MAIN, MP_POST }
 

Protected Member Functions

void addLine (UMisItem *elemList, UMisItem *newLine)
 
virtual bool checkSyntax (USmlSource *cnn)
 
virtual const char * getEditLines ()
 
int getLinesCnt (UMisItem *fromLine)
 
int trimWhiteSpace (char *s)
 
bool unpackBlock (USmlSource *cnn, USmlTag *tag, UMisItem **itemList)
 
bool unpackInitPostBlock (USmlSource *cnn, USmlTag *tag, UMisItem **itemList, MisPart iniBlock)
 
bool unpackLine (USmlSource *cnn, char *line, UMisItem **itemNext, int lineNum, MisPart iniBlock)
 
bool unpackSequence (USmlSource *cnn, char *lines, UMisItem **itemList, int lineNum, MisPart iniBlock=MP_MAIN)
 
- Protected Member Functions inherited from UMisItem
int symbolLength (const char *exp)
 

Protected Attributes

UVarCalccalc
 
char fileName [MAX_FILENAME_LENGTH]
 
bool inEditAppend
 
UMisIteminiLines
 
UMisItemmainLines
 
char name [MAX_VAR_NAME_SIZE]
 
UMisItempostLines
 
- Protected Attributes inherited from UMisItem
int lineNumber
 

Additional Inherited Members

- Public Types inherited from UMisItem
enum  ResultValue {
  RV_EMPTY, RV_OK, RV_OK_FALSE, RV_OK_AGAIN,
  RV_SYNTAX_ERROR, RV_FAILED, RV_IF_TRUE, RV_IF_FALSE
}
 
- Static Public Member Functions inherited from UMisItem
static bool isRem (const char *r)
 

Detailed Description

Class that holds the base for a mission or a mission segment

Member Enumeration Documentation

enum UMisRule::MisPart
protected

Possible return values of an evaluation

Enumerator
MP_INIT 
MP_MAIN 
MP_POST 

Constructor & Destructor Documentation

UMisRule::UMisRule ( )

Constructor

UMisRule::~UMisRule ( )
virtual

DEstructor

Member Function Documentation

void UMisRule::addIniLine ( UMisItem newLine)
inline

Add a line to the ini-segment

void UMisRule::addLine ( UMisItem elemList,
UMisItem newLine 
)
protected

Add a line to this segment

References UMisItem::next.

void UMisRule::addMainLine ( UMisItem newLine)
inline

Add a line to the ini-segment

void UMisRule::addPostLine ( UMisItem newLine)
inline

Add a line to the ini-segment

bool UMisRule::checkSyntax ( USmlSource cnn)
protectedvirtual

Check the syntax validity of the block statement (not the lines in the block).

Parameters
cnnis a pointer to the source - may be NULL if the source is unavailable
Returns
true if no errors were found.

References UMisItem::symbolLength(), and USmlSource::syntaxError().

virtual const char* UMisRule::getDataType ( )
inlinevirtual

Get (end) type of this structure

Reimplemented from UMisItem.

virtual const char* UMisRule::getEditLines ( )
inlineprotectedvirtual

Get the edit lines (un-implemented parts of a plan)

Returns
NULL if no edit lines are available.

Reimplemented in UMisLoadedRule.

const char* UMisRule::getFileName ( )
inline

Get plan name

Returns
a pointer to the filename string

References buf.

Referenced by UMisRuleState::getStateStr(), and UFuncRule::listMission().

UMisItem* UMisRule::getIniLines ( )
inline

Get the first ini-line

Returns
NULL is no init lines are defined.

Referenced by UMisRuleState::step().

int UMisRule::getIniLinesCnt ( )
inline

Get number of ini-lines returns number of ini-lines

int UMisRule::getLinesCnt ( UMisItem fromLine)
protected

Count number of (remaining lines fstarting at this line

References UMisItem::next.

UMisItem* UMisRule::getMainLines ( )
inline

Get the first main-line

Returns
NULL is no init lines are defined.

Referenced by UMisRuleState::getStateStr(), and UMisRuleState::step().

int UMisRule::getMainLinesCnt ( )
inline

Get number of main-lines returns number of main-lines

const char* UMisRule::getName ( )
inline
UMisItem* UMisRule::getPostLines ( )
inline

Get the first post-line

Returns
NULL is no init lines are defined.

Referenced by UMisRuleState::step().

int UMisRule::getPostLinesCnt ( )
inline

Get number of post-lines returns number of post-lines

virtual bool UMisRule::isEdit ( )
inlinevirtual

Is this plan in editing mode - i.e. append is allowed

Returns
true if plan is marked as under edit, i.e. not runable and not active

Reimplemented in UMisLoadedRule.

const char * UMisRule::print ( const char *  preStr,
char *  buf,
const int  bufCnt 
)
virtual

Print mission plan to buffer

Parameters
preStra string to add before the plan lines
bufa string buffer to hold the plan
bufCntthe size of the buffer

Reimplemented from UMisItem.

References buf, UMisItem::isA(), UMisItem::next, UMisItem::print(), str2xml(), and str2xmlMin().

Referenced by UResRule::getRuleList(), UFuncRule::listAllMissions(), and UResRule::UResRule().

virtual int UMisRule::setBusyCnt ( int  delta)
inlinevirtual

Adjust the number of times this plan is beeing used by the sequencer - add 1 every time it is used in a plan state and remove one when plan state is released

Returns
0 busy is not implemented at this level.

Reimplemented in UMisLoadedRule.

Referenced by UMisRuleState::initCall(), UMisRuleState::remove(), UMisRuleState::runCall(), and UMisRuleState::runControl().

void UMisRule::setCalc ( UVarCalc calculator)
inline

set syntax check var pool calculator

Referenced by UMisLoadedRule::completeEdit(), UMisLoadedRule::unpack(), and unpackBlock().

void UMisRule::setLogFile ( ULogFile logFile)
inline
void UMisRule::setName ( const char *  toName)
inline

Set just name pf plan

References MAX_VAR_NAME_SIZE.

Referenced by UResRule::addNewRule().

int UMisRule::trimWhiteSpace ( char *  s)
protected

TRim off all pre and post white space and line feeds

Parameters
sc-string to trim
Returns
length of trimmed string
bool UMisRule::unpackBlock ( USmlSource cnn,
USmlTag tag,
UMisItem **  itemList 
)
protected

Unpack a block structure - either a command or an block (if, loop or otherwise) This is the same as a plan, but without the init and post structures.

Parameters
cnnis the source for more data (the XML file)
tagis the block start tag
itemListis the position of the pointer, where the block is to be added
Returns
true

References setCalc(), setLogFile(), and unpackRule().

bool UMisRule::unpackInitPostBlock ( USmlSource cnn,
USmlTag tag,
UMisItem **  itemList,
MisPart  iniBlock 
)
protected

Unpacks a sequence of statements until the end-tag is discovered. The statements are added to the pointer in the item list.

Parameters
cnnis the source for more data (the XML file)
tagis the block start tag
itemListis the position of the pointer, where the block is to be added
iniBlockflag for specific block part 0=main, 1=ini, 2=post
Returns
true

References USmlSource::getLineNumber(), USmlSource::getNextTag(), USmlTagIn::getTagName(), USmlTagIn::isAStartTag(), USmlTagIn::isTagA(), USmlTagIn::isTagAnEnd(), UMisItem::next, USmlSource::skipToEndTag(), USmlSource::syntaxError(), and xml2str().

bool UMisRule::unpackLine ( USmlSource cnn,
char *  line,
UMisItem **  itemNext,
int  lineNum,
MisPart  iniBlock 
)
protected

Unpack a text line to any of the allowed line types, that is if, call, remark, control or assignment.

Parameters
linethe line to unpack
itemNextthe pointer that should point to the new line
iniBlockflag for specific block part 0=main, 1=ini, 2=post
Returns
true if a line is added, otherwise syntax error

References UMisItem::findStopChar(), UMisItem::setLine(), UMisItem::symbolLength(), and USmlSource::syntaxError().

bool UMisRule::unpackRule ( USmlSource cnn,
USmlTag tag 
)
bool UMisRule::unpackSequence ( USmlSource cnn,
char *  lines,
UMisItem **  itemList,
int  lineNum,
MisPart  iniBlock = MP_MAIN 
)
protected

Unpacks a sequence of statements until the end-tag is discovered. The statements are added to the pointer in the item list.

Parameters
cnnis the source for more data (the XML file)
linestext buffer with line separated expressions
itemListis the position of the pointer, where the block is to be added
iniBlockflag for specific block part 0=main (default), 1=ini, 2=post
Returns
true

References UMisItem::next.

Member Data Documentation

UVarCalc* UMisRule::calc
protected

Syntax check calculator

char* UMisRule::condition

Condition string at start of block Must be evaluated to true to execute block

Referenced by UMisRuleState::getStateStr(), UMisRuleState::methodCall(), and UMisRuleState::step().

string UMisRule::dependPlugin

Dependency, this is a list of plugin dependecies - a space separated list of plug-in modules that need to be present for this mission to succeed. If some of the listed plug-ins are optional, there should be a note in the description, so that the user may select to start the mission anyhow. The list is therefore not enforced as mandatory, but a tool for the user.

string UMisRule::description

Description string

char* UMisRule::destination

destination if the block is to be implemented by another command enterpreter. This could be 'server.send' or 'smr.send'

Referenced by UMisRuleState::runRuleCommands(), and UMisRuleState::step().

char UMisRule::fileName[MAX_FILENAME_LENGTH]
protected

filename

Referenced by UResRule::getSyntaxErrorString().

bool UMisRule::inEditAppend
protected

is the current plan in edit-append mode. this will affect the handling of xml blocks to allow end of (file) with no XML end tag.

Referenced by UMisLoadedRule::completeEdit().

UMisItem* UMisRule::iniLines
protected

First ini-line

bool UMisRule::isFull

Is this a full rule or just a block (isPlan == false) - only full rules have init and post structures

Referenced by UResRule::addNewRule(), UMisRuleState::runBreak(), UMisRuleState::runMainLines(), and UMisRuleState::step().

bool UMisRule::isLoop

Is this block a loop

bool UMisRule::isRule

Is this plan a rule - has an if attrubute

Referenced by UMisRuleState::addRule(), UFuncRule::listAllMissions(), and UMisRuleState::runEnable().

bool UMisRule::isRun

Is this plan a flagged to run when loaded

Referenced by UMisRuleState::addRule(), and UFuncRule::listAllMissions().

bool UMisRule::isSwitch

It this block part of a switch statement

Referenced by UMisRuleState::runBreak(), UMisRuleState::runSwitch(), and UMisRuleState::step().

bool UMisRule::isTop

Is this plan a top level executable mission

Referenced by UResRule::addNewRule(), UMisRuleState::runBreak(), and UResRule::unpackMissionRule().

ULogFile* UMisRule::logm

Logfile for any mission load statements

UMisItem* UMisRule::mainLines
protected

First main-line

char UMisRule::name[MAX_VAR_NAME_SIZE]
protected

Name of rule or block

Referenced by UResRule::getRule(), UResRule::tryUnloadRule(), and UResRule::UResRule().

int UMisRule::order

Priority order of this plan - relative to other (sub) plans. This value controls in wich order the list of (sub) plans are assigned processing time, i.e. if a number of sub-plans evaluate some value - e.g. the robot pose - then thise can be assigned to be evaluated before another subplan, that combines or selects the usable results from the others. A priority with a low number is executed first. The value range is 1..100, where 1 is executed before the others. if two plans have the same priority order, then the order is un-determined. Default value is 50.

Referenced by UMisRuleState::runMainLines().

char* UMisRule::parameters

Parameter string to be implemented at start of block Could be 'x=1 y=2 th=0.57' these should be created on varpool with these default values.

Referenced by UMisRuleState::createParameterVar(), and UMisRuleState::setRule().

int UMisRule::parametersCnt

number of parameters found in plan

Referenced by UMisRuleState::createParameterVar(), UMisRuleState::initCall(), and UMisRuleState::setParameters().

UMisItem* UMisRule::postLines
protected

First post-line

int UMisRule::switchValue

The switch value

Referenced by UMisRuleState::advanceToCase(), and UMisRuleState::runSwitch().


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