[openrtm-commit:02721] r862 - trunk/OpenRTM-aist-Python/OpenRTM_aist

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 8月 2日 (水) 16:59:55 JST


Author: miyamoto
Date: 2017-08-02 16:59:55 +0900 (Wed, 02 Aug 2017)
New Revision: 862

Modified:
   trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
   trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
Log:
[incompat,->RELENG_1_2] refs #4149 , refs #4150

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py	2017-07-26 07:04:25 UTC (rev 861)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py	2017-08-02 07:59:55 UTC (rev 862)
@@ -875,12 +875,18 @@
   #
   def createComponent(self, comp_args):
     self._rtcout.RTC_TRACE("Manager.createComponent(%s)", comp_args)
-    self._listeners.rtclifecycle_.preCreate(comp_args)
+    
     comp_prop = OpenRTM_aist.Properties()
     comp_id   = OpenRTM_aist.Properties()
 
     if not self.procComponentArgs(comp_args, comp_id, comp_prop):
       return None
+    
+    comp = self.getComponent(comp_prop)
+    if comp:
+      return comp
+    
+    self._listeners.rtclifecycle_.preCreate(comp_args)
 
     if comp_prop.findNode("exported_ports"):
       exported_ports = OpenRTM_aist.split(comp_prop.getProperty("exported_ports"),
@@ -2469,29 +2475,36 @@
   #                        coil::Properties& comp_conf)
   def procComponentArgs(self, comp_arg, comp_id, comp_conf):
     id_and_conf = [s.strip() for s in comp_arg.split("?")]
+    
     if len(id_and_conf) != 1 and len(id_and_conf) != 2:
       self._rtcout.RTC_ERROR("Invalid arguments. Two or more '?'")
       return False
 
+    prof = OpenRTM_aist.CompParam.prof_list
+    param_num = len(prof)
+
+    
     if id_and_conf[0].find(":") == -1:
-      id_and_conf[0] = "RTC:::" + id_and_conf[0] + ":"
+      id_and_conf[0] = prof[0] + ":::" + id_and_conf[0] + ":"
 
     id = [s.strip() for s in id_and_conf[0].split(":")]
+    
 
-    if len(id) != 5:
+    if len(id) != param_num:
       self._rtcout.RTC_ERROR("Invalid RTC id format.")
       return False
 
-    prof = ["RTC", "vendor", "category", "implementation_id", "version"]
+    #prof = ["RTC", "vendor", "category", "implementation_id", "language", "version"]
 
     if id[0] != prof[0]:
       self._rtcout.RTC_ERROR("Invalid id type.")
       return False
 
-    for i in [1,2,3,4]:
+    for i in range(1,param_num):
       comp_id.setProperty(prof[i], id[i])
       self._rtcout.RTC_TRACE("RTC basic profile %s: %s", (prof[i], id[i]))
-
+    
+    
     if len(id_and_conf) == 2:
       conf = [s.strip() for s in id_and_conf[1].split("&")]
       for i in range(len(conf)):
@@ -2604,7 +2617,7 @@
         self._rtcout.RTC_DEBUG(type_prop)
         if self._config.findNode("config_file"):
           config_fname.append(self._config.getProperty("config_file"))
-
+    
     comp.setProperties(prop)
     type_prop.mergeProperties(name_prop)
     type_prop.setProperty("config_file",OpenRTM_aist.flatten(OpenRTM_aist.unique_sv(config_fname)))

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py	2017-07-26 07:04:25 UTC (rev 861)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py	2017-08-02 07:59:55 UTC (rev 862)
@@ -25,9 +25,152 @@
 import re
 
 
+##
+# @if jp
+# @class CompParam
+# @brief CompParam ¥¯¥é¥¹
+#
+# RTC¤Î¥Ù¥ó¥À̾¡¢¥«¥Æ¥´¥ê̾¡¢ID¡¢¸À¸ì¡¢¥Ð¡¼¥¸¥ç¥ó¤ò³ÊǼ¤¹¤ë¹½Â¤ÂÎ
+#
+# @since 1.2.0
+#
+# @else
+# @class CompParam
+# @brief CompParam class
+# @endif
+class CompParam:
+  prof_list = ["RTC", "vendor", "category", "implementation_id", "language", "version"]
+  ##
+  # @if jp
+  # @brief ¥³¥ó¥¹¥È¥é¥¯¥¿
+  #
+  # ¥³¥ó¥¹¥È¥é¥¯¥¿
+  #
+  # @param self
+  # @param module_name ¥â¥¸¥å¡¼¥ë̾
+  #
+  # @else
+  # @brief Constructor
+  #
+  # @param self
+  # @param module_name 
+  #
+  # @endif
+  def __init__(self, module_name):
+    module_name = module_name.split("?")[0]
+    param_list = module_name.split(":")
+    if len(param_list) < len(CompParam.prof_list):
+      self._type = "RTC"
+      self._vendor = ""
+      self._category = ""
+      self._impl_id = module_name
+      self._language = "Python"
+      self._version = ""
+    else:
+      self._type = param_list[0]
+      self._vendor = param_list[1]
+      self._category = param_list[2]
+      self._impl_id = param_list[3]
+      if param_list[4]:
+        self._language = param_list[4]
+      else:
+        self._language = "Python"
+      self._version = param_list[5]
+    
+    
+  ##
+  # @if jp
+  # @brief ¥Ù¥ó¥À̾¼èÆÀ
+  #
+  # 
+  #
+  # @param self
+  # @return ¥Ù¥ó¥À̾
+  #
+  # @else
+  # @brief 
+  #
+  # @param self
+  # @return 
+  #
+  # @endif
+  def vendor(self):
+    return self._vendor
+  ##
+  # @if jp
+  # @brief ¥«¥Æ¥´¥ê̾¼èÆÀ
+  #
+  # 
+  #
+  # @param self
+  # @return ¥«¥Æ¥´¥ê̾
+  #
+  # @else
+  # @brief 
+  #
+  # @param self
+  # @return 
+  #
+  # @endif
+  def category(self):
+    return self._category
+  ##
+  # @if jp
+  # @brief ID¼èÆÀ
+  #
+  # 
+  #
+  # @param self
+  # @return ID
+  #
+  # @else
+  # @brief 
+  #
+  # @param self
+  # @return 
+  #
+  # @endif
+  def impl_id(self):
+    return self._impl_id
+  ##
+  # @if jp
+  # @brief ¸À¸ì¼èÆÀ
+  #
+  # 
+  #
+  # @param self
+  # @return ¸À¸ì
+  #
+  # @else
+  # @brief 
+  #
+  # @param self
+  # @return 
+  #
+  # @endif
+  def language(self):
+    return self._language
+  ##
+  # @if jp
+  # @brief ¥Ð¡¼¥¸¥ç¥ó¼èÆÀ
+  #
+  # 
+  #
+  # @param self
+  # @return ¥Ð¡¼¥¸¥ç¥ó
+  #
+  # @else
+  # @brief 
+  #
+  # @param self
+  # @return 
+  #
+  # @endif
+  def version(self):
+    return self._version
+  
+  
 
-
-
 class ManagerServant(RTM__POA.Manager):
   """
   """
@@ -354,10 +497,11 @@
     self.get_parameter_by_modulename("manager_address",module_name)
     manager_name = self.get_parameter_by_modulename("manager_name",module_name)
     module_name = module_name[0]
-    tmp = [module_name]
-    language = self.get_parameter_by_modulename("language",tmp)
+
+    comp_param = CompParam(module_name)
     
     
+    
     if self._isMaster:
       guard = OpenRTM_aist.ScopedLock(self._slaveMutex)
       for slave in self._slaves[:]:
@@ -366,7 +510,7 @@
           prop = OpenRTM_aist.Properties()
           OpenRTM_aist.NVUtil.copyToProperties(prop, prof)
           slave_lang = prop.getProperty("manager.language")
-          if slave_lang == language:
+          if slave_lang == comp_param.language():
             rtc = slave.create_component(module_name)
             if not CORBA.is_nil(rtc):
               return rtc
@@ -1090,9 +1234,6 @@
 
     return RTM.Manager._nil
 
-
-
-
   ##
   # @if jp
   # @brief ¥â¥¸¥å¡¼¥ë̾¤«¤é¥Ñ¥é¥á¡¼¥¿¤ò¼è¤ê½Ð¤¹
@@ -1111,7 +1252,7 @@
   # @param module_name
   # @return 
   # @endif
-  # RTC::RTObject_ptr get_parameter_by_modulename(string param_name, string &module_name)
+  # std::string get_parameter_by_modulename(string param_name, string &module_name)
   def get_parameter_by_modulename(self, param_name, module_name):
     arg = module_name[0]
     pos0 = arg.find("&"+param_name+"=")
@@ -1195,11 +1336,8 @@
       mgrobj = self.findManager_by_name(mgrstr)
     
 
-    tmp = [arg]
-    language = self.get_parameter_by_modulename("language",tmp)
-    arg = tmp[0]
-    if not language:
-      language = "Python"
+
+    comp_param = CompParam(arg)
     
     
     
@@ -1208,7 +1346,7 @@
     if CORBA.is_nil(mgrobj):
       self._rtcout.RTC_WARN("%s cannot be found.", mgrstr)
       config = copy.deepcopy(self._mgr.getConfig())
-      rtcd_cmd = config.getProperty("manager.modules."+language+".manager_cmd")
+      rtcd_cmd = config.getProperty("manager.modules."+comp_param.language()+".manager_cmd")
       
       if not rtcd_cmd:
         rtcd_cmd = "rtcd_python"
@@ -1215,7 +1353,7 @@
       #rtcd_cmd = "rtcd_python.bat"
 
       load_path = config.getProperty("manager.modules.load_path")
-      load_path_language = config.getProperty("manager.modules."+language+".load_paths")
+      load_path_language = config.getProperty("manager.modules."+comp_param.language()+".load_paths")
       load_path = load_path + "," + load_path_language
       
       if platform.system() == "Windows":
@@ -1228,7 +1366,7 @@
       cmd += " -o " + "manager.name:" + config.getProperty("manager.name")
       cmd += " -o " + "manager.instance_name:" + mgrstr
       cmd += " -o " + "\"manager.modules.load_path:" + load_path + "\""
-      cmd += " -o " + "manager.supported_languages:" + language
+      cmd += " -o " + "manager.supported_languages:" + comp_param.language()
       cmd += " -o " + "manager.shutdown_auto:NO"
       
       
@@ -1364,21 +1502,19 @@
     # find manager
     mgrobj = self.findManager(mgrstr)
 
-    tmp = [arg]
-    language = self.get_parameter_by_modulename("language",tmp)
-    arg = tmp[0]
-    if not language:
-      language = "Python"
 
+    comp_param = CompParam(arg)
+    
 
+
     if CORBA.is_nil(mgrobj):
       config = copy.deepcopy(self._mgr.getConfig())
-      rtcd_cmd = config.getProperty("manager.modules."+language+".manager_cmd")
+      rtcd_cmd = config.getProperty("manager.modules."+comp_param.language()+".manager_cmd")
       if not rtcd_cmd:
         rtcd_cmd = "rtcd_python"
 
       load_path = config.getProperty("manager.modules.load_path")
-      load_path_language = config.getProperty("manager.modules."+language+".load_path")
+      load_path_language = config.getProperty("manager.modules."+comp_param.language()+".load_path")
       load_path = load_path + "," + load_path_language
 
       if platform.system() == "Windows":



More information about the openrtm-commit mailing list