Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions OpenRTM_aist/CORBA_RTCUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,3 +1769,192 @@ def getPort(self):
# @endif
def isAddressOnly(self):
return self._addressonly


##
# @if jp
# @class RTCURIObject クラス
# @brief RTCURIObject クラス
# rtcname形式、rtcloc形式のURIから通信先のアドレス、RTC名等を
# 取得する機能を提供するクラス
# rtcname形式は以下のようにrtcname.{通信プロトコル}/{アドレス}/{ネームサーバーでの登録パス}
# で指定可能である。通信プロトコルを省略するとiiopに設定する。
#
# rtcname.ssliop://localhost:2809/test.host_cxt/ConsoleOut0
#
# ただし、http通信を指定する場合は以下のようにアドレスの後は#で区切る必要がある。
#
# rtcname.https://localhost:2809/call#test.host_cxt/ConsoleOut0
#
# rtcloc形式は以下のようにrtcloc.{通信プロトコル}/{アドレス}/{カテゴリ名}/{RTC名}
# で指定可能である。通信プロトコルを省略するとiiopに設定する。
#
# rtcloc.ssliop://localhost:2810/example/ConsoleOut0
#
# ただし、http通信を指定する場合は以下のようにアドレスの後は#で区切る必要がある。
#
# rtcloc.http://localhost:2810/call#example/ConsoleOut0
#
# @since 2.0.0
#
# @else
# @class RTCURIObject class
# @brief RTCURIObject class
# @brief
#
# @since 2.0.0
#
# @endif
class RTCURIObject:
##
# @if jp
#
# @brief コンストラクタ
#
# @param uri rtcname形式、もしくはrtcloc形式のURI
# @param isrtcname rtcname形式を指定する場合はtrue、それ以外はfalse
# @param isrtcloc rtcloc形式を指定する場合はtrue、それ以外はfalse
#
# @else
#
# @brief Consructor
#
#
# @param uri
# @param isrtcname
# @param isrtcloc
#
# @endif
def __init__(self, uri, isrtcname=False, isrtcloc=False):
self._is_rtcname = False
self._is_rtcloc = False
self._rtcpath = ""
self._address = ""
pos = uri.find("://")
if pos >= 0:
ptype = uri[0:pos]
addrname = uri[pos+3:]
protocol = ""

if ptype.find("rtcname") == 0:
self._is_rtcname = True
elif ptype.find("rtcloc") == 0:
self._is_rtcloc = True
else:
return

if isrtcname:
if not self._is_rtcname:
return

if isrtcloc:
if not self._is_rtcloc:
return

pos = ptype.find(".")
seprtc = "/"
if pos >= 0:
protocol = ptype[pos+1:]
if protocol == "http" or protocol == "https" or protocol == "ws" or protocol == "wss":
seprtc = "#"

pos = addrname.find(seprtc)
hostport = ""

if pos >= 0:
hostport = addrname[0:pos]
self._rtcpath = addrname[pos+1:]
else:
hostport = addrname

if hostport != "*":
if protocol == "http" or protocol == "https" or protocol == "ws" or protocol == "wss":
self._address = protocol
self._address += "://"
self._address += hostport

else:
self._address = "corbaloc:"
self._address += protocol
self._address += ":"
self._address += hostport
else:
self._address = hostport

##
# @if jp
#
# @brief RTC名を取得する
#
# rtcname形式の場合はネームサーバーに登録したRTCのパスを取得できる。
# context1.kind1/context2.kind2/..../RTC_name
#
# rtcloc形式の場合はカテゴリ名/RTC名で取得できる。
#
# @return RTC名
#
# @else
#
# @brief
#
# @return
#
# @endif
def getRTCName(self):
return self._rtcpath

##
# @if jp
#
# @brief 通信先のアドレスを取得する
#
#
# @return 通信先のアドレス
#
# @else
#
# @brief
#
# @return
#
# @endif
def getAddress(self):
return self._address

##
# @if jp
#
# @brief URIがrtcname形式かを判定する
#
# @return true:rtcname形式、false:それ以外
#
# @return RTC名
#
# @else
#
# @brief
#
# @return
#
# @endif
def isRTCNameURI(self):
return self._is_rtcname

##
# @if jp
#
# @brief URIがrtcname形式かを判定する
#
# @brief URIがrtcloc形式かを判定する
#
# @return true:rtcname形式、false:それ以外
#
# @else
#
# @brief
#
# @return
#
# @endif
def isRTCLocURI(self):
return self._is_rtcloc
3 changes: 2 additions & 1 deletion OpenRTM_aist/CorbaNaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def __del__(self):
# @endif

def init(self, name_server):
self._nameServer = OpenRTM_aist.CORBA_RTCUtil.CorbaURI(name_server, "NameService").toString()
self._nameServer = OpenRTM_aist.CORBA_RTCUtil.CorbaURI(
name_server, "NameService").toString()
obj = self._orb.string_to_object(self._nameServer)
self._rootContext = obj._narrow(CosNaming.NamingContext)
if CORBA.is_nil(self._rootContext):
Expand Down
23 changes: 15 additions & 8 deletions OpenRTM_aist/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3215,9 +3215,12 @@ def initPreConnection(self):
if not ("interface_type" in configs.keys()):
configs["interface_type"] = "corba_cdr"

tmp = port0_str.split(".")
tmp.pop()
comp0_name = ".".join([x.strip() for x in tmp])
pos_port0 = port0_str.rfind(".")
comp0_name = ""
if pos_port0 >= 0:
comp0_name = port0_str[0:pos_port0]
else:
comp0_name = port0_str

port0_name = port0_str

Expand All @@ -3240,7 +3243,7 @@ def initPreConnection(self):
comp0_ref, port0_name)

if CORBA.is_nil(port0_var):
self._rtcout.RTC_DEBUG("port %s found: " % port0_str)
self._rtcout.RTC_DEBUG("port %s not found: " % port0_str)
continue

if not ports:
Expand All @@ -3257,9 +3260,13 @@ def initPreConnection(self):

for port_str in ports:

tmp = port_str.split(".")
tmp.pop()
comp_name = ".".join([x.strip() for x in tmp])
pos_port = port_str.rfind(".")
comp_name = ""
if pos_port >= 0:
comp_name = port_str[0:pos_port]
else:
comp_name = port_str

port_name = port_str

if comp_name.find("://") == -1:
Expand All @@ -3281,7 +3288,7 @@ def initPreConnection(self):
comp_ref, port_name)

if CORBA.is_nil(port_var):
self._rtcout.RTC_DEBUG("port %s found: " % port_str)
self._rtcout.RTC_DEBUG("port %s not found: " % port_str)
continue

prop = OpenRTM_aist.Properties()
Expand Down
Loading
Loading