44 if (!eventProcessor._ptr)
46 eventProcessor =
impl->__parentState;
50 if ((eventProcessor.get() ==
impl->__parentState &&
52 (
impl->__parentState &&
impl->__parentState->activeSubstate.get() !=
this))
54 ARMARX_VERBOSE <<
"The state " << stateName <<
" is not active anymore - event '"
55 <<
event->eventName <<
"' omitted" << std::endl;
57 if (
impl->__parentState->activeSubstate)
60 <<
"Active state is now: "
61 << StateBasePtr::dynamicCast(
impl->__parentState->activeSubstate)->stateName;
72 StateControllerPtr::dynamicCast(eventProcessor);
74 if (eventController._ptr)
78 impl->manager->addEvent(event, eventController);
104 const std::string& desc)
113 if (!
impl->__parentState)
124 ConditionHandlerInterfacePrx conditionHandlerPrx = context->conditionHandlerPrx;
126 std::string uniqueEventIdentifier =
127 context->eventDistributor->registerEvent(evt, eventProcessor,
impl->visitCounter);
130 sentEvent->eventName = uniqueEventIdentifier;
132 ARMARX_DEBUG <<
"registered event: " << sentEvent->eventName
133 <<
", EventRecv:" << sentEvent->eventReceiverName <<
flush;
134 installedConditions.push_back(condition.
getImpl());
135 ConditionIdentifier condId = conditionHandlerPrx->installConditionWithDescription(
136 context->eventDistributor->getListener(),
143 __installedConditionIdentifiers.push_back(condId);
158 context->conditionHandlerPrx->begin_removeCondition(conditionId);
167 ARMARX_INFO <<
"Installing Timeout Event (Timeout: " << timeoutDurationMs <<
"ms)" <<
flush;
179 if (!
impl->__parentState)
185 std::stringstream timerName;
186 timerName <<
"Timer_" << context->
getName() <<
"_" << stateName <<
"_"
187 <<
impl->localUniqueId <<
"_" << evt->eventName <<
"_" << timeoutDurationMs
192 ChannelRefPtr::dynamicCast(context->
systemObserverPrx->startTimer(timerName.str()));
193 __installedTimerChannelRefs.push_back(result.
actionId);
195 ChannelRefPtr::dynamicCast(result.
actionId)->getDataFieldIdentifier(
"elapsedMs"),
220 ARMARX_INFO <<
"Installing Counter Event (Counter Threshold: " << counterThreshold
221 <<
", InitialValue: " << initialValue <<
")" <<
flush;
233 if (!
impl->__parentState)
239 std::stringstream counterName;
240 counterName <<
"Counter_" << stateName <<
"_" <<
impl->localUniqueId <<
"_"
245 result.
actionId = ChannelRefPtr::dynamicCast(
247 __installedCounterChannelRefs.push_back(result.
actionId);
249 ChannelRefPtr::dynamicCast(result.
actionId)->getDataFieldIdentifier(
"value"),
270 StateUtility::checkEventIsHandled(
const EventPtr& event)
const
274 if (!
impl->__parentState)
279 for (
unsigned int i = 0; i <
impl->__parentState->transitions.size(); ++i)
281 TransitionIceBase& t =
impl->__parentState->transitions.at(i);
283 if (t.evt->eventName == event->eventName)
294 const StringVariantContainerBaseMap& properties)
297 evt->properties = properties;
302 StateUtility::_removeInstalledConditions()
307 ARMARX_INFO <<
"Statechart Context is NULL - cannot clear installed conditions";
310 for (
auto c : __installedConditionIdentifiers)
315 __installedConditionIdentifiers.clear();
317 for (
auto c : __installedTimerChannelRefs)
322 __installedTimerChannelRefs.clear();
324 for (
auto c : __installedCounterChannelRefs)
329 __installedCounterChannelRefs.clear();
An Event is used to communicate between e.g.
Literals are part of the user front end of the ArmarX condition mechanism.
static VarList createParameterList()
Static helper method to create an empty parameterlist.
std::string getName() const
Retrieve name of object.
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
std::unique_ptr< Impl > impl
StatePhase getStatePhase() const
ContextType * getContext() const
friend class StatechartContext
void removeCondition(ConditionIdentifier conditionId)
Utility function to remove an installed condition on the distributed conditionhandler.
void removeCounterEvent(const ActionEventIdentifier &id)
void removeTimeoutEvent(const ActionEventIdentifier &id)
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
EventPtr createEvent()
Utility function to create a new Event.
ActionEventIdentifier setCounterEvent(int counterThreshold, const EventPtr &evt, int initialValue=0)
ConditionIdentifier installCondition(const Term &condition, const EventPtr evt, const std::string &desc="")
Utility function to install a condition on the distributed conditionhandler.
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...
This class contains a statechart and provides the interfaces to distributed components.
StatechartEventDistributorPtr eventDistributor
The EventListenerInterface instance, that receives events from observers and redirects them to the co...
SystemObserverInterfacePrx systemObserverPrx
Terms are part of the user front end of the ArmarX condition mechanism.
TermImplPtr getImpl() const
Retrieve term implementation object as used in the ArmarX Framework in order to build distributed exp...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_VERBOSE
The logging level for verbose information.
This file offers overloads of toIce() and fromIce() functions for STL container types.
const LogSender::manipulator flush
IceInternal::Handle< Event > EventPtr
Typedef of EventPtr as IceInternal::Handle<Event> for convenience.
IceInternal::Handle< StateBase > StateBasePtr
IceInternal::Handle< StateController > StateControllerPtr
Struct for the return value of setCounter/TimerEvent.
ChannelRefBasePtr actionId
ConditionIdentifier conditionId