[openrtm-commit:01756] r657 - in trunk/OpenRTM-aist-Python/OpenRTM_aist: . RTM_IDL
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 2月 25日 (木) 06:26:48 JST
Author: miyamoto
Date: 2016-02-25 06:26:48 +0900 (Thu, 25 Feb 2016)
New Revision: 657
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/DefaultConfiguration.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/RTM_IDL/Manager.idl
Log:
[incompat,new_func,->RELENG_1_2] add string_to_component() to NamingManager. ref #3411
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/DefaultConfiguration.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/DefaultConfiguration.py 2016-02-24 20:49:49 UTC (rev 656)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/DefaultConfiguration.py 2016-02-24 21:26:48 UTC (rev 657)
@@ -75,6 +75,7 @@
"manager.auto_shutdown_duration", "10.0",
"manager.name", "manager",
"manager.command", "rtcd",
+ "manager.nameservers", "default",
"manager.language", "Python",
"manager.local_service.enabled_services","ALL",
"sdo.service.provider.enabled_service", "ALL",
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py 2016-02-24 20:49:49 UTC (rev 656)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py 2016-02-24 21:26:48 UTC (rev 657)
@@ -2541,6 +2541,8 @@
if noc is None:
continue
cns = noc._cosnaming
+ if cns is None:
+ continue
bl = cns.listByKind(nsname,kind)
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py 2016-02-24 20:49:49 UTC (rev 656)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py 2016-02-24 21:26:48 UTC (rev 657)
@@ -953,7 +953,47 @@
return RTM.Manager._nil
+ ##
+ # @if jp
+ # @brief 指定名のRTCを取得
+ # @param self
+ # @param name RTC名
+ # @return RTCのリスト
+ # @else
+ #
+ # @brief
+ # @param self
+ # @param name
+ # @return
+ # @endif
+ # RTCList get_components_by_name(string name)
+ def get_components_by_name(self, name):
+ self._rtcout.RTC_TRACE("get_components_by_name()")
+ rtcs = self._mgr.getComponents()
+ crtcs = []
+ tmp = [name]
+ name = OpenRTM_aist.eraseHeadBlank(tmp)
+ rtc_name = tmp[0].split("/")
+ for rtc in rtcs:
+ if len(rtc_name) == 1:
+ if rtc.getInstanceName() == rtc_name[0]:
+ crtcs.append(rtc.getObjRef())
+ else:
+ if rtc_name[0] == "*":
+ if rtc.getInstanceName() == rtc_name[1]:
+ crtcs.append(rtc.getObjRef())
+ else:
+ if rtc.getCategory() == rtc_name[0]:
+ if rtc.getInstanceName() == rtc_name[1]:
+ crtcs.append(rtc.getObjRef())
+
+
+
+
+ return crtcs
+
+
class is_equiv:
def __init__(self, mgr):
self._mgr = mgr
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py 2016-02-24 20:49:49 UTC (rev 656)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/NamingManager.py 2016-02-24 21:26:48 UTC (rev 657)
@@ -20,6 +20,8 @@
import sys
import OpenRTM_aist
+import CORBA
+import RTM
##
@@ -60,6 +62,8 @@
def bindObject(self, name, rtobj):
pass
+ def bindPortObject(self, name, port):
+ pass
##
# @if jp
@@ -97,7 +101,26 @@
def isAlive(self):
pass
+ ##
+ # @if jp
+ #
+ # @brief rtcloc形式でRTCのオブジェクトリファレンスを取得する
+ #
+ # @return RTCのオブジェクトリファレンス
+ #
+ # @else
+ #
+ # @brief
+ #
+ # @return
+ #
+ # @endif
+ #
+ # virtual RTCList string_to_component(string name) = 0;
+ def string_to_component(self, name):
+ return []
+
##
# @if jp
#
@@ -238,6 +261,205 @@
##
# @if jp
#
+# @class NamingOnManager
+# @brief Manager 用 NamingServer 管理クラス
+#
+#
+# @since 1.2.0
+#
+# @else
+#
+# @biref
+#
+# @endif
+class NamingOnManager(NamingBase):
+ """
+ """
+
+ ##
+ # @if jp
+ #
+ # @brief コンストラクタ
+ #
+ # コンストラクタ
+ #
+ # @param self
+ # @param orb ORB
+ # @param names NamingServer 名称
+ #
+ # @else
+ #
+ # @endif
+ def __init__(self, orb):
+ self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf('manager.namingonmanager')
+ self._cosnaming = None
+ #self.isMaster = isMaster
+ #self.masters = masters
+ #self.slaves = slaves
+ self._orb = orb
+
+
+ ##
+ # @if jp
+ #
+ # @brief
+ #
+ #
+ #
+ # @param self
+ # @param name バインド時の名称
+ # @param rtobj or mgr バインド対象オブジェクト
+ #
+ # @else
+ #
+ # @endif
+ def bindObject(self, name, rtobj):
+ """self._rtcout.RTC_TRACE("bindObject(name = %s, rtobj or mgr)", name)
+ print isinstance(rtobj, OpenRTM.ManagerServant)
+ if isinstance(rtobj, OpenRTM.ManagerServant):
+
+ self.manager = rtobj"""
+ return
+
+
+ ##
+ # @if jp
+ #
+ # @brief
+ #
+ #
+ # @param self
+ # @param name バインド時の名称
+ # @param port バインド対象オブジェクト
+ #
+ # @else
+ #
+ # @endif
+ def bindPortObject(self, name, port):
+ self._rtcout.RTC_TRACE("bindPortObject(name = %s, port)", name)
+
+ return
+
+
+ ##
+ # @if jp
+ #
+ # @brief
+ #
+ #
+ # @param self
+ # @param name アンバインド対象オブジェクト
+ #
+ # @else
+ #
+ # @endif
+ def unbindObject(self, name):
+ self._rtcout.RTC_TRACE("unbindObject(name = %s)", name)
+
+ return
+
+
+ ##
+ # @if jp
+ #
+ # @brief
+ #
+ # @return true:生存している, false:生存していない
+ #
+ # @else
+ #
+ # @brief Check if the name service is alive
+ #
+ # @return true: alive, false:non not alive
+ #
+ # @endif
+ #
+ # virtual bool isAlive();
+ def isAlive(self):
+ self._rtcout.RTC_TRACE("isAlive()")
+ return True
+
+ ##
+ # @if jp
+ #
+ # @brief rtcloc形式でRTCのオブジェクトリファレンスを取得する
+ #
+ # @param name rtcloc形式でのRTC名
+ # rtcloc://localhost:2809/example/ConsoleIn
+ # @return RTCのオブジェクトリファレンス
+ #
+ # @else
+ #
+ # @brief
+ #
+ # @return
+ #
+ # @endif
+ #
+ # virtual RTCList string_to_component();
+ def string_to_component(self, name):
+ rtc_list = []
+ tmp = name.split("//")
+ if len(tmp) > 1:
+ tag = tmp[0]
+ url = tmp[1]
+ r = url.split("/")
+ if len(r) > 1:
+ host = r[0]
+ rtc_name = url.replace(host+"/","")
+
+ mgr = self.getManager(host)
+ if mgr:
+ rtc_list = mgr.get_components_by_name(rtc_name)
+
+ slaves = mgr.get_slave_managers()
+ for ms in slaves:
+ rtc_list.extend(ms.get_components_by_name(rtc_name))
+
+ return rtc_list
+ return rtc_list
+
+ ##
+ # @if jp
+ #
+ # @brief 指定マネージャ名、ポート名でManagerのオブジェクトリファレンスを取得
+ #
+ # @return Managerのオブジェクトリファレンス
+ #
+ # @else
+ #
+ # @brief
+ #
+ # @return
+ #
+ # @endif
+ #
+ # virtual Manager_ptr getManager(string name);
+ def getManager(self, name):
+ try:
+ mgrloc = "corbaloc:iiop:"
+
+ manager_name = "manager"
+ mgrloc += name
+ mgrloc += "/" + manager_name
+
+ mobj = self._orb.string_to_object(mgrloc)
+ mgr = mobj._narrow(RTM.Manager)
+
+ self._rtcout.RTC_DEBUG("corbaloc: %s", mgrloc)
+ return mgr
+ except CORBA.SystemException:
+ self._rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
+ except:
+ self._rtcout.RTC_ERROR("Unknown exception cought.")
+ self._rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
+ return RTM.Manager._nil
+
+
+
+##
+# @if jp
+#
# @class NamingManager
# @brief NamingServer 管理クラス
#
@@ -291,7 +513,7 @@
# @brief NameServer の登録
#
# 指定した形式の NameServer を登録する。
- # 現在指定可能な形式は CORBA のみ。
+ # CORBAとManagerが指定可能
#
# @param self
# @param method NamingService の形式
@@ -305,8 +527,8 @@
(method, name_server))
name = self.createNamingObj(method, name_server)
self._names.append(self.NameServer(method, name_server, name))
+
-
##
# @if jp
#
@@ -538,6 +760,11 @@
(method, name_server))
return None
+
+ elif mth == "manager":
+
+ name = OpenRTM_aist.NamingOnManager(self._manager.getORB())
+ return name
return None
@@ -739,6 +966,31 @@
def getNameServices(self):
return self._names
+ ##
+ # @if jp
+ #
+ # @brief rtcloc形式でRTCのオブジェクトリファレンスを取得
+ #
+ # @param name rtcloc形式でのRTC名
+ # rtcloc://localhost:2809/example/ConsoleIn
+ # @return RTCのオブジェクトリファレンスのリスト
+ #
+ # @else
+ #
+ # @brief
+ #
+ # @return
+ #
+ # @endif
+ #
+ # RTCList string_to_component(string name);
+ def string_to_component(self, name):
+ for n in self._names:
+ comps = n.ns.string_to_component(name)
+ if len(comps) > 0:
+ return comps
+ return []
+
# Name Servers' method/name and object
##
# @if jp
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/RTM_IDL/Manager.idl
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/RTM_IDL/Manager.idl 2016-02-24 20:49:49 UTC (rev 656)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/RTM_IDL/Manager.idl 2016-02-24 21:26:48 UTC (rev 657)
@@ -450,6 +450,28 @@
RTC::ReturnCode_t shutdown();
RTC::ReturnCode_t restart();
+
+ /*!
+ * @if jp
+ * @brief 指定名のRTCオブジェクトリファレンスを取得
+ *
+ *
+ *
+ * @param name RTC名
+ * @return RTCリスト
+ *
+ * @else
+ * @brief
+ *
+ *
+ *
+ * @param name name
+ * @return list of RTC
+ *
+ * @endig
+ */
+ RTC::RTCList get_components_by_name(in string name);
+
Object get_service(in string name);
// ServiceProfileList get_service_profiles();
};
More information about the openrtm-commit
mailing list