AURobotServers
4
|
#include <uresrulestate.h>
Public Types | |
enum | BlockState { inactive, init, main, post } |
Public Member Functions | |
bool | addRule (UMisRule *plan, bool activate) |
UMisRuleState * | getCalled () |
Get called plan state If this plan is waiting in a called plan, get the called plan state. More... | |
UMisRuleState * | getCaller (const char *name) |
get the state structure of the first caller of the plan with this name. The caller makes the plan busy, so it is nice to know who is calling this plan. More... | |
UMisRule * | getRule () |
bool | getStateStr (const char *pre, char *buff, const int buffCnt) |
int | getSubRulesCnt () |
bool | isActive (const char *planName) |
is the subplan with this name active More... | |
bool | isActive () |
bool | isLogOpen () |
virtual bool | methodCall (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct=NULL, int *returnStructCnt=NULL) |
virtual bool | methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct=NULL, int *returnStructCnt=NULL) |
void | remove () |
bool | remove (const char *name) |
bool | setActive (bool doStart, bool onceOnly) |
void | setLogFile (ULogFile *logFile) |
bool | setParameters (double dpar[], int dparCnt) |
bool | setParameters (UVariable *params[], int paramsCnt) |
bool | setRule (UMisRule *plan, UMisRuleState *hasParent, ULogFile *logFile) |
bool | startStopRule (const char *planName, bool start) |
Start or stop one of the subplans for this mission Stating a started or stopping a stopped plan makes no change Stopping a started plan makes the plan execute any post-lines before inactivation Starting an rule sets also the auto-repeat flag. More... | |
bool | step (int *breakLevels, const bool aLastCall) |
void | toLog (const char *logString) |
UMisRuleState () | |
~UMisRuleState () | |
Public Member Functions inherited from UVarCalc | |
double | evaluateD (const char *line, const char *start, const char **end, bool *evaluated, bool syntaxCheck) |
Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More... | |
bool | evaluateParametersD (const char *sourceLine, const char **paramStart, double *paramValues, int *paramValuesCnt, char **paramStr, char *paramOrder, int maxParamCount, int maxParamStrCount, int maxParamStrLength) |
bool | evaluateParametersV (const char *sourceLine, const char **paramStart, char *paramOrder, UVariable *params[], int *paramsCnt, int maxParamsCnt) |
bool | evaluateToStringD (const char *sourceLine, const char *paramStart, const char **nextChar, char *dest, int destLength) |
bool | evaluateToStringV (const char *sourceLine, const char *paramStart, const char **nextChar, char *dest, int destLength) |
double | evaluateUnaryValD (const char *line, const char *start, const char **end, bool *evaluated, bool syntaxCheck) |
Evaluate an expression. More... | |
bool | evaluateUnaryValV (const char *line, const char *start, const char **end, UVariable *value, bool syntaxCheck) |
bool | evaluateV (const char *line, const char *start, const char **end, UVariable *value, bool syntaxCheck) |
Evaluate an expression. More... | |
char * | getErrorTxt () |
int | getErrorTxtMaxCnt () |
bool | getIdentifier (const char *id, int idCnt, const char *allowed, const char **oChar) |
bool | getValueAnyD (UVarPool *scope, const char *name, double *value, const char **params) |
Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More... | |
bool | getValueAnyV (UVarPool *scope, const char *name, UVariable *value, const char **params) |
Get value for the variable or function call with this name Variables and functions in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More... | |
bool | getVariableAny (UVarPool *scope, const char *name, UVariable *value) |
Get the variable with this name in the specified scope (incl. math) Variables in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More... | |
bool | getVariableRefAny (UVarPool *scope, const char *name, UVariable **found, int *nameIndex) |
Get reference to variable with this name in the specified scope (incl. math) Variables in the local scope has first priority, then gradually one scope at a time until root scope. After that the math scope is tested. true if found. More... | |
bool | isDefined (UVarPool *scope, const char *varName) |
Is this variable defined in the scope. The test is for variables and structures, and in the provided scope as well as any parent scope. further the math scope is tested too. More... | |
bool | isRemark (const char *string) |
bool | setResource (UResBase *resource, bool remove) |
Called by server core when new resources are available. More... | |
UVarCalc () | |
virtual | ~UVarCalc () |
Public Member Functions inherited from UVarPool | |
int | addMethod (UVarMethodImplement *implementor, const char *formalName, const char *paramTypes, const char *comment) |
int | addMethodV (UVarMethodImplement *implementor, const char *formalName, const char *paramTypes, const char *comment) |
int | addStruct (const char *name, UVarPool *varStruct) |
int | addStructLink (const char *name, UVarPool *toVarStruct) |
Add a link to another place in the var tree but do not change anything in the linked structure. More... | |
UVarPool * | addStructLocal (const char *name, const char *note, bool copy) |
UVariable * | addVar (const char *name, const double initialValue, const char *type, const char *comment) |
UVariable * | addVar (const char *name, const double initialValue, UVariable::varType type, const char *comment, const char *attValue=NULL) |
UVariable * | addVar (const char *name, const UVariable *source, const char *comment) |
UVariable * | addVar (const char *name, const char *comment) |
UVariable * | addVarA (const char *name, const char *attValue, 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) |
Call a method in the root var pool. It may be in this structure or in any sub-structure that the 'name' indicate. More... | |
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) |
Call a method in this var pool. It may be in this structure or in any sub-structure that the 'name' indicate. More... | |
bool | callLocalV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt) |
Call a method in this var pool (using UVariable parameters). It may be in this structure or in any sub-structure that the 'name' indicate. More... | |
bool | callScope (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt) |
Call a method in this scope, i.e. try if it fits a call in any of the parent var pools. It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More... | |
bool | callScopeV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt) |
Call a method in this scope - using UVariable parameters, i.e. try if it fits a call in any of the parent var pools. It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More... | |
bool | createVarSpace (const int varCnt, const int structCnt, const int methCnt, const char *note, bool copy) |
void | deleteAll () |
void | deleteMethod (const char *name, const char *paramStr) |
void | deleteMethods (UVarMethodImplement *owner) |
void | deleteStruct (const char *name) |
const char * | getDescription () |
const char * | getFullPreName (char *name, const int MNL) |
const char * | getFullPreName () |
bool | getGlobalString (const char *name, const char **value) |
bool | getGlobalValue (const char *name, double *value) |
bool | getGlobalValue (const char *name, bool *value) |
bool | getGlobalValue (const char *name, UTime *value) |
UVariable * | getGlobalVariable (const char *name, int *element=NULL) |
get pointer to variable object NB! the returned pointer may be ilegal if module that owns the variable is unloaded so it must be used only while executing one command in main server core thread, if needed in a thread - like the sequencer, then get the value only - getValue(). More... | |
UVarMethod * | getLocalMethod (const char *name, const char *paramList) |
UVarPool * | getLocalMethod (const char *name, const char *paramList, UVarMethod **method) |
UVarMethod * | getLocalMethod (const int index) |
int | getLocalMethodIdx (const char *name, const char *paramList) |
Get index of this method in this var pool. More... | |
double | getLocalValue (int idx, int element=0) |
bool | getLocalValue (const char *name, double *value) |
bool | getLocalValue (const char *name, bool *value) |
bool | getLocalValue (const char *name, UTime *value) |
UPosition | getLocalValue3D (int idx) |
UPosRot | getLocalValue6D (int idx) |
bool | getLocalValueBool (int idx) |
int | getLocalValueInt (int idx) |
UPose | getLocalValuePose (int idx) |
URotation | getLocalValueRot (int idx) |
UTime | getLocalValueTime (int idx) |
UVariable * | getLocalVar (int index) |
UVariable * | getLocalVariable (const char *name, int *element) |
get pointer to variable object in this variable tree More... | |
int | getLocalVarIndex (const char *name, int *element) |
ULogFile * | getLogVar () |
ULock * | getLogVarLock () |
int | getMethodCnt () |
int | getMethodMax () |
UVarPool * | getParentVarPool () |
UVarPool * | getParentVarPoolScope () |
const char * | getPreName () |
UVarPool * | getRootVarPool () |
bool | getScopeValue (const char *name, double *value) |
UVarPool * | getStruct (const char *name) |
UVarPool * | getStruct (const int idx) |
int | getStructCnt () |
UVarPool * | getStructDeep (const char *fullName, char *varName, const int varNameCnt) |
UVarPool * | getStructDeep (const char *fullName, const bool mayAdd, char *varName, const int varNameCnt) |
int | getStructIdx (const char *name) |
int | getStructMax () |
const char * | getVarDescription (int idx) |
int | getVarMax () |
char * | getVarName (int index) |
UVariable ** | getVars () |
int | getVarsCnt () |
bool | isLogfileOpen () |
bool | isVarPoolVerbose () |
void | listVars (const char *preStr, char *buff, const int buffCnt, bool andStructs) |
void | setDescription (const char *note, bool copy) |
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 (const int index, const double value, const int element) |
bool | setLocalVar (const int index, UVariable *value) |
bool | setLocalVar (const char *name, const double value, bool mayAdd, UVariable::varType vartyp, const char *attValue=NULL) |
Assigns a value to a variable. The variable may be a part of a structure. More... | |
bool | setLocalVar (const char *name, const char *value, bool mayAdd, const char *vartyp, UTime *updTime=NULL, bool *added=NULL) |
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 (const int index, const double value, const int element) |
bool | setLocalVarPose (int idx, UPose *value) |
bool | setLocalVarRot (int idx, URotation *value) |
void | setLogfile (ULogFile *fileHandle, ULock *fileLock) |
void | setParentVarPool (UVarPool *parent) |
void | setParentVarPoolScope (UVarPool *parent) |
bool | setPreName (const char *name) |
bool | setScopeVar (const char *name, const double value, bool mayAdd) |
bool | setScopeVar (const char *name, const UVariable *source, bool mayAdd) |
void | setVerbose (bool value) |
UVarPool () | |
virtual | ~UVarPool () |
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 UServerPush | |
int | addPushCommand (UServerInMsg *msg) |
virtual void | callGotNewDataWithObject () |
bool | doPushCall (UServerPushElement *pe, const char *value) |
void | flushClientCmds (int clientIdx) |
UServerPushImplement * | getImplementor () |
int | getPushCmdCnt (int *cmdCnt, int *callCnt) |
UServerPushQueue * | getPushQueue () |
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 () |
Public Member Functions inherited from UVarMethodImplement | |
virtual | ~UVarMethodImplement () |
Protected Member Functions | |
void | advanceToCase () |
virtual void | createBaseVar () |
bool | createParameterVar (bool syntaxCheck) |
virtual UMisRule * | getSubRule (const char *name) |
UMisRuleState * | getSubRuleState (const char *name) |
UMisItem::ResultValue | initCall (bool inLine, bool extraPar, int extraParVal) |
bool | isInMain () |
void | logActualCall (const int lineNumber, const char *funcName, const char *parOrder, char *sppar[], double dpar[]) |
void | logActualCallV (const int lineNumber, const char *funcName, const char *parOrder, UVariable **params) |
int | methodWait (double secs, int repeat) |
Implement a wait control method when called first time (repeat == 0) the start time is stored. on subsequent calles (repeat > 0) then time passed is calculated in return value is set accordingly. More... | |
UMisItem::ResultValue | runBreak (int *breakLevels) |
UMisItem::ResultValue | runCall (int *breakLevels, bool lastCall) |
Execute a call to a rule. More... | |
UMisItem::ResultValue | runCase (int *breakLevels) |
UMisItem::ResultValue | runControl (int *breakLevels, bool lastCall) |
Execute a control call. More... | |
UMisItem::ResultValue | runEnable (UMisEnable *eLine) |
UMisItem::ResultValue | runLine (bool lastCall, int *breakLevels) |
UMisItem::ResultValue | runLines (int *breakLevels, int maxStatements) |
UMisItem::ResultValue | runLoop (int *breakLevels, UMisLoop *lLine) |
bool | runMainLines (int *breakLevel, const bool lastCall) |
bool | runRuleCommands () |
UMisItem::ResultValue | runSwitch (UMisItem *nextLine) |
bool | skipOneStatement (bool anIf) |
Protected Member Functions inherited from UVarCalc | |
virtual bool | getLocalScopeVaiable (const char *name, double *value) |
Protected Member Functions inherited from UVarPool | |
bool | createFunctionStack (const int maxCount) |
bool | createVarPoolStack (const int maxCount) |
bool | createVarStack (const int maxCount) |
virtual bool | evaluateSystemFunction (const char *name, const double pars[], int parsCnt, double *value, bool syntaxCheck) |
Protected Attributes | |
bool | automaticRestart |
int | automaticRestartCnt |
BlockState | blockState |
UMisRuleState * | errBlock |
int | errCnt |
int | errLevel |
UMisRuleState * | inCall |
bool | inIf [inIfCntMax] |
int | inIfCnt |
bool | initialized |
is the rule initialized More... | |
ULogFile * | logf |
UMisRule * | misRule |
UMisRuleState * | parent |
int | seqAgainCnt |
UMisItem * | seqLine |
UMisRuleState * | subRules [MAX_SUBPLANS] |
int | subRulesCnt |
UVariable ** | varParameters |
UVariable * | varWait |
UTime | waitStart |
Protected Attributes inherited from UVarCalc | |
char | errorTxt [MAX_ERROR_SIZE] |
Protected Attributes inherited from UVarPool | |
const char * | description |
ULogFile * | logVar |
ULock * | logVarLock |
UVarPool ** | varPools |
bool * | varPoolsLocal |
bool | verbose |
Static Protected Attributes | |
static const int | inIfCntMax = 10 |
static const int | MAX_SUBPLANS = 100 |
Class that holds the current execution state of a mission plan. The state has pointers to all sub-plans, that (if active) are to be executed at every new step. The state holds info of any calls to other plans, that are to be executed as part of the main part of the plan. The state also has a error report in 'errLevel' (0=OK, 1=warning (continues), 2=error (execution may be halted), and an error text in errorTxt. The class generates (or may generate) a number of local variables, and will be created on the global variable stack.
UMisRuleState::UMisRuleState | ( | ) |
Constructor
References automaticRestart, automaticRestartCnt, blockState, createBaseVar(), errBlock, errCnt, errLevel, inactive, inCall, inIfCnt, initialized, logf, misRule, parent, seqAgainCnt, subRulesCnt, and varParameters.
Referenced by addRule(), and initCall().
UMisRuleState::~UMisRuleState | ( | ) |
Destructor
References subRules, subRulesCnt, and varParameters.
bool UMisRuleState::addRule | ( | UMisRule * | plan, |
bool | activate | ||
) |
Add this plan line as new sub-plan to this sequencer state.
plan | is a pointer to the plan to be added. |
activate,if | true the plan is set for automatic restart and active |
References UMisRule::isRule, UMisRule::isRun, logf, MAX_SUBPLANS, setActive(), setRule(), subRules, subRulesCnt, and UMisRuleState().
Referenced by getRule(), runLines(), and UResRuleState::UResRuleState().
|
protected |
Advance program counter to after the right case statement
References getRule(), UMisItem::isA(), UMisCase::isInList(), UMisItem::next, seqLine, and UMisRule::switchValue.
Referenced by isInMain(), and step().
|
protectedvirtual |
Create variables and local functions
Reimplemented in UMisSeqRoot.
References UVarPool::addMethod(), UVarPool::addMethodV(), UVarPool::addVar(), and varWait.
Referenced by getCalled(), UResRuleState::getIterationCnt(), UMisSeqRoot::getMissions(), UMisRuleState(), UMisSeqRoot::UMisSeqRoot(), and UResRuleState::UResRuleState().
|
protected |
Convert parameter line to variables.
syntaxCheck | when true no variables are created, just convert to names and values. |
References UVarPool::addVar(), UVarCalc::errorTxt, UVarCalc::evaluateV(), UVarCalc::getIdentifier(), USmlTagIn::getNextAttribute(), MAX_ERROR_SIZE, MAX_SML_NAME_LENGTH, MAX_VAR_NAME_SIZE, misRule, UMisRule::parameters, UMisRule::parametersCnt, USmlTagIn::setTag(), and varParameters.
Referenced by getCalled(), and setRule().
|
inline |
Get called plan state If this plan is waiting in a called plan, get the called plan state.
References createBaseVar(), createParameterVar(), getSubRule(), getSubRuleState(), inCall, initCall(), runLine(), and runLines().
Referenced by UFuncRule::unloadRule().
UMisRuleState * UMisRuleState::getCaller | ( | const char * | name | ) |
get the state structure of the first caller of the plan with this name. The caller makes the plan busy, so it is nice to know who is calling this plan.
name | the name of the plan |
References getCaller(), UMisRule::getName(), getRule(), inCall, subRules, and subRulesCnt.
Referenced by getCaller(), UResRuleState::getCaller(), UResRuleState::getIterationCnt(), and isActive().
|
inline |
Get a pointer to current plan
References addRule(), getStateStr(), methodCall(), methodCallV(), misRule, setActive(), and setParameters().
Referenced by advanceToCase(), getCaller(), getStateStr(), getSubRule(), getSubRuleState(), initCall(), remove(), runCall(), runControl(), runEnable(), runMainLines(), startStopRule(), and UFuncRule::unloadRule().
bool UMisRuleState::getStateStr | ( | const char * | pre, |
char * | buff, | ||
const int | buffCnt | ||
) |
Get a state string, with the state of all subplans.
pre | is a prestring printed before all lines |
buff | is the character buffer where to put the data |
buffCnt | is the length of the buff prameter |
References automaticRestartCnt, blockState, UMisRule::condition, errCnt, UMisRule::getFileName(), UMisLineItem::getLine(), UMisItem::getLineNumber(), ULogFile::getLogName(), UMisRule::getMainLines(), UMisRule::getName(), UVarPool::getPreName(), getRule(), getStateStr(), UVarPool::getStruct(), UVarPool::getStructCnt(), inactive, inCall, init, UVarPool::listVars(), logf, misRule, seqAgainCnt, seqLine, subRules, and subRulesCnt.
Referenced by getRule(), getStateStr(), and UResRuleState::UResRuleState().
|
protectedvirtual |
Get related plan, try: 1 daughter plans, 2 parent's daughter plans (sisters), 3-N grand-parent's daughters until no more parents
name | name of the plan |
Reimplemented in UMisSeqRoot.
References UMisRule::getName(), getRule(), getSubRule(), parent, subRules, and subRulesCnt.
Referenced by getCalled(), UMisSeqRoot::getMissions(), getSubRule(), UMisSeqRoot::getSubRule(), and initCall().
|
inline |
get number of subplans
References subRulesCnt.
|
protected |
Get related plan state, looking in this order: 1 daughter plans, 2 parent's daughter plans (sisters), 3-N grand-parent's daughters until no more parents
name | name of the plan |
References UMisRule::getName(), getRule(), getSubRuleState(), parent, subRules, and subRulesCnt.
Referenced by getCalled(), getSubRuleState(), isActive(), runEnable(), and startStopRule().
|
protected |
Prepare a plan (a call or an in-line block) for a step.
inLineBlock | the call is an in-line block rather than a call to a plan |
extraPar | set true if in a control call, then the repeat count is added |
extraParVal | is the vale added if extra parameter is needed |
References UVarPool::callScopeV(), UVarCalc::errorTxt, UVarCalc::evaluateParametersV(), UMisLineItem::getLine(), UMisItem::getLineNumber(), UMisCall::getNameCopy(), UMisCall::getParameters(), getRule(), getSubRule(), UVariable::getValued(), inCall, logActualCallV(), logf, MAX_ERROR_SIZE, MAX_STRUCT_NAMES, MAX_VAR_NAME_SIZE, UMisRule::parametersCnt, roundi(), UMisItem::RV_EMPTY, UMisItem::RV_OK, UMisItem::RV_OK_AGAIN, UMisItem::RV_SYNTAX_ERROR, seqLine, setActive(), UMisRule::setBusyCnt(), setParameters(), setRule(), UVariable::setValued(), and UMisRuleState().
Referenced by getCalled(), runCall(), and runControl().
bool UMisRuleState::isActive | ( | const char * | planName | ) |
is the subplan with this name active
planName | name of subplan. |
References getSubRuleState(), and isActive().
Referenced by isActive().
|
inline |
Is the state of this plan active
References blockState, getCaller(), and inactive.
Referenced by UResRuleState::getIterationCnt(), and setLogFile().
|
inlineprotected |
Is the state main, that is sequencer is in a control-command
References advanceToCase(), blockState, logActualCall(), logActualCallV(), main, methodWait(), runBreak(), runCall(), runCase(), runControl(), runEnable(), runLoop(), runMainLines(), runRuleCommands(), runSwitch(), and skipOneStatement().
Referenced by runCall(), and runControl().
bool UMisRuleState::isLogOpen | ( | ) |
Is the logfile open.
References ULogFile::isLogOpen(), and logf.
Referenced by setLogFile(), and toLog().
|
protected |
Log the actual call to a function with all parameters evaluated
lineNumber | is the line number from source |
funcName | is the name of the function (before ()) |
parOrder | is the parameter order (only s and d are valid) |
sppar | is an array of string parameters |
dpar | is an array of double parameters |
References logf, and ULogFile::toLog().
Referenced by isInMain().
|
protected |
Log the actual call to a function with all parameters evaluated
lineNumber | is the line number from source |
funcName | is the name of the function (before ()) |
parOrder | is the parameter order (only s and d are valid) |
params | is the parameter array of UVariable values |
References logf, and ULogFile::toLog().
Referenced by initCall(), isInMain(), and runRuleCommands().
|
virtual |
A varPool method with this class as implementor is called.
name | is the name of the called function |
paramOrder | is a string with one char for each parameter in the call - d is double, s is string, c is class object. |
strings | is an array of string pointers for the string type parameters (may be NULL if not used) |
doubles | is an array with double typed parameters (may be NULL if not used) |
value | is the (direct) result of the class, either a double value, or 0.0 for false 1.0 for true (2.0 for implicit stop if a controll call from mission sequencer). |
returnStruct | is an array of class object pointers that can be used as parameters or return objects (may be NULL) |
returnStructCnt | is the number of objects in the returnStruct buffer |
Reimplemented from UVarMethodImplement.
References UMisRule::condition, UVarCalc::evaluateV(), UVariable::getBool(), UVariable::getValued(), UVariable::isDouble(), methodWait(), misRule, and roundi().
Referenced by getRule().
|
virtual |
A varPool method with this class as implementor is called.
name | is the name of the called function |
paramOrder | is a string with one char for each parameter in the call - d is double, s is string, c is class object. |
params | is an array of variable pointers with the actual parameters, in the order specified by order |
returnStruct | is an array of class object pointers that can return values or objects (may be NULL) if no result value is needed (a procedure call) |
returnStructCnt | is the number of objects in the returnStruct buffer |
Reimplemented from UVarMethodImplement.
References UVariable::copy(), UVarCalc::evaluateV(), UMisRule::getName(), UVariable::getValued(), UVariable::isDouble(), misRule, UVariable::setValued(), and UVariable::setValues().
Referenced by getRule(), and UResRuleState::UResRuleState().
|
protected |
Implement a wait control method when called first time (repeat == 0) the start time is stored. on subsequent calles (repeat > 0) then time passed is calculated in return value is set accordingly.
secs,then | time to wait (may change from call to call) |
repeat | count - assumed to be incremented for each wait call |
References UTime::getTimePassed(), UTime::now(), UVariable::setValued(), varWait, and waitStart.
Referenced by isInMain(), and methodCall().
void UMisRuleState::remove | ( | ) |
Remove all state info and all state variables related to this mission state
References blockState, UVarPool::deleteStruct(), errBlock, errLevel, UMisRule::getName(), getRule(), inactive, inCall, misRule, remove(), seqAgainCnt, seqLine, UMisRule::setBusyCnt(), step(), subRules, and subRulesCnt.
Referenced by remove(), runCall(), and runControl().
bool UMisRuleState::remove | ( | const char * | name | ) |
Remove this named subplan from the state structure (and all its sub-structures)
name | is the plan name to be removed from the statate structure |
References UVarPool::deleteStruct(), UMisRule::getName(), getRule(), remove(), subRules, and subRulesCnt.
|
protected |
Execute a break This is done by finding the level of wich to break. If level is undefined, then default is 1 level, i.e. break current plock If level is a number, then this number determines the break level (0 is no break) if level is a plan (or block) identifier, then the levels to this block is used.
breakLevels | is set after the call to the number of levels to break. |
References errCnt, UVarCalc::errorTxt, UMisItem::getLineNumber(), UMisRule::getName(), UMisBreak::getParam(), UMisBreak::getParamCopy(), UMisRule::isFull, UMisItem::isRem(), UMisRule::isSwitch, UMisRule::isTop, MAX_ERROR_SIZE, MAX_VAR_NAME_SIZE, misRule, parent, UMisItem::RV_OK, UMisItem::RV_SYNTAX_ERROR, and seqLine.
Referenced by isInMain(), and runLine().
|
protected |
Execute a call to a rule.
breakLevel | should return the number of levels to break, and left unchanged if no break levels were executed. |
lastCall | if set to true, then a control statement is terminated and any post code run |
References UVarPool::deleteStruct(), UMisRule::getName(), getRule(), inCall, initCall(), UMisItem::isA(), isInMain(), remove(), UMisItem::RV_OK, UMisItem::RV_OK_AGAIN, seqAgainCnt, seqLine, UMisRule::setBusyCnt(), and step().
Referenced by isInMain(), and runLine().
|
protected |
A case statement is found terminating the statements in a case construction
breakLevels | is set to 1 on exit |
References UMisItem::RV_OK.
Referenced by isInMain(), and runLine().
|
protected |
Execute a control call.
breakLevel | should return the number of levels to break, and left unchanged if no break levels were executed. |
lastCall | if set to true, then a control statement is terminated and any post code run |
References UVarPool::deleteStruct(), errCnt, UMisControl::evaluateCondition(), UMisControl::getCondition(), UMisItem::getLineNumber(), UMisRule::getName(), getRule(), inCall, initCall(), UMisCall::isA(), isInMain(), logf, remove(), UMisItem::RV_FAILED, UMisItem::RV_OK, UMisItem::RV_OK_AGAIN, UMisItem::RV_OK_FALSE, seqAgainCnt, seqLine, UMisRule::setBusyCnt(), step(), and ULogFile::toLog().
Referenced by isInMain(), and runLine().
|
protected |
Enable the plan state with this name, if it is within scope. Scope is current plans subplans and any direct parent's subplan.
planName | the name of the plan |
value | is true when the plan should be enables and false if to be disabled. |
References UVarCalc::errorTxt, UVarCalc::evaluateToStringV(), UMisLineItem::getLine(), UMisEnable::getParam(), UMisEnable::getParamCopy(), getRule(), getSubRuleState(), UMisEnable::isEnable(), UMisRule::isRule, MAX_ERROR_SIZE, MAX_VAR_NAME_SIZE, UMisItem::RV_OK, UMisItem::RV_SYNTAX_ERROR, and setActive().
Referenced by isInMain(), and runLine().
|
protected |
Execute the line in seqLine.
lastCall | is used if the line is a control statement, where a last call must be executed when leaving the statement. |
breakLevels | is the result of a break level |
References blockState, UMisItem::execute(), UMisLineItem::getDataType(), UVarPool::getFullPreName(), UMisLineItem::getLine(), UMisItem::getLineNumber(), UMisItem::isA(), logf, UMisItem::next, runBreak(), runCall(), runCase(), runControl(), runEnable(), runLoop(), runSwitch(), seqLine, and ULogFile::toLog().
Referenced by getCalled(), runLines(), and runMainLines().
|
protected |
run lines starting at seqLine
breakLevels | [out] set to number of levels to break if a break statement is reached. |
maxStatements | is -1 of no limit, else max number of statements, used by loops to allow just one statement. |
References addRule(), blockState, errCnt, errLevel, UVarCalc::errorTxt, UVarPool::getFullPreName(), UMisItem::getLineNumber(), inIf, inIfCnt, inIfCntMax, init, UMisItem::isA(), logf, UMisItem::next, runLine(), UMisItem::RV_IF_FALSE, UMisItem::RV_IF_TRUE, UMisItem::RV_OK, UMisItem::RV_OK_AGAIN, UMisItem::RV_SYNTAX_ERROR, seqAgainCnt, seqLine, skipOneStatement(), and ULogFile::toLog().
Referenced by getCalled(), runLoop(), runMainLines(), and step().
|
protected |
Run this loop statement.
lLine | is the loop definition line |
breakLevels | set to 1..N if a break line is found |
References UMisLoop::evalCondition(), UMisItem::isA(), UMisLoop::loopLine, UMisItem::next, UMisLoop::runInitAssignment(), runLines(), UMisLoop::runLoopAssignment(), UMisItem::RV_OK, UMisItem::RV_OK_AGAIN, UMisItem::RV_SYNTAX_ERROR, seqAgainCnt, and seqLine.
Referenced by isInMain(), and runLine().
|
protected |
Run the main part of the plan starting at the line in seqLine.
breakLevel | should return the number of levels to break, and left unchanged if no break levels were executed. |
lastCall | when true, the lines should be get the final call, as needed before the post lines. |
References blockState, getRule(), UMisItem::isA(), UMisRule::isFull, misRule, UMisRule::order, ULock::post(), runLine(), runLines(), UMisItem::RV_OK, UMisItem::RV_OK_AGAIN, UMisItem::RV_SYNTAX_ERROR, seqLine, step(), subRules, and subRulesCnt.
Referenced by isInMain(), and step().
|
protected |
Run main lines in a plan with just command parameters
References UVarPool::callScopeV(), UMisRule::destination, errCnt, UVarCalc::evaluateParametersV(), UMisLineItem::getLine(), UMisItem::getLineNumber(), UVarCalc::isRemark(), logActualCallV(), logf, misRule, UMisItem::next, seqLine, and ULogFile::toLog().
Referenced by isInMain(), and step().
|
protected |
Run a switch statement, evaluation the switch value and setting the value in the next block structure
References UVarCalc::errorTxt, UMisCaseSwitch::evaluateExpr(), UMisItem::getDataType(), UMisItem::isA(), UMisRule::isSwitch, MAX_ERROR_SIZE, UMisItem::next, UMisItem::RV_OK, UMisItem::RV_SYNTAX_ERROR, seqLine, and UMisRule::switchValue.
Referenced by isInMain(), and runLine().
bool UMisRuleState::setActive | ( | bool | doStart, |
bool | onceOnly | ||
) |
Activate or inactivate this plan. if set active (doStart=true) and is active already, then state is not changed if doStart=false and is active, then run post conde and set to inactive
doStart | sets the state to init if true, else set the state to inavtive. |
onceOnly | activate the plan once only, i.e. no automatic repeat. |
References automaticRestart, automaticRestartCnt, blockState, inactive, init, main, and step().
Referenced by addRule(), getRule(), initCall(), runEnable(), and startStopRule().
|
inline |
Set logfile
References isActive(), isLogOpen(), logf, startStopRule(), and toLog().
bool UMisRuleState::setParameters | ( | double | dpar[], |
int | dparCnt | ||
) |
Set the value of the actual parameters.
dpar | is an array of doubles with the new value for the parameters |
dparCnt | is the number of valid parameters. |
References errCnt, UMisRule::getName(), misRule, UMisRule::parametersCnt, UVariable::setValued(), and varParameters.
Referenced by getRule(), and initCall().
bool UMisRuleState::setParameters | ( | UVariable * | params[], |
int | paramsCnt | ||
) |
Set the value of the actual parameters.
params | is an array of UVariable with the new value for the parameters |
paramsCnt | is the number of valid parameters. |
References errCnt, UMisRule::getName(), misRule, UMisRule::parametersCnt, UVariable::setValue(), and varParameters.
bool UMisRuleState::setRule | ( | UMisRule * | plan, |
UMisRuleState * | hasParent, | ||
ULogFile * | logFile | ||
) |
Set this plan state to the plan described in this plan structure.
plan | plan to prepare state for. |
hasParent | is the pointer to the parent plan - or NULL if this is the root plan. |
logFile | is a pointer to a logfile where sufficient information is to be saved to allow replay |
References UVarPool::addStruct(), blockState, createParameterVar(), UVarPool::createVarSpace(), errLevel, UMisRule::getName(), UVarPool::getParentVarPool(), inactive, inCall, init, logf, misRule, UMisRule::parameters, parent, UVarPool::setParentVarPool(), and UVarPool::setPreName().
Referenced by addRule(), and initCall().
|
protected |
Skip a statement after an if or an else statement
anIf | is true if it was just after an 'if' statement |
References errCnt, errLevel, UMisItem::getLineNumber(), UMisItem::isA(), logf, UMisItem::next, UMisItem::RV_SYNTAX_ERROR, seqLine, and ULogFile::toLog().
Referenced by isInMain(), and runLines().
bool UMisRuleState::startStopRule | ( | const char * | planName, |
bool | start | ||
) |
Start or stop one of the subplans for this mission Stating a started or stopping a stopped plan makes no change Stopping a started plan makes the plan execute any post-lines before inactivation Starting an rule sets also the auto-repeat flag.
planName | is the plan name to be manipulated |
start | determines wheather the plan is to be activated or deactivated |
References getRule(), getSubRuleState(), and setActive().
Referenced by UResRuleState::getIterationCnt(), and setLogFile().
bool UMisRuleState::step | ( | int * | breakLevels, |
const bool | aLastCall | ||
) |
Execute a step in this plan. This means allow all active subplans to step first, then make a step of the main function of this plan.
breakLevels | the levels og plans that are to be removed, i.e. if breakLevels returns 1 when this level is completed, that is all postLines are executed and all postLines of subRules are executed too. |
aLastCall | when true, this is the last call to this plan, and the plan should do a last call and run the post-lines. |
References absf(), advanceToCase(), automaticRestart, automaticRestartCnt, blockState, UMisRule::condition, UMisRule::destination, errCnt, UVarCalc::errorTxt, UVarCalc::evaluateV(), UMisRule::getIniLines(), UMisItem::getLineNumber(), UMisRule::getMainLines(), UMisRule::getPostLines(), UVariable::getValued(), inactive, init, initialized, UMisRule::isFull, UMisRule::isSwitch, logf, main, misRule, ULock::post(), runLines(), runMainLines(), runRuleCommands(), UMisItem::RV_SYNTAX_ERROR, seqAgainCnt, seqLine, and ULogFile::toLog().
Referenced by UMisSeqRoot::getMissions(), remove(), runCall(), runControl(), runMainLines(), setActive(), and UMisSeqRoot::step().
void UMisRuleState::toLog | ( | const char * | logString | ) |
Send a string to the logfile This function can tolerate that the logfile pointer is not set and the logfile is not open.
References isLogOpen(), logf, and ULogFile::toLog().
Referenced by UResRuleState::addRule(), UResRuleState::removeRule(), UResRuleState::seqIterateStep(), and setLogFile().
|
protected |
Set to automatic restart. Automatic restart is enabled as a separate thing to do 'all the time' This will reset the state to 'init' after the 'post' is finished, otherwise the state will change to 'inactive' after 'post' is finished
Referenced by setActive(), step(), and UMisRuleState().
|
protected |
Cycle counter for this automatic restart plan
Referenced by getStateStr(), setActive(), step(), and UMisRuleState().
|
protected |
state of this plan block
Referenced by getStateStr(), isActive(), isInMain(), remove(), runLine(), runLines(), runMainLines(), setActive(), setRule(), step(), and UMisRuleState().
|
protected |
The block where an error is reported - NULL if no error
Referenced by remove(), and UMisRuleState().
|
protected |
Error count, to suppress excessive printout and log
Referenced by getStateStr(), runBreak(), runControl(), runLines(), runRuleCommands(), setParameters(), skipOneStatement(), step(), and UMisRuleState().
|
protected |
the error level - 0 is no error, 1 is warning, 2 is error
Referenced by remove(), runLines(), setRule(), skipOneStatement(), and UMisRuleState().
|
protected |
When next line is in a (nested) call, then the called function is block in its own right and the state of this block is at the end of this pointer. Ef not in a call, then this pointer is NULL
Referenced by getCalled(), getCaller(), getStateStr(), initCall(), remove(), runCall(), runControl(), setRule(), and UMisRuleState().
|
protected |
Result of last if evaluation
Referenced by runLines().
|
protected |
nesting level of if statements
Referenced by runLines(), and UMisRuleState().
|
staticprotected |
Maximum number of nested if statements
Referenced by runLines().
|
protected |
is the rule initialized
Referenced by step(), and UMisRuleState().
|
protected |
logfile to log any execution statements
Referenced by addRule(), getStateStr(), initCall(), isLogOpen(), logActualCall(), logActualCallV(), runControl(), runLine(), runLines(), runRuleCommands(), setLogFile(), setRule(), skipOneStatement(), step(), toLog(), and UMisRuleState().
|
staticprotected |
max number of subplans allown in any plan
Referenced by addRule().
|
protected |
Mission plan definition
Referenced by createParameterVar(), getRule(), getStateStr(), methodCall(), methodCallV(), remove(), runBreak(), runMainLines(), runRuleCommands(), setParameters(), setRule(), step(), and UMisRuleState().
|
protected |
parent block that called this plan
Referenced by getSubRule(), getSubRuleState(), runBreak(), setRule(), and UMisRuleState().
|
protected |
Counter of the number of times a process line is called
Referenced by getStateStr(), remove(), runCall(), runControl(), runLines(), runLoop(), step(), and UMisRuleState().
|
protected |
Next line to be executed in this
Referenced by advanceToCase(), getStateStr(), initCall(), remove(), runBreak(), runCall(), runControl(), runLine(), runLines(), runLoop(), runMainLines(), runRuleCommands(), runSwitch(), skipOneStatement(), and step().
|
protected |
Subplans defined by this plan
Referenced by addRule(), getCaller(), getStateStr(), getSubRule(), getSubRuleState(), remove(), runMainLines(), and ~UMisRuleState().
|
protected |
Number of subplans defined
Referenced by addRule(), getCaller(), getStateStr(), getSubRule(), getSubRulesCnt(), getSubRuleState(), remove(), runMainLines(), UMisRuleState(), and ~UMisRuleState().
|
protected |
index to parameter variables - the count is in misRule->parametersCnt
Referenced by createParameterVar(), setParameters(), UMisRuleState(), and ~UMisRuleState().
|
protected |
Index to remaining wait time
Referenced by createBaseVar(), and methodWait().
|
protected |
start time for wait method
Referenced by methodWait().