State Class Reference

#include <ArmarXCore/statechart/State.h>

+ Inheritance diagram for State:

Classes

struct  Impl
 

Public Member Functions

virtual RemoteStatePtr addDynamicRemoteState (std::string instanceName)
 Function to add a new dynamic remote substate to this state. More...
 
virtual RemoteStatePtr addRemoteState (std::string stateName, std::string proxyName, std::string instanceName="")
 Function to add a new remote substate to this state. More...
 
StateBasePtr addState (StateBasePtr pNewState)
 
template<>
StatePtr addState (std::string const &stateName)
 
template<>
StatePtr addState (std::string const &stateName)
 
template<class derivedState >
IceInternal::Handle< derivedState > addState (std::string const &stateName="")
 Function to add a new substate to this state. Should be called in the defineState()-function. More...
 
bool addToInput (const std::string &key, const ContainerType &type, bool optional, VariantContainerBasePtr defaultValue=VariantContainerBasePtr())
 Adds a key,type-pair to the input parameters. More...
 
bool addToInput (const std::string &key, VariantTypeId type, bool optional, VariantPtr defaultValue=VariantPtr())
 Adds a new parameter list to the input parameters with a specific type. More...
 
bool addToLocal (const std::string &key, const ContainerType &type, VariantContainerBasePtr defaultValue=VariantContainerBasePtr())
 Adds a new parameter list to the local parameters with a specific type. More...
 
bool addToLocal (const std::string &key, VariantTypeId type, VariantPtr defaultValue=VariantPtr())
 Adds a key,type-pair to the local parameters. More...
 
bool addToOutput (const std::string &key, const ContainerType &type, bool optional)
 Adds a new parameter list to the output parameters with a specific type. More...
 
bool addToOutput (const std::string &key, VariantTypeId type, bool optional)
 Adds a key,type-pair to the output parameters. More...
 
TransitionIceBase & addTransition (EventPtr event, StateIceBasePtr sourceState, StateIceBasePtr destinationState, ParameterMappingIceBasePtr mappingToNextStatesInput=nullptr, ParameterMappingIceBasePtr mappingToParentStatesLocal=nullptr, ParameterMappingIceBasePtr mappingToParentStatesOutput=nullptr)
 
template<class EventType >
TransitionIceBase & addTransition (StateIceBasePtr sourceState, StateIceBasePtr destinationState, ParameterMappingIceBasePtr mappingToNextStatesInput=nullptr, ParameterMappingIceBasePtr mappingToParentStatesLocal=nullptr, ParameterMappingIceBasePtr mappingToParentStatesOutput=nullptr)
 Function to add a new transition between to substates to this state. More...
 
template<class EventType >
TransitionIceBase & addTransitionFromAllStates (StateIceBasePtr destinationState, ParameterMappingIceBasePtr mappingToNextStatesInput=nullptr, ParameterMappingIceBasePtr mappingToParentStatesLocal=nullptr, ParameterMappingIceBasePtr mappingToParentStatesOutput=nullptr)
 Function to add a new transition from all substates to destinationState. More...
 
void cancelSubstates ()
 Use this function in the onEnter() function, if you want to avoid that the substates (i.e. More...
 
StateBasePtr clone () const override
 Generates a new copy of this state with the same statename, substates, transitions, overidden functions etc. More...
 
StateBasePtr createEmptyCopy () const override
 Generates a new copy of this state with the same overidden functions. stateName, substates, transition etc. are not set. More...
 
std::string getGlobalIdString () const
 Getter for the global state identifier string. More...
 
unsigned int getId () const
 Returns an id to this state, that is guaranteed to be unique in this process. More...
 
StateBasePtr getInitState () const
 Getter for the initial state. The initial state is automatically entered, when this state is entered. More...
 
template<typename T >
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput (const std::string &key) const
 getInput can be used to access a specific input parameter.
More...
 
template<typename T >
std::enable_if_t< !(std::is_base_of_v< VariantDataClass, T >||std::is_base_of_v< VariantContainerBase, T >), TgetInput (const std::string &key) const
 getInput can be used to access a specific input parameter.
More...
 
VariantPtr getInput (const std::string &key) const
 getInput can be used to access a specific input parameter. More...
 
StateParameterMap getInputParameters () override
 Returns a new copy of the inputparameters-dictionary, so that the caller cannot modify them (const won't work due to pointers). More...
 
template<typename T >
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getLocal (const std::string &key) const
 getLocal can be used to access a specific input parameter.
More...
 
template<typename T >
std::enable_if_t< !(std::is_base_of_v< VariantDataClass, T >||std::is_base_of_v< VariantContainerBase, T >), TgetLocal (const std::string &key) const
 getLocal can be used to access a specific input parameter.
More...
 
VariantContainerBasePtr getLocalContainer (std::string const &key)
 
StateParameterMap & getLocalParameters ()
 Getter for the local parameter map. More...
 
template<typename T >
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getOutput (const std::string &key) const
 getOutput can be used to access a specific input parameter.
More...
 
template<typename T >
std::enable_if_t< !(std::is_base_of_v< VariantDataClass, T >||std::is_base_of_v< VariantContainerBase, T >), TgetOutput (const std::string &key) const
 getOutput can be used to access a specific input parameter.
More...
 
StateParameterMap & getOutputParameters () override
 getter function to get the map of output parameters More...
 
void inheritInputFromSubstate (std::string stateName)
 
bool init (StatechartContextInterface *context, StatechartManager *manager)
 Function to initialize this state. Must be called in the highest level of the hierarchy - and only there. More...
 
bool isInputParameterSet (const std::string &key) const
 Checks whether a given input parameter is set or not. More...
 
bool isLocalParameterSet (const std::string &key) const
 
bool isOutputParameterSet (const std::string &key) const
 
bool isUnbreakable () const
 
StateBasePtr setInitState (StateBasePtr initState, ParameterMappingPtr initialStateMapping=ParameterMappingPtr())
 Sets the initial substate of this state. More...
 
void setInput (std::string const &key, const Variant &value)
 setInput() sets an input parameter. More...
 
void setInput (std::string const &key, const VariantContainerBase &valueList)
 setInput() sets an input parameter list. More...
 
void setLocal (std::string const &key, const Variant &value)
 setLocal() sets a local parameter. More...
 
void setLocal (std::string const &key, const VariantContainerBase &valueList)
 setLocal() sets a local parameter list. More...
 
void setOutput (std::string const &key, const Variant &value)
 setOuput() sets an output parameter of this state.
More...
 
void setOutput (std::string const &key, const VariantContainerBase &valueList)
 setOuput() sets an output parameter LIST of this state.
More...
 
void setStateClassNameFromTypeName (const std::string &typeName)
 
void setStateName (const std::string &newName)
 
void setUnbreakable (bool setUnbreakable=true)
 With this function the state can be made unbreakable. More...
 
void setUseRunFunction (bool useRunFuntion)
 setUseRunFunction can be used to configurate whether the thread with the async. More...
 
- Public Member Functions inherited from StateUtility
template<class EventClass >
EventPtr createEvent ()
 Utility function to create a new Event. More...
 
EventPtr createEvent (const std::string &eventName, const StringVariantContainerBaseMap &properties=StringVariantContainerBaseMap())
 Utility function to create a new Event. More...
 
- Public Member Functions inherited from StateController
bool __applyMappings (const StateControllerPtr &srcState, const TransitionIceBase &t, const EventPtr &event, TransitionError &error)
 Apply the mappings during a transitions. More...
 
virtual bool __breakActiveSubstate (const EventPtr event)
 
bool __checkExistenceOfTransition (const TransitionIceBase &transition)
 
virtual void __enqueueEvent (const EventPtr event)
 
virtual void __finalize (const EventPtr event)
 Function that gets called, when a state enters a FinalSubstate. Virtual function, so that RemoteStateWrapper can override it. More...
 
bool __findValidTransition (const EventPtr &event, const StateIceBasePtr &sourceState, TransitionIceBase &resultTransition, TransitionError &error) const
 
StateControllerPtr __getParentState () const
 Getter function that automatically casts the parentState member of StateBase into StateControllerPtr. More...
 
virtual unsigned int __getUnbreakableBufferSize () const
 
virtual bool __getUnbreakableBufferStati () const
 Before:Function to get the unbreakable-buffer status of all parent state - recursively. More...
 
virtual void __notifyEventBufferedDueToUnbreakableState (bool eventBuffered=true)
 
void __printTransitionError (const TransitionError &transitionError, const EventPtr &event) const
 
virtual void __processBufferedEvents ()
 Processes buffered events, that could not be processed immediately due to unbreakable substates. More...
 
virtual void __processEvent (const EventPtr event, bool buffered=false)
 Main function to control the statemachine/state. More...
 
virtual void __substatesFinished (const EventPtr ev)
 Function that gets called, when a state enters a FinalSubstate. Virtual function, so that RemoteStateWrapper can override it. More...
 
TransitionError __validateTransition (const TransitionIceBase &transition, const EventPtr event, const StateIceBasePtr &sourceState, const StateIceBasePtr &destinationState) const
 
void __waitForRemoteStates () const
 
virtual bool _baseOnBreak (const EventPtr evt)
 Called by StateControllerprocessEvent()-function or parentstate. Must NOT be called by user. More...
 
virtual void _baseOnEnter ()
 Called by StateControllerprocessEvent()-function or parentstate. More...
 
virtual void _baseOnExit ()
 Called by StateController::processEvent()-function or parentstate. Must NOT be called by user. More...
 
virtual void _baseRun ()
 
virtual void _startRun ()
 
void addProfilerRecursive (Profiler::ProfilerPtr profiler, int recursiveLevels=0)
 addProfilerRecursive recursively adds a new armarx::Profiler::Profiler object as armarx::StateController::localProfiler(the default one does not do anything at all). More...
 
void addTransitionFunction (const TransitionIceBase &t, transitionFunction function)
 
void disableRunFunction ()
 disableRunFunction sets useRunFunction to false and waits (blocking) for the current StateBase::run() function to complete. More...
 
void disableStateReporting (bool disable=true)
 Disables the reporting to profilers for this states during state visits. More...
 
void enter (const StringVariantContainerBaseMap &tempInputParameters=StringVariantContainerBaseMap())
 Function to set the statemachine in the first state and call OnEnter(). More...
 
bool findTransition (const std::string &eventName, const std::string sourceStateName, TransitionIceBase &transition)
 
std::string getTransitionID (const std::string &eventName, const std::string sourceStateName) const
 
std::string getTransitionID (const TransitionIceBase &t) const
 
bool isFinished () const
 
bool isRunningTaskFinished () const
 Checks whether the run() function has already finished. More...
 
bool isRunningTaskStopped () const
 isRunningTaskStopped checks whether the RunningTask, that executes run() is requested to stop. More...
 
void removeProfilerRecursive (Profiler::ProfilerPtr profiler, int recursiveLevels=0)
 
 StateController ()
 
 StateController (const StateController &source)
 
void waitForRunningTaskToFinish () const
 Waits until the run-function has finished. More...
 
void waitForStateToFinish (int timeoutMs=-1) const
 waitForStateToFinish waits until this thread has finished (i.e. More...
 
 ~StateController () override
 
- Public Member Functions inherited from StateBase
void __checkPhase (const std::vector< StatePhase > &allowedTypes, const char *functionName) const
 
void __checkPhase (StatePhase allowedType, const char *functionName) const
 Helper function for checking if a function was called in valid position of the statechart. More...
 
void __checkPhaseMin (StatePhase allowedType, const char *functionName) const
 
void __copyDefaultValuesToInput ()
 
StringVariantContainerBaseMap __getSetInputAndLocalParameters () const
 Combines both maps to one map and returns a new map of only the set parameters. More...
 
virtual bool __hasActiveSubstate ()
 Virtual function to indicate wheter a state has an active substate or not. To be overridden by RemoteState to deligate the call to the real state. More...
 
virtual bool __hasSubstates ()
 Virtual function to indicate wheter a state has substates or not. To be overridden by RemoteState to deligate the call to the real state. More...
 
void __setParentState (StateBase *parentState)
 
void __throwUnknownParameter (const StateParameterMap &paramMap, const std::string &key) const
 
void __updateGlobalStateId ()
 
virtual void __updateGlobalStateIdRecursive ()
 
bool addParameter (StateParameterMap &paramMap, const std::string &key, VariantTypeId type, bool optional, VariantPtr defaultValue=VariantPtr()) const
 
bool addParameterContainer (StateParameterMap &paramMap, const std::string &key, const ContainerType &containerType, bool optional, VariantContainerBasePtr defaultValue=VariantContainerBasePtr()) const
 
void clearSelfPointer ()
 
virtual void deepCopy (const StateBase &sourceState, bool reset=true)
 Function to copy the states with all it substates and transitions. More...
 
virtual void defineParameters ()
 Virtual function, in which input/local/output parameters can be specified. More...
 
virtual void defineState ()
 Virtual function, in which this state can be configured. More...
 
virtual void defineSubstates ()
 Virtual function, in which substates, transition and mappings can be added. More...
 
StateBasePtr findSubstateByName (const std::string &substateName)
 Utility function to find a substate of this state by the name. More...
 
template<typename ContextType >
ContextType * getContext () const
 
StatechartContextInterfacegetContext (bool checkNULL=true) const
 
std::string getGlobalHierarchyString () const
 
std::string getLocalHierarchyString () const
 Function to get a string that contains als parent states and this state. (e.g. "Robot->Functional->Idling") More...
 
Ice::Int getLocalUniqueId () const
 
void getParameter (const StateParameterMap &paramMap, const std::string &key, VariantPtr &value) const
 
void getParameterContainer (const StateParameterMap &paramMap, const std::string &key, VariantContainerBasePtr &valueContainer) const
 
const std::string & getStateClassName () const
 
std::string getStateName () const
 getStateName More...
 
StatePhase getStatePhase () const
 
EventPtr getTriggeredEndstateEvent () const
 This function returns the event that was triggered by entering an endstate. More...
 
void inheritInputParameters ()
 
bool init (StatechartContextInterface *context, StatechartManager *manager)
 Function to initialize this state. Must be called in the highest level of the hierarchy - and only there. More...
 
virtual bool isInitialized () const
 Returns the status of this state. Only if a state is initialized, it can be used. More...
 
bool isParameterSet (const StateParameterMap &paramMap, const std::string &key) const
 
virtual void onBreak ()
 Virtual function, in which the behaviour of state is defined, when it is abnormally exited. Can be overridden, but it is optional.
An abnormal exit only occurs in hierarchy-levels greater 1.
When a parent state is left before the substates are finished, the OnBreak()-function is called in the active substate and in all it's active substates.
If this function is not implemented, the normal OnExit()-function is called.
More...
 
virtual void onEnter ()
 Virtual function, in which the behaviour of state is defined, when it is entered.
Can be overridden, but it is optional. More...
 
virtual void onExit ()
 Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden, but it is optional. More...
 
StateBaseoperator= (const StateBase &source)
 
virtual void refetchSubstates ()
 This functions updates the substates. More...
 
void reset ()
 Function to reset the state: clear name, clear substatesList, clear transition etc. More...
 
virtual void run ()
 Virtual function, that can be reimplemented to calculate complex operations. More...
 
void setContext (StatechartContextInterface *context)
 
void setInitialized (bool enable)
 
void setParameter (StateParameterMap &paramMap, const std::string &key, const Variant &variant)
 
void setParameterContainer (StateParameterMap &paramMap, const std::string &key, const VariantContainerBase &valueContainer)
 
void setParameterContainer (StateParameterMap &paramMap, const std::string &key, const VariantContainerBasePtr &valueContainer)
 
void setStateClassName (std::string className)
 setStateClassName() sets the string, that contains a stringrepresentation of this class. Should not be called usually. The classname gets automatically set in the constructor of the derived class StateTemplate<T>. More...
 
void setStatePhase (StatePhase newPhase)
 
 StateBase ()
 
 StateBase (const StateBase &source)
 
virtual bool waitForInitialization (int timeoutMS=-1) const
 
 ~StateBase () override
 
- Public Member Functions inherited from Logging
SpamFilterDataPtr deactivateSpam (float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
 disables the logging for the current line for the given amount of seconds. More...
 
MessageTypeT getEffectiveLoggingLevel () const
 
 Logging ()
 
void setLocalMinimumLoggingLevel (MessageTypeT level)
 With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set. More...
 
void setTag (const LogTag &tag)
 
void setTag (const std::string &tagName)
 
virtual ~Logging ()
 

Protected Member Functions

Stateoperator= (const State &source)
 
 State ()
 
 State (const State &source)
 
 ~State () override
 
- Protected Member Functions inherited from StateUtility
ConditionIdentifier installCondition (const Term &condition, const EventPtr evt, const std::string &desc="")
 Utility function to install a condition on the distributed conditionhandler. More...
 
template<class Eventclass >
ConditionIdentifier installCondition (const Term &condition, const std::string &desc="")
 Utility function to install a condition on the distributed conditionhandler. More...
 
void removeCondition (ConditionIdentifier conditionId)
 Utility function to remove an installed condition on the distributed conditionhandler. More...
 
void removeCounterEvent (const ActionEventIdentifier &id)
 
void removeTimeoutEvent (const ActionEventIdentifier &id)
 
void sendEvent (const EventPtr event, StateBasePtr eventProcessor=nullptr)
 Function to send an event to a specific state from an onEnter()-function. Must not be called anywhere else. The event is processed after the onEnter()-function of this and all initial substates have returned.
Use of this function should be avoided since this statemachine is blocked until this event and all subsequent sendEvents() are processed. More...
 
template<class Event >
void sendEvent (StateBasePtr eventProcessor=nullptr)
 
ActionEventIdentifier setCounterEvent (int counterThreshold, const EventPtr &evt, int initialValue=0)
 
template<class Eventclass >
ActionEventIdentifier setCounterEvent (int counterThreshold, int initialValue=0)
 
template<class Eventclass >
ActionEventIdentifier setTimeoutEvent (int timeoutDurationMs)
 
ActionEventIdentifier setTimeoutEvent (int timeoutDurationMs, const EventPtr &evt)
 Utility function to start a timer on the systemObserver and register an event on the conditionHandler. The condition is automatically removed, when the state is left. More...
 
- Protected Member Functions inherited from Logging
bool checkLogLevel (MessageTypeT level) const
 
const LogSenderPtrgetLogSender () const
 Retrieve log sender. More...
 
LogSenderPtr loghelper (const char *file, int line, const char *function) const
 

Additional Inherited Members

- Public Types inherited from StateController
using transitionFunction = std::function< void(StateController *state, const StateIceBasePtr &nextState, const StateIceBasePtr &previousState)>
 
using TransitionFunctionMap = std::map< std::string, transitionFunction >
 
- Public Types inherited from StateBase
enum  StatePhase {
  ePreDefined, eStatechartDefinitions, eSubstatesDefinitions, eParametersDefinitions,
  eDefined, eEntering, eEntered, eBreaking,
  eExiting, eExited
}
 enum that specifies the phase in which the state is currently in used to control the usage of state-functions in the correct context More...
 
- Static Public Member Functions inherited from StateBase
static std::vector< StateBasePtrGetActiveStateLeafs (StateBasePtr toplevelState)
 
- Public Attributes inherited from StateController
std::unique_ptr< Implcimpl
 
- Public Attributes inherited from StateBase
std::unique_ptr< Implimpl
 
- Protected Attributes inherited from Logging
MessageTypeT minimumLoggingLevel
 
SpamFilterDataPtr spamFilter
 
LogTag tag
 

Detailed Description

Class that offers the main functionality needed to create a statechart. Only functions from this class and StateUtility should be used to define custom statecharts.

Definition at line 54 of file State.h.

Constructor & Destructor Documentation

◆ State() [1/2]

State ( )
protected

Definition at line 56 of file State.cpp.

+ Here is the caller graph for this function:

◆ State() [2/2]

State ( const State source)
protected

Definition at line 61 of file State.cpp.

◆ ~State()

~State ( )
overrideprotected

Definition at line 82 of file State.cpp.

Member Function Documentation

◆ addDynamicRemoteState()

RemoteStatePtr addDynamicRemoteState ( std::string  instanceName)
virtual

Function to add a new dynamic remote substate to this state.

A Dynamic Remote State is only a placeholder for the real state that is located in another application. Most functioncalls to a Remote State are redirected to the state in other application. The interface is the same as to a normal state.
The differene to a Remote State is, that the location of the real state is unspecified until the Dynamic Remote State-onEnter() function is called by the system. The location of the real state must be specified in the input parameters of the state.
So the inputparameter map must contain a field 'proxyName' and a field 'stateName' with the corresponding values.

Note
Can only be called in defineSubstates() (exception otherwise).
Returns
returns a shared pointer to the created state for convenience. The state is inserted into the std::vector substateList as well.

Reimplemented in RemoteStateOffererBase.

Definition at line 200 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addRemoteState()

RemoteStatePtr addRemoteState ( std::string  stateName,
std::string  proxyName,
std::string  instanceName = "" 
)
virtual

Function to add a new remote substate to this state.

A Remote State is only a placeholder for the real state that is located in another application. Most functioncalls to a Remote State are redirected to the state in other application. The interface is the same as to a normal state.

Parameters
stateNameString that describes this state. Must exist on the specified proxy, otherwise an exception is thrown. It is the name, that was set by setStateName(stateName) or addState(stateName).
proxyNameName of the Ice Proxy, that offers the state
Note
Can only be called in defineSubstates() (exception otherwise).
Returns
returns a shared pointer to the created state for convenience. The state is inserted into the std::vector substateList as well.

Reimplemented in RemoteStateOffererBase.

Definition at line 151 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addState() [1/4]

StateBasePtr addState ( StateBasePtr  pNewState)

Definition at line 135 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addState() [2/4]

StatePtr addState ( std::string const &  stateName)

Definition at line 506 of file State.cpp.

+ Here is the call graph for this function:

◆ addState() [3/4]

StatePtr addState ( std::string const &  stateName)

◆ addState() [4/4]

IceInternal::Handle< derivedState > addState ( std::string const &  stateName = "")

Function to add a new substate to this state. Should be called in the defineState()-function.

Parameters
derivedStateTemplate parameter that specifies the derived state class of the added state. Must be derived from StateTemplate or class State itself if no further functionality is required.
stateNameString that describes this state. Should be unique in this hierarchy level.
Note
Can only be called in defineSubstates() (exception otherwise).
Returns
returns a shared pointer to the created state for convenience. The state is inserted into the std::vector substateList as well.

Definition at line 528 of file State.h.

+ Here is the call graph for this function:

◆ addToInput() [1/2]

bool addToInput ( const std::string &  key,
const ContainerType &  type,
bool  optional,
VariantContainerBasePtr  defaultValue = VariantContainerBasePtr() 
)

Adds a key,type-pair to the input parameters.

Parameters
keyString to describe the parameter
typeVariable that defines the type of this parameter
optionalFlag to indicate whether or not this parameter must be set, when this state is entered
Returns
returns false if the key already exists. The old type resides.
Note
Can only be called in defineParameters() (exception otherwise).

Definition at line 280 of file State.cpp.

+ Here is the call graph for this function:

◆ addToInput() [2/2]

bool addToInput ( const std::string &  key,
VariantTypeId  type,
bool  optional,
VariantPtr  defaultValue = VariantPtr() 
)

Adds a new parameter list to the input parameters with a specific type.

Parameters
keyString to describe the parameter
typeVariable that defines the type of this parameter
optionalFlag to indicate whether or not this parameter must be set, when this state is entered
Returns
returns false if the key already exists. The old type resides.
Note
Can only be called in defineParameters() (exception otherwise).

Definition at line 274 of file State.cpp.

+ Here is the call graph for this function:

◆ addToLocal() [1/2]

bool addToLocal ( const std::string &  key,
const ContainerType &  type,
VariantContainerBasePtr  defaultValue = VariantContainerBasePtr() 
)

Adds a new parameter list to the local parameters with a specific type.

Parameters
keyString to describe the parameter
typeVariable that defines the type of this parameter
optionalFlag to indicate whether or not this parameter must be set, when this state is entered
Returns
returns false if the key already exists. The old type resides.
Note
Can only be called in defineParameters() (exception otherwise).

Definition at line 299 of file State.cpp.

+ Here is the call graph for this function:

◆ addToLocal() [2/2]

bool addToLocal ( const std::string &  key,
VariantTypeId  type,
VariantPtr  defaultValue = VariantPtr() 
)

Adds a key,type-pair to the local parameters.

Parameters
keyString to describe the parameter
typeVariable that defines the type of this parameter
optionalFlag to indicate whether or not this parameter must be set, when this state is entered
Returns
returns false if the key already exists. The old type resides.
Note
Can only be called in defineParameters() (exception otherwise).

Definition at line 307 of file State.cpp.

+ Here is the call graph for this function:

◆ addToOutput() [1/2]

bool addToOutput ( const std::string &  key,
const ContainerType &  type,
bool  optional 
)

Adds a new parameter list to the output parameters with a specific type.

Parameters
keyString to describe the parameter
typeVariable that defines the type of this parameter
optionalFlag to indicate whether or not this parameter must be set, when this state is entered
Returns
returns false if the key already exists. The old type resides.
Note
Can only be called in defineParameters() (exception otherwise).

Definition at line 293 of file State.cpp.

+ Here is the call graph for this function:

◆ addToOutput() [2/2]

bool addToOutput ( const std::string &  key,
VariantTypeId  type,
bool  optional 
)

Adds a key,type-pair to the output parameters.

Parameters
keyString to describe the parameter
typeVariable that defines the type of this parameter
optionalFlag to indicate whether or not this parameter must be set, when this state is entered
Returns
returns false if the key already exists. The old type resides.
Note
Can only be called in defineParameters() (exception otherwise).

Definition at line 287 of file State.cpp.

+ Here is the call graph for this function:

◆ addTransition() [1/2]

TransitionIceBase & addTransition ( EventPtr  event,
StateIceBasePtr  sourceState,
StateIceBasePtr  destinationState,
ParameterMappingIceBasePtr  mappingToNextStatesInput = nullptr,
ParameterMappingIceBasePtr  mappingToParentStatesLocal = nullptr,
ParameterMappingIceBasePtr  mappingToParentStatesOutput = nullptr 
)

Definition at line 232 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTransition() [2/2]

TransitionIceBase & addTransition ( StateIceBasePtr  sourceState,
StateIceBasePtr  destinationState,
ParameterMappingIceBasePtr  mappingToNextStatesInput = nullptr,
ParameterMappingIceBasePtr  mappingToParentStatesLocal = nullptr,
ParameterMappingIceBasePtr  mappingToParentStatesOutput = nullptr 
)

Function to add a new transition between to substates to this state.

Template Parameters
EventTypeType of the event that trigers this transition.
Parameters
pSourceStateShared pointer to the state, that must be the active state before this transition. OnExit() is called there.
pDestinationShared pointer to the state, in which this transition will end. OnEnter() is called there.
pMappingMapping from the outputDictionary of pSourceState and the eventDictionary to the inputDictionary of pDestinationState
Note
Can only be called in defineSubstates() (exception otherwise).
Returns
returns reference to added transition

Definition at line 547 of file State.h.

+ Here is the call graph for this function:

◆ addTransitionFromAllStates()

TransitionIceBase & addTransitionFromAllStates ( StateIceBasePtr  destinationState,
ParameterMappingIceBasePtr  mappingToNextStatesInput = nullptr,
ParameterMappingIceBasePtr  mappingToParentStatesLocal = nullptr,
ParameterMappingIceBasePtr  mappingToParentStatesOutput = nullptr 
)

Function to add a new transition from all substates to destinationState.

Note
Can only be called in defineSubstates() (exception otherwise).

Definition at line 558 of file State.h.

+ Here is the call graph for this function:

◆ cancelSubstates()

void cancelSubstates ( )

Use this function in the onEnter() function, if you want to avoid that the substates (i.e.

the initial state) are entered.

Definition at line 349 of file State.cpp.

+ Here is the call graph for this function:

◆ clone()

StateBasePtr clone ( ) const
overridevirtual

Generates a new copy of this state with the same statename, substates, transitions, overidden functions etc.

Implements StateBase.

Reimplemented in NoUserCodeState.

Definition at line 450 of file State.cpp.

+ Here is the call graph for this function:

◆ createEmptyCopy()

StateBasePtr createEmptyCopy ( ) const
overridevirtual

Generates a new copy of this state with the same overidden functions. stateName, substates, transition etc. are not set.

Implements StateBase.

Definition at line 457 of file State.cpp.

+ Here is the call graph for this function:

◆ getGlobalIdString()

std::string getGlobalIdString ( ) const

Getter for the global state identifier string.

It contains all parent states to the top of the statechart including remote states. Example: RobotControl->Functional->VisualServo

Definition at line 96 of file State.cpp.

◆ getId()

unsigned int getId ( ) const

Returns an id to this state, that is guaranteed to be unique in this process.

Definition at line 91 of file State.cpp.

◆ getInitState()

StateBasePtr getInitState ( ) const

Getter for the initial state. The initial state is automatically entered, when this state is entered.

Returns
Shared pointer to the initial state, NULL if not set.
See also
setInitState()

Definition at line 101 of file State.cpp.

◆ getInput() [1/3]

std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput ( const std::string &  key) const

getInput can be used to access a specific input parameter.

This version is for complex variant types.

Exceptions
InvalidTypeException
Template Parameters
TType of the requested variant. The return type depends on this.
Parameters
keyof the parameter
Returns
Since the user must not be able to modify the inputparameters and constant IceSharedPointers are not possible, a copy of the requested Variant is returned.

Definition at line 598 of file State.h.

+ Here is the call graph for this function:

◆ getInput() [2/3]

std::enable_if_t< !(std::is_base_of_v< VariantDataClass, T >||std::is_base_of_v< VariantContainerBase, T >), T > getInput ( const std::string &  key) const

getInput can be used to access a specific input parameter.

This version is for basic variant types like int, float, bool, string.

Exceptions
InvalidTypeException
Template Parameters
TType of the requested variant. The return type depends on this.
Parameters
keyof the parameter
Returns
Since the user must not be able to modify the inputparameters and constant IceSharedPointers are not possible, a copy of the requested Variant is returned.

Definition at line 618 of file State.h.

◆ getInput() [3/3]

VariantPtr getInput ( const std::string &  key) const

getInput can be used to access a specific input parameter.

Exceptions
InvalidTypeException
Template Parameters
TType of the requested variant. The return type depends on this.
Parameters
keyof the parameter
Returns
Since the user must not be able to modify the inputparameters and constant IceSharedPointers are not possible, a copy of the requested Variant is returned.

Definition at line 374 of file State.cpp.

+ Here is the call graph for this function:

◆ getInputParameters()

StateParameterMap getInputParameters ( )
overridevirtual

Returns a new copy of the inputparameters-dictionary, so that the caller cannot modify them (const won't work due to pointers).

These values are reset immediately after this state is left (onExit/onBreak was called)

Returns
new instance of the inputparameters-dictionary

Implements StateBase.

Definition at line 366 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocal() [1/2]

std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getLocal ( const std::string &  key) const

getLocal can be used to access a specific input parameter.

This version is for complex variant types.

Exceptions
InvalidTypeException
Template Parameters
TType of the requested variant. The return type depends on this.
Parameters
keyof the parameter
Returns
A pointer to the requested value

Definition at line 629 of file State.h.

+ Here is the call graph for this function:

◆ getLocal() [2/2]

std::enable_if_t< !(std::is_base_of_v< VariantDataClass, T >||std::is_base_of_v< VariantContainerBase, T >), T > getLocal ( const std::string &  key) const

getLocal can be used to access a specific input parameter.

This version is for basic variant types like int, float, bool, string.

Exceptions
InvalidTypeException
Template Parameters
TType of the requested variant. The return type depends on this.
Parameters
keyof the parameter
Returns
A copy of the requested value.

Definition at line 649 of file State.h.

◆ getLocalContainer()

VariantContainerBasePtr getLocalContainer ( std::string const &  key)

Definition at line 479 of file State.cpp.

+ Here is the call graph for this function:

◆ getLocalParameters()

StateParameterMap & getLocalParameters ( )

Getter for the local parameter map.

Returns
returns a reference to the local parameters map.

Definition at line 385 of file State.cpp.

+ Here is the caller graph for this function:

◆ getOutput() [1/2]

std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getOutput ( const std::string &  key) const

getOutput can be used to access a specific input parameter.

This version is for complex variant types.

Exceptions
InvalidTypeException
Template Parameters
TType of the requested variant. The return type depends on this.
Parameters
keyof the parameter
Returns
A pointer to the requested value

Definition at line 660 of file State.h.

+ Here is the call graph for this function:

◆ getOutput() [2/2]

std::enable_if_t< !(std::is_base_of_v< VariantDataClass, T >||std::is_base_of_v< VariantContainerBase, T >), T > getOutput ( const std::string &  key) const

getOutput can be used to access a specific input parameter.

This version is for basic variant types like int, float, bool, string.

Exceptions
InvalidTypeException
Template Parameters
TType of the requested variant. The return type depends on this.
Parameters
keyof the parameter
Returns
A copy of the requested value.

Definition at line 680 of file State.h.

◆ getOutputParameters()

StateParameterMap & getOutputParameters ( )
overridevirtual

getter function to get the map of output parameters

Returns
returns the reference to this state's output parameters (the complete map)
See also
getOutput, setOutput, getInput, getInputParameters

Reimplemented from StateBase.

Definition at line 111 of file State.cpp.

+ Here is the caller graph for this function:

◆ inheritInputFromSubstate()

void inheritInputFromSubstate ( std::string  stateName)

Definition at line 266 of file State.cpp.

+ Here is the call graph for this function:

◆ init()

bool init ( StatechartContextInterface context,
StatechartManager manager 
)

Function to initialize this state. Must be called in the highest level of the hierarchy - and only there.

Note
init() of substates is automatically called.
Parameters
contextpointer to a StatechartContext, that holds the objects to communicate with other components like observers, kinematic unit etc.

Definition at line 84 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInputParameterSet()

bool isInputParameterSet ( const std::string &  key) const

Checks whether a given input parameter is set or not.

Parameters
keyName of the input parameter
Returns
returns true if the given parameter is set.

Definition at line 489 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLocalParameterSet()

bool isLocalParameterSet ( const std::string &  key) const

Definition at line 494 of file State.cpp.

+ Here is the call graph for this function:

◆ isOutputParameterSet()

bool isOutputParameterSet ( const std::string &  key) const

Definition at line 499 of file State.cpp.

+ Here is the call graph for this function:

◆ isUnbreakable()

bool isUnbreakable ( ) const

Definition at line 106 of file State.cpp.

◆ operator=()

State & operator= ( const State source)
protected

Definition at line 74 of file State.cpp.

+ Here is the call graph for this function:

◆ setInitState()

StateBasePtr setInitState ( StateBasePtr  initState,
ParameterMappingPtr  initialStateMapping = ParameterMappingPtr() 
)

Sets the initial substate of this state.

This initial state is automatically entered, when the parent state is entered. On the implicit transition a parameter mapping from the parent's input and local parameters is done. The mapping can be specified with setInitialStateMapping()

Parameters
initStateThe state that should be the initial state
initialStateMappingA ParameterMapping that maps *this's input to the state's input in the first parameter(use mapFromParent()). This mapping is copied and then stored.
Note
Can only be called in defineSubstates() (exception otherwise).

Definition at line 319 of file State.cpp.

+ Here is the call graph for this function:

◆ setInput() [1/2]

void setInput ( std::string const &  key,
const Variant value 
)

setInput() sets an input parameter.

Parameters
keyof the parameter
valueof the parameter of any by the Variant supported type

Definition at line 390 of file State.cpp.

+ Here is the call graph for this function:

◆ setInput() [2/2]

void setInput ( std::string const &  key,
const VariantContainerBase &  valueList 
)

setInput() sets an input parameter list.

Parameters
keyof the parameter
valueof the parameter of any by the Variant supported type

Definition at line 403 of file State.cpp.

+ Here is the call graph for this function:

◆ setLocal() [1/2]

void setLocal ( std::string const &  key,
const Variant value 
)

setLocal() sets a local parameter.

Local means, that this parameter can be written and read in this state's onEnter(), onBreak(), onEnter() and only there.

Parameters
keyof the parameter
valueof the parameter of any by the Variant supported type

Definition at line 417 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLocal() [2/2]

void setLocal ( std::string const &  key,
const VariantContainerBase &  valueList 
)

setLocal() sets a local parameter list.

Local means, that this parameter can be written and read in this state's onEnter(), onBreak(), onEnter() and only there.

Parameters
keyof the parameter
valueof the parameter of any by the Variant supported type

Definition at line 425 of file State.cpp.

+ Here is the call graph for this function:

◆ setOutput() [1/2]

void setOutput ( std::string const &  key,
const Variant value 
)

setOuput() sets an output parameter of this state.

Can be called in onEnter(), onBreak(), onExit(). Following states can access this parameter.

Parameters
keyof the parameter
valueof the parameter of any by the Variant supported type

Definition at line 434 of file State.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOutput() [2/2]

void setOutput ( std::string const &  key,
const VariantContainerBase &  valueList 
)

setOuput() sets an output parameter LIST of this state.

Can be called in onEnter(), onBreak(), onExit(). Following states can access this parameter.

Parameters
keyof the parameter
valueof the parameter of any by the Variant supported type

Definition at line 442 of file State.cpp.

+ Here is the call graph for this function:

◆ setStateClassNameFromTypeName()

void setStateClassNameFromTypeName ( const std::string &  typeName)

Definition at line 360 of file State.cpp.

+ Here is the call graph for this function:

◆ setStateName()

void setStateName ( const std::string &  newName)

Definition at line 355 of file State.cpp.

◆ setUnbreakable()

void setUnbreakable ( bool  setUnbreakable = true)

With this function the state can be made unbreakable.

Unbreakable means that a parent state cannot be left, while this state is active.

Parameters
setSet to true if the state should be made unbreakable

Definition at line 338 of file State.cpp.

+ Here is the call graph for this function:

◆ setUseRunFunction()

void setUseRunFunction ( bool  useRunFuntion)

setUseRunFunction can be used to configurate whether the thread with the async.

run-function should be started/used.

This should be set to false in time-critical states.

See also
StateBase::run(), _baseRun(), _startRun()
Parameters
useRunFuntion

Definition at line 344 of file State.cpp.


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