[openrtm-commit:03062] r915 - trunk/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 1月 17日 (水) 09:43:18 JST
Author: miyamoto
Date: 2018-01-17 09:43:18 +0900 (Wed, 17 Jan 2018)
New Revision: 915
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/Factory.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/FactoryInit.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/NodeNumberingPolicy.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/NumberingPolicy.py
Log:
[compat,bugfix,->RELENG_1_2] fixed bug.
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Factory.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Factory.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Factory.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -239,7 +239,7 @@
FactoryBase.__init__(self, profile)
if policy is None:
- self._policy = OpenRTM_aist.DefaultNumberingPolicy()
+ self._policy = OpenRTM_aist.ProcessUniquePolicy()
else:
self._policy = policy
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/FactoryInit.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/FactoryInit.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/FactoryInit.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -42,7 +42,7 @@
OpenRTM_aist.InPortSHMConsumerInit()
OpenRTM_aist.OutPortSHMProviderInit()
OpenRTM_aist.OutPortSHMConsumerInit()
- OpenRTM_aist.DefaultNumberingPolicyInit()
+ OpenRTM_aist.ProcessUniquePolicyInit()
OpenRTM_aist.NodeNumberingPolicyInit()
OpenRTM_aist.NamingServiceNumberingPolicyInit()
OpenRTM_aist.LogstreamFileInit()
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -450,10 +450,8 @@
for i in range(len(mods)):
if mods[i] is None or mods[i] == "":
continue
- tmp = [mods[i]]
- OpenRTM_aist.eraseHeadBlank(tmp)
- OpenRTM_aist.eraseTailBlank(tmp)
- mods[i] = tmp[0]
+ mods[i] = mods[i].strip()
+
basename = os.path.basename(mods[i]).split(".")[0]
basename += "Init"
@@ -1452,10 +1450,6 @@
lmpm_ = [s.strip() for s in self._config.getProperty("manager.preload.modules").split(",")]
for mpm_ in lmpm_:
- tmp = [mpm_]
- OpenRTM_aist.eraseHeadBlank(tmp)
- OpenRTM_aist.eraseTailBlank(tmp)
- mpm_ = tmp[0]
if len(mpm_) == 0:
continue
basename_ = mpm_.split(".")[0]+"Init"
@@ -1730,7 +1724,15 @@
def initORB(self):
self._rtcout.RTC_TRACE("Manager.initORB()")
try:
- args = OpenRTM_aist.split(self.createORBOptions(), " ")
+ tmp_args = self.createORBOptions().split("\"")
+ args = []
+ for i in range(len(tmp_args)):
+ if i%2 == 0:
+ args.extend(tmp_args[i].split(" "))
+ else:
+ args.append(tmp_args[i])
+
+
args.insert(0,"manager")
argv = OpenRTM_aist.toArgv(args)
@@ -2317,7 +2319,7 @@
tm.set_time(duration)
if self._timer:
self._timer.registerListenerObj(self._mgrservant,
- OpenRTM_aist.ManagerServant.update_master_manager,
+ OpenRTM_aist.ManagerServant.updateMasterManager,
tm)
otherref = None
@@ -3083,14 +3085,13 @@
connectors = str(self._config.getProperty("manager.components.preconnect")).split(",")
for c in connectors:
- tmp = [c]
- OpenRTM_aist.eraseHeadBlank(tmp)
- OpenRTM_aist.eraseTailBlank(tmp)
- c = tmp[0]
+ c = c.strip()
if len(c) == 0:
continue
conn_prop = c.split("(")
- if len(conn_prop) < 2:
+ if len(conn_prop) == 1:
+ conn_prop.append("dataflow_type=push&interface_type=corba_cdr")
+ elif len(conn_prop) < 2:
self._rtcout.RTC_ERROR("Invalid format for pre-connection.")
continue
conn_prop[1] = conn_prop[1].replace(")","")
@@ -3159,14 +3160,8 @@
for o in opt_props:
temp = o.split("=")
if len(temp) == 2:
- s = [temp[0]]
- OpenRTM_aist.eraseHeadBlank(s)
- OpenRTM_aist.eraseTailBlank(s)
- temp[0] = s[0]
- s = [temp[1]]
- OpenRTM_aist.eraseHeadBlank(s)
- OpenRTM_aist.eraseTailBlank(s)
- temp[1] = s[0]
+ temp[0] = temp[0].strip()
+ temp[1] = temp[1].strip()
prop.setProperty("dataport."+temp[0],temp[1])
if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect(c, prop, port0_var, port1_var):
@@ -3192,11 +3187,9 @@
self._rtcout.RTC_TRACE("Components pre-activation: %s" % str(self._config.getProperty("manager.components.preactivation")))
comps = str(self._config.getProperty("manager.components.preactivation")).split(",")
for c in comps:
- tmp = [c]
- OpenRTM_aist.eraseHeadBlank(tmp)
- OpenRTM_aist.eraseTailBlank(tmp)
- c = tmp[0]
+ c = c.strip()
if c:
+ comp_ref = None
if c.find("://") == -1:
comp = self.getComponent(c)
if comp is None:
@@ -3233,10 +3226,7 @@
for i in range(len(comps)):
if comps[i] is None or comps[i] == "":
continue
- tmp = [comps[i]]
- OpenRTM_aist.eraseHeadBlank(tmp)
- OpenRTM_aist.eraseTailBlank(tmp)
- comps[i] = tmp[0]
+ comps[i] = comps[i].strip()
self.createComponent(comps[i])
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -481,11 +481,11 @@
self._rtcout.RTC_TRACE("create_component(%s)", module_name)
- rtc = self.create_component_by_address(module_name)
+ rtc = self.createComponentByAddress(module_name)
if not CORBA.is_nil(rtc):
return rtc
- rtc = self.create_component_by_mgrname(module_name)
+ rtc = self.createComponentByManagerName(module_name)
if not CORBA.is_nil(rtc):
return rtc
@@ -494,8 +494,8 @@
#module_name = module_name.split("&")[0]
module_name = [module_name]
- self.get_parameter_by_modulename("manager_address",module_name)
- manager_name = self.get_parameter_by_modulename("manager_name",module_name)
+ self.getParameterByModulename("manager_address",module_name)
+ manager_name = self.getParameterByModulename("manager_name",module_name)
module_name = module_name[0]
comp_param = CompParam(module_name)
@@ -522,7 +522,7 @@
if not manager_name:
module_name = module_name + "&manager_name=manager_%p"
- rtc = self.create_component_by_mgrname(module_name)
+ rtc = self.createComponentByManagerName(module_name)
return rtc
else:
@@ -1178,9 +1178,9 @@
# @param manager_name
# @return
# @endif
- # RTC::Manager_ptr findManager_by_name(string manager_name)
- def findManager_by_name(self, manager_name):
- self._rtcout.RTC_TRACE("findManager_by_name(manager_name = %s)", manager_name)
+ # RTC::Manager_ptr findManagerByName(string manager_name)
+ def findManagerByName(self, manager_name):
+ self._rtcout.RTC_TRACE("findManagerByName(manager_name = %s)", manager_name)
prop = self._mgr.getConfig()
name = prop.getProperty("manager.instance_name")
if name == manager_name:
@@ -1252,8 +1252,8 @@
# @param module_name
# @return
# @endif
- # std::string get_parameter_by_modulename(string param_name, string &module_name)
- def get_parameter_by_modulename(self, param_name, module_name):
+ # std::string getParameterByModulename(string param_name, string &module_name)
+ def getParameterByModulename(self, param_name, module_name):
arg = module_name[0]
pos0 = arg.find("&"+param_name+"=")
pos1 = arg.find("?"+param_name+"=")
@@ -1263,11 +1263,13 @@
if pos0 == -1 and pos1 == -1:
return ""
+ pos = 0
if pos0 == -1:
pos = pos1
else:
pos = pos0
+ paramstr = ""
endpos = arg.find('&', pos + 1)
if endpos == -1:
endpos = arg.find('?', pos + 1)
@@ -1316,14 +1318,14 @@
# @param module_name
# @return
# @endif
- # RTC::RTObject_ptr create_component_by_mgrname(string module_name)
- def create_component_by_mgrname(self, module_name):
+ # RTC::RTObject_ptr createComponentByManagerName(string module_name)
+ def createComponentByManagerName(self, module_name):
arg = module_name
tmp = [arg]
- mgrstr = self.get_parameter_by_modulename("manager_name",tmp)
+ mgrstr = self.getParameterByModulename("manager_name",tmp)
arg = tmp[0]
if not mgrstr:
@@ -1333,7 +1335,7 @@
if mgrstr == "manager_%p":
mgrobj = RTM.Manager._nil
else:
- mgrobj = self.findManager_by_name(mgrstr)
+ mgrobj = self.findManagerByName(mgrstr)
@@ -1373,16 +1375,7 @@
self._rtcout.RTC_DEBUG("Invoking command: %s.", cmd)
-
- ret = OpenRTM_aist.launch_shell(cmd)
-
- if ret == -1:
- self._rtcout.RTC_DEBUG("%s: failed", cmd)
- return RTC.RTObject._nil
- time.sleep(0.01)
- count = 0
-
slaves_names = []
regex = r'manager_[0-9]+'
if mgrstr == "manager_%p":
@@ -1402,6 +1395,19 @@
del guard_slave
+
+
+ ret = OpenRTM_aist.launch_shell(cmd)
+
+
+ if ret == -1:
+ self._rtcout.RTC_DEBUG("%s: failed", cmd)
+ return RTC.RTObject._nil
+ time.sleep(0.01)
+ count = 0
+
+
+
t0_ = OpenRTM_aist.Time()
while CORBA.is_nil(mgrobj):
@@ -1425,7 +1431,7 @@
del guard_slave
else:
- mgrobj = self.findManager_by_name(mgrstr)
+ mgrobj = self.findManagerByName(mgrstr)
count += 1
if count > 1000:
break
@@ -1482,12 +1488,12 @@
# @param module_name
# @return
# @endif
- # RTC::RTObject_ptr create_component_by_address(string module_name)
- def create_component_by_address(self, module_name):
+ # RTC::RTObject_ptr createComponentByAddress(string module_name)
+ def createComponentByAddress(self, module_name):
arg = module_name
tmp = [arg]
- mgrstr = self.get_parameter_by_modulename("manager_address",tmp)
+ mgrstr = self.getParameterByModulename("manager_address",tmp)
arg = tmp[0]
if not mgrstr:
@@ -1495,7 +1501,7 @@
mgrvstr = mgrstr.split(":")
if len(mgrvstr) != 2:
- self._rtcout.RTC_WARN("Invalid manager name: %s", mgrstr)
+ self._rtcout.RTC_WARN("Invalid manager address: %s", mgrstr)
return RTC.RTObject._nil
@@ -1579,8 +1585,8 @@
# @brief
# @param self
# @endif
- # void update_master_manager()
- def update_master_manager(self):
+ # void updateMasterManager()
+ def updateMasterManager(self):
if not self._isMaster and self._objref:
guard = OpenRTM_aist.ScopedLock(self._masterMutex)
if len(self._masters) > 0:
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -256,7 +256,11 @@
self._rtcout.RTC_TRACE("isAlive()")
return self._cosnaming.isAlive()
+ def getCorbaNaming(self):
+ self._rtcout.RTC_TRACE("getCorbaNaming()")
+ return self._cosnaming
+
##
# @if jp
#
@@ -275,13 +279,13 @@
# @else
#
# @endif
- def get_RTC_by_Name(self, context, name, rtcs):
+ def getComponentByName(self, context, name, rtcs):
length = 500
bl,bi = context.list(length)
for i in bl:
if i.binding_type == CosNaming.ncontext:
next_context = context.resolve(i.binding_name)
- self.get_RTC_by_Name(next_context, name, rtcs)
+ self.getComponentByName(next_context, name, rtcs)
elif i.binding_type == CosNaming.nobject:
if i.binding_name[0].id == name and i.binding_name[0].kind == "rtc":
@@ -289,7 +293,8 @@
cc = OpenRTM_aist.CorbaConsumer()
cc.setObject(context.resolve(i.binding_name))
obj = cc.getObject()._narrow(RTC.RTObject)
- rtcs.append(obj)
+ if not obj._non_existent():
+ rtcs.append(obj)
except:
self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
@@ -325,6 +330,7 @@
rtc_name = url[len(host)+1:]
try:
+ cns = None
if host == "*":
cns = self._cosnaming
else:
@@ -334,7 +340,7 @@
if len(names) == 2 and names[0] == "*":
root_cxt = cns.getRootContext()
- self.get_RTC_by_Name(root_cxt, names[1], rtc_list)
+ self.getComponentByName(root_cxt, names[1], rtc_list)
return rtc_list
else:
rtc_name += ".rtc"
@@ -379,10 +385,14 @@
#
# @param self
# @param orb ORB
- # @param names NamingServer ̾¾Î
+ # @param mgr ¥Þ¥Í¡¼¥¸¥ã
#
# @else
#
+ # @param self
+ # @param orb ORB
+ # @param mgr
+ #
# @endif
def __init__(self, orb, mgr):
self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf('manager.namingonmanager')
@@ -478,7 +488,7 @@
#
# @param name rtcloc·Á¼°¤Ç¤ÎRTC̾
# rtcloc://localhost:2809/example/ConsoleIn
- # @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹
+ # @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È
#
# @else
#
@@ -503,7 +513,7 @@
rtc_name = url[len(host)+1:]
mgr = self.getManager(host)
- if mgr:
+ if not CORBA.is_nil(mgr):
rtc_list = mgr.get_components_by_name(rtc_name)
slaves = mgr.get_slave_managers()
@@ -521,6 +531,8 @@
# @if jp
#
# @brief »ØÄê¥Û¥¹¥È̾¡¢¥Ý¡¼¥È̾¤ÇManager¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ
+ #
+ # @param name ¥Û¥¹¥È̾¡¢¥Ý¡¼¥È̾
#
# @return Manager¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹
#
@@ -536,6 +548,7 @@
def getManager(self, name):
if name == "*":
mgr_sev = self._mgr.getManagerServant()
+ mgr = None
if mgr_sev.is_master():
mgr = mgr_sev.getObjRef()
else:
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -77,6 +77,7 @@
return num_str
else:
num += 1
+ return OpenRTM_aist.otos(num)
##
# @if jp
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/NodeNumberingPolicy.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/NodeNumberingPolicy.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/NodeNumberingPolicy.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -74,6 +74,7 @@
return num_str
else:
num += 1
+ return OpenRTM_aist.otos(num)
##
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/NumberingPolicy.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/NumberingPolicy.py 2018-01-16 06:46:58 UTC (rev 914)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/NumberingPolicy.py 2018-01-17 00:43:18 UTC (rev 915)
@@ -95,7 +95,7 @@
##
# @if jp
#
-# @class DefaultNumberingPolicy
+# @class ProcessUniquePolicy
# @brief ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®»þ¥Í¡¼¥ß¥ó¥°¡¦¥Ý¥ê¥·¡¼(̿̾µ¬Â§)´ÉÍýÍÑ¥¯¥é¥¹
#
# ¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ëºÝ¤Î¥Í¡¼¥ß¥ó¥°¡¦¥Ý¥ê¥·¡¼(̿̾µ¬Â§)¤ò´ÉÍý¤¹¤ë¤¿¤á¤Î
@@ -106,7 +106,7 @@
# @else
#
# @endif
-class DefaultNumberingPolicy(NumberingPolicy):
+class ProcessUniquePolicy(NumberingPolicy):
"""
"""
@@ -209,8 +209,11 @@
raise NumberingPolicy.ObjectNotFound()
-def DefaultNumberingPolicyInit():
+def ProcessUniquePolicyInit():
+ OpenRTM_aist.NumberingPolicyFactory.instance().addFactory("default",
+ OpenRTM_aist.ProcessUniquePolicy,
+ OpenRTM_aist.Delete)
OpenRTM_aist.NumberingPolicyFactory.instance().addFactory("process_unique",
- OpenRTM_aist.DefaultNumberingPolicy,
+ OpenRTM_aist.ProcessUniquePolicy,
OpenRTM_aist.Delete)
More information about the openrtm-commit
mailing list