38 for (
const auto& arg : inputArguments)
40 ContainerTypePtr type = checkIfLibraryNeedsToBeLoaded(arg.second);
43 ARMARX_DEBUG <<
"Loading lib for variant: " << type->typeId;
44 _loadedDynamicLibraries[type->typeId] =
45 variantInfo->loadLibraryOfVariant(type->typeId);
53 const std::string& stateName,
57 for (
const auto& arg : inputArguments)
59 if (checkIfLibraryNeedsToBeLoaded(arg.second))
61 ARMARX_ERROR <<
"DynamicLibrary for argument '" << arg.first
62 <<
"' is not loaded! Statechart will not be started.";
69 ARMARX_WARNING <<
"SimpleStatechartExecutor is not ready. Cannot start statechart";
73 RemoteStateOffererIceBasePrx prx;
76 prx = getProxy<RemoteStateOffererIceBasePrx>(proxyName,
false);
78 catch (::Ice::NotRegisteredException& e)
80 ARMARX_WARNING <<
"RemoteStateOfferer '" << proxyName <<
"' not available!";
86 ARMARX_WARNING <<
"RemoteStateOfferer '" << proxyName <<
"' not available!";
90 StateBasePtr stateBasePtr = StateBasePtr::dynamicCast(prx->getStatechart(stateName));
94 <<
"' does not have an available state with name: '" << stateName
99 _prx = RemoteStateOffererInterfacePrx::checkedCast(prx);
100 _currentStateId = _prx->createRemoteStateInstance(
101 stateName,
nullptr, stateName, stateName + IceUtil::generateUUID());
104 _prx->callRemoteState(_currentStateId,
input);
107 std::unique_lock lock(_finishedMutex);
114 _runningTask->stop(
false);
117 this, &SimpleStatechartExecutor::statechartTask,
"StatechartManager");
118 _runningTask->start();
125 std::unique_lock lock(_finishedMutex);
126 if (!_finished && _prx && isCurrentStateIdValid())
128 _prx->breakActiveSubstateRemotely(_currentStateId,
nullptr);
129 _prx->breakRemoteState(_currentStateId,
nullptr);
131 _finishedCondition.wait(lock);
136 _finishedCondition.notify_all();
138 _currentStateId = -1;
147 StatechartExecutionResult
150 std::unique_lock lock(_finishedMutex);
154 _finishedCondition.wait(lock);
160 StringVariantContainerBaseMap
163 std::unique_lock lock(_finishedMutex);
170 return StringVariantContainerBaseMap();
177 std::unique_lock lock(_finishedMutex);
180 return _lastOutputParameters;
192 for (
const auto& typeName : typeNames)
194 ARMARX_INFO <<
"Loading library for type '" << typeName <<
"'";
195 _loadedDynamicLibraries[typeName] = variantInfo->loadLibraryOfVariant(typeName);
203 std::string packagesString =
204 getProperty<std::string>(
"PackagesForVariantLibraries").getValue();
219 for (
const auto& it : _loadedDynamicLibraries)
229 std::unique_lock lock(_finishedMutex);
231 _finishedCondition.notify_all();
233 _runningTask->stop();
245 SimpleStatechartExecutor::statechartTask()
247 while (_prx && isCurrentStateIdValid() && !_prx->isRemoteStateFinished(_currentStateId))
253 _lastResult = (_aborted ? eAborted : eSuccess);
255 _lastOutputParameters = _prx->getStatechartInstance(_currentStateId)->outputParameters;
257 _lastOutputParameters = _prx->getStatechartInstance(_currentStateId)->outputParameters;
259 std::unique_lock lock(_finishedMutex);
261 _finishedCondition.notify_all();
267 SimpleStatechartExecutor::checkIfLibraryNeedsToBeLoaded(
268 const StateParameterIceBasePtr parameter)
const
270 bool loadLib =
false;
271 ContainerTypePtr containerType = parameter->value->getContainerType();
272 if (containerType->typeId ==
"::armarx::SingleTypeVariantListBase" ||
273 containerType->typeId ==
"::armarx::StringValueMapBase")
275 while (containerType->subType)
277 containerType = containerType->subType;
279 loadLib = _loadedDynamicLibraries.count(containerType->typeId) == 0;
284 if (variant && variant->get()->data->ice_id() ==
"::armarx::VariantData")
286 loadLib = _loadedDynamicLibraries.count(containerType->typeId) == 0;
290 return loadLib ? containerType : ContainerTypePtr();
294 SimpleStatechartExecutor::isCurrentStateIdValid()
const
296 for (
const auto& it : _prx->getAvailableStateInstances())
298 if (it.first == _currentStateId)