32#include <ArmarXCore/interface/statechart/StatechartIce.h>
42#define EVENTTOALL "toAll"
43#define STATEINFO ARMARX_INFO << armarx::LogTag("State: " + stateName)
69 template <
typename ContextType>
73 ContextType*
c =
dynamic_cast<ContextType*
>(
getContext());
78 "Could not cast context to requested type!");
113 LocalException(
"The state '" + state->stateName +
"' does not expect the event '" +
114 event->eventName +
"' (EventReceiverState: '" +
115 event->eventReceiverName +
"')")
126 return "eUnexpectedEvent";
235 const std::string& key,
240 StateParameterMap& paramMap,
241 const std::string& key,
242 const ContainerType& containerType,
244 VariantContainerBasePtr defaultValue = VariantContainerBasePtr())
const;
248 const std::string& key,
249 const VariantContainerBasePtr& valueContainer);
251 const std::string& key,
252 const VariantContainerBase& valueContainer);
256 const std::string& key,
259 const std::string& key,
260 VariantContainerBasePtr& valueContainer)
const;
262 bool isParameterSet(
const StateParameterMap& paramMap,
const std::string& key)
const;
314 void __checkPhase(
const std::vector<StatePhase>& allowedTypes,
315 const char* functionName)
const;
318 const std::string& key)
const;
This class is the implementation of the Slice Definition of a state.
void getParameterContainer(const StateParameterMap ¶mMap, const std::string &key, VariantContainerBasePtr &valueContainer) const
virtual void defineState()
Virtual function, in which this state can be configured.
StateBase & operator=(const StateBase &source)
virtual void run()
Virtual function, that can be reimplemented to calculate complex operations.
virtual bool isInitialized() const
Returns the status of this state. Only if a state is initialized, it can be used.
StateBasePtr findSubstateByName(const std::string &substateName)
Utility function to find a substate of this state by the name.
void __updateGlobalStateId()
bool isParameterSet(const StateParameterMap ¶mMap, const std::string &key) const
virtual StateBasePtr createEmptyCopy() const =0
void setParameter(StateParameterMap ¶mMap, const std::string &key, const Variant &variant)
virtual bool __hasActiveSubstate()
Virtual function to indicate wheter a state has an active substate or not. To be overridden by Remote...
static std::vector< StateBasePtr > GetActiveStateLeafs(StateBasePtr toplevelState)
void __setParentState(StateBase *parentState)
virtual bool waitForInitialization(int timeoutMS=-1) const
void __checkPhase(StatePhase allowedType, const char *functionName) const
Helper function for checking if a function was called in valid position of the statechart.
void __checkPhaseMin(StatePhase allowedType, const char *functionName) const
virtual void onBreak()
Virtual function, in which the behaviour of state is defined, when it is abnormally exited....
void setContext(StatechartContextInterface *context)
void inheritInputParameters()
void setStatePhase(StatePhase newPhase)
bool addParameterContainer(StateParameterMap ¶mMap, const std::string &key, const ContainerType &containerType, bool optional, VariantContainerBasePtr defaultValue=VariantContainerBasePtr()) const
EventPtr getTriggeredEndstateEvent() const
This function returns the event that was triggered by entering an endstate.
void setStateClassName(std::string className)
setStateClassName() sets the string, that contains a stringrepresentation of this class....
virtual StateParameterMap & getOutputParameters()
virtual StateBasePtr clone() const =0
Pure virtual function to clone of the derived class type.
const std::string & getStateClassName() const
virtual void __updateGlobalStateIdRecursive()
virtual void defineParameters()
Virtual function, in which input/local/output parameters can be specified.
void __copyDefaultValuesToInput()
virtual void defineSubstates()
Virtual function, in which substates, transition and mappings can be added.
void setParameterContainer(StateParameterMap ¶mMap, const std::string &key, const VariantContainerBasePtr &valueContainer)
virtual void deepCopy(const StateBase &sourceState, bool reset=true)
Function to copy the states with all it substates and transitions.
virtual void onEnter()
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
bool addParameter(StateParameterMap ¶mMap, const std::string &key, VariantTypeId type, bool optional, VariantPtr defaultValue=VariantPtr()) const
std::string getLocalHierarchyString() const
Function to get a string that contains als parent states and this state. (e.g. "Robot->Functional->Id...
bool init(StatechartContextInterface *context, StatechartManager *manager)
Function to initialize this state. Must be called in the highest level of the hierarchy - and only th...
std::unique_ptr< Impl > impl
StatePhase
enum that specifies the phase in which the state is currently in used to control the usage of state-f...
StatePhase getStatePhase() const
std::string getGlobalHierarchyString() const
virtual bool __hasSubstates()
Virtual function to indicate wheter a state has substates or not. To be overridden by RemoteState to ...
StringVariantContainerBaseMap __getSetInputAndLocalParameters() const
Combines both maps to one map and returns a new map of only the set parameters.
void __throwUnknownParameter(const StateParameterMap ¶mMap, const std::string &key) const
Ice::Int getLocalUniqueId() const
void reset()
Function to reset the state: clear name, clear substatesList, clear transition etc.
void getParameter(const StateParameterMap ¶mMap, const std::string &key, VariantPtr &value) const
virtual void refetchSubstates()
This functions updates the substates.
ContextType * getContext() const
std::string getStateName() const
getStateName
void setInitialized(bool enable)
virtual void onExit()
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
virtual StateParameterMap getInputParameters()=0
Not const because RemoteState implementation gets the current parameters via Ice and sets them.
The Variant class is described here: Variants.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Variant > VariantPtr
IceInternal::Handle< Event > EventPtr
Typedef of EventPtr as IceInternal::Handle<Event> for convenience.
IceInternal::Handle< StateBase > StateBasePtr
~eUnexpectedEvent() noexcept override
eUnexpectedEvent(const EventPtr event, StateIceBasePtr state)
std::string name() const override