StateTreeModel.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #include "StateTreeModel.h"
25 
26 #include "../io/GroupXmlReader.h"
27 #include "../io/GroupXmlWriter.h"
28 #include "../io/XmlWriter.h"
29 
37 #include <QMessageBox>
38 #include <omp.h>
39 
40 #include <filesystem>
41 
42 
43 using namespace armarx;
44 using namespace statechartio;
45 using namespace statechartmodel;
46 
48  iceCommunicator(ic),
49  variantInfo(variantInfo)
50 {
51  StateTreeNodePtr nullNode;
52  StatechartGroupPtr nullGroup;
53  this->rootNode.reset(new StateTreeNode(QString(), "", StateTreeNode::Folder, nullNode, nullGroup, false));
54 }
55 
57 {
58  QList<statechartmodel::StatePtr> statesToAnnotate;
59 
60  for (int i = 0; i < groups.count(); i++)
61  {
62  StatechartGroupPtr group = groups.at(i);
63  ARMARX_INFO_S << "loading group " << group->getName();
64 
65  for (int j = 0; j < group->getRootNode()->getChildren().count(); j++)
66  {
67  loadNode(group->getRootNode()->getChildren().at(j), group->getBoostGroupPath(), statesToAnnotate);
68  }
69  }
70 
72 }
73 
75 {
76  QList<statechartmodel::StatePtr> statesToAnnotate;
77 
78  for (int j = 0; j < group->getRootNode()->getChildren().count(); j++)
79  {
80  loadNode(group->getRootNode()->getChildren().at(j), group->getBoostGroupPath(), statesToAnnotate);
81  }
82 
84 }
85 
86 void StateTreeModel::annotateStateRerefences(const QList<statechartmodel::StatePtr>& statesToAnnotate)
87 {
88  QMap<QString, statechartmodel::StatePtr> referenceMap;
89  QMapIterator<QString, StateTreeNodePtr> i(uuidToNodeMap);
90 
91  while (i.hasNext())
92  {
93  i.next();
94  referenceMap.insert(i.key(), i.value()->getState());
95  }
96 
97  for (int i = 0; i < statesToAnnotate.count(); i++)
98  {
99  statesToAnnotate.at(i)->addReferences(referenceMap);
100  }
101 }
102 
104 {
105  QMap<QString, statechartmodel::StatePtr> referenceMap;
106  QMapIterator<QString, StateTreeNodePtr> i(uuidToNodeMap);
107 
108  while (i.hasNext())
109  {
110  i.next();
111  referenceMap.insert(i.key(), i.value()->getState());
112  }
113 
114  for (auto i : uuidToNodeMap)
115  {
116  i->getState()->addReferences(referenceMap);
117  }
118 }
119 
120 void StateTreeModel::loadNode(StateTreeNodePtr node, std::filesystem::path parentPath, QList<statechartmodel::StatePtr>& allTheStates)
121 {
122  std::filesystem::path nodePath = node->getBoostPath(parentPath);
123 
124  if (node->getNodeType() == StateTreeNode::State)
125  {
126  try
127  {
128  QString xml = GuiStatechartGroupXmlReader::ReadFileContents(QString::fromUtf8(nodePath.string().c_str()));
129  std::shared_ptr<XmlReader> reader(new XmlReader(iceCommunicator, variantInfo));
130  reader->parseXml(xml);
131  statechartmodel::StatePtr state = reader->getLoadedState();
132  state->setEditable(node->getGroup()->getWriteAccess() == StatechartGroup::eWritable);
133  setNodeState(node, state);
134  uuidToNodeMap.insert(state->getUUID(), node);
135  allTheStates.append(state);
136  }
138  {
139  ARMARX_ERROR_S << ex.what();
140  }
141 
142  }
143  else if (node->getNodeType() == StateTreeNode::Folder)
144  {
145  for (int i = 0; i < node->getChildren().count(); i++)
146  {
147  loadNode(node->getChildren().at(i), nodePath, allTheStates);
148  }
149  }
150 }
151 
152 StatechartGroupPtr StateTreeModel::loadGroup(QString groupDefinitionFile, StateTreeNodePtr rootNode)
153 {
154  StatechartGroupPtr group = GuiStatechartGroupXmlReader::ReadXml(groupDefinitionFile, rootNode);
155 
156  if (groupExists(group->getBoostGroupPath()))
157  {
158  return StatechartGroupPtr();
159  }
160  group->getPackageName();
161  loadVariantInfos(group->getPackageName().toStdString());
162  groups.append(group);
163  return group;
164 }
165 
167 {
168  groups.clear();
169  uuidToNodeMap.clear();
170 }
171 
173 {
174  groups.append(group);
175 }
176 
178 {
179  if (node->getNodeType() == StateTreeNode::State)
180  {
181  uuidToNodeMap.insert(node->getState()->getUUID(), node);
182  }
183 }
184 
186 {
187  if (node->getNodeType() == StateTreeNode::State && node->getState())
188  {
189  uuidToNodeMap.remove(node->getState()->getUUID());
190  }
191 }
192 
193 void StateTreeModel::saveAll(QPointer<QProgressDialog> progressDialog)
194 {
195  if (progressDialog)
196  {
197  progressDialog->setMinimum(0);
198  progressDialog->setMaximum(groups.count());
199  progressDialog->setLabelText("Saving statechart groups");
200  }
201  auto startTime = IceUtil::Time::now();
202  #pragma omp parallel for schedule(static,1)
203  for (int i = 0; i < groups.count(); i++)
204  {
205  StatechartGroupPtr group = groups.at(i);
206  if (group->getWriteAccess() == StatechartGroup::eReadOnly)
207  {
208  continue;
209  }
210  std::filesystem::create_directories(group->getBoostDefinitionFilePath().parent_path());
211  GroupXmlWriter::WriteXml(group, group->getDefinitionFilePath(), true);
212 
213  for (int j = 0; j < group->getRootNode()->getChildren().count(); j++)
214  {
215  saveNode(group->getRootNode()->getChildren().at(j), group->getBoostGroupPath());
216  }
217  if (omp_get_thread_num() == 0)
218  {
219  if (progressDialog && (IceUtil::Time::now() - startTime).toMilliSeconds() > 1000)
220  {
221  progressDialog->setValue(i + 1);
222  // QMetaObject::invokeMethod(progressDialog, "setValue", Q_ARG(int, (i + 1)));
223  }
224  }
225  }
226 }
227 
228 void StateTreeModel::saveNode(StateTreeNodePtr node, std::filesystem::path parentPath)
229 {
230  std::filesystem::path nodePath = node->getBoostPath(parentPath);
231 
232  if (node->getGroup()->getWriteAccess() == StatechartGroup::eReadOnly)
233  {
234  return;
235  }
236 
237  if (node->getNodeType() == StateTreeNode::State)
238  {
239  try
240  {
241  if (node->getState())
242  {
243  XmlWriter writer(variantInfo);
244  writer.serialize(node->getState(), uuidToNodeMap);
245  //GroupXmlWriter::WriteFileContents(QString::fromUtf8(nodePath.string().c_str()), writer.getXmlString(true));
246  if (StatechartGroupGenerator::writeFileContentsIfChanged(nodePath.string(), writer.getXmlString(true).toUtf8().data()))
247  {
248  ARMARX_INFO_S << "Writing new state definition to " << nodePath.string();
249  }
250  }
251  }
253  {
254  ARMARX_ERROR_S << ex.what();
255  }
256  catch (std::exception& e)
257  {
258  QMetaObject::invokeMethod(this, "showWarning", Q_ARG(QString, "Saving state failed!"), Q_ARG(QString, QString::fromStdString(std::string(e.what())).split("Backtrace:").first()));
259  }
260 
261  }
262  else if (node->getNodeType() == StateTreeNode::Folder)
263  {
264 
265  std::filesystem::create_directory(nodePath);
266 
267  for (int i = 0; i < node->getChildren().count(); i++)
268  {
269  saveNode(node->getChildren().at(i), nodePath);
270  }
271  }
272 }
273 
275 {
276  QString doxString = "/**\n";
277  doxString += "@defgroup " + group->getPackageName() + "-" + group->getName() + " " + group->getName() + "";
278  doxString += "\n@ingroup Statecharts\n";
279  doxString += group->getDescription();
280  doxString += "@defgroup " + group->getPackageName() + "-" + group->getName() + "-Substates " + group->getName() + " Substates\n";
281  doxString += "@ingroup " + group->getPackageName() + "-" + group->getName();
282  doxString += "\n*/";
283 
284  // GroupXmlWriter::WriteFileContents(doxyGroupPath, doxString);
285 }
286 
287 const CMakePackageFinder& StateTreeModel::getPackageFinder(const QString& packageName)
288 {
289  std::unique_lock lock(findersMutex);
290  auto it = finders.find(packageName);
291  if (it == finders.end())
292  {
293  finders.insert(std::make_pair(packageName, CMakePackageFinder(packageName.toStdString())));
294  return finders.at(packageName);
295  }
296  else
297  {
298  return it->second;
299  }
300 
301 }
302 
303 void StateTreeModel::loadVariantInfos(const std::string& packageName)
304 {
305  //ARMARX_INFO << "loadVariantInfos: " << packageName;
306  auto finder = getPackageFinder(QString::fromStdString(packageName));
307  bool loaded = variantInfo->isPackageLoaded(packageName);
308  if (!finder.packageFound())
309  {
310  if (!!loaded)
311  {
312  ARMARX_WARNING_S << "Could not find package " << packageName << " - generated code might be incomplete";
313  }
314  }
315  else
316  {
317  if (!loaded)
318  {
319  ARMARX_INFO_S << "Loading variant info for " << packageName << " and its dependencies";
320  variantInfo = VariantInfo::ReadInfoFilesRecursive(packageName, finder.getConfigDir(), false, variantInfo);
321  }
322  auto contains = [](const std::map<VariantTypeId, std::string>& map, const std::string & value)
323  {
324  for (const auto& v : map)
325  {
326  if (v.second == value)
327  {
328  return true;
329  }
330  }
331  return false;
332  };
333 
334 
335  for (VariantInfo::LibEntryPtr lib : variantInfo->getLibs())
336  {
337  if (lib->getPackageName() != packageName)
338  {
339  continue;
340  }
341  for (VariantInfo::VariantEntryPtr var : lib->getVariants())
342  {
343 
344  if (!contains(Variant::getTypes(), var->getBaseTypeName()))
345  {
346  //ARMARX_IMPORTANT << VAROUT(Variant::getTypes());
347  //ARMARX_INFO << "loading lib for " << var->getBaseTypeName();
348  DynamicLibraryPtr lib = variantInfo->loadLibraryOfVariant(var->getBaseTypeName());
349  ARMARX_CHECK_EXPRESSION(lib) << var->getBaseTypeName();
350  lib->setUnloadOnDestruct(false);
351 
353 
354  Variant::addTypeName(var->getBaseTypeName());
355  // ARMARX_IMPORTANT << VAROUT(Variant::getTypes());
356  if (iceCommunicator->getValueFactoryManager()->find(var->getBaseTypeName()))
357  {
358  ARMARX_INFO << "Loaded variant " << var->getBaseTypeName();
359  }
360  else
361  {
362  ARMARX_WARNING << "variant " << var->getBaseTypeName() << " could not be loaded. Adding Variant TypeName only.";
363  }
364  }
365  }
366  }
367 
368  for (auto& dep : finder.getDependencies())
369  {
370  loadVariantInfos(dep);
371  }
372  }
373 }
374 
375 void StateTreeModel::generateAllBaseClasses(QPointer<QProgressDialog> progressDialog)
376 {
377  if (progressDialog)
378  {
379  progressDialog->setMinimum(0);
380  progressDialog->setMaximum(groups.count());
381  progressDialog->setLabelText("Generating code for statechart groups");
382  }
383  auto startTime = IceUtil::Time::now();
384  #pragma omp parallel for schedule(static,1)
385  for (int i = 0; i < groups.size(); ++i)
386  // for (const StatechartGroupPtr& group : groups)
387  {
388  const StatechartGroupPtr& group = groups.at(i);
389  generateBaseClasses(group);
390  if (omp_get_thread_num() == 0)
391  {
392  if (progressDialog && (IceUtil::Time::now() - startTime).toMilliSeconds() > 1000)
393  {
394  progressDialog->setValue(i + 1);
395  // QMetaObject::invokeMethod(progressDialog, "setValue", Q_ARG(int, (i + 1)));
396  }
397  }
398  else
399  {
400  if (progressDialog && (IceUtil::Time::now() - startTime).toMilliSeconds() > 1000)
401  {
402  QMetaObject::invokeMethod(progressDialog, "setValue", Q_ARG(int, (i + 1)));
403  }
404  }
405  }
406 }
407 
408 std::set<std::string> StateTreeModel::getVariantOfStatesWithNoCpp(const StatechartGroupPtr& group)
409 {
410  std::set<std::string> variantTypes;
411  std::set<std::string> alreadyLinkedTypes;
412  for (StateTreeNodePtr& stateNode : group->getAllNodes())
413  {
414  std::set<std::string>* currentTypeSet = &variantTypes;
415 
416  if (stateNode->checkCppExists())
417  {
418  // only need if no cpp exists
419  currentTypeSet = &alreadyLinkedTypes;
420  }
421  auto state = stateNode->getState();
422  if (!state)
423  {
424  continue;
425  }
426  for (auto param : state->getInputAndLocalParameters())
427  {
428  QString type = param->type;
429  currentTypeSet->insert(type.toStdString());
430  }
431  for (auto param : state->getOutputParameters())
432  {
433  QString type = param->type;
434  currentTypeSet->insert(type.toStdString());
435  }
436  }
437 
438 
439  std::set<std::string> resultingTypes;
440  std::set_difference(variantTypes.begin(), variantTypes.end(),
441  alreadyLinkedTypes.begin(), alreadyLinkedTypes.end(),
442  std::inserter(resultingTypes, resultingTypes.end()));
443 
444  std::set<std::string> innerVariantTypes;
445  for (auto& type : resultingTypes)
446  {
447  auto containerType = VariantContainerType::FromString(type);
448  while (containerType->subType)
449  {
450  containerType = containerType->subType;
451  }
452  if (!variantInfo->isBasic(containerType->typeId))
453  {
454  innerVariantTypes.insert(containerType->typeId);
455  }
456  }
457 
458  return innerVariantTypes;
459 }
460 
462 {
463  /*std::filesystem::create_directories(group->getBoostDefinitionFilePath().parent_path());
464  std::vector<std::string> namespaces;
465  namespaces.push_back("armarx");
466  namespaces.push_back(group->getName().toUtf8().data());*/
467  auto checkPackage = [&](const CMakePackageFinder & finder)
468  {
469  if (!finder.packageFound())
470  {
471  QMetaObject::invokeMethod(this, "showWarning", Q_ARG(QString, "State Generation Error"), Q_ARG(QString, "Could not find the package '" + QString::fromStdString(finder.getName()) + "' - Did you run cmake for that package already? Skipping state generation of stategroup " + group->getName()));
472  return false;
473  }
474  else
475  {
476  return true;
477  }
478  };
479 
480 
481  std::map<QString, CMakePackageFinder>::const_iterator it;
482  {
483  std::unique_lock lock(findersMutex);
484  it = finders.find(group->getPackageName());
485 
486 
487 
488  if (it == finders.end())
489  {
490  CMakePackageFinder finder(group->getPackageName().toStdString());
491 
492  if (!checkPackage(finder))
493  {
494  return;
495  }
496 
497  it = finders.insert(std::make_pair(group->getPackageName(), finder)).first;
498  }
499  }
500 
501  CMakePackageFinder packageFinder = it->second;
502 
503  if (!checkPackage(packageFinder))
504  {
505  return;
506  }
507  else if (packageFinder.getBuildDir().empty())
508  {
509  ARMARX_WARNING_S << "Build dir for package '" << packageFinder.getName() << "' is empty! Skipping generating files.";
510  return;
511  }
512 
513 
514  std::filesystem::path doxyFile = packageFinder.getBuildDir();
515 
516  if (!doxyFile.string().empty())
517  {
518  doxyFile /= "doxygen";
519  }
520  else
521  {
522  doxyFile = ".";
523  }
524 
525  doxyFile /= group->getName().toStdString() + ".dox";
526  generateGroupDocString(group, QString::fromStdString(doxyFile.string()));
527 
528  std::set<std::string> proxies;
529  proxies.insert("ArmarXCoreInterfaces.systemObserver");
530  proxies.insert("ArmarXCoreInterfaces.conditionHandler");
531  for (QString p : group->getProxies())
532  {
533  proxies.insert(p.toUtf8().data());
534  }
535  Ice::StringSeq proxyVec(proxies.begin(), proxies.end());
536  if (group->contextGenerationEnabled())
537  {
538  std::set<std::string> innerVariantTypes = getVariantOfStatesWithNoCpp(group);
540  group->getPackageName().toUtf8().data(),
541  group->getName().toUtf8().data(),
542  proxyVec,
543  variantInfo,
544  innerVariantTypes,
545  false);
546  //std::string cpp = XmlContextBaseClassGenerator::GenerateCpp(namespaces, proxies, group->getName().toUtf8().data(), variantInfo);
547  //writeIfChanged((group->getBoostGroupPath() / (std::string(group->getName().toUtf8().data()) + "StatechartContext.generated.h")).c_str(), cpp);
548  }
549 
550  for (StateTreeNodePtr node : group->getRootNode()->getChildren())
551  {
552  generateBaseClass(node, packageFinder.getBuildDir(), variantInfo, proxyVec);
553  }
554 }
555 
556 void StateTreeModel::generateBaseClass(StateTreeNodePtr node, std::filesystem::path buildDir, VariantInfoPtr variantInfo, std::vector<std::string> proxies)
557 {
558  //std::filesystem::path nodePath = node->getBoostPath(parentPath);
559  if (node->getNodeType() == StateTreeNode::State)
560  {
561  try
562  {
563  if (node->getState() && node->getCppExists())
564  {
565  XmlWriter writer(variantInfo);
566  writer.serialize(node->getState(), uuidToNodeMap);
567  std::string xml = writer.getXmlString(false).toUtf8().data();
568  StatechartGroupGenerator::generateStateFile(node->getState()->getStateName().toUtf8().data(), RapidXmlReader::FromXmlString(xml), buildDir, node->getGroup()->getPackageName().toUtf8().data(), node->getGroup()->getName().toUtf8().data(), proxies, node->getGroup()->contextGenerationEnabled(), variantInfo, false);
569  //std::string cpp = XmlStateBaseClassGenerator::GenerateCpp(namespaces, RapidXmlReader::FromXmlString(xml), proxies, node->getGroup()->contextGenerationEnabled(), node->getGroup()->getName().toUtf8().data(), variantInfo);
570  //std::string targetPath(nodePath.replace_extension().string() + ".generated.h");
571  //writeIfChanged(targetPath, cpp);
572  }
573  }
575  {
576  ARMARX_ERROR_S << ex.what();
577  }
578  catch (std::exception& e)
579  {
580  QMessageBox::warning(0, "Saving state failed!", QString::fromStdString(std::string(e.what())).split("Backtrace:").first());
581  }
582 
583  }
584  else if (node->getNodeType() == StateTreeNode::Folder)
585  {
586  //std::filesystem::create_directory(nodePath);
587  for (StateTreeNodePtr child : node->getChildren())
588  {
589  generateBaseClass(child, buildDir, variantInfo, proxies);
590  }
591  }
592 }
593 
594 void StateTreeModel::writeIfChanged(std::string targetPath, std::string contents)
595 {
596  bool identical = false;
597 
598  if (std::filesystem::exists(std::filesystem::path(targetPath)))
599  {
600  std::string currentContents = RapidXmlReader::ReadFileContents(targetPath);
601  identical = contents == currentContents;
602  }
603 
604  if (!identical)
605  {
606  QString qtargetPath = QString::fromUtf8(targetPath.data());
607  //QMessageBox::information(NULL, "test", qtargetPath);
608  ARMARX_LOG_S << "Generated file " << targetPath;
609  GroupXmlWriter::WriteFileContents(qtargetPath, QString::fromUtf8(contents.data()));
610  }
611  else
612  {
613  ARMARX_LOG_S << "Skipping identical file " << targetPath;
614  //QMessageBox::information(NULL, "test", "current file and generated output are identical.");
615  }
616 }
617 
619 {
620  return rootNode;
621 }
622 
623 QList<StatechartGroupPtr> StateTreeModel::getGroups() const
624 {
625  return QList<StatechartGroupPtr>(groups);
626 }
627 
628 StatechartGroupPtr StateTreeModel::getGroupByName(const QString& groupName) const
629 {
630  auto it = std::find_if(groups.constBegin(), groups.constEnd(), [&](const StatechartGroupPtr & g)
631  {
632  return g->getName() == groupName;
633  });
634 
635  if (it != groups.constEnd())
636  {
637  return *it;
638  }
639  else
640  {
641  return StatechartGroupPtr();
642  }
643 }
644 
646 {
647  if (!state)
648  {
649  return StateTreeNodePtr();
650  }
651 
652  return getNodeByUuid(state->getUUID());
653 }
654 
656 {
657  QMap<QString, StateTreeNodePtr>::const_iterator it = uuidToNodeMap.find(uuid);
658 
659  if (it != uuidToNodeMap.end())
660  {
661  return it.value();
662  }
663  else
664  {
665  return StateTreeNodePtr();
666  }
667 }
668 
670 {
671  node->state = state;
672  node->checkCppExists();
673  node->display = state->getStateName();
674  connect(state.get(), SIGNAL(substateChanged(statechartmodel::StateInstancePtr, statechartmodel::SignalType)), SLOT(notifySubstateChanged(statechartmodel::StateInstancePtr, statechartmodel::SignalType)));
675 }
676 
678 {
679  QList<StateInstancePtr> instances;
680  QMapIterator<QString, StateTreeNodePtr> i(uuidToNodeMap);
681 
682  while (i.hasNext())
683  {
684  i.next();
685  QMapIterator<QString, StateInstancePtr> itSubstate = i.value()->getState()->getSubstates();
686 
687  while (itSubstate.hasNext())
688  {
689  itSubstate.next();
690  statechartmodel::StatePtr state = itSubstate.value()->getStateClass();
691 
692  if (state && node->getState() == state)
693  {
694  instances.append(itSubstate.value());
695  }
696  }
697  }
698 
699  return instances;
700 }
701 
703 {
704  return groupExists(group->getBoostGroupPath());
705 }
706 
707 bool StateTreeModel::groupExists(std::filesystem::path groupPath)
708 {
709  foreach (StatechartGroupPtr g, groups)
710  {
711  if (g->getBoostGroupPath() == groupPath)
712  {
713  return true;
714  }
715  }
716  return false;
717 }
718 
719 void StateTreeModel::notifySubstateChanged(StateInstancePtr substate, SignalType signalType)
720 {
721  if (signalType == eAdded || signalType == eRemoved)
722  {
724  }
725 }
726 
727 void StateTreeModel::showWarning(QString title, QString message)
728 {
729  QMessageBox::warning(0, title, message);
730 }
731 
732 
733 
734 
735 /*
736 StatechartGroupTreeNodePtr StateTreeModel::createNewState(QString name, StatechartGroupTreeNodePtr parent)
737 {
738  statechartmodel::StatePtr state(new State());
739  state->setStateName(name);
740  StatechartGroupTreeNodePtr node(new StatechartGroupTreeNode(name, name + ".xml", StatechartGroupTreeNode::State, parent, parent->getGroup()));
741  node->setState(state);
742  parent->appendChild(node);
743  uuidToNodeMap.insert(state->getUUID(), node);
744  return node;
745 }*/
armarx::StateTreeModel::notifyNewStateTreeNode
void notifyNewStateTreeNode(StateTreeNodePtr node)
Definition: StateTreeModel.cpp:177
armarx::StateTreeModel::getNodeByState
StateTreeNodePtr getNodeByState(statechartmodel::StatePtr state) const
Definition: StateTreeModel.cpp:645
armarx::StateTreeNode
Definition: StateTreeNode.h:40
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
armarx::StatechartGroupGenerator::generateStatechartContextFile
static bool generateStatechartContextFile(const std::string &statechartGroupXmlFilePath, const std::string &packagePath, const std::optional< std::string > &packageIncludePath=std::nullopt)
Definition: StateGroupGenerator.cpp:134
armarx::GuiStatechartGroupXmlReader::ReadFileContents
static QString ReadFileContents(QString path)
Definition: GroupXmlReader.cpp:109
armarx::RapidXmlReader::ReadFileContents
static std::string ReadFileContents(const std::string &path)
Definition: RapidXmlReader.h:462
XmlStateBaseClassGenerator.h
armarx::DynamicLibraryPtr
std::shared_ptr< DynamicLibrary > DynamicLibraryPtr
Definition: DynamicLibrary.h:123
armarx::StateTreeNodePtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr
Definition: StatechartGroupDefs.h:31
armarx::GroupXmlWriter::WriteXml
static void WriteXml(StatechartGroupPtr group, QString path, bool indent=true)
Definition: GroupXmlWriter.cpp:41
FileIOException.h
ArmarXManager.h
armarx::StatechartGroupGenerator::generateStateFile
static bool generateStateFile(const std::string &statechartGroupXmlFilePath, const std::string &statePath, const std::string &packagePath, const std::optional< std::string > &packageIncludePath=std::nullopt)
Definition: StateGroupGenerator.cpp:61
armarx::RapidXmlReader::FromXmlString
static RapidXmlReaderPtr FromXmlString(const std::string &xml)
Definition: RapidXmlReader.h:491
DynamicLibrary.h
armarx::StateTreeModel::loadGroupStates
void loadGroupStates(StatechartGroupPtr group)
Definition: StateTreeModel.cpp:74
armarx::StatechartGroupGenerator::writeFileContentsIfChanged
static bool writeFileContentsIfChanged(const std::string &path, const std::string &contents)
Definition: StateGroupGenerator.cpp:402
armarx::StatechartGroup::eWritable
@ eWritable
Definition: StatechartGroup.h:40
armarx::StateTreeModel::addGroup
void addGroup(StatechartGroupPtr group)
Definition: StateTreeModel.cpp:172
armarx::StateTreeModel::StateTreeModel
StateTreeModel(Ice::CommunicatorPtr ic, VariantInfoPtr variantInfo)
Definition: StateTreeModel.cpp:47
armarx::StateTreeModel::generateAllBaseClasses
void generateAllBaseClasses(QPointer< QProgressDialog > progressDialog=NULL)
Definition: StateTreeModel.cpp:375
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:53
armarx::Variant::getTypes
static const std::map< VariantTypeId, std::string > & getTypes()
Returns the mapping of currently registered types.
Definition: Variant.cpp:746
message
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
Definition: CMakeLists.txt:8
FactoryCollectionBase.h
armarx::StateTreeModel::clear
void clear()
Definition: StateTreeModel.cpp:166
armarx::StatechartGroup::eReadOnly
@ eReadOnly
Definition: StatechartGroup.h:40
armarx::armem::contains
bool contains(const MemoryID &general, const MemoryID &specific)
Indicates whether general is "less specific" than, or equal to, specific, i.e.
Definition: MemoryID.cpp:558
armarx::StateTreeModel::saveAll
void saveAll(QPointer< QProgressDialog > progressDialog=NULL)
Definition: StateTreeModel.cpp:193
armarx::VariantInfo::VariantEntryPtr
std::shared_ptr< VariantEntry > VariantEntryPtr
Definition: VariantInfo.h:48
armarx::statechartmodel::StateInstancePtr
std::shared_ptr< StateInstance > StateInstancePtr
Definition: StateInstance.h:138
armarx::StateTreeModel::annotateStateRerefences
void annotateStateRerefences(const QList< statechartmodel::StatePtr > &statesToAnnotate)
Definition: StateTreeModel.cpp:86
armarx::StateTreeModel::annotateAllStateRerefences
void annotateAllStateRerefences()
Definition: StateTreeModel.cpp:103
IceInternal::Handle< ::Ice::Communicator >
armarx::exceptions::local::FileOpenException
Definition: FileIOException.h:58
armarx::StateTreeModel::saveNode
void saveNode(StateTreeNodePtr node, std::filesystem::path parentPath)
Definition: StateTreeModel.cpp:228
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::statechartio::XmlWriter::serialize
void serialize(armarx::statechartmodel::StateCPtr state, const QMap< QString, StateTreeNodePtr > &uuidToNodeMap=QMap< QString, StateTreeNodePtr >())
Builds XML data structures for serialization of the given state object.
Definition: XmlWriter.cpp:45
armarx::GroupXmlWriter::WriteFileContents
static void WriteFileContents(QString path, QString contents)
Definition: GroupXmlWriter.cpp:90
armarx::StateTreeModel::groupExists
bool groupExists(StatechartGroupPtr group)
Definition: StateTreeModel.cpp:702
armarx::StateTreeModel::loadNode
void loadNode(StateTreeNodePtr node, std::filesystem::path parentPath, QList< statechartmodel::StatePtr > &allTheReaders)
Definition: StateTreeModel.cpp:120
armarx::StateTreeModel::getGroups
QList< StatechartGroupPtr > getGroups() const
Definition: StateTreeModel.cpp:623
armarx::VariantInfo::ReadInfoFilesRecursive
static VariantInfoPtr ReadInfoFilesRecursive(const std::string &rootPackageName, const std::string &rootPackagePath, bool showErrors, VariantInfoPtr variantInfo=VariantInfoPtr())
Definition: VariantInfo.cpp:347
armarx::CMakePackageFinder::getName
std::string getName() const
Returns the name of the given package.
Definition: CMakePackageFinder.cpp:480
ARMARX_ERROR_S
#define ARMARX_ERROR_S
Definition: Logging.h:209
armarx::StateTreeModel::getNodeByUuid
StateTreeNodePtr getNodeByUuid(const QString &uuid) const
Definition: StateTreeModel.cpp:655
armarx::StateTreeNode::State
@ State
Definition: StateTreeNode.h:45
StateTreeModel.h
armarx::StateTreeModel::generateGroupDocString
void generateGroupDocString(StatechartGroupPtr group, QString doxyGroupPath)
Definition: StateTreeModel.cpp:274
armarx::statechartmodel::eAdded
@ eAdded
Definition: SignalType.h:35
armarx::StateTreeModel::generateBaseClasses
void generateBaseClasses(const StatechartGroupPtr &group)
Definition: StateTreeModel.cpp:461
ARMARX_LOG_S
#define ARMARX_LOG_S
Definition: Logging.h:145
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:206
armarx::statechartio::XmlWriter::getXmlString
QString getXmlString(bool indent=true) const
Builds the XML document for the state object that has been handled by serialize() before.
Definition: XmlWriter.cpp:84
armarx::StatechartGroupPtr
std::shared_ptr< StatechartGroup > StatechartGroupPtr
Definition: StatechartGroupDefs.h:34
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
StateGroupGenerator.h
XmlContextBaseClassGenerator.h
armarx::statechartmodel::eRemoved
@ eRemoved
Definition: SignalType.h:40
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::statechartmodel::SignalType
SignalType
The SignalType enum.
Definition: SignalType.h:33
armarx::StateTreeModel::loadAllStates
void loadAllStates()
Definition: StateTreeModel.cpp:56
armarx::StateTreeModel::getPackageFinder
const CMakePackageFinder & getPackageFinder(const QString &packageName)
Definition: StateTreeModel.cpp:287
armarx::StateTreeModel::setNodeState
void setNodeState(StateTreeNodePtr node, statechartmodel::StatePtr state)
Definition: StateTreeModel.cpp:669
armarx::StateTreeModel::loadGroup
StatechartGroupPtr loadGroup(QString groupDefinitionFile, StateTreeNodePtr rootNode)
Definition: StateTreeModel.cpp:152
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::StateTreeModel::notifyDeleteStateTreeNode
void notifyDeleteStateTreeNode(StateTreeNodePtr node)
Definition: StateTreeModel.cpp:185
armarx::StateTreeModel::writeIfChanged
void writeIfChanged(std::string targetPath, std::string contents)
Definition: StateTreeModel.cpp:594
armarx::StateTreeModel::getGroupByName
StatechartGroupPtr getGroupByName(const QString &groupName) const
Definition: StateTreeModel.cpp:628
armarx::statechartmodel::StatePtr
std::shared_ptr< State > StatePtr
Definition: State.h:46
armarx::StateTreeNode::Folder
@ Folder
Definition: StateTreeNode.h:45
armarx::CMakePackageFinder::getBuildDir
std::string getBuildDir() const
Definition: CMakePackageFinder.h:136
armarx::StateTreeModel::generateBaseClass
void generateBaseClass(StateTreeNodePtr node, std::filesystem::path buildDir, VariantInfoPtr variantInfo, std::vector< std::string > proxies)
Definition: StateTreeModel.cpp:556
armarx::statechartio::XmlReader
XML reader class used to build State objects from XML representations.
Definition: XmlReader.h:38
armarx::statechartio::XmlWriter
XML writer class used to build XML representations of State objects.
Definition: XmlWriter.h:61
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
armarx::StateTreeModel::loadVariantInfos
void loadVariantInfos(const std::string &packageName)
Definition: StateTreeModel.cpp:303
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::StateTreeModel::stateAddedOrRemoved
void stateAddedOrRemoved()
armarx::StateTreeModel::findStateUsages
QList< statechartmodel::StateInstancePtr > findStateUsages(StateTreeNodePtr node)
Definition: StateTreeModel.cpp:677
armarx::VariantInfo::LibEntryPtr
std::shared_ptr< LibEntry > LibEntryPtr
Definition: VariantInfo.h:172
armarx::VariantContainerType::FromString
static ContainerTypePtr FromString(const std::string &typeStr)
Definition: VariantContainer.cpp:262
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::Variant::addTypeName
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
Definition: Variant.cpp:751
armarx::ArmarXManager::RegisterKnownObjectFactoriesWithIce
static void RegisterKnownObjectFactoriesWithIce(const Ice::CommunicatorPtr &ic)
Registers all object factories that are known with Ice.
Definition: ArmarXManager.cpp:1204
armarx::StateTreeModel::getRootNode
StateTreeNodePtr getRootNode() const
Definition: StateTreeModel.cpp:618
armarx::GuiStatechartGroupXmlReader::ReadXml
static StatechartGroupPtr ReadXml(QString groupDefinitionFile, StateTreeNodePtr virtualRoot)
Definition: GroupXmlReader.cpp:49