21 auto& p = parent<SkillManagerComponentPluginUser>();
22 p.getProxy(myPrx, -1);
34 for (
const auto& [providerName, providerPrx] : skillProviderMap)
36 auto allSkills = providerPrx->getSkillDescriptions();
37 for (
const auto& [currentSkillID, skillDesc] : allSkills)
39 if (currentSkillID.skillName == skillId.
skillName)
41 return {providerName};
45 return {
"INVALID PROVIDER NAME"};
51 std::scoped_lock l(skillProviderMapMutex);
52 if (skillProviderMap.find(providerInfo.
providerId) == skillProviderMap.end())
60 ARMARX_INFO <<
"Trying to add a provider with name '"
62 <<
"' but the provider already exists. "
63 <<
"Overwriting the old provider info.";
71 std::scoped_lock l(skillProviderMapMutex);
72 if (
auto it = skillProviderMap.find(providerId); it != skillProviderMap.end())
75 skillProviderMap.erase(it);
80 <<
"' but it couldn't be found.";
90 std::unique_lock l(skillProviderMapMutex);
101 if (
auto it = skillProviderMap.find(provderId); it != skillProviderMap.end())
103 const auto& provider = it->second;
107 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
108 << provderId <<
"'. Removing it from skills.";
109 skillProviderMap.erase(it);
113 "Skill execution failed. Could not execute a skill of provider '" +
114 provderId.toString() +
"' because the provider does not exist.");
123 .callbackInterface = myPrx};
126 provider->begin_executeSkill(provider_executionRequest.toProviderIce());
128 auto provider_statusUpdate_ice = provider->end_executeSkill(async);
135 catch (
const std::exception &e)
139 handleExceptionNonLockingThrow(__PRETTY_FUNCTION__, e, provderId);
146 "Skill execution failed. Could not execute a skill of provider '" +
147 provderId.
toString() +
"' because the provider does not exist.");
158 std::unique_lock l(skillProviderMapMutex);
169 if (
auto it = skillProviderMap.find(provderId); it != skillProviderMap.end())
171 const auto& provider = it->second;
175 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
176 << provderId <<
"'. Removing it from skills.";
177 skillProviderMap.erase(it);
181 "Skill execution failed. Could not execute a skill of provider '" +
182 provderId.toString() +
"' because the provider does not exist.");
191 .callbackInterface = myPrx};
194 provider->begin_executeSkillAsync(provider_executionRequest.toProviderIce());
196 auto provider_executionID_ice = provider->end_executeSkillAsync(async);
201 executionId.skillId.providerId = provderId;
204 catch (
const std::exception &e)
208 handleExceptionNonLockingThrow(__PRETTY_FUNCTION__, e, provderId);
215 "Skill execution failed. Could not execute a skill of provider '" +
216 provderId.
toString() +
"' because the provider does not exist.");
229 std::unique_lock l(skillProviderMapMutex);
231 it != skillProviderMap.end())
233 const auto& providerId = it->first;
234 const auto& provider = it->second;
238 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
239 << providerId <<
"'. Removing it from skills.";
240 skillProviderMap.erase(it);
246 auto async = provider->begin_updateSkillParameters(executionId.
toProviderIce(),
247 data->toAronDictDTO());
249 auto r = provider->end_updateSkillParameters(async);
252 catch (
const std::exception &e)
256 handleExceptionNonLocking(__PRETTY_FUNCTION__, e, providerId);
275 std::unique_lock l(skillProviderMapMutex);
277 it != skillProviderMap.end())
279 const auto& providerId = it->first;
280 const auto& provider = it->second;
284 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
285 << providerId <<
"'. Removing it from skills.";
286 skillProviderMap.erase(it);
292 auto async = provider->begin_abortSkill(executionId.
toProviderIce());
294 auto r = provider->end_abortSkill(async);
297 catch (
const std::exception &e)
301 handleExceptionNonLocking(__PRETTY_FUNCTION__, e, providerId);
318 std::unique_lock l(skillProviderMapMutex);
320 it != skillProviderMap.end())
322 const auto& providerId = it->first;
323 const auto& provider = it->second;
327 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
328 << providerId <<
"'. Removing it from skills.";
329 skillProviderMap.erase(it);
335 auto async = provider->begin_abortSkill(executionId.
toProviderIce());
338 catch (
const std::exception &e)
340 handleExceptionNonLocking(__PRETTY_FUNCTION__, e, providerId);
351 std::optional<skills::SkillDescription>
354 ARMARX_DEBUG <<
"getSkillDescription for skill " << skillId;
356 ARMARX_CHECK(skillId.isFullySpecified()) <<
"Got: " << skillId.toString();
358 std::unique_lock l(skillProviderMapMutex);
359 if (
auto it = skillProviderMap.find(*skillId.providerId); it != skillProviderMap.end())
361 const auto& providerId = it->first;
362 const auto& provider = it->second;
366 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
367 << providerId <<
"'. Removing it from skills.";
368 skillProviderMap.erase(it);
371 "Skill execution failed. Could not query a "
372 "status update of a skill of provider '" +
373 providerId.toString() +
374 "' because the provider does not exist.");
379 auto async = provider->begin_getSkillDescription(skillId.toProviderIce());
381 auto provider_desc_ice = provider->end_getSkillDescription(async);
383 if (not provider_desc_ice)
393 catch (
const std::exception &e)
395 handleExceptionNonLockingThrow(__PRETTY_FUNCTION__, e, providerId);
404 std::map<skills::SkillID, skills::SkillDescription>
407 std::map<skills::SkillID, skills::SkillDescription>
ret;
409 std::scoped_lock l(skillProviderMapMutex);
410 for (
auto it = skillProviderMap.cbegin(); it != skillProviderMap.cend();)
412 const auto& providerId = it->first;
413 const auto& provider = it->second;
417 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
418 << providerId <<
"'. Removing it from skills.";
419 it = skillProviderMap.erase(it);
425 skills::provider::dto::SkillDescriptionMap m = provider->getSkillDescriptions();
427 for (
const auto& [provider_skillId_ice, skillDescription_ice] : m)
436 catch (
const std::exception &e)
438 if (
auto _it = handleExceptionNonLocking(__PRETTY_FUNCTION__, e, providerId))
447 std::optional<skills::SkillStatusUpdate>
454 std::unique_lock l(skillProviderMapMutex);
456 it != skillProviderMap.end())
458 const auto& providerId = it->first;
459 const auto& provider = it->second;
463 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
464 << providerId <<
"'. Removing it from skills.";
465 skillProviderMap.erase(it);
468 "Skill execution failed. Could not query a "
469 "status update of a skill of provider '" +
470 providerId.toString() +
471 "' because the provider does not exist.");
476 auto async = provider->begin_getSkillExecutionStatus(executionId.
toProviderIce());
478 auto provider_statusUpdate_ice = provider->end_getSkillExecutionStatus(async);
480 if (not provider_statusUpdate_ice)
487 provider_statusUpdate_ice.value(), providerId);
490 catch (
const std::exception &e)
494 handleExceptionNonLockingThrow(__PRETTY_FUNCTION__, e, providerId);
503 std::map<skills::SkillExecutionID, skills::SkillStatusUpdate>
506 std::map<skills::SkillExecutionID, skills::SkillStatusUpdate>
ret;
508 std::scoped_lock l(skillProviderMapMutex);
509 for (
auto it = skillProviderMap.cbegin(); it != skillProviderMap.cend();)
511 const auto& providerId = it->first;
512 const auto& provider = it->second;
516 ARMARX_WARNING << __PRETTY_FUNCTION__ <<
": Found disconnected skill provider '"
517 << providerId <<
"'. Removing it from skills.";
518 it = skillProviderMap.erase(it);
524 auto m = provider->getSkillExecutionStatuses();
526 for (
const auto& [provider_executionId_ice, provider_statusUpdate_ice] : m)
535 catch (
const std::exception &e)
537 if (
auto _it = handleExceptionNonLocking(__PRETTY_FUNCTION__, e, providerId))
546 std::optional<std::map<skills::ProviderID, skills::provider::dti::SkillProviderInterfacePrx>::iterator>
547 SkillManagerComponentPlugin::handleExceptionNonLocking(
548 const char* funcName,
const std::exception& e,
skills::ProviderID providerId,
bool eraseSkillProvider)
551 if (
auto it = skillProviderMap.find(providerId); eraseSkillProvider and it != skillProviderMap.end())
554 <<
": Found disconnected or buggy skill provider '" << providerId
555 <<
"' during execution. Removing it from skills. "
556 <<
"Error: " << e.what();
557 return skillProviderMap.erase(it);
562 <<
": Found disconnected or buggy skill provider '" << providerId
563 <<
"' during execution. However, it already got removed... "
564 <<
"Error: " << e.what();
570 SkillManagerComponentPlugin::handleExceptionNonLockingThrow(
571 const char* funcName,
const std::exception& e, skills::ProviderID providerId,
bool eraseSkillProvider)
574 handleExceptionNonLocking(funcName, e, providerId, eraseSkillProvider);
576 throw skills::error::SkillException(
578 "Skill execution failed. Could not execute a skill of provider '" +
579 providerId.toString() +
"' because the provider does not exist.");
601 const skills::manager::dto::ProviderID& provider,
608 skills::manager::dto::SkillStatusUpdate
610 const skills::manager::dto::SkillExecutionRequest& info,
617 skills::manager::dto::SkillExecutionID
619 const skills::manager::dto::SkillExecutionRequest& info,
620 const Ice::Current& current)
626 skills::provider::dto::ParameterUpdateResult
628 const skills::manager::dto::SkillExecutionID& info,
630 const Ice::Current& current)
632 skills::provider::dto::ParameterUpdateResult
ret;
639 skills::provider::dto::AbortSkillResult
641 const Ice::Current& current)
643 skills::provider::dto::AbortSkillResult
ret;
649 skills::provider::dto::AbortSkillResult
651 const skills::manager::dto::SkillExecutionID&
id,
652 const Ice::Current& )
654 skills::provider::dto::AbortSkillResult
ret;
662 const skills::provider::dto::SkillStatusUpdate& statusUpdate,
663 const skills::callback::dto::ProviderID& pid,
671 skills::manager::dto::SkillDescriptionMap
674 skills::manager::dto::SkillDescriptionMap
ret;
678 for (
const auto& [k,
v] : m)
680 ret.insert({k.toManagerIce(),
v.toManagerIce()});
686 IceUtil::Optional<skills::manager::dto::SkillDescription>
688 const Ice::Current& current)
694 return o->toManagerIce();
699 IceUtil::Optional<skills::manager::dto::SkillStatusUpdate>
701 const skills::manager::dto::SkillExecutionID& executionId,
702 const Ice::Current& current)
708 return o->toManagerIce();
713 skills::manager::dto::SkillStatusUpdateMap
716 skills::manager::dto::SkillStatusUpdateMap
ret;
720 for (
const auto& [k,
v] : m)
722 ret.insert({k.toManagerIce(),
v.toManagerIce()});