22 from omniORB
import CORBA
24 import RTC,RTM,RTM__POA
46 self.
_mgr = OpenRTM_aist.Manager.instance()
56 config = copy.deepcopy(self.
_mgr.getConfig())
58 if OpenRTM_aist.toBool(config.getProperty(
"manager.is_master"),
"YES",
"NO",
True):
60 self.
_rtcout.RTC_TRACE(
"This manager is master.")
63 self.
_rtcout.RTC_WARN(
"Manager CORBA servant creation failed.")
67 self.
_rtcout.RTC_TRACE(
"Manager CORBA servant was successfully created.")
71 self.
_rtcout.RTC_TRACE(
"This manager is slave.")
73 owner = self.
findManager(config.getProperty(
"corba.master_manager"))
75 self.
_rtcout.RTC_INFO(
"Master manager not found")
79 self.
_rtcout.RTC_WARN(
"Manager CORBA servant creation failed.")
83 owner.add_slave_manager(self.
_objref)
86 self.
_rtcout.RTC_ERROR(
"Unknown exception cought.")
87 self.
_rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
115 for i
in range(len(self.
_slaves)):
117 if CORBA.is_nil(self.
_slaves[i]):
121 self.
_slaves[i] = RTM.Manager._nil
154 self.
_rtcout.RTC_TRACE(
"ManagerServant::load_module(%s, %s)", (pathname, initfunc))
155 self.
_mgr.load(pathname, initfunc)
180 self.
_rtcout.RTC_TRACE(
"ManagerServant::unload_module(%s)", pathname)
181 self.
_mgr.unload(pathname)
204 self.
_rtcout.RTC_TRACE(
"get_loadable_modules()")
207 prof = self.
_mgr.getLoadableModules()
208 cprof = [ RTM.ModuleProfile([])
for i
in prof ]
210 for i
in range(len(prof)):
235 self.
_rtcout.RTC_TRACE(
"get_loaded_modules()")
236 prof = self.
_mgr.getLoadedModules()
237 cprof = [RTM.ModuleProfile([])
for i
in prof]
239 for i
in range(len(prof)):
266 self.
_rtcout.RTC_TRACE(
"get_factory_profiles()")
267 prof = self.
_mgr.getFactoryProfiles()
268 cprof = [RTM.ModuleProfile([])
for i
in prof]
270 for i
in range(len(prof)):
296 self.
_rtcout.RTC_TRACE(
"create_component(%s)", module_name)
299 pos0 = arg.find(
"&manager=")
300 pos1 = arg.find(
"?manager=")
302 if pos0 == -1
and pos1 == -1:
304 rtc = self.
_mgr.createComponent(module_name)
306 return RTC.RTObject._nil
307 return rtc.getObjRef()
319 endpos = arg.find(
'&', pos + 1)
321 mgrstr = arg[(pos + 1):]
323 mgrstr = arg[(pos + 1): endpos]
324 self.
_rtcout.RTC_VERBOSE(
"Manager arg: %s", mgrstr)
325 mgrvstr = mgrstr.split(
":")
326 if len(mgrvstr) != 2:
327 self.
_rtcout.RTC_WARN(
"Invalid manager name: %s", mgrstr)
328 return RTC.RTObject._nil
330 eqpos = mgrstr.find(
"=")
332 self.
_rtcout.RTC_WARN(
"Invalid argument: %s", module_name)
333 return RTC.RTObject._nil
335 mgrstr = mgrstr[eqpos + 1:]
336 self.
_rtcout.RTC_DEBUG(
"Manager is %s", mgrstr)
340 if CORBA.is_nil(mgrobj):
341 cmd =
"rtcd_python -p " 344 self.
_rtcout.RTC_DEBUG(
"Invoking command: %s.", cmd)
345 ret = OpenRTM_aist.launch_shell(cmd)
347 self.
_rtcout.RTC_DEBUG(
"%s: failed", cmd)
348 return RTC.RTObject._nil
353 while CORBA.is_nil(mgrobj):
360 if CORBA.is_nil(mgrobj):
361 self.
_rtcout.RTC_WARN(
"Manager cannot be found.")
362 return RTC.RTObject._nil
368 arg = arg[:pos] + arg[endpos:]
369 self.
_rtcout.RTC_DEBUG(
"Creating component on %s", mgrstr)
370 self.
_rtcout.RTC_DEBUG(
"arg: %s", arg)
372 rtobj = mgrobj.create_component(arg)
373 self.
_rtcout.RTC_DEBUG(
"Component created %s", arg)
375 except CORBA.SystemException:
376 self.
_rtcout.RTC_DEBUG(
"Exception was caught while creating component.")
377 self.
_rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
378 return RTC.RTObject._nil
380 self.
_rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
382 return RTC.RTObject._nil
405 self.
_rtcout.RTC_TRACE(
"delete_component(%s)", instance_name)
406 self.
_mgr.deleteComponent(instance_name)
429 self.
_rtcout.RTC_TRACE(
"get_components()")
432 rtcs = self.
_mgr.getComponents()
436 crtcs.append(rtc.getObjRef())
439 self.
_rtcout.RTC_DEBUG(
"%d slave managers exists.", len(self.
_slaves))
440 for i
in range(len(self.
_slaves)):
442 if not CORBA.is_nil(self.
_slaves[i]):
447 self._RTC_INFO(
"slave (%d) has disappeared.", i)
448 self.
_slaves[i] = RTM.Manager._nil
477 rtcs = self.
_mgr.getComponents()
478 cprofs = [rtc.get_component_profile()
for rtc
in rtcs]
482 self.
_rtcout.RTC_DEBUG(
"%d slave managers exists.", len(self.
_slaves))
484 for i
in range(len(self.
_slaves)):
486 if not CORBA.is_nil(self.
_slaves[i]):
491 self.
_rtcout.RTC_INFO(
"slave (%d) has disappeared.", i)
492 self.
_slaves[i] = RTM.Manager._nil
520 self.
_rtcout.RTC_TRACE(
"get_profile()")
521 prof = RTM.ModuleProfile([])
546 self.
_rtcout.RTC_TRACE(
"get_configuration()")
575 self.
_rtcout.RTC_TRACE(
"set_configuration(name = %s, value = %s)", (name, value))
576 self.
_mgr.getConfig().setProperty(name, value)
609 self.
_rtcout.RTC_TRACE(
"is_master(): %s", ret)
636 self.
_rtcout.RTC_TRACE(
"get_master_managers()")
668 self.
_rtcout.RTC_TRACE(
"add_master_manager(), %d masters", len(self.
_masters))
672 self.
_rtcout.RTC_ERROR(
"Already exists.")
673 return RTC.BAD_PARAMETER
676 self.
_rtcout.RTC_TRACE(
"add_master_manager() done, %d masters", len(self.
_masters))
703 self.
_rtcout.RTC_TRACE(
"remove_master_manager(), %d masters", len(self.
_masters))
708 self.
_rtcout.RTC_ERROR(
"Not found.")
709 return RTC.BAD_PARAMETER
712 self.
_rtcout.RTC_TRACE(
"remove_master_manager() done, %d masters", len(self.
_masters))
741 self.
_rtcout.RTC_TRACE(
"get_slave_managers(), %d slaves", len(self.
_slaves))
767 self.
_rtcout.RTC_TRACE(
"add_slave_manager(), %d slaves", len(self.
_slaves))
772 self.
_rtcout.RTC_ERROR(
"Already exists.")
773 return RTC.BAD_PARAMETER
776 self.
_rtcout.RTC_TRACE(
"add_slave_manager() done, %d slaves", len(self.
_slaves))
803 self.
_rtcout.RTC_TRACE(
"remove_slave_manager(), %d slaves", len(self.
_slaves))
807 self.
_rtcout.RTC_ERROR(
"Not found.")
808 return RTC.BAD_PARAMETER
811 self.
_rtcout.RTC_TRACE(
"remove_slave_manager() done, %d slaves", len(self.
_slaves))
842 self.
_mgr.terminate()
872 return CORBA.Object._nil
901 poa = self.
_mgr.getORB().resolve_initial_references(
"omniINSPOA")
902 poa._get_the_POAManager().activate()
903 id = self.
_mgr.getConfig().getProperty(
"manager.name")
904 poa.activate_object_with_id(id, self)
905 mgrobj = poa.id_to_reference(id)
906 self.
_objref = mgrobj._narrow(RTM.Manager)
908 self.
_rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
925 self.
_rtcout.RTC_TRACE(
"findManager(host_port = %s)", host_port)
927 config = copy.deepcopy(self.
_mgr.getConfig())
928 mgrloc =
"corbaloc:iiop:" 930 mgrloc +=
"/" + config.getProperty(
"manager.name")
931 self.
_rtcout.RTC_DEBUG(
"corbaloc: %s", mgrloc)
933 mobj = self.
_mgr.getORB().string_to_object(mgrloc)
934 mgr = mobj._narrow(RTM.Manager)
937 except CORBA.SystemException:
938 self.
_rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
941 self.
_rtcout.RTC_ERROR(
"Unknown exception cought.")
942 self.
_rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
944 return RTM.Manager._nil
952 if not self.
_mgr or not mgr:
953 return self.
_mgr == mgr
955 return self.
_mgr._is_equivalent(mgr)
def get_loaded_modules(self)
Getting loaded module profiles.
def get_service(self, name)
Get the reference of RTC.
def erase(seq, index)
Erase the element of the specified index.
def createINSManager(self)
À®¸ù:true, ¼ºÇÔ:false.
def load_module(self, pathname, initfunc)
Loading a module.
def get_components(self)
Getting RT-Component list running on this manager.
def get_loadable_modules(self)
Getting loadable module profiles.
def push_back_list(seq1, seq2)
def set_configuration(self, name, value)
Setting manager's configuration.
def get_component_profiles(self)
Getting RT-Component's profile list running on this manager.
def push_back(seq, elem)
Push the new element back to the CORBA sequence.
def fork(self)
The copy of the process is generated.
def create_component(self, module_name)
Creating an RT-Component.
def __init__(self)
Constructor.
def remove_slave_manager(self, mgr)
Removing a slave manager.
def add_master_manager(self, mgr)
Getting a master manager.
def __del__(self)
Virtual destructor.
def shutdown(self)
This method shutdowns RTC.
def delete_component(self, instance_name)
Deleting an RT-Component.
def get_factory_profiles(self)
Getting component factory profiles.
def get_master_managers(self)
Getting master managers.
def get_configuration(self)
Getting this manager's configuration.
def get_profile(self)
Getting this manager's profile.
def get_slave_managers(self)
Getting slave managers.
def remove_master_manager(self, mgr)
Removing a master manager.
def findManager(self, host_port)
Find the reference of Manager.
def getObjRef(self)
Get the reference of Manager.
def unload_module(self, pathname)
Unloading a module.
def is_master(self)
Whether this manager is master or not.
def add_slave_manager(self, mgr)
Getting a slave manager.
def find(seq, f)
Return the index of CORBA sequence element that functor matches.
def copyFromProperties(nv, prop)
Copy to NVList from Proeprties.
def restart(self)
This method restarts RTC.