ArmarXManager.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 ArmarXCore::core
19  * @author Kai Welke (kai dot welke at kit dot edu)
20  * @date 2012
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
26 #include <ArmarXCore/core/Component.h> // for ComponentPtr, Component
27 #include <ArmarXCore/core/IceManager.h> // for IceManager
28 #include <ArmarXCore/core/ManagedIceObject.h> // for ManagedIceObject
32 #include <ArmarXCore/core/system/ArmarXDataPath.h> // for ArmarXDataPath
34 #include <ArmarXCore/core/time/LocalTimeServer.h> // for LocalTimeServer
35 #include <ArmarXCore/core/time/TimeUtil.h> // for TimeUtil
38 #include <Ice/BuiltinSequences.h> // for StringSeq
39 #include <Ice/Communicator.h> // for CommunicatorPtr, etc
40 #include <Ice/Identity.h> // for Identity
41 #include <Ice/Initialize.h> // for initialize
42 #include <Ice/LocalException.h> // for AlreadyRegisteredException, etc
43 #include <Ice/NativePropertiesAdmin.h>
44 #include <Ice/ObjectAdapter.h> // for ObjectAdapterPtr
45 #include <Ice/ObjectF.h> // for upCast
46 #include <Ice/Properties.h> // for Properties
47 #include <Ice/Metrics.h> // for Metrics
48 #include <Ice/PropertiesF.h> // for upCast
49 #include <Ice/Proxy.h> // for Object
50 #include <Ice/ProxyF.h> // for ObjectPrx
51 #include <IceGrid/Admin.h> // for Admin, ObjectObserverPrx, upCast
52 #include <IceGrid/Registry.h> // for RegistryPrx, upCast
53 #include <IceUtil/Handle.h> // for HandleBase, Handle
54 #include <IceStorm/IceStorm.h> // for TopicPrx, TopicManagerPrx, etc
55 
56 #include <cstddef> // for size_t, NULL
57 #include <chrono> // for seconds
58 #include <iostream> // for operator<<, basic_ostream, etc
59 #include <map> // for _Rb_tree_iterator, etc
60 #include <ratio> // for ratio
61 #include <sstream> // for basic_stringbuf<>::int_type, etc
62 #include <string> // for string, allocator, etc
63 #include <thread> // for thread, sleep_for
64 #include <utility> // for pair, make_pair, move
65 #include <vector> // for vector, vector<>::iterator
66 #include <unistd.h> // for hostname
67 #include <limits.h> // for hostname max length
68 
72 #include "ArmarXCore/core/exceptions/Exception.h" // for LocalException, etc
73 #include "ArmarXCore/core/logging/LogSender.h" // for LogSender
74 #include "ArmarXCore/core/logging/Logging.h" // for ARMARX_VERBOSE, etc
75 #include "ArmarXCore/core/services/tasks/ThreadList.h" // for ThreadList
76 #include "ArmarXCore/interface/core/BasicTypes.h"
77 #include "ArmarXCore/interface/core/Log.h" // for LogPrx, MessageType, etc
78 #include "ArmarXCore/interface/core/ManagedIceObjectDefinitions.h"
79 #include "ArmarXCore/interface/core/ThreadingIceBase.h" // for upCast
80 #include "ArmarXManager.h" // for ArmarXManager, etc
82 #include "IceGridAdmin.h" // for IceGridAdmin
84 
85 namespace Ice
86 {
87  struct Current;
88 } // namespace Ice
89 
90 namespace armarx
91 {
92 #define MANAGEROBJNAME applicationName + "Manager"
93 #define OBJOBSNAME std::string("ArmarXObjectObserver_") + applicationName
94 
95  // *******************************************************
96  // construction
97  // *******************************************************
98  ArmarXManager::ArmarXManager(std::string applicationName, int port, std::string host, std::string locatorName, Ice::StringSeq args) :
99  applicationName(applicationName),
100  managerState(eCreated)
101  {
102  // initialize communicator
103  std::stringstream defaultLocator;
104  defaultLocator << "--Ice.Default.Locator=" << locatorName << ":tcp -p " << port << " -h " << host;
105  args.push_back(defaultLocator.str());
106  Ice::CommunicatorPtr communicator = Ice::initialize(args);
107 
108  // init members
109  init(applicationName, communicator);
110  }
111 
112  ArmarXManager::ArmarXManager(std::string applicationName, const Ice::CommunicatorPtr& communicator) :
113  applicationName(applicationName),
114  managerState(eCreated)
115  {
116  // init members
117  init(applicationName, communicator);
118  }
119 
120 
122  {
123  shutdown();
124  waitForShutdown();
125  }
126 
127  bool ArmarXManager::checkIceConnection(bool printHint) const
128  {
129  return CheckIceConnection(iceManager->getCommunicator(), printHint);
130  }
131 
132  bool ArmarXManager::CheckIceConnection(const Ice::CommunicatorPtr& communicator, bool printHint)
133  {
134  const std::string armarxHint = "'\nDid you start armarx?\n\nTo start armarx: armarx start\n"
135  "To kill a hanging armarx: armarx killIce" ;
136  try
137  {
138  if (communicator->getProperties()->getProperty("Ice.Default.Locator").empty())
139  {
140  if (printHint)
141  {
142  std::cerr << "Required Ice property 'Ice.Default.Locator' not set! "
143  << "It has to has a value similar to 'IceGrid/Locator:tcp -p 4061 -h localhost'";
144  }
145  return false;
146  }
147  auto locatorProp = communicator->getProperties()->getProperty("Ice.Default.Locator");
148  auto pos = locatorProp.find_first_of(':');
149  std::string locatorId = locatorProp.substr(0, pos) ;
150  auto proxy = communicator->stringToProxy(locatorId);
151  IceGrid::LocatorPrx::checkedCast(proxy);
152  }
153  catch (...)
154  {
155  if (printHint)
156  {
157  std::cerr << "Could not contact default locator at '"
158  << communicator->getProperties()->getProperty("Ice.Default.Locator")
159  << armarxHint;
160  }
161  return false;
162  }
163 
164  try
165  {
166  std::string registryId = "IceGrid/Registry";
167  auto proxy = communicator->stringToProxy(registryId);
168  IceGrid::RegistryPrx::checkedCast(proxy);
169  }
170  catch (...)
171  {
172  if (printHint)
173  {
174  std::cerr << "Could not contact IceGrid registry at '"
175  << communicator->getProperties()->getProperty("IceGrid.Registry.Client.Endpoints")
176  << armarxHint;
177  }
178  return false;
179  }
180 
181  try
182  {
183  IceManager::GetTopicManager(communicator);
184  }
185  catch (const Ice::NoEndpointException& e)
186  {
187  std::cout << "Caught exception: \n" << e.what() << std::endl;
188 
189  if (printHint)
190  {
191  std::cerr << "Could not contact TopicManager at '"
192  // This string is actually used in IceManager::GetTopicManager()
193  << "IceStorm/TopicManager"
194  // << communicator->getProperties()->getProperty("IceStormAdmin.TopicManager.Default")
195  << armarxHint;
196  }
197  return false;
198  }
199 
200  return true;
201  }
202 
203  // *******************************************************
204  // ArmarXManager property setters
205  // *******************************************************
207  {
209  }
210 
211 
213  {
214  ThreadList::getApplicationThreadList()->enableProfiler(enable);
215  }
216 
217 
219  {
221  }
222 
223  void ArmarXManager::setDataPaths(std::string dataPaths)
224  {
226  }
227 
228  // *******************************************************
229  // adding / removing ManagedIceObjects
230  // *******************************************************
231 
232 
233  void ArmarXManager::addObject(const ManagedIceObjectPtr& object, bool addWithOwnAdapter, const std::string& objectName, bool useOwnScheduleThread)
234  {
235  addObject(object,
236  addWithOwnAdapter ? Ice::ObjectAdapterPtr() : getAdapter(), objectName, useOwnScheduleThread);
237  }
238  void ArmarXManager::addObject(const ManagedIceObjectPtr& object, const std::string& objectName, bool addWithOwnAdapter, bool useOwnScheduleThread)
239  {
240  addObject(object, addWithOwnAdapter, objectName, useOwnScheduleThread);
241  }
242 
243  void ArmarXManager::addObject(const ManagedIceObjectPtr& object, Ice::ObjectAdapterPtr objectAdapterToAddTo, const std::string& objectName, bool useOwnScheduleThread)
244  {
245  if (!object)
246  {
247  throw LocalException("Cannot add NULL object");
248  }
249  {
250  auto cptr = ComponentPtr::dynamicCast(object);
251  if (cptr && !cptr->createdByComponentCreate)
252  {
253  throw LocalException("Components need to be created by Component::create");
254  }
255  }
256 
257  if (!objectName.empty())
258  {
259  if (!object->getName().empty())
260  {
261  ARMARX_INFO << "Adding object with custom name: " << objectName;
262  }
263  object->setName(objectName);
264  }
265  if (object->getName().empty())
266  {
267  object->setName(object->getDefaultName());
268  }
269  if (object->getName().empty())
270  {
271  throw LocalException("Object name must not be empty");
272  }
273  auto lock = acquireManagedObjectsMutex();
274  if (!lock)
275  {
276  return;
277  }
278 
279  bool reachable = false;
280 
281  try
282  {
283  reachable = getIceManager()->isObjectReachable(object->getName());
284  }
285  catch (...)
286  {
287  throw;
288  }
289 
290  if (reachable)
291  {
292  throw Ice::AlreadyRegisteredException(__FILE__, __LINE__, object->ice_id(), object->getName());
293  }
294 
295  try
296  {
297  ArmarXObjectSchedulerPtr objectScheduler = new ArmarXObjectScheduler(this, iceManager, object, objectAdapterToAddTo, useOwnScheduleThread);
298  auto pair = managedObjects.insert(std::make_pair(object->getName(), std::move(objectScheduler)));
299  if (!pair.second)
300  {
301  ARMARX_WARNING << "Insert of object scheduler in managedObjects failed since there is already a scheduler for name " << object->getName();
302  }
303  if (!useOwnScheduleThread)
304  {
305  std::scoped_lock lock(schedulerListMutex);
306  singleThreadedSchedulers.at(rand() % singleThreadedSchedulers.size())->addObjectScheduler(pair.first->second);
307  }
308  }
309  catch (...)
310  {
311  throw;
312  }
313  }
314 
315  void ArmarXManager::addObjectAsync(const ManagedIceObjectPtr& object, const std::string& objectName, bool addWithOwnAdapter, bool useOwnScheduleThread)
316  {
317  ArmarXManagerPtr manager(this);
318  std::thread
319  {
320  [ = ]
321  {
322  try
323  {
324  manager->addObject(object, objectName, addWithOwnAdapter, useOwnScheduleThread);
325  }
326  catch (...)
327  {
329  }
330  }
331 
332  } .detach();
333  }
334 
335  void ArmarXManager::removeObjectBlocking(const std::string& objectName)
336  {
337  ArmarXObjectSchedulerPtr scheduler;
338  {
339  auto lock = acquireManagedObjectsMutex();
340  if (!lock)
341  {
342  return;
343  }
344  scheduler = managedObjects.find(objectName)->second;
345  }
346  try
347  {
348  if (scheduler)
349  {
350  removeObject(scheduler, true);
351  }
352  }
353  catch (...)
354  {
355  throw;
356  }
357 
358  }
359 
360  void ArmarXManager::removeObjectNonBlocking(const std::string& objectName)
361  {
362  auto removal = [objectName, this]()
363  {
364  ArmarXObjectSchedulerPtr scheduler;
365  {
366  auto lock = acquireManagedObjectsMutex();
367  if (!lock)
368  {
369  return;
370  }
371  scheduler = managedObjects.find(objectName)->second;
372  }
373  try
374  {
375  this->removeObject(scheduler, false);
376 
377  }
378  catch (...)
379  {
380  throw;
381  }
382 
383  };
384  std::thread {removal} .detach();
385  }
386 
388  {
389  removeObjectBlocking(object->getName());
390  }
391 
393  {
394  removeObjectNonBlocking(object->getName());
395  }
396 
397  // *******************************************************
398  // shutdown handling
399  // *******************************************************
401  {
402  // assure no state changed
403  managerStateMutex.lock();
404 
405  if (managerState == eShutdown)
406  {
407  managerStateMutex.unlock();
408  return;
409  }
410 
411  // wait for shutdown
412  std::unique_lock lock(shutdownMutex);
413  managerStateMutex.unlock();
414  shutdownCondition.wait(lock);
415  ARMARX_VERBOSE << "Waiting for shutdown finished";
416  }
417 
419  {
420  try
421  {
422  // check state
423  {
424  std::scoped_lock lock(managerStateMutex);
425 
426  // do not shutdown if shutdown is in progress
427  if (managerState >= eShutdownInProgress)
428  {
429  return;
430  }
431 
432  managerState = eShutdownInProgress;
433 
434  // locking managedObjects ne done before state mutex is released
435  managedObjectsMutex.lock();
436  }
437 
438  ARMARX_VERBOSE << "Shutting down ArmarXManager" << std::endl;
439 
440  // stop cleanup task. All objects will be removed manually in shutdown
441  cleanupSchedulersTask->stop();
442 
443  if (checkDependencyStatusTask)
444  {
445  checkDependencyStatusTask->stop();
446  }
447 
448  sharedRemoteHandleState.reset();
449  remoteReferenceCountControlBlockManager.reset();
450 
451  disconnectAllObjects();
452 
453  // shutdown log sender
455 
456  // remove all managed objects
457  removeAllObjects(true);
458  try
459  {
460  iceManager->getIceGridSession()->getAdmin()->removeObject(Ice::Identity {MANAGEROBJNAME, ""});
461  }
462  catch (...) {}
463 
464  singleThreadedSchedulers.clear();
465 
466  try
467  {
468  // deactivate all object adapters (and do internal iceManager shutdown)
469  iceManager->shutdown();
470 
471  // wait until all adapters have been deactivated
472  iceManager->waitForShutdown();
473  }
474  catch (...)
475  {
476  }
477  // destroy manager and communicator
478  iceManager->destroy();
479 
480  // set to NULL to avoid cycle in pointers ArmarXManager <-> ArmarXObjectObserver
481  objObserver = nullptr;
482 
483  // set state to shutdown and notify waitForShutdown
484  {
485  std::scoped_lock lock(managerStateMutex);
486 
487  // inform waiting threads of shutdown
488  {
489  std::unique_lock lock(shutdownMutex);
490  ARMARX_VERBOSE << "notifying shutdown waiters" << std::endl;
491  shutdownCondition.notify_all();
492  }
493 
494  managerState = eShutdown;
495  }
496 
497  managedObjectsMutex.unlock();
498  }
499  catch (std::exception& e)
500  {
501  ARMARX_INFO << "shutdown failed with exception!\n" << e.what() << std::endl;
502  }
503 
504  ARMARX_INFO << "Shutdown of ArmarXManager finished!" << std::endl;
505  }
506 
507  void ArmarXManager::asyncShutdown(std::size_t timeoutMs)
508  {
509  std::thread {[this, timeoutMs]{
510  std::this_thread::sleep_for(std::chrono::milliseconds{timeoutMs});
511  shutdown();
512  }
513  } .detach();
514  }
515 
517  {
518  std::scoped_lock lock(managerStateMutex);
519  return (managerState == eShutdown);
520  }
521 
522 
523  // *******************************************************
524  // getters
525  // *******************************************************
526 
528  {
529  return iceManager;
530  }
531 
533  {
534  return iceManager->getCommunicator();
535  }
536 
537  std::vector<ManagedIceObjectPtr> ArmarXManager::getManagedObjects()
538  {
539  std::vector<ManagedIceObjectPtr> objects;
540 
541  auto lock = acquireManagedObjectsMutex();
542  if (!lock)
543  {
544  return objects;
545  }
546 
547  ObjectSchedulerMap::iterator iter = managedObjects.begin();
548 
549  while (iter != managedObjects.end())
550  {
551  objects.push_back(iter->second->getObject());
552  iter++;
553  }
554 
555 
556  return objects;
557  }
558 
559 
560 
561  // *******************************************************
562  // Slice MiceManagerInsightProvider implementation
563  // *******************************************************
564 
565  std::string ArmarXManager::getHostname(const Ice::Current&)
566  {
567  char hostname[HOST_NAME_MAX];
568  gethostname(hostname, HOST_NAME_MAX);
569  return std::string(hostname);
570  }
571 
572  Ice::StringSeq ArmarXManager::getObjectNames(const Ice::Current& c)
573  {
574  return getManagedObjectNames();
575  }
576 
577  mice::MiceObjectConnectivity ArmarXManager::getMiceObjectConnectivity(const std::string& objectName, const Ice::Current& c)
578  {
579  mice::MiceObjectConnectivity miceCon = mice::MiceObjectConnectivity();
580  ManagedIceObjectConnectivity con = getObjectConnectivity(objectName);
581  miceCon.subscribedTopics = con.usedTopics;
582  miceCon.publishedTopics = con.offeredTopics;
583  miceCon.usedObjects = Ice::StringSeq();
584 
585  for(const auto &entry : con.dependencies) {
586  miceCon.usedObjects.push_back(entry.first);
587  }
588 
589  return miceCon;
590  }
591 
592 
593  IceMX::MetricsAdminPrx ArmarXManager::getMetricsAdmin(const Ice::Current&)
594  {
595  Ice::ObjectPrx adminObj = getIceManager()->getCommunicator()->getAdmin();
596  IceMX::MetricsAdminPrx metrAdmin = IceMX::MetricsAdminPrx::checkedCast(adminObj, "Metrics");
597  return metrAdmin;
598  }
599 
600 
601 
602  // *******************************************************
603  // Slice ArmarXManagerInterface implementation
604  // *******************************************************
605  ManagedIceObjectState ArmarXManager::getObjectState(const std::string& objectName, const Ice::Current& c)
606  {
607  auto lock = acquireManagedObjectsMutex();
608  if (!lock)
609  {
610  return eManagedIceObjectExiting;
611  }
612 
613  ObjectSchedulerMap::iterator iter = managedObjects.find(objectName);
614 
615  if (iter == managedObjects.end())
616  {
617  return eManagedIceObjectExited;
618  }
619 
620  ManagedIceObjectState state = (ManagedIceObjectState)iter->second->getObject()->getState();
621 
622  return state;
623  }
624 
625  ManagedIceObjectConnectivity ArmarXManager::getObjectConnectivity(const std::string& objectName, const Ice::Current& c)
626  {
627  auto lock = acquireManagedObjectsMutex();
628  if (!lock)
629  {
630  return ManagedIceObjectConnectivity();
631  }
632 
633  ObjectSchedulerMap::iterator iter = managedObjects.find(objectName);
634 
635  if (iter == managedObjects.end())
636  {
637  return ManagedIceObjectConnectivity();
638  }
639 
640  ManagedIceObjectConnectivity con = iter->second->getObject()->getConnectivity();
641 
642 
643  return con;
644  }
645 
646 
647  StringStringDictionary ArmarXManager::getObjectProperties(const ::std::string& objectName, const ::Ice::Current&)
648  {
649  StringStringDictionary propertyMap;
650  ObjectSchedulerMap::iterator iter = managedObjects.find(objectName);
651 
652  if (iter == managedObjects.end())
653  {
654  return propertyMap;
655  }
656 
657  ComponentPtr component = ComponentPtr::dynamicCast(iter->second->getObject());
658 
659  if (!component)
660  {
661  return propertyMap;
662  }
663  ARMARX_CHECK_EXPRESSION(component->getPropertyDefinitions());
664  auto result = component->getPropertyDefinitions()->getPropertyValues(component->getPropertyDefinitions()->getPrefix());
665  return result;
666  }
667 
668  ObjectPropertyInfos ArmarXManager::getObjectPropertyInfos(const ::std::string& objectName, const ::Ice::Current&)
669  {
670  ObjectPropertyInfos propertyMap;
671  ObjectSchedulerMap::iterator iter = managedObjects.find(objectName);
672 
673  if (iter == managedObjects.end())
674  {
675  return propertyMap;
676  }
677 
678  ComponentPtr component = ComponentPtr::dynamicCast(iter->second->getObject());
679 
680  if (!component)
681  {
682  return propertyMap;
683  }
684 
685  ARMARX_CHECK_EXPRESSION(component->getPropertyDefinitions());
686  for (auto prop : component->getPropertyDefinitions()->getPropertyValues())
687  {
688  propertyMap[component->getPropertyDefinitions()->getPrefix() + prop.first] = {component->getPropertyDefinitions()->getDefinitionBase(prop.first)->isConstant(),
689  prop.second
690  };
691  }
692  return propertyMap;
693  }
694 
695  ObjectPropertyInfos ArmarXManager::getApplicationPropertyInfos(const Ice::Current&)
696  {
697  ObjectPropertyInfos propertyMap;
698  if (!Application::getInstance() || !Application::getInstance()->getPropertyDefinitions())
699  {
700  return propertyMap;
701  }
702  for (auto prop : Application::getInstance()->getPropertyDefinitions()->getPropertyValues())
703  {
704  propertyMap[Application::getInstance()->getPropertyDefinitions()->getPrefix() + prop.first] = {Application::getInstance()->getPropertyDefinitions()->getDefinitionBase(prop.first)->isConstant(),
705  prop.second
706  };
707  }
708  return propertyMap;
709  }
710 
711 
712  Ice::PropertiesAdminPrx ArmarXManager::getPropertiesAdmin(const Ice::Current&)
713  {
714  Ice::ObjectPrx adminObj = getIceManager()->getCommunicator()->getAdmin();
715  Ice::PropertiesAdminPrx propAdmin = Ice::PropertiesAdminPrx::checkedCast(adminObj, "Properties");
716  return propAdmin;
717  }
718 
719 
721  {
722  for (ManagedIceObjectPtr& managedObject : getManagedObjects())
723  {
724  ComponentPtr component = ComponentPtr::dynamicCast(managedObject);
725  if (component)
726  {
727  component->setIceProperties(properties);
728  }
729  }
730  }
731 
732  void ArmarXManager::updateComponentIceProperties(const Ice::PropertyDict& properties)
733  {
734  for (ManagedIceObjectPtr& managedObject : getManagedObjects())
735  {
736  ComponentPtr component = ComponentPtr::dynamicCast(managedObject);
737  if (component)
738  {
739  component->updateIceProperties(properties);
740  }
741  }
742  }
743 
744 
745  Ice::StringSeq ArmarXManager::getManagedObjectNames(const Ice::Current& c)
746  {
747  Ice::StringSeq objectNames;
748 
749  auto lock = acquireManagedObjectsMutex();
750  if (!lock)
751  {
752  return objectNames;
753  }
754 
755  ObjectSchedulerMap::iterator iter = managedObjects.begin();
756 
757  while (iter != managedObjects.end())
758  {
759  objectNames.push_back(iter->first);
760  iter++;
761  }
762 
763 
764  return objectNames;
765  }
766 
768  public Ice::PropertiesAdminUpdateCallback
769  {
770  public:
772  application(application)
773  {
774  }
775 
776  void updated(const Ice::PropertyDict& changes) override
777  {
778  // ARMARX_INFO << "Properties were updated: " << changes;
779  if (application)
780  {
781  application->updateIceProperties(changes);
782  }
783  }
784  private:
785  armarx::ApplicationPtr application;
786  };
788 
789  // *******************************************************
790  // private methods
791  // *******************************************************
792  void ArmarXManager::init(std::string applicationName, const Ice::CommunicatorPtr& communicator)
793  {
795 
797 
798 
799  // create ice manager
800  iceManager = new IceManager(
801  communicator, applicationName,
802  appInstance ? appInstance->getProperty<std::string>("TopicSuffix").getValue() : "");
803 
804 
805  if (!checkIceConnection())
806  {
807  throw Ice::ConnectFailedException(__FILE__, __LINE__);
808  }
809 
810  this->installProcessFacet();
811 
812  // init logging
813  LogSender::setProxy(applicationName,
814  iceManager->getTopic<LogPrx>("Log"));
815 
816  setTag("ArmarXManager");
817 
819 
820 
821  // make sure icegrid session exists before continuing
822  auto icegrid = iceManager->getIceGridSession();
823  // register obj observer for onDisconnect
824  objObserver = new ArmarXObjectObserver(this);
825  Ice::ObjectAdapterPtr observerAdapter;
826  Ice::ObjectPrx oPrx = icegrid->registerObjectWithNewAdapter(objObserver, OBJOBSNAME, observerAdapter);
827  IceGrid::ObjectObserverPrx objObsPrx = IceGrid::ObjectObserverPrx::checkedCast(oPrx);
828  icegrid->setObjectObserver(objObsPrx);
829 
830  // register manager to ice
831  icegrid->registerObjectWithNewAdapter(this, MANAGEROBJNAME, armarxManagerAdapter);
832 
833 
834 
835  // create periodic task for starter cleanup
836  cleanupSchedulersTask = new PeriodicTask<ArmarXManager>(this, &ArmarXManager::cleanupSchedulers, 500, false, "ArmarXManager::cleanupSchedulers");
837  cleanupSchedulersTask->start();
838 
839  checkDependencyStatusTask = new PeriodicTask<ArmarXManager>(this, &ArmarXManager::checkDependencies, 1000, false, "ArmarXManager::DependenciesChecker");
840  checkDependencyStatusTask->start();
841 
842 
843  // set manager state to running
844  {
845  std::scoped_lock lock(managerStateMutex);
846  managerState = eRunning;
847  }
848 
849  // create ThreadList for this process
850  ThreadList::getApplicationThreadList()->setApplicationThreadListName(applicationName + "ThreadList");
851 
852  try
853  {
855  }
856  catch (...) {}
857 
858  // create a local TimeServer for this process
859  if (appInstance && appInstance->getProperty<bool>("UseTimeServer").getValue())
860  {
861  ARMARX_VERBOSE << "Using time from global time server.";
862  LocalTimeServer::getApplicationTimeServer()->setApplicationTimeServerName(applicationName + "LocalTimeServer");
865  }
866  else
867  {
868  ARMARX_VERBOSE << "Using time from local system clock.";
869  }
870 
871  sharedRemoteHandleState.reset(
873  {
874  appInstance ?
875  appInstance->getProperty<unsigned int>("RemoteHandlesDeletionTimeout").getValue() :
877  }
878  );
879  remoteReferenceCountControlBlockManager.reset(new RemoteReferenceCountControlBlockManager {IceUtil::Time::milliSeconds(100)});
880  }
881 
882  void ArmarXManager::cleanupSchedulers()
883  {
884  std::scoped_lock lock(terminatingObjectsMutex);
885 
886  ObjectSchedulerList::iterator iter = terminatingObjects.begin();
887 
888  while (iter != terminatingObjects.end())
889  {
890  const ArmarXObjectSchedulerPtr& sched = *iter;
891  ARMARX_VERBOSE << deactivateSpam(1, sched->getObject()->getName()) <<
892  "Checking termination state of " << sched->getObject()->getName() <<
893  ": " << ManagedIceObject::GetObjectStateAsString(sched->getObjectState());
894  // remove terminated starters
895  if ((*iter)->isTerminated())
896  {
897  ARMARX_VERBOSE << "Delayed Removal of ManagedIceObject " << (*iter)->getObject()->getName() << " finished";
898  iter = terminatingObjects.erase(iter);
899  }
900  else
901  {
902  iter++;
903  }
904  }
905  }
906 
907  void ArmarXManager::disconnectDependees(const std::string& object)
908  {
909  try
910  {
911  std::vector<std::string> dependees = getDependendees(object);
912 
913  auto lock = acquireManagedObjectsMutex();
914  if (!lock)
915  {
916  return;
917  }
918 
919  for (const auto& dependee : dependees)
920  {
921  ArmarXManager::ObjectSchedulerMap::iterator it = managedObjects.find(dependee);
922  ARMARX_INFO << deactivateSpam(10, dependee + object) << "'" << dependee << "' disconnected because of '" << object << "'";
923 
924  if (it != managedObjects.end())
925  {
926  it->second->disconnected(true);
927  }
928  }
929  }
930  catch (...)
931  {
932  throw;
933  }
934 
935  }
936 
937  void ArmarXManager::disconnectAllObjects()
938  {
939  auto lock = acquireManagedObjectsMutex();
940  if (!lock)
941  {
942  return;
943  }
944  ObjectSchedulerMap::iterator iter = managedObjects.begin();
945 
946  for (; iter != managedObjects.end(); iter++)
947  {
948  iter->second->disconnected(false);
949  }
950  }
951 
952 
953  std::vector<std::string> ArmarXManager::getDependendees(const std::string& removedObject)
954  {
955  std::vector<std::string> result;
956 
957  auto lock = acquireManagedObjectsMutex();
958  if (!lock)
959  {
960  return result;
961  }
962 
963  try
964  {
965 
966  ObjectSchedulerMap::const_iterator it = managedObjects.begin();
967 
968  for (; it != managedObjects.end(); it++)
969  {
970  ArmarXObjectSchedulerPtr scheduler = it->second;
971 
972  if (scheduler->dependsOn(removedObject))
973  {
974  result.push_back(it->first);
975  }
976  }
977  }
978  catch (...)
979  {
980  throw;
981  }
982 
983  return result;
984  }
985 
986  void ArmarXManager::wakeupWaitingSchedulers()
987  {
988  auto lock = acquireManagedObjectsMutex();
989  if (!lock)
990  {
991  return;
992  }
993 
994  try
995  {
996 
997  ObjectSchedulerMap::const_iterator it = managedObjects.begin();
998 
999  for (; it != managedObjects.end(); it++)
1000  {
1001  ArmarXObjectSchedulerPtr scheduler = it->second;
1002  scheduler->wakeupDependencyCheck();
1003  }
1004  }
1005  catch (...)
1006  {
1007  throw;
1008  }
1009 
1010  }
1011 
1012  void ArmarXManager::removeAllObjects(bool blocking)
1013  {
1014  ObjectSchedulerMap tempMap;
1015  {
1016  std::scoped_lock lock(managedObjectsMutex);
1017  tempMap = managedObjects;
1018  }
1019 
1020  for (auto& it : tempMap)
1021  {
1022  removeObject(it.second, false);
1023  }
1024 
1025  if (blocking)
1026  {
1027  for (auto objectScheduler : terminatingObjects)
1028  {
1029  objectScheduler->waitForTermination();
1030 
1031  }
1032 
1033  terminatingObjects.clear();
1034  }
1035 
1036  }
1037 
1038 
1039  bool ArmarXManager::removeObject(const ArmarXObjectSchedulerPtr& objectScheduler, bool blocking)
1040  {
1041  if (!objectScheduler)
1042  {
1043  return true;
1044  }
1045 
1046  const std::string objName = objectScheduler->getObject()->getName();
1047 
1048  try
1049  {
1050  iceManager->removeObject(objName);
1051  {
1052  std::scoped_lock lock2(managedObjectsMutex);
1053  managedObjects.erase(objectScheduler->getObject()->getName());
1054  }
1055  // terminate
1056  objectScheduler->terminate();
1057 
1058  if (blocking)
1059  {
1060  objectScheduler->waitForTermination();
1061  ARMARX_VERBOSE << "Blocking removal of ManagedIceObject " << objName << " finished";
1062  }
1063  else // only move to terminating list if delayed removal
1064  {
1065  ARMARX_VERBOSE << "Inserting ManagedIceObject into delayed removal list: " << objName;
1066  std::scoped_lock lockTerm(terminatingObjectsMutex);
1067  terminatingObjects.push_back(objectScheduler);
1068  }
1069 
1070  return true;
1071  }
1072  catch (...)
1073  {
1074  ARMARX_ERROR << "Removing of object '" << objName << "' failed with an exception!\n" << GetHandledExceptionString();
1075  }
1076 
1077  return false;
1078  }
1079 
1080 
1081 
1082  //bool ArmarXManager::removeObject(const ObjectSchedulerMap::iterator& iter, bool blocking)
1083  //{
1084  // if (iter != managedObjects.end())
1085  // {
1086  // const std::string objName = iter->second->getObject()->getName();
1087 
1088  // try
1089  // {
1090 
1091  // ARMARX_VERBOSE << "Removing ManagedIceObject " << objName << " - blocking = " << blocking;
1092 
1093 
1094  // ArmarXObjectSchedulerPtr objectScheduler = iter->second;
1095 
1096 
1097  // // managedObjects.erase(iter);
1098  // return removeObject(objectScheduler, blocking);
1099  // }
1100  // catch (...)
1101  // {
1102  // ARMARX_ERROR << "Removing of object '" << objName << "' failed with an exception!";
1103  // handleExceptions();
1104  // }
1105  // }
1106 
1107  // return false;
1108  //}
1109 
1110  ArmarXObjectSchedulerPtr ArmarXManager::findObjectScheduler(const std::string& objectName) const
1111  {
1112  std::scoped_lock lock(managedObjectsMutex);
1113  auto it = managedObjects.find(objectName);
1114  if (it != managedObjects.end())
1115  {
1116  return it->second;
1117  }
1118  else
1119  {
1120  return ArmarXObjectSchedulerPtr();
1121  }
1122  }
1123 
1124  void ArmarXManager::checkDependencies()
1125  {
1126 
1127 
1128  auto lock = acquireManagedObjectsMutex();
1129  if (!lock)
1130  {
1131  return;
1132  }
1133 
1134  try
1135  {
1136  ObjectSchedulerMap::const_iterator it = managedObjects.begin();
1137 
1138  for (; it != managedObjects.end(); it++)
1139  {
1140  const ArmarXObjectSchedulerPtr& scheduler = it->second;
1141 
1142  if (scheduler->getObjectState() == eManagedIceObjectStarted && !scheduler->checkDependenciesStatus())
1143  {
1144  scheduler->disconnected(true);
1145  }
1146  }
1147  }
1148  catch (...)
1149  {
1150  throw;
1151  }
1152 
1153  }
1154 
1155  auto ArmarXManager::acquireManagedObjectsMutex() -> ScopedRecursiveLockPtr
1156  {
1157  // assure no state change until lock of managedObjectsMutex
1158  std::scoped_lock lock(managerStateMutex);
1159 
1160  if (managerState >= eShutdownInProgress)
1161  {
1162  return ScopedRecursiveLockPtr();
1163  }
1164 
1165  // lock access to managed objects
1166  ScopedRecursiveLockPtr lock2(new std::scoped_lock<std::recursive_mutex>(managedObjectsMutex));
1167 
1168  return lock2;
1169  }
1170 
1171  void ArmarXManager::installProcessFacet()
1172  {
1173  ApplicationPtr appInstance = Application::getInstance();
1174  Ice::CommunicatorPtr applicationCommunicator = getCommunicator();
1175  ARMARX_CHECK_EXPRESSION(applicationCommunicator);
1176  // remove default Ice::Process facet
1177  if (applicationCommunicator->findAdminFacet("Process"))
1178  {
1179  applicationCommunicator->removeAdminFacet("Process");
1180  }
1181  // create and register new Ice::Process facet
1182  Ice::ProcessPtr applicationProcessFacet = new ApplicationProcessFacet(*this);
1183  applicationCommunicator->addAdminFacet(applicationProcessFacet, "Process");
1184 
1185  IcePropertyChangeCallbackPtr propertyChangeCallback = new IcePropertyChangeCallback(appInstance);
1186 
1187  Ice::ObjectPtr obj = applicationCommunicator->findAdminFacet("Properties");
1188  Ice::NativePropertiesAdminPtr admin = Ice::NativePropertiesAdminPtr::dynamicCast(obj);
1189  if (admin)
1190  {
1191  admin->addUpdateCallback(propertyChangeCallback);
1192  }
1193  else
1194  {
1195  ARMARX_WARNING << "Could not get properties admin - online property changing will not work";
1196  }
1197 
1198  // activate new Ice::Process facet and PropertyChangeCallback
1199  applicationCommunicator->getAdmin();
1200  }
1201 
1203 
1205  {
1206  std::unique_lock lock(FactoryCollectionBase_RegistrationListMutex());
1207 
1209  {
1210  //ARMARX_INFO_S << "looking for " << preregistration->getFactories();
1211  for (const auto& id2factory : preregistration->getFactories())
1212  {
1213  if (!ic->getValueFactoryManager()->find(id2factory.first))
1214  {
1215  //ARMARX_IMPORTANT_S << "adding object factory for " << id2factory.first;
1216  ic->getValueFactoryManager()->add(id2factory.second, id2factory.first);
1217  }
1218  }
1219  }
1220 
1221  }
1222 
1224  {
1226  }
1227 
1229  {
1230  return armarxManagerAdapter;
1231  }
1232 
1233  const std::shared_ptr<SharedRemoteHandleState>& ArmarXManager::getSharedRemoteHandleState() const
1234  {
1235  return sharedRemoteHandleState;
1236  }
1237 
1239  {
1240  std::scoped_lock lock(schedulerListMutex);
1241  for (int i = 0; i < increaseBy; ++i)
1242  {
1243  singleThreadedSchedulers.push_back(new ArmarXMultipleObjectsScheduler());
1244  }
1245  }
1246 
1247  bool LoadLibFromAbsolutePath(const std::string& path)
1248  {
1249  //these variables should be shared between ArmarXManager -> use static variables
1250  static std::map<std::string, DynamicLibraryPtr> loadedLibs;
1251  static std::mutex libsMutex;
1252  std::lock_guard<std::mutex> guard {libsMutex};
1253  if (loadedLibs.count(path))
1254  {
1255  return true;
1256  }
1257  DynamicLibraryPtr lib(new DynamicLibrary());
1258  try
1259  {
1260  lib->load(path);
1261  }
1262  catch (...)
1263  {
1264  handleExceptions();
1265  return false;
1266  }
1267 
1268  if (lib->isLibraryLoaded())
1269  {
1270  ARMARX_INFO << "Loaded library " << path;
1271  loadedLibs[path] = lib;
1272  }
1273  else
1274  {
1275  ARMARX_ERROR << "Could not load lib " + path + ": " + lib->getErrorMessage();
1276  return false;
1277  }
1278  return true;
1279  }
1280 // bool ArmarXManager::loadLibFromPath(const std::string& path)
1281 // {
1282 // std::string absPath;
1283 // if (ArmarXDataPath::getAbsolutePath(path, absPath))
1284 // {
1285 // return LoadLibFromAbsolutePath(absPath);
1286 // }
1287 // ARMARX_ERROR << "Could not find library " + path;
1288 // return false;
1289 // }
1290 // bool ArmarXManager::loadLibFromPackage(const std::string& package, const std::string& libname)
1291 // {
1292 // CMakePackageFinder finder(package);
1293 // if (!finder.packageFound())
1294 // {
1295 // ARMARX_ERROR << "Could not find package '" << package << "'";
1296 // return false;
1297 // }
1298 //
1299 // for (auto libDirPath : Split(finder.getLibraryPaths(), ";"))
1300 // {
1301 // std::filesystem::path fullPath = libDirPath;
1302 // fullPath /= "lib" + libname + "." + DynamicLibrary::GetSharedLibraryFileExtension();
1303 // if (!std::filesystem::exists(fullPath))
1304 // {
1305 // fullPath = libDirPath;
1306 // fullPath /= libname;
1307 // if (!std::filesystem::exists(fullPath))
1308 // {
1309 // continue;
1310 // }
1311 // }
1312 // if (LoadLibFromAbsolutePath(fullPath.string()))
1313 // {
1314 // return true;
1315 // }
1316 // }
1317 // ARMARX_ERROR << "Could not find library " << libname << " in package " << package;
1318 // return false;
1319 // }
1320 
1321 
1322  StringVariantBaseMap armarx::ArmarXManager::getMetaInfo(const std::string& objectName, const Ice::Current&)
1323  {
1324  std::scoped_lock lock(managedObjectsMutex);
1325  StringStringDictionary propertyMap;
1326  ObjectSchedulerMap::iterator iter = managedObjects.find(objectName);
1327 
1328  if (iter == managedObjects.end())
1329  {
1330  return StringVariantBaseMap();
1331  }
1332 
1333  return iter->second->getObject()->getMetaInfoMap();
1334  }
1335 }
armarx::ArmarXManager::setComponentIceProperties
void setComponentIceProperties(const Ice::PropertiesPtr &properties)
Calls Component::setIceProperties() on all components assigend to this ArmarXManager Instance.
Definition: ArmarXManager.cpp:720
armarx::ArmarXManager::getApplicationPropertyInfos
ObjectPropertyInfos getApplicationPropertyInfos(const ::Ice::Current &) override
Definition: ArmarXManager.cpp:695
armarx::ArmarXManager::addObjectAsync
virtual void addObjectAsync(const ManagedIceObjectPtr &object, const std::string &objectName, bool addWithOwnAdapter=true, bool useOwnScheduleThread=true)
Definition: ArmarXManager.cpp:315
armarx::ArmarXManager::getObjectPropertyInfos
ObjectPropertyInfos getObjectPropertyInfos(const ::std::string &objectName, const ::Ice::Current &) override
Definition: ArmarXManager.cpp:668
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::MessageTypeT
MessageTypeT
Definition: LogSender.h:45
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
armarx::IceManager
The IceManager class provides simplified access to commonly used Ice features.
Definition: IceManager.h:106
armarx::Logging::minimumLoggingLevel
MessageTypeT minimumLoggingLevel
Definition: Logging.h:272
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::ArmarXManager::waitForShutdown
void waitForShutdown()
Wait for shutdown.
Definition: ArmarXManager.cpp:400
armarx::DynamicLibraryPtr
std::shared_ptr< DynamicLibrary > DynamicLibraryPtr
Definition: DynamicLibrary.h:123
armarx::ArmarXManager::ArmarXManager
ArmarXManager(std::string applicationName, int port=4061, std::string host="localhost", std::string locatorName="IceGrid/Locator", Ice::StringSeq args=Ice::StringSeq())
ArmarXManager constructor.
Definition: ArmarXManager.cpp:98
armarx::IcePropertyChangeCallbackPtr
IceUtil::Handle< IcePropertyChangeCallback > IcePropertyChangeCallbackPtr
Definition: ArmarXManager.cpp:787
armarx::LogSender::SetGlobalMinimumLoggingLevel
static void SetGlobalMinimumLoggingLevel(MessageTypeT level)
With setGlobalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set for the whol...
Definition: LogSender.cpp:677
armarx::ProxyType::component
@ component
ArmarXManager.h
armarx::SharedRemoteHandleState
This holds the shared state of all RemoteHandleControlBlocks for one armarx manager.
Definition: RemoteHandleControlBlock.h:52
armarx::ArmarXManager::enableProfiling
void enableProfiling(bool enable)
Enable or disable profiling of CPU Usage.
Definition: ArmarXManager.cpp:212
DynamicLibrary.h
armarx::ArmarXManager::getAdapter
const Ice::ObjectAdapterPtr & getAdapter() const
Definition: ArmarXManager.cpp:1228
armarx::ArmarXManager::CheckIceConnection
static bool CheckIceConnection(const Ice::CommunicatorPtr &communicator, bool printHint)
Definition: ArmarXManager.cpp:132
armarx::IcePropertyChangeCallback
Definition: ArmarXManager.cpp:767
armarx::LogSender::SetSendLoggingActivated
static void SetSendLoggingActivated(bool activated=true)
Definition: LogSender.cpp:708
armarx::ArmarXManager::increaseSchedulers
void increaseSchedulers(int increaseBy)
increased the number of single threaded schedulers.
Definition: ArmarXManager.cpp:1238
armarx::ArmarXManager::getMetricsAdmin
IceMX::MetricsAdminPrx getMetricsAdmin(const Ice::Current &=Ice::emptyCurrent) override
Definition: ArmarXManager.cpp:593
armarx::ArmarXManager::isShutdown
bool isShutdown()
Whether ArmarXManager shutdown has been finished.
Definition: ArmarXManager.cpp:516
PeriodicTask.h
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
FactoryCollectionBase.h
armarx::ThreadList::getApplicationThreadList
static ThreadListPtr getApplicationThreadList()
getApplicationThreadList retrieves the ThreadList, that contains all TimerTasks and PeriodicTasks in ...
Definition: ThreadList.cpp:189
armarx::ManagedIceObject::GetObjectStateAsString
static std::string GetObjectStateAsString(int state)
Definition: ManagedIceObject.cpp:213
armarx::ArmarXManager::getMetaInfo
StringVariantBaseMap getMetaInfo(const std::string &, const Ice::Current &) override
Definition: ArmarXManager.cpp:1322
ArmarXObjectObserver.h
armarx::ArmarXManager::getManagedObjects
std::vector< ManagedIceObjectPtr > getManagedObjects() override
Retrieve pointers to all ManagedIceObject.
Definition: ArmarXManager.cpp:537
IceInternal::Handle< ::Ice::Communicator >
armarx::ArmarXManager::PeriodicTask< ArmarXManager >
friend class PeriodicTask< ArmarXManager >
Definition: ArmarXManager.h:102
armarx::GetHandledExceptionString
std::string GetHandledExceptionString()
Definition: Exception.cpp:147
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::ArmarXManager::getHostname
std::string getHostname(const Ice::Current &c=Ice::emptyCurrent) override
Gets the hostname of the host running the manager.
Definition: ArmarXManager.cpp:565
armarx::IcePropertyChangeCallback::IcePropertyChangeCallback
IcePropertyChangeCallback(armarx::ApplicationPtr application)
Definition: ArmarXManager.cpp:771
LocalTimeServer.h
armarx::ArmarXManager::getSharedRemoteHandleState
const std::shared_ptr< SharedRemoteHandleState > & getSharedRemoteHandleState() const
Definition: ArmarXManager.cpp:1233
Property.h
ManagedIceObject.h
armarx::ArmarXManager::updateComponentIceProperties
void updateComponentIceProperties(const Ice::PropertyDict &properties)
Definition: ArmarXManager.cpp:732
armarx::ArmarXManager::getPropertiesAdmin
Ice::PropertiesAdminPrx getPropertiesAdmin(const Ice::Current &=Ice::emptyCurrent) override
Definition: ArmarXManager.cpp:712
armarx::ArmarXManager::removeObjectNonBlocking
void removeObjectNonBlocking(const ManagedIceObjectPtr &object) override
Removes an object from the manager.
Definition: ArmarXManager.cpp:392
armarx::ArmarXManager::addObject
void addObject(const ManagedIceObjectPtr &object, bool addWithOwnAdapter=true, const std::string &objectName="", bool useOwnScheduleThread=true) override
Add a ManagedIceObject to the manager.
Definition: ArmarXManager.cpp:233
RemoteHandleControlBlock.h
armarx::ArmarXObjectScheduler
Takes care of the lifecycle management of ManagedIceObjects.
Definition: ArmarXObjectScheduler.h:74
armarx::FactoryCollectionBase::PreregistrationList
static std::vector< FactoryCollectionBasePtr > & PreregistrationList()
Definition: FactoryCollectionBase.cpp:57
armarx::RemoteReferenceCountControlBlockManager
Definition: RemoteReferenceCount.h:250
ThreadList.h
armarx::ArmarXManager::enableLogging
void enableLogging(bool enable)
Enable or disable logging.
Definition: ArmarXManager.cpp:206
armarx::ArmarXMultipleObjectsScheduler
Definition: ArmarXMultipleObjectsScheduler.h:37
IceManager.h
ArmarXObjectScheduler.h
IceGridAdmin.h
armarx::ApplicationPtr
IceUtil::Handle< Application > ApplicationPtr
Definition: Application.h:93
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::ArmarXManager::checkIceConnection
bool checkIceConnection(bool printHint=true) const
Definition: ArmarXManager.cpp:127
armarx::ArmarXManager::ArmarXObjectObserver
friend class ArmarXObjectObserver
Definition: ArmarXManager.h:103
armarx::Application::getInstance
static ApplicationPtr getInstance()
Retrieve shared pointer to the application object.
Definition: Application.cpp:289
armarx::ArmarXObjectSchedulerPtr
IceUtil::Handle< ArmarXObjectScheduler > ArmarXObjectSchedulerPtr
Definition: ArmarXFwd.h:33
armarx::ArmarXDataPath::initDataPaths
static void initDataPaths(const std::string &dataPathList)
Definition: ArmarXDataPath.cpp:477
armarx::ArmarXManager::getObjectState
ManagedIceObjectState getObjectState(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Retrieve state of a ManagedIceObject.
Definition: ArmarXManager.cpp:605
Component.h
armarx::ArmarXManager::getObjectNames
Ice::StringSeq getObjectNames(const Ice::Current &c=Ice::emptyCurrent) override
Retrieve the names of all ManagedIceObject.
Definition: ArmarXManager.cpp:572
armarx::ArmarXManager::getObjectProperties
::armarx::StringStringDictionary getObjectProperties(const ::std::string &objectName, const ::Ice::Current &=Ice::emptyCurrent) override
getObjectProperties is used to retrieve the properties of an object
Definition: ArmarXManager.cpp:647
ExpressionException.h
Ice
Definition: DBTypes.cpp:64
armarx::TimeUtil::SetTimeServer
static void SetTimeServer(LocalTimeServerPtr ts)
Definition: TimeUtil.cpp:99
armarx::ArmarXManager::getMiceObjectConnectivity
mice::MiceObjectConnectivity getMiceObjectConnectivity(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Retrieve connectivity of a ManagedIceObject.
Definition: ArmarXManager.cpp:577
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
armarx::LogSender::SetLoggingActivated
static void SetLoggingActivated(bool activated=true, bool showMessage=true)
setLoggingActivated() is used to activate or disable the logging facilities in the whole application
Definition: LogSender.cpp:694
TimeUtil.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ArmarXManager::setDataPaths
void setDataPaths(std::string dataPaths)
Set data paths used to search for datafiles.
Definition: ArmarXManager.cpp:223
armarx::ArmarXManager::getObjectConnectivity
ManagedIceObjectConnectivity getObjectConnectivity(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Retrieve connectivity of a ManagedIceObject.
Definition: ArmarXManager.cpp:625
armarx::LogSender::setProxy
static void setProxy(const std::string &componentName, LogPrx logProxy)
Definition: LogSender.cpp:136
IceUtil::Handle< ArmarXObjectScheduler >
LogSender.h
IceInternal::ProxyHandle< ::IceProxy::armarx::Log >
armarx::FactoryCollectionBase_RegistrationListMutex
std::mutex & FactoryCollectionBase_RegistrationListMutex()
Definition: FactoryCollectionBase.cpp:35
armarx::SharedRemoteHandleState::DEFAULT_DELETION_DELAY
static const unsigned int DEFAULT_DELETION_DELAY
The amount of time (in ms) required to pass after a RemoteHandleControlBlock's usecount has reacht ze...
Definition: RemoteHandleControlBlock.h:58
armarx::ArmarXManager::getManagedObjectNames
Ice::StringSeq getManagedObjectNames(const Ice::Current &c=Ice::emptyCurrent) override
Retrieve the names of all ManagedIceObject.
Definition: ArmarXManager.cpp:745
ManagedIceObjectRegistryInterface.h
armarx::Logging::deactivateSpam
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
Definition: Logging.cpp:92
armarx::IceManager::GetTopicManager
static IceStorm::TopicManagerPrx GetTopicManager(Ice::CommunicatorPtr communicator)
Definition: IceManager.cpp:263
armarx::ArmarXManager::removeObjectBlocking
void removeObjectBlocking(const ManagedIceObjectPtr &object) override
Removes an object from the manager.
Definition: ArmarXManager.cpp:387
armarx::LocalTimeServer::getApplicationTimeServer
static LocalTimeServerPtr getApplicationTimeServer()
Get the applications LocalTimeServer instance.
Definition: LocalTimeServer.cpp:109
armarx::ArmarXManager::registerKnownObjectFactoriesWithIce
void registerKnownObjectFactoriesWithIce()
non static convenience version of ArmarXManager::RegisterKnownObjectFactoriesWithIce()
Definition: ArmarXManager.cpp:1223
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
armarx::Logging::setTag
void setTag(const LogTag &tag)
Definition: Logging.cpp:55
armarx::DynamicLibrary
The DynamicLibrary class provides a mechanism to load libraries at runtime.
Definition: DynamicLibrary.h:49
ArmarXMultipleObjectsScheduler.h
Logging.h
armarx::ArmarXManager::shutdown
void shutdown()
Shuts down the ArmarXManager.
Definition: ArmarXManager.cpp:418
armarx::ScopedRecursiveLockPtr
std::shared_ptr< ScopedRecursiveLock > ScopedRecursiveLockPtr
Definition: Synchronization.h:143
armarx::handleExceptions
void handleExceptions()
Definition: Exception.cpp:141
armarx::ArmarXManager::~ArmarXManager
~ArmarXManager() override
Definition: ArmarXManager.cpp:121
ApplicationProcessFacet.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::LoadLibFromAbsolutePath
bool LoadLibFromAbsolutePath(const std::string &path)
Definition: ArmarXManager.cpp:1247
armarx::ArmarXManager::getCommunicator
const Ice::CommunicatorPtr & getCommunicator() const
Definition: ArmarXManager.cpp:532
ArmarXDataPath.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
Exception.h
armarx::ArmarXManager::RegisterKnownObjectFactoriesWithIce
static void RegisterKnownObjectFactoriesWithIce(const Ice::CommunicatorPtr &ic)
Registers all object factories that are known with Ice.
Definition: ArmarXManager.cpp:1204
armarx::ArmarXManager::asyncShutdown
void asyncShutdown(std::size_t timeoutMs=0)
Calls shutdown() after a timeout.
Definition: ArmarXManager.cpp:507
Application.h
armarx::ArmarXManager::setGlobalMinimumLoggingLevel
void setGlobalMinimumLoggingLevel(MessageTypeT minimumLoggingLevel)
Set minimum logging level to output in log stream.
Definition: ArmarXManager.cpp:218
armarx::IcePropertyChangeCallback::updated
void updated(const Ice::PropertyDict &changes) override
Definition: ArmarXManager.cpp:776
armarx::ArmarXManager::getIceManager
const IceManagerPtr & getIceManager() const
Retrieve the instance of the icemanager.
Definition: ArmarXManager.cpp:527