6 Copyright (C) 2009-2014     8     RT-Synthesis Research Group     9     Intelligent Systems Research Institute,    10     National Institute of Advanced Industrial Science and Technology (AIST),    13 Licensed under the Eclipse Public License -v 1.0 (EPL)    14 http://www.opensource.org/licenses/eclipse-1.0.txt    16 Object representing a manager node in the tree.    21 from omniORB 
import CORBA, TRANSIENT_ConnectFailed, UNKNOWN_UserException
    27                                FailedToCreateComponentError, \
    28                                FailedToDeleteComponentError, \
    29                                FailedToSetConfigurationError, \
    30                                FailedToAddMasterManagerError, \
    31                                FailedToRemoveMasterManagerError, \
    32                                FailedToAddSlaveManagerError, \
    33                                FailedToRemoveSlaveManagerError
    43     '''Node representing a manager on a name server.    45     Manager nodes can occur below name server and directory nodes. They may    46     store child components and child managers. They can be used to add and    47     remove new components and managers to the tree at run time.    50     def __init__(self, name=None, parent=None, obj=None, *args, **kwargs):
    51         '''Constructor. Calls the TreeNode constructor.'''    52         super(Manager, self).
__init__(name=name, parent=parent, *args,
    61         '''Create a component out of a loaded module.    63         Turns a previously-loaded shared module into a component in the    64         manager. This will invalidate any objects that are children of this    67         The @ref module_name argument can contain options that set various    68         properties of the new component. These must be appended to the module    69         name, prefixed by a question mark for each property, in key=value    70         format. For example, to change the instance name of the new component,    71         append '?instance_name=new_name' to the module name.    73         @param module_name Name of the module to turn into a component.    74         @raises FailedToCreateComponentError    78             if not self._obj.create_component(module_name):
    79                 raise FailedToCreateComponentError(module_name)
    85         '''Delete a component.    87         Deletes the component specified by @ref instance_name from the manager.    88         This will invalidate any objects that are children of this node.    90         @param instance_name The instance name of the component to delete.    91         @raises FailedToDeleteComponentError    95             if self._obj.delete_component(instance_name) != RTC.RTC_OK:
    96                 raise FailedToDeleteComponentError(instance_name)
   102         '''Load a shared library.   104         Call this function to load a shared library (DLL file under Windows,   105         shared object under UNIX) into the manager.   107         @param path The path to the shared library.   108         @param init_func The name entry function in the library.   109         @raises FailedToLoadModuleError   114                 if self._obj.load_module(path, init_func) != RTC.RTC_OK:
   116         except CORBA.UNKNOWN, e:
   117             if e.args[0] == UNKNOWN_UserException:
   123         '''Unload a loaded shared library.   125         Call this function to remove a shared library (e.g. a component) that   126         was previously loaded.   128         @param path The path to the shared library.   129         @raises FailedToUnloadModuleError   133             if self._obj.unload_module(path) != RTC.RTC_OK:
   134                 raise FailedToUnloadModuleError(path)
   138         '''The list of components in this manager, if any.   140         This information can also be found by listing the children of this node   141         that are of type @ref Component. That method is more useful as it returns   142         the tree entries for the components.   152         '''The factory profiles of all loaded modules.'''   156                 for fp 
in self._obj.get_factory_profiles():
   164         '''Set a configuration parameter of the manager.   166         @param The parameter to set.   167         @value The new value for the parameter.   168         @raises FailedToSetConfigurationError   172             if self._obj.set_configuration(param, value) != RTC.RTC_OK:
   173                 raise FailedToSetConfigurationError(param, value)
   179         '''The configuration dictionary of the manager.'''   187         '''The manager's profile.'''   190                 profile = self._obj.get_profile()
   198         '''Fork the manager.'''   203         '''Shut down the manager.'''   208         '''Restart the manager.'''   217         '''Is this node a directory?'''   222         '''Is this node a manager?'''   228         '''The RTM::Manager object that this node contains.'''   234         '''Is this manager node a master manager?   236         Master managers have a direct presence on the name server. Slave   237         managers are only present as children of other managers.   241             return self._obj.is_master()
   245         '''The list of loadable module profile dictionaries.'''   249                 for mp 
in self._obj.get_loadable_modules():
   255         '''The list of loaded module profile dictionaries.'''   259                 for mp 
in self._obj.get_loaded_modules():
   265         '''The list of master managers of this manager, if any.   267         If this manager is a master, this list will be empty.   272                 raise NotImplementedError
   277         '''The list of slave managers of this manager, if any.   279         This information can also be found by listing the children of this node   280         that are of type @ref Manager.   295             if self._obj.add_master_manager(new_master.object) != RTC.RTC_OK:
   296                 raise FailedToAddMasterManagerError
   304             if self._obj.add_save_manager(new_slave.object) != RTC.RTC_OK:
   305                 raise FailedToAddSlaveManagerError(self.
name, new_slave.name)
   330                 comps = self._obj.get_components()
   331             except CORBA.BAD_PARAM, e:
   332                 print >>sys.stderr, 
'{0}: {1}'.format(
   333                         os.path.basename(sys.argv[0]), e)
   337                 profile = c.get_component_profile()
   338                 instance_name = profile.instance_name
   340                 leaf = 
Component(instance_name + 
'.rtc', self, c)
   347                 mgrs = self._obj.get_slave_managers()
   348             except CORBA.BAD_OPERATION:
   356                 except CORBA.TRANSIENT, e:
   357                     if e.args[0] == TRANSIENT_ConnectFailed:
   358                         print >>sys.stderr, 
'{0}: Warning: zombie slave of '\
   359                                 'manager {1} found'.format(sys.argv[0],
   367                     name = 
'slave{0}'.format(index)
   376             if self._obj.remove_master_manager(master.object) != RTC.RTC_OK:
   377                 raise FailedToRemoveMasterManagerError
   384             if self._obj.remove_slave_manager(slave.object) != RTC.RTC_OK:
   385                 raise FailedToRemoveSlaveManagerError(self.
name, slave.name)
   394                 if self.parent.is_manager:
   395                     self.parent._remove_slave(self)
   398             new_parent._add_slave(self)
 
def _parse_manager_children(self)
def _add_master(self, new_master)
Internal functions. 
def __init__(self, name=None, parent=None, obj=None, args, kwargs)
def _parse_children(self)
def _add_slave(self, new_slave)
def unload_module(self, path)
def loadable_modules(self)
def load_module(self, path, init_func)
def fork(self)
Undocumented functions. 
def create_component(self, module_name)
Module and component management. 
def factory_profiles(self)
def _add_child(self, new_child)
def _remove_slave(self, slave)
def _remove_master(self, master)
def _parse_component_children(self)
def nvlist_to_dict(nvlist)
def delete_component(self, instance_name)
def is_directory(self)
Node functionality. 
def set_config_parameter(self, param, value)
Manager configuration. 
def _set_parent(self, new_parent)