29 #include <Ice/Properties.h>
30 #include <IceUtil/UUID.h>
32 #include <SimoxUtility/algorithm/string/string_tools.h>
40 #include "../StatechartEventDistributor.h"
49 uuid = IceUtil::generateUUID();
55 std::string groupFilepathString =
56 PropertyUser::getProperty<std::string>(
"XMLStatechartGroupDefinitionFile").getValue();
57 std::string profileName =
58 PropertyUser::getProperty<std::string>(
"XMLStatechartProfile").getValue();
67 throw LocalException(
"Could not find profile '" + profileName +
"'");
73 Ice::StringSeq includePaths;
77 for (
const std::string& projectName : packages)
79 if (projectName.empty())
85 auto pathsString =
project.getIncludePaths();
88 includePaths.end(), projectIncludePaths.begin(), projectIncludePaths.end());
94 reader->readXml(std::filesystem::path(groupFilepathString));
96 auto extraProperties = reader->getConfigurationFileContent();
97 if (!extraProperties.empty())
100 std::filesystem::path temp =
101 std::filesystem::temp_directory_path() /
std::to_string(std::random_device{}());
103 std::ofstream file(temp.string().c_str());
104 file << extraProperties;
106 props->load(temp.string());
107 std::filesystem::remove(temp);
108 for (
auto& prop : props->getPropertiesForPrefix(
""))
117 std::string libPath =
"lib" + reader->getGroupName() +
".so";
122 std::string libPathNextGen =
123 "lib" + reader->getPackageName() +
"_" + reader->getGroupName() +
".so";
132 libPathNextGen, libPathNextGen, libpathList,
false))
140 ARMARX_ERROR <<
"Could not find state user code lib file `" << libPath <<
"` or `"
141 << libPathNextGen <<
"`";
151 <<
"\nAvailable classes are:\n"
156 if (PropertyUser::getProperty<std::string>(
"XMLRemoteStateOffererName").isSet())
159 PropertyUser::getProperty<std::string>(
"XMLRemoteStateOffererName").getValue();
167 obj->forceComponentCreatedByComponentCreateFunc();
168 StatechartContextPtr::dynamicCast(
offerer)->setReportingTopic(
169 getProperty<std::string>(
"StateReportingTopic").getValue());
171 if (getProperty<bool>(
"EnableProfiling").getValue() &&
172 !obj->getProperty<
bool>(
"EnableProfiling").isSet())
174 obj->enableProfiler(
true);
190 Split(getProperty<std::string>(
"StatesToEnter").getValue(),
",",
true,
true))
192 simox::alg::trim(state);
204 return "XMLStateComponent";
218 ARMARX_ERROR <<
"Could not find state user code lib file: " << libPath;
245 bool useExisitingPrx)
249 RemoteStateOffererInterfacePrx off =
250 getArmarXManager()->getIceManager()->getProxy<RemoteStateOffererInterfacePrx>(
253 off->createRemoteStateInstance(stateClassName,
nullptr,
"TopLevel", stateClassName);
254 off->callRemoteState(stateId, StringVariantContainerBaseMap());
255 stateIDStartedUsingExisitingPrx = stateId;
260 context->getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted);
261 RemoteStateOffererIceBasePtr off = RemoteStateOffererIceBasePtr::dynamicCast(
offerer);
263 off->createRemoteStateInstance(stateClassName,
nullptr,
"TopLevel", stateClassName);
264 off->callRemoteState(stateId, StringVariantContainerBaseMap());
273 RemoteStateOffererInterfacePrx off =
274 getArmarXManager()->getIceManager()->getProxy<RemoteStateOffererInterfacePrx>(
276 if (stateIDStartedUsingExisitingPrx != -1 &&
277 off->getAvailableStateInstances().count(stateIDStartedUsingExisitingPrx) != 0)
279 ARMARX_DEBUG <<
"Exiting state with id: " << stateIDStartedUsingExisitingPrx
280 <<
" which has been started using already running proxy.";
281 off->breakActiveSubstateRemotely(stateIDStartedUsingExisitingPrx,
nullptr);
282 off->breakRemoteState(stateIDStartedUsingExisitingPrx,
nullptr);
283 off->removeInstance(stateIDStartedUsingExisitingPrx);