42 if (!eventProcessor._ptr)
44 eventProcessor =
impl->__parentState;
50 || (
impl->__parentState &&
impl->__parentState->activeSubstate.get() !=
this))
52 ARMARX_VERBOSE <<
"The state " << stateName <<
" is not active anymore - event '" <<
event->eventName <<
"' omitted" << std::endl;
54 if (
impl->__parentState->activeSubstate)
56 ARMARX_VERBOSE <<
"Active state is now: " << StateBasePtr::dynamicCast(
impl->__parentState->activeSubstate)->stateName;
68 if (eventController._ptr)
72 impl->manager->addEvent(event, eventController);
106 if (!
impl->__parentState)
117 ConditionHandlerInterfacePrx conditionHandlerPrx = context->conditionHandlerPrx;
119 std::string uniqueEventIdentifier = context->eventDistributor->registerEvent(evt, eventProcessor,
impl->visitCounter);
122 sentEvent->eventName = uniqueEventIdentifier;
124 ARMARX_DEBUG <<
"registered event: " << sentEvent->eventName <<
", EventRecv:" << sentEvent->eventReceiverName <<
flush;
125 installedConditions.push_back(condition.
getImpl());
126 ConditionIdentifier condId = conditionHandlerPrx->installConditionWithDescription(context->eventDistributor->getListener(), condition.
getImpl(), sentEvent, desc,
true,
false, {});
127 __installedConditionIdentifiers.push_back(condId);
133 auto context = getContext<StatechartContext>();
141 context->conditionHandlerPrx->begin_removeCondition(conditionId);
149 ARMARX_INFO <<
"Installing Timeout Event (Timeout: " << timeoutDurationMs <<
"ms)" <<
flush;
161 if (!
impl->__parentState)
167 std::stringstream timerName;
168 timerName <<
"Timer_" << context->
getName() <<
"_" << stateName <<
"_" <<
impl->localUniqueId <<
"_" << evt->eventName <<
"_" << timeoutDurationMs <<
"ms";
172 __installedTimerChannelRefs.push_back(result.
actionId);
196 ARMARX_INFO <<
"Installing Counter Event (Counter Threshold: " << counterThreshold <<
", InitialValue: " << initialValue <<
")" <<
flush;
208 if (!
impl->__parentState)
214 std::stringstream counterName;
215 counterName <<
"Counter_" << stateName <<
"_" <<
impl->localUniqueId <<
"_" << evt->eventName;
220 __installedCounterChannelRefs.push_back(result.
actionId);
239 StateUtility::checkEventIsHandled(
const EventPtr& event)
const
243 if (!
impl->__parentState)
248 for (
unsigned int i = 0; i <
impl->__parentState->transitions.size(); ++i)
250 TransitionIceBase& t =
impl->__parentState->transitions.at(i);
252 if (t.evt->eventName == event->eventName)
264 evt->properties = properties;
268 void StateUtility::_removeInstalledConditions()
273 ARMARX_INFO <<
"Statechart Context is NULL - cannot clear installed conditions";
276 for (
auto c : __installedConditionIdentifiers)
281 __installedConditionIdentifiers.clear();
283 for (
auto c : __installedTimerChannelRefs)
288 __installedTimerChannelRefs.clear();
290 for (
auto c : __installedCounterChannelRefs)
295 __installedCounterChannelRefs.clear();