30 #include <IceUtil/UUID.h>
36 #include "../StatechartEventDistributor.h"
38 #include <Ice/Properties.h>
40 #include <SimoxUtility/algorithm/string/string_tools.h>
47 uuid = IceUtil::generateUUID();
52 std::string groupFilepathString = PropertyUser::getProperty<std::string>(
"XMLStatechartGroupDefinitionFile").getValue();
53 std::string profileName = PropertyUser::getProperty<std::string>(
"XMLStatechartProfile").getValue();
61 throw LocalException(
"Could not find profile '" + profileName +
"'");
69 Ice::StringSeq includePaths;
73 for (
const std::string& projectName : packages)
75 if (projectName.empty())
81 auto pathsString =
project.getIncludePaths();
83 includePaths.insert(includePaths.end(), projectIncludePaths.begin(), projectIncludePaths.end());
90 reader->readXml(std::filesystem::path(groupFilepathString));
92 auto extraProperties = reader->getConfigurationFileContent();
93 if (!extraProperties.empty())
96 std::filesystem::path temp = std::filesystem::temp_directory_path() /
std::to_string(std::random_device{}());
98 std::ofstream file(temp.string().c_str());
99 file << extraProperties;
101 props->load(temp.string());
102 std::filesystem::remove(temp);
103 for (
auto& prop : props->getPropertiesForPrefix(
""))
112 std::string libPath =
"lib" + reader->getGroupName() +
".so";
117 std::string libPathNextGen =
"lib" + reader->getPackageName() +
"_" + reader->getGroupName() +
".so";
131 ARMARX_ERROR <<
"Could not find state user code lib file `" << libPath <<
"` or `" << libPathNextGen <<
"`";
143 if (PropertyUser::getProperty<std::string>(
"XMLRemoteStateOffererName").isSet())
145 offererName = PropertyUser::getProperty<std::string>(
"XMLRemoteStateOffererName").getValue();
152 obj->forceComponentCreatedByComponentCreateFunc();
153 StatechartContextPtr::dynamicCast(
offerer)->setReportingTopic(getProperty<std::string>(
"StateReportingTopic").getValue());
155 if (getProperty<bool>(
"EnableProfiling").getValue() && !obj->getProperty<
bool>(
"EnableProfiling").isSet())
157 obj->enableProfiler(
true);
172 for (
auto state :
Split(getProperty<std::string>(
"StatesToEnter").getValue(),
",",
true,
true))
174 simox::alg::trim(state);
185 return "XMLStateComponent";
198 ARMARX_ERROR <<
"Could not find state user code lib file: " << libPath;
227 RemoteStateOffererInterfacePrx off =
getArmarXManager()->getIceManager()->getProxy<RemoteStateOffererInterfacePrx>(
iceObjName);
228 auto stateId = off->createRemoteStateInstance(stateClassName,
nullptr,
"TopLevel", stateClassName);
229 off->callRemoteState(stateId, StringVariantContainerBaseMap());
230 stateIDStartedUsingExisitingPrx = stateId;
235 context->getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted);
236 RemoteStateOffererIceBasePtr off = RemoteStateOffererIceBasePtr::dynamicCast(
offerer);
237 auto stateId = off->createRemoteStateInstance(stateClassName,
nullptr,
"TopLevel", stateClassName);
238 off->callRemoteState(stateId, StringVariantContainerBaseMap());
246 RemoteStateOffererInterfacePrx off =
getArmarXManager()->getIceManager()->getProxy<RemoteStateOffererInterfacePrx>(
iceObjName);
247 if (stateIDStartedUsingExisitingPrx != -1 && off->getAvailableStateInstances().count(stateIDStartedUsingExisitingPrx) != 0)
249 ARMARX_DEBUG <<
"Exiting state with id: " << stateIDStartedUsingExisitingPrx <<
" which has been started using already running proxy.";
250 off->breakActiveSubstateRemotely(stateIDStartedUsingExisitingPrx,
nullptr);
251 off->breakRemoteState(stateIDStartedUsingExisitingPrx,
nullptr);
252 off->removeInstance(stateIDStartedUsingExisitingPrx);