[openrtm-commit:01776] r674 - trunk/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 2月 27日 (土) 16:51:41 JST
Author: miyamoto
Date: 2016-02-27 16:51:41 +0900 (Sat, 27 Feb 2016)
New Revision: 674
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py
Log:
[compat,bugfix,->RELENG_1_2] The bug of NamingOnCorba.string_to_component() has been fixed. refs #3401.
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py 2016-02-27 02:35:11 UTC (rev 673)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py 2016-02-27 07:51:41 UTC (rev 674)
@@ -22,6 +22,8 @@
import OpenRTM_aist
import CORBA
import RTM
+import RTC
+import CosNaming
##
@@ -255,6 +257,42 @@
return self._cosnaming.isAlive()
+ ##
+ # @if jp
+ #
+ # @brief RTCの検索
+ #
+ # ネーミングサービスからRTCをインスタンス名から検索し、
+ # 一致するRTCのリストを取得する
+ #
+ # @param self
+ # @param context 現在検索中のコンテキスト
+ # @param name RTCのインスタンス名
+ # @param rtcs RTCのリスト
+ #
+ # @return
+ #
+ # @else
+ #
+ # @endif
+ def get_RTC_by_Name(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)
+ elif i.binding_type == CosNaming.nobject:
+
+ if i.binding_name[0].id == name and i.binding_name[0].kind == "rtc":
+ try:
+ cc = OpenRTM_aist.CorbaConsumer()
+ cc.setObject(context.resolve(i.binding_name))
+ obj = cc.getObject()._narrow(RTC.RTObject)
+ rtcs.append(obj)
+ except:
+ self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
+
##
# @if jp
@@ -282,19 +320,28 @@
r = url.split("/")
if len(r) > 1:
host = r[0]
- rtc_name = url.replace(host+"/","")
+
+ rtc_name = url[len(host)+1:]
+
try:
if host == "*":
cns = self._cosnaming
else:
orb = OpenRTM_aist.Manager.instance().getORB()
cns = OpenRTM_aist.CorbaNaming(orb,host)
- rtc_name += ".rtc"
- obj = cns.resolveStr(rtc_name)
- if CORBA.is_nil(obj):
- return []
- rtc_list.append(obj)
- return rtc_list
+ names = rtc_name.split("/")
+
+ if len(names) == 2 and names[0] == "*":
+ root_cxt = cns.getRootContext()
+ self.get_RTC_by_Name(root_cxt, names[1], rtc_list)
+ return rtc_list
+ else:
+ rtc_name += ".rtc"
+ obj = cns.resolveStr(rtc_name)
+ if CORBA.is_nil(obj):
+ return []
+ rtc_list.append(obj)
+ return rtc_list
except:
return []
@@ -455,7 +502,7 @@
r = url.split("/")
if len(r) > 1:
host = r[0]
- rtc_name = url.replace(host+"/","")
+ rtc_name = url[len(host)+1:]
mgr = self.getManager(host)
if mgr:
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py 2016-02-27 02:35:11 UTC (rev 673)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingServiceNumberingPolicy.py 2016-02-27 07:51:41 UTC (rev 674)
@@ -10,13 +10,13 @@
import string
import OpenRTM_aist
-import CosNaming
+
##
# @if jp
#
@@ -94,35 +94,7 @@
def onDelete(self, obj):
pass
- ##
- # @if jp
- #
- # @brief RTCの検索
- #
- # ネーミングサービスからRTCをインスタンス名から検索し、
- # 一致するRTCがある場合はTrueを返す
- #
- # @param self
- # @param context 現在検索中のコンテキスト
- # @param name RTCのインスタンス名
- #
- # @return 判定
- #
- # @else
- #
- # @endif
- def find_RTC_by_Name(self, context, name):
- length = 500
- bl,bi = context.list(length)
- for i in bl:
- if i.binding_type == CosNaming.ncontext:
- next_context = context.resolve(i.binding_name)
- if self.find_RTC_by_Name(next_context, name):
- return True
- elif i.binding_type == CosNaming.nobject:
- if i.binding_name[0].id == name and i.binding_name[0].kind == "rtc":
- return True
- return False
+
@@ -143,19 +115,17 @@
#
# @endif
def find(self, name):
- ns = self._mgr._namingManager._names
- for n in ns:
- noc = n.ns
- if noc is None:
- continue
- cns = noc._cosnaming
- if cns is None:
- continue
- root_cxt = cns.getRootContext()
- return self.find_RTC_by_Name(root_cxt, name)
+ rtcs = []
+ rtc_name = "rtcname://*/*/"
+ rtc_name += name
+ rtcs = self._mgr._namingManager.string_to_component(rtc_name)
+
+ if len(rtcs) > 0:
+ return True
+ else:
+ return False
-
def NamingServiceNumberingPolicyInit():
OpenRTM_aist.NumberingPolicyFactory.instance().addFactory("ns_unique",
OpenRTM_aist.NamingServiceNumberingPolicy,
More information about the openrtm-commit
mailing list