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

#include <uresrule.h>

Inheritance diagram for UResRule:
Inheritance graph

Public Member Functions

UMisLoadedRuleaddNewRule (const char *name)
 Add a new rule in edit mode to the list of plans. The new plan is not a rule, and will not be active. It is based on loaded plan, but nothing is entered and the editStr is empty. More...
 
bool completeEdit (UMisLoadedRule *plan)
 
int getMissionCnt ()
 
UMisLoadedRulegetRule (const char *name, bool runableRulesOnly)
 
UMisLoadedRulegetRule (const int idx)
 
bool getRuleList (const char *name, char *buf, const int bufCnt)
 
const char * getSyntaxErrorString ()
 
bool loadFile (const char *name)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
void setDefRule (const char *defRule)
 
bool tryUnloadRule (const char *name)
 
 UResRule ()
 
virtual ~UResRule ()
 
- 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)
 
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 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 bool methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt)
 
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 ()
 

Protected Member Functions

void appendRule (UMisLoadedRule *plan)
 
void createBaseVar ()
 
bool unpackMissionRule (USmlSource *cnn, USmlTag *tag, const char *fileName)
 
- 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

UMisLoadedRuleplanRoot
 
char synErrBuf [SYN_ERR_BUF_SIZE]
 
UVariablevarMisCount
 
- 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 SYN_ERR_BUF_SIZE = 10000
 
- 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 ()
 
- Public Attributes inherited from UReplay
bool replayTimeAdvancePending
 
UTime replayTimeNow
 

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

UResRule::UResRule ( )
inline

Constructor

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

UResRule::~UResRule ( )
virtual

Destructor

Member Function Documentation

UMisLoadedRule * UResRule::addNewRule ( const char *  name)

Add a new rule in edit mode to the list of plans. The new plan is not a rule, and will not be active. It is based on loaded plan, but nothing is entered and the editStr is empty.

Parameters
nameis the name of the new plan.
Returns
a pointer to the new plan

References UMisRule::isFull, UMisRule::isTop, UMisLoadedRule::setEdit(), UMisRule::setName(), and UMisLoadedRule::UMisLoadedRule().

Referenced by UFuncRule::editRule().

void UResRule::appendRule ( UMisLoadedRule plan)
protected

Append a (new) plan at the end of the loaded plan list.

Parameters
planis the new plan to be added. The 'next' pointer is not changed, and should be set to a valid plan or NULL.

References UMisLoadedRule::nextRule.

bool UResRule::completeEdit ( UMisLoadedRule plan)

Complete the pllan with the lines in the editString buffer

Parameters
planthe plan to be completed against the global variable base
Returns
true if successful

References UMisLoadedRule::completeEdit(), and UMisRule::setLogFile().

Referenced by UFuncRule::editRule().

void UResRule::createBaseVar ( )
protected

Create the smrif related variables

int UResRule::getMissionCnt ( )

Get number of loaded missions.

Returns
total number of missions (executable or not)

References UMisLoadedRule::nextRule.

Referenced by UFuncRule::listAllMissions(), and UFuncRule::loadRuleFile().

UMisLoadedRule * UResRule::getRule ( const char *  name,
bool  runableRulesOnly 
)

Find a plan with this name.

Parameters
nameis the name of the plan to get, plan name is not case sensitive
runableRulesOnly,iftrue, then plans in edit mode gets ignored
Returns
a pointer to the found plan or NULL if not found.

References UMisRule::getName(), UMisLoadedRule::isEdit(), UMisRule::name, and UMisLoadedRule::nextRule.

Referenced by UFuncRule::editRule(), UFuncRule::listAllMissions(), UFuncRule::listMission(), UFuncRule::loadRuleFile(), and UFuncRule::unloadRule().

UMisLoadedRule * UResRule::getRule ( const int  idx)

Find a plan with this index. The index should be between 0 and (getMissionCount() - 1).

Returns
a pointer to the found plan or NULL if not found.

References UMisLoadedRule::nextRule.

bool UResRule::getRuleList ( const char *  name,
char *  buf,
const int  bufCnt 
)

Get a list of a mission or a list of loaded missions

Parameters
nameis either "" or a name of a valid mission
bufis the buffer where to store the result
bufCntis the size of the buffer
Returns
true if data is in the buffer

References buf, and UMisRule::print().

Referenced by UFuncRule::listMission().

const char* UResRule::getSyntaxErrorString ( )
inline

Get syntax error buffer

References buf, UMisLoadedRule::completeEdit(), and UMisRule::fileName.

Referenced by UFuncRule::loadRuleFile().

bool UResRule::loadFile ( const char *  name)
const char * UResRule::print ( const char *  preString,
char *  buff,
int  buffCnt 
)
virtual

print status to a string buffer

Reimplemented from UResVarPool.

void UResRule::setDefRule ( const char *  defRule)

Set default plan

bool UResRule::tryUnloadRule ( const char *  name)

Unload this specific plan if it it is not busy

Parameters
namethe not case sensitive plan name
Returns
true if plan is deleted - otherwise the plan is not found or busy

References UMisLoadedRule::isBusy(), UMisRule::name, and UMisLoadedRule::nextRule.

Referenced by UFuncRule::unloadRule().

bool UResRule::unpackMissionRule ( USmlSource cnn,
USmlTag tag,
const char *  fileName 
)
protected

Unpack and gcreate a new plan tree.

Parameters
cnnis the connection to a source (file)
tagis the opening plan tag
fileNamepointer for source filename (for on-line debug)
Returns
true if plan is unpacked and added, fails also is a plan with that name already exists.

References USmlTagIn::getAttValue(), UMisRule::isTop, USmlSource::isVerbose(), MAX_FILENAME_LENGTH, UMisLoadedRule::setEdit(), UMisRule::setLogFile(), USmlSource::skipToEndTag(), UMisLoadedRule::sourceFileName, UMisLoadedRule::UMisLoadedRule(), and UMisLoadedRule::unpack().

Member Data Documentation

UMisLoadedRule* UResRule::planRoot
protected

Root of mission plan tree. The base of the tree is loaded plans, that is including file source etc.

const int UResRule::SYN_ERR_BUF_SIZE = 10000
staticprotected

size of syntax error buffer

char UResRule::synErrBuf[SYN_ERR_BUF_SIZE]
protected

syntax error buffer

UVariable* UResRule::varMisCount
protected

index to mission count


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