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

#include <ureskeep.h>

Inheritance diagram for UKeepItem:
Inheritance graph

Public Member Functions

bool createBaseVar ()
 
UServerPushgetPushHandle (bool on)
 
bool isA (const char *name)
 
bool isWait ()
 
bool monitorTest (int exprFor, bool *evaluated=NULL)
 
const char * print (const char *preStr, char *buff, const int buffCnt)
 
void setAllow (double secs)
 
void setAllowOff (bool value)
 
void setCore (UCmdExe *pCore)
 
void setExpr (int expFor, const char *expr)
 
void setLogFile (ULogFile *logf)
 
void setName (const char *name)
 
void setWait (bool value)
 
bool tick ()
 
 UKeepItem ()
 
 ~UKeepItem ()
 
- 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...
 
UVarPooladdStructLocal (const char *name, const char *note, bool copy)
 
UVariableaddVar (const char *name, const double initialValue, const char *type, const char *comment)
 
UVariableaddVar (const char *name, const double initialValue, UVariable::varType type, const char *comment, const char *attValue=NULL)
 
UVariableaddVar (const char *name, const UVariable *source, const char *comment)
 
UVariableaddVar (const char *name, const char *comment)
 
UVariableaddVarA (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)
 
UVariablegetGlobalVariable (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...
 
UVarMethodgetLocalMethod (const char *name, const char *paramList)
 
UVarPoolgetLocalMethod (const char *name, const char *paramList, UVarMethod **method)
 
UVarMethodgetLocalMethod (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)
 
UVariablegetLocalVar (int index)
 
UVariablegetLocalVariable (const char *name, int *element)
 get pointer to variable object in this variable tree More...
 
int getLocalVarIndex (const char *name, int *element)
 
ULogFilegetLogVar ()
 
ULockgetLogVarLock ()
 
int getMethodCnt ()
 
int getMethodMax ()
 
UVarPoolgetParentVarPool ()
 
UVarPoolgetParentVarPoolScope ()
 
const char * getPreName ()
 
UVarPoolgetRootVarPool ()
 
bool getScopeValue (const char *name, double *value)
 
UVarPoolgetStruct (const char *name)
 
UVarPoolgetStruct (const int idx)
 
int getStructCnt ()
 
UVarPoolgetStructDeep (const char *fullName, char *varName, const int varNameCnt)
 
UVarPoolgetStructDeep (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)
 
UServerPushImplementgetImplementor ()
 
int getPushCmdCnt (int *cmdCnt, int *callCnt)
 
UServerPushQueuegetPushQueue ()
 
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 ()
 

Protected Attributes

UCmdExecore
 pointer to server core (to send start and stop commands using "do") More...
 
UServerPusheventOff
 
UServerPusheventOn
 
ULogFilelogfile
 
UTime offTime
 
int tickCnt
 
UTime tickTime
 
UVariablevarAllow
 allow this many seconds after start command is issued More...
 
UVariablevarAllowOff
 allow off state to be stable More...
 
UVariablevarKeepName
 pointer to name variable More...
 
UVariablevarMonitorCnt
 number of monitorng actions More...
 
UVariablevarOffCnt
 number of monitorng actions More...
 
UVariablevarOffExpr
 pointer to expression to monitor More...
 
UVariablevarOnExpr
 pointer to expression to monitor More...
 
UVariablevarRunningOK
 pointer to result of monitoring process More...
 
UVariablevarTickInterval
 
UVariablevarUnknownExpr
 pointer to expression to monitor More...
 
UVariablevarWait
 pointer to wait variable for this keep More...
 
- Protected Attributes inherited from UVarCalc
char errorTxt [MAX_ERROR_SIZE]
 
- Protected Attributes inherited from UVarPool
const char * description
 
ULogFilelogVar
 
ULocklogVarLock
 
UVarPool ** varPools
 
bool * varPoolsLocal
 
bool verbose
 

Additional Inherited Members

- 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)
 

Detailed Description

Class to hold the needed items to montor the state of a process or a server

Constructor & Destructor Documentation

UKeepItem::UKeepItem ( )

Constructor

References core, eventOff, eventOn, logfile, tickCnt, and UServerPush::UServerPush().

Referenced by UResKeep::add().

UKeepItem::~UKeepItem ( )

DEstructor

References eventOff, and eventOn.

Member Function Documentation

bool UKeepItem::createBaseVar ( )
UServerPush* UKeepItem::getPushHandle ( bool  on)
inline

Get a handle to a push object for process, or overall

References createBaseVar(), eventOff, eventOn, isA(), setAllow(), setAllowOff(), setCore(), setExpr(), setName(), and setWait().

Referenced by UFuncKeep::handleKeepPush(), and UResKeep::UResKeep().

bool UKeepItem::isA ( const char *  name)

Test if this this keep matches the provided name

Parameters
namethe proveded name to compare against

References UVariable::getValues(), and varKeepName.

Referenced by getPushHandle().

bool UKeepItem::isWait ( )
inline

Is this keep in wait mode

Returns
true if waiting

References UVariable::getValueBool(), monitorTest(), print(), and varWait.

Referenced by tick().

bool UKeepItem::monitorTest ( int  exprFor,
bool *  evaluated = NULL 
)

Update the monitoring process for this keep.

Parameters
evaluatedis set to false if a syntax error is detected in the expression.
Returns
true if the expression is evaluated higher than 0.5, i.e. true.

References UVarPool::callGlobal(), UVarCalc::errorTxt, UVarCalc::evaluateD(), UVariable::getValues(), roundi(), varOffExpr, varOnExpr, and varUnknownExpr.

Referenced by UFuncKeep::handleKeep(), isWait(), and tick().

const char * UKeepItem::print ( const char *  preStr,
char *  buff,
const int  buffCnt 
)

Print current status to this buffer string

Parameters
preStrstart by inserting this string into buffer
buffstart of buffer
bufCntlength of buffer
Returns
a pointer to the buffer

References bool2str(), UVariable::getBool(), UVariable::getInt(), UVariable::getValued(), UVariable::getValues(), varAllow, varKeepName, varOffExpr, varOnExpr, varRunningOK, varTickInterval, varUnknownExpr, and varWait.

Referenced by isWait(), and UResKeep::UResKeep().

void UKeepItem::setAllow ( double  secs)

Set number of seconds to allow a process to start (typically after an off condition)

Parameters
secsis number of seconds to wait before first monitoring action takes place.

References UVariable::setDouble(), and varAllow.

Referenced by getPushHandle(), and UFuncKeep::handleKeep().

void UKeepItem::setAllowOff ( bool  value)

Set number of seconds to allow a process to start (typically after an off condition)

Parameters
valueallow off as a steady state, when value is true, otherwise an off condition will change state to unknown, and thus retrigger an off event after the allowed allow (to start) time.

References UVariable::setBool(), and varAllowOff.

Referenced by getPushHandle(), and UFuncKeep::handleKeep().

void UKeepItem::setCore ( UCmdExe pCore)

Set the receiver of the event commands (the implementor)

Parameters
implementorimplements the commands

References core, eventOff, eventOn, and UServerPush::setImplementor().

Referenced by UResKeep::add(), and getPushHandle().

void UKeepItem::setExpr ( int  expFor,
const char *  expr 
)

Set the expression that the keep function is to monitor.

Parameters
expForwhich of the three expressions are to be set -1=unknown, 0=off, 1=on
expris the expression that should evaluate to true (exp > 0.5) when process is OK.

References UVariable::setValues(), varOffExpr, varOnExpr, and varUnknownExpr.

Referenced by getPushHandle(), and UFuncKeep::handleKeep().

void UKeepItem::setLogFile ( ULogFile logf)
inline

Set pointer to the resource logfile

Referenced by UResKeep::add().

void UKeepItem::setName ( const char *  name)

Set the name of the keep process - may also be the process to keep.

Parameters
nameis the symbol name of the keep process.

References UVariable::setValues(), and varKeepName.

Referenced by UResKeep::add(), and getPushHandle().

void UKeepItem::setWait ( bool  value)

Set the (server) command to be issued, to start the (not running) process Set the (server) command to be issued, to stop the (not running) process Send the stop command now. If wait is true, then this will terminate the process. If wait is false, then this will restart the process Set the wait flag. If waiting, then the monitoring of this keep is off (and no action taken) When the flag is switched on, then the monitoring is restarted.

Parameters
valueis the new value for the wait flag.

References UVariable::setBool(), and varWait.

Referenced by UResKeep::getKeepsCnt(), getPushHandle(), and UFuncKeep::handleKeep().

bool UKeepItem::tick ( )

Member Data Documentation

UCmdExe* UKeepItem::core
protected

pointer to server core (to send start and stop commands using "do")

Referenced by UResKeep::createResources(), setCore(), and UKeepItem().

UServerPush* UKeepItem::eventOff
protected
UServerPush* UKeepItem::eventOn
protected

on process is on handler

Referenced by getPushHandle(), setCore(), tick(), UKeepItem(), UResKeep::UResKeep(), and ~UKeepItem().

ULogFile* UKeepItem::logfile
protected

logfile to save events

Referenced by tick(), and UKeepItem().

UTime UKeepItem::offTime
protected

Last time off was detected

Referenced by tick().

int UKeepItem::tickCnt
protected

Client connection to the other server number of iterations

Referenced by tick(), and UKeepItem().

UTime UKeepItem::tickTime
protected

Last tick time

Referenced by tick().

UVariable* UKeepItem::varAllow
protected

allow this many seconds after start command is issued

Referenced by createBaseVar(), print(), setAllow(), and tick().

UVariable* UKeepItem::varAllowOff
protected

allow off state to be stable

Referenced by createBaseVar(), setAllowOff(), and tick().

UVariable* UKeepItem::varKeepName
protected

pointer to name variable

Referenced by createBaseVar(), isA(), print(), setName(), and tick().

UVariable* UKeepItem::varMonitorCnt
protected

number of monitorng actions

Referenced by createBaseVar(), and tick().

UVariable* UKeepItem::varOffCnt
protected

number of monitorng actions

Referenced by createBaseVar(), and tick().

UVariable* UKeepItem::varOffExpr
protected

pointer to expression to monitor

Referenced by createBaseVar(), monitorTest(), print(), setExpr(), and tick().

UVariable* UKeepItem::varOnExpr
protected

pointer to expression to monitor

Referenced by createBaseVar(), monitorTest(), print(), setExpr(), and tick().

UVariable* UKeepItem::varRunningOK
protected

pointer to result of monitoring process

Referenced by createBaseVar(), print(), and tick().

UVariable* UKeepItem::varTickInterval
protected

interval between ticks

Referenced by createBaseVar(), print(), and tick().

UVariable* UKeepItem::varUnknownExpr
protected

pointer to expression to monitor

Referenced by createBaseVar(), monitorTest(), print(), setExpr(), and tick().

UVariable* UKeepItem::varWait
protected

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