42 using namespace Generator;
56 includeNode.
append_attribute(
"file", ArmarXDataPath::GetDefaultUserConfigPath() +
"/icegrid-sync-variables.icegrid.xml");
63 variableScenarioDependencyNode.
append_attribute(
"name",
"ARMARX_SCENARIO_DEPENDENCY_CONFIG");
64 variableScenarioDependencyNode.
append_attribute(
"value",
"dependencies.cfg");
67 variablePackageConfigDir.
append_attribute(
"name",
"ARMARX_PACKAGE_CONFIG_DIR");
88 std::map<std::string, RapidXmlWriterNode> existingNodes;
90 for (
auto app : *scenario->getApplications())
92 if (!existingNodes.count(app->getEffectiveNodeName()))
96 existingNodes.insert(make_pair(app->getEffectiveNodeName(), node));
99 generateComponent(app);
101 if (app->getInstanceName().empty())
103 includeAppNode.
append_attribute(
"file",
"icegrid/" + app->getName() +
".icegrid.xml");
107 includeAppNode.
append_attribute(
"file",
"icegrid/" + app->getName() +
"." + app->getInstanceName() +
".icegrid.xml");
111 writer.
saveToFile(scenario->getFolder() +
"/" + scenario->getName() +
".icegrid.xml",
true);
125 includeNode.
append_attribute(
"file", ArmarXDataPath::GetDefaultUserConfigPath() +
"/icegrid-sync-variables.icegrid.xml");
129 variableScenarioDirNode.
append_attribute(
"value",
"${ARMARX_SYNC_DIR}/share/" + scenario->getPackage()->getName() +
"/scenarios/" + scenario->getName());
132 variableScenarioDependencyNode.
append_attribute(
"name",
"ARMARX_SCENARIO_DEPENDENCY_CONFIG");
133 variableScenarioDependencyNode.
append_attribute(
"value",
"dependencies.remote.cfg");
136 variablePackageConfigDir.
append_attribute(
"name",
"ARMARX_PACKAGE_CONFIG_DIR");
137 variablePackageConfigDir.
append_attribute(
"value",
"${ARMARX_SYNC_DIR}/share/" + scenario->getPackage()->getName() +
"/config");
155 std::map<std::string, RapidXmlWriterNode> existingNodes;
157 for (
auto app : *scenario->getApplications())
159 if (!existingNodes.count(app->getEffectiveNodeName()))
163 existingNodes.insert(make_pair(app->getEffectiveNodeName(), node));
166 generateComponent(app);
168 if (app->getInstanceName().empty())
170 includeAppNode.
append_attribute(
"file",
"icegrid/" + app->getName() +
".icegrid.xml");
174 includeAppNode.
append_attribute(
"file",
"icegrid/" + app->getName() +
"." + app->getInstanceName() +
".icegrid.xml");
178 writer.
saveToFile(scenario->getFolder() +
"/" + scenario->getName() +
".remote.icegrid.xml",
true);
190 applicationNode.
append_attribute(
"componentExeDir",
"${" + app->getPackageName() +
"_BIN_DIR}");
193 std::string armarXConfigValue = (app->getScenario()->isGlobalConfigFileexistent() ? app->getScenario()->getGlobalConfigPath() +
"," :
"")
194 + (app->getInstanceName().empty() ?
"${ARMARX_SCENARIO_DIR}/config/" + app->getName() +
".cfg" :
"${ARMARX_SCENARIO_DIR}/config/" + app->getName() +
"." + app->getInstanceName() +
".cfg");
209 applicationNode.
append_attribute(
"ArmarXDependenciesConfig",
"${ARMARX_PACKAGE_CONFIG_DIR}/${ARMARX_SCENARIO_DEPENDENCY_CONFIG}");
210 applicationNode.
append_attribute(
"ArmarXLoggingGroup", app->getScenario()->getName());
212 std::filesystem::create_directory(app->getScenario()->getFolder() +
"/icegrid");
213 if (app->getInstanceName().empty())
215 writer.
saveToFile(app->getScenario()->getFolder() +
"/icegrid/" + app->getName() +
".icegrid.xml",
true);
219 writer.
saveToFile(app->getScenario()->getFolder() +
"/icegrid/" + app->getName() +
"." + app->getInstanceName() +
".icegrid.xml",
true);
227 IceGrid::ApplicationDescriptor result;
228 result.name = scenario->getName();
230 IceGrid::StringStringDict variables;
231 variables[
"ARMARX_SYNC_DIR"] = getDefaultSyncFile();
232 variables[
"ARMARX_SCENARIO_DIR"] = scenario->getFolder();
233 variables[
"ARMARX_SCENARIO_DEPENDENCY_CONFIG"] =
"dependencies.cfg";
234 variables[
"ARMARX_PACKAGE_CONFIG_DIR"] = finder.
getConfigDir();
235 variables[
"ArmarX_LD_LIB_PATH"] =
"";
236 variables[
"ArmarX_PATH"] =
"";
237 variables[
"ARMARX_LOGGING_GROUP"] = scenario->getName();
242 variables[dep +
"_BIN_DIR"] = currentFinder.
getBinaryDir();
245 result.variables = variables;
247 IceGrid::ApplicationDescriptor defaultDesc = iceAdmin->getDefaultApplicationDescriptor();
248 result.serverTemplates = defaultDesc.serverTemplates;
249 auto v = IceGrid::ServerDescriptorPtr::dynamicCast(result.serverTemplates[
"ArmarXComponentTemplate"].descriptor.get());
252 result.serviceTemplates = defaultDesc.serviceTemplates;
259 IceGrid::ApplicationDescriptor result = generateEmptyLocalApplicationDescriptor(scenario, iceAdmin);
261 for (
auto app : *scenario->getApplications())
263 if (!app->getEnabled())
268 result.nodes[app->getEffectiveNodeName()].serverInstances.push_back(generateComponentNode(app));
276 IceGrid::ApplicationDescriptor result;
277 result.name = scenario->getName();
279 IceGrid::StringStringDict variables;
280 variables[
"ARMARX_SYNC_DIR"] = getDefaultSyncFile();
281 variables[
"ARMARX_SCENARIO_DIR"] =
"${ARMARX_SYNC_DIR}/share/" + scenario->getPackage()->getName() +
"/scenarios/" + scenario->getName();
282 variables[
"ARMARX_SCENARIO_DEPENDENCY_CONFIG"] =
"dependencies.remote.cfg";
283 variables[
"ARMARX_PACKAGE_CONFIG_DIR"] =
"${ARMARX_SYNC_DIR}/share/" + scenario->getPackage()->getName() +
"/config";
284 variables[
"ArmarX_LD_LIB_PATH"] =
"${ARMARX_SYNC_DIR}/lib:${ARMARX_SYNC_DIR}/usr/lib";
285 variables[
"ArmarX_PATH"] =
"${ARMARX_SYNC_DIR}/bin:${ARMARX_SYNC_DIR}/usr/bin";
286 variables[
"ARMARX_LOGGING_GROUP"] = scenario->getName();
292 variables[dep +
"_BIN_DIR"] =
"${ARMARX_SYNC_DIR}/bin";
295 result.variables = variables;
297 IceGrid::ApplicationDescriptor defaultDesc = iceAdmin->getDefaultApplicationDescriptor();
298 result.serverTemplates = defaultDesc.serverTemplates;
299 auto v = IceGrid::ServerDescriptorPtr::dynamicCast(result.serverTemplates[
"ArmarXComponentTemplate"].descriptor.get());
303 result.serviceTemplates = defaultDesc.serviceTemplates;
312 IceGrid::ApplicationDescriptor result = generateEmptyRemoteApplicationDescriptor(scenario, iceAdmin);
314 for (
auto app : *scenario->getApplications())
316 if (!app->getEnabled())
320 result.nodes[app->getEffectiveNodeName()].serverInstances.push_back(generateComponentNode(app));
328 IceGrid::ServerInstanceDescriptor result;
329 result._cpp_template =
"ArmarXComponentTemplate";
330 result.parameterValues[
"component"] = app->getName();
332 result.parameterValues[
"componentExeDir"] =
"${" + app->getPackageName() +
"_BIN_DIR}";
334 std::string armarXConfigValue = (app->getScenario()->isGlobalConfigFileexistent() ? app->getScenario()->getGlobalConfigPath() +
"," :
"")
335 + (app->getInstanceName().empty() ?
"${ARMARX_SCENARIO_DIR}/config/" + app->getName() +
".cfg" :
"${ARMARX_SCENARIO_DIR}/config/" + app->getName() +
"." + app->getInstanceName() +
".cfg");
337 result.parameterValues[
"configDomain"] = app->getConfigDomain();
338 result.parameterValues[
"ArmarXConfig"] = armarXConfigValue;
339 result.parameterValues[
"ArmarXDependenciesConfig"] =
"${ARMARX_PACKAGE_CONFIG_DIR}/${ARMARX_SCENARIO_DEPENDENCY_CONFIG}";
340 result.parameterValues[
"ArmarXLoggingGroup"] = app->getScenario()->getName();
341 result.parameterValues[
"activationTimeout"] =
"10";
347 std::string IceGridXmlGenerator::getSyncDirFromFile(std::string path)
357 ARMARX_DEBUG_S <<
"Your icegrid-sync-variables file is ill formatted (Error: " << exception.what() <<
")";
370 doc.
saveToFile(ArmarXDataPath::GetDefaultUserConfigPath() +
"/icegrid-sync-variables.icegrid.xml",
true);
375 IceGrid::ApplicationUpdateDescriptor result;
376 result.name = descriptor.name;
378 for (
auto nodes : descriptor.nodes)
380 IceGrid::NodeUpdateDescriptor nodeUpdate;
381 nodeUpdate.name = nodes.first;
382 nodeUpdate.serverInstances = nodes.second.serverInstances;
384 nodeUpdate.propertySets = nodes.second.propertySets;
385 nodeUpdate.serverInstances = nodes.second.serverInstances;
386 nodeUpdate.servers = nodes.second.servers;
387 nodeUpdate.variables = nodes.second.variables;
388 result.nodes.push_back(nodeUpdate);
391 result.serverTemplates = descriptor.serverTemplates;
392 result.serviceTemplates = descriptor.serviceTemplates;
393 result.variables = result.variables;
400 return getSyncDirFromFile(ArmarXDataPath::GetDefaultUserConfigPath() +
"/icegrid-sync-variables.icegrid.xml");