PortBase.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
16 
17 
18 import threading
19 import copy
20 
21 import OpenRTM_aist
22 import RTC, RTC__POA
23 
24 
25 
26 
115 class PortBase(RTC__POA.PortService):
116  """
117  """
118 
119 
120 
121 
146  def __init__(self, name=None):
147  self._ownerInstanceName = "unknown"
148  self._objref = self._this()
149 
150  self._profile = RTC.PortProfile("", [], RTC.PortService._nil, [], RTC.RTObject._nil,[])
151  # Now Port name is <instance_name>.<port_name>. r1648
152  if name is None:
153  self._profile.name = "unknown.unknown"
154  else:
155  self._profile.name = self._ownerInstanceName+"."+name
156 
157  self._profile.port_ref = self._objref
158  self._profile.owner = RTC.RTObject._nil
159  self._profile_mutex = threading.RLock()
160  self._connection_mutex = threading.RLock()
161  self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf(name)
164  self._onConnected = None
166  self._onDisconnected = None
167  self._onConnectionLost = None
169  self._portconnListeners = None
170  return
171 
172 
173 
190  def __del__(self):
191  self._rtcout.RTC_TRACE("PortBase.__del__()")
192  try:
193  mgr = OpenRTM_aist.Manager.instance().getPOA()
194  oid = mgr.servant_to_id(self)
195  mgr.deactivate_object(oid)
196  except:
197  self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
198 
199 
200 
243  def get_port_profile(self):
244  self._rtcout.RTC_TRACE("get_port_profile()")
245 
246  self.updateConnectors()
247 
249 
250  prof = RTC.PortProfile(self._profile.name,
251  self._profile.interfaces,
252  self._profile.port_ref,
253  self._profile.connector_profiles,
254  self._profile.owner,
255  self._profile.properties)
256 
257  return prof
258 
259 
260 
285  def getPortProfile(self):
286  self._rtcout.RTC_TRACE("getPortProfile()")
287  return self._profile
288 
289 
290 
332  self._rtcout.RTC_TRACE("get_connector_profiles()")
333 
334  self.updateConnectors()
335 
337  return self._profile.connector_profiles
338 
339 
340 
366  def get_connector_profile(self, connector_id):
367  self._rtcout.RTC_TRACE("get_connector_profile(%s)", connector_id)
368 
369  self.updateConnectors()
370 
372  index = OpenRTM_aist.CORBA_SeqUtil.find(self._profile.connector_profiles,
373  self.find_conn_id(connector_id))
374  if index < 0:
375  conn_prof = RTC.ConnectorProfile("","",[],[])
376  return conn_prof
377 
378  conn_prof = RTC.ConnectorProfile(self._profile.connector_profiles[index].name,
379  self._profile.connector_profiles[index].connector_id,
380  self._profile.connector_profiles[index].ports,
381  self._profile.connector_profiles[index].properties)
382  return conn_prof
383 
384 
385 
543  def connect(self, connector_profile):
544  self._rtcout.RTC_TRACE("connect()")
545  if self.isEmptyId(connector_profile):
547  self.setUUID(connector_profile)
548  assert(not self.isExistingConnId(connector_profile.connector_id))
549  del guard
550  else:
552  if self.isExistingConnId(connector_profile.connector_id):
553  self._rtcout.RTC_ERROR("Connection already exists.")
554  return (RTC.PRECONDITION_NOT_MET,connector_profile)
555  del guard
556 
557  try:
558  retval,connector_profile = connector_profile.ports[0].notify_connect(connector_profile)
559  if retval != RTC.RTC_OK:
560  self._rtcout.RTC_ERROR("Connection failed. cleanup.")
561  self.disconnect(connector_profile.connector_id)
562 
563  return (retval, connector_profile)
564  #return connector_profile.ports[0].notify_connect(connector_profile)
565  except:
566  self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
567  return (RTC.BAD_PARAMETER, connector_profile)
568 
569  return (RTC.RTC_ERROR, connector_profile)
570 
571 
572 
688  def notify_connect(self, connector_profile):
689  self._rtcout.RTC_TRACE("notify_connect()")
690 
691  guard_connection = OpenRTM_aist.ScopedLock(self._connection_mutex)
692 
693  # publish owned interface information to the ConnectorProfile
694  retval = [RTC.RTC_OK for i in range(3)]
695 
696  self.onNotifyConnect(self.getName(),connector_profile)
697  retval[0] = self.publishInterfaces(connector_profile)
698  if retval[0] != RTC.RTC_OK:
699  self._rtcout.RTC_ERROR("publishInterfaces() in notify_connect() failed.")
700 
701  self.onPublishInterfaces(self.getName(), connector_profile, retval[0])
702  if self._onPublishInterfaces:
703  self._onPublishInterfaces(connector_profile)
704 
705  # call notify_connect() of the next Port
706  retval[1], connector_profile = self.connectNext(connector_profile)
707  if retval[1] != RTC.RTC_OK:
708  self._rtcout.RTC_ERROR("connectNext() in notify_connect() failed.")
709 
710  self.onConnectNextport(self.getName(), connector_profile, retval[1])
711  # subscribe interface from the ConnectorProfile's information
712  if self._onSubscribeInterfaces:
713  self._onSubscribeInterfaces(connector_profile)
714 
715  retval[2] = self.subscribeInterfaces(connector_profile)
716  if retval[2] != RTC.RTC_OK:
717  self._rtcout.RTC_ERROR("subscribeInterfaces() in notify_connect() failed.")
718  #self.notify_disconnect(connector_profile.connector_id)
719 
720  self.onSubscribeInterfaces(self.getName(), connector_profile, retval[2])
721 
722  self._rtcout.RTC_PARANOID("%d connectors are existing",
723  len(self._profile.connector_profiles))
724 
726  # update ConnectorProfile
727  index = self.findConnProfileIndex(connector_profile.connector_id)
728  if index < 0:
729  OpenRTM_aist.CORBA_SeqUtil.push_back(self._profile.connector_profiles,
730  connector_profile)
731  self._rtcout.RTC_PARANOID("New connector_id. Push backed.")
732 
733  else:
734  self._profile.connector_profiles[index] = connector_profile
735  self._rtcout.RTC_PARANOID("Existing connector_id. Updated.")
736 
737  for ret in retval:
738  if ret != RTC.RTC_OK:
739  self.onConnected(self.getName(), connector_profile, ret)
740  return (ret, connector_profile)
741 
742  # connection established without errors
743  if self._onConnected:
744  self._onConnected(connector_profile)
745  self.onConnected(self.getName(), connector_profile, RTC.RTC_OK)
746  return (RTC.RTC_OK, connector_profile)
747 
748 
749 
815  def disconnect(self, connector_id):
816  self._rtcout.RTC_TRACE("disconnect(%s)", connector_id)
817 
818  index = self.findConnProfileIndex(connector_id)
819 
820  if index < 0:
821  self._rtcout.RTC_ERROR("Invalid connector id: %s", connector_id)
822  return RTC.BAD_PARAMETER
823 
825  if index < len(self._profile.connector_profiles):
826  prof = self._profile.connector_profiles[index]
827  del guard
828 
829  if len(prof.ports) < 1:
830  self._rtcout.RTC_FATAL("ConnectorProfile has empty port list.")
831  return RTC.PRECONDITION_NOT_MET
832 
833  for i in range(len(prof.ports)):
834  p = prof.ports[i]
835  try:
836  return p.notify_disconnect(connector_id)
837  except:
838  self._rtcout.RTC_WARN(OpenRTM_aist.Logger.print_exception())
839  continue
840 
841  self._rtcout.RTC_ERROR("notify_disconnect() for all ports failed.")
842  return RTC.RTC_ERROR
843 
844 
845 
934  def notify_disconnect(self, connector_id):
935  self._rtcout.RTC_TRACE("notify_disconnect(%s)", connector_id)
936 
937  guard_connection = OpenRTM_aist.ScopedLock(self._connection_mutex)
938  # The Port of which the reference is stored in the beginning of
939  # connectorProfile's PortServiceList is master Port.
940  # The master Port has the responsibility of disconnecting all Ports.
941  # The slave Ports have only responsibility of deleting its own
942  # ConnectorProfile.
943 
945 
946  index = self.findConnProfileIndex(connector_id)
947 
948  if index < 0:
949  self._rtcout.RTC_ERROR("Invalid connector id: %s", connector_id)
950  return RTC.BAD_PARAMETER
951 
952  prof = RTC.ConnectorProfile(self._profile.connector_profiles[index].name,
953  self._profile.connector_profiles[index].connector_id,
954  self._profile.connector_profiles[index].ports,
955  self._profile.connector_profiles[index].properties)
956  self.onNotifyDisconnect(self.getName(), prof)
957 
958  retval = self.disconnectNext(prof)
959  self.onDisconnectNextport(self.getName(), prof, retval)
960 
961  if self._onUnsubscribeInterfaces:
962  self._onUnsubscribeInterfaces(prof)
963  self.onUnsubscribeInterfaces(self.getName(), prof)
964  self.unsubscribeInterfaces(prof)
965 
966  if self._onDisconnected:
967  self._onDisconnected(prof)
968 
969  OpenRTM_aist.CORBA_SeqUtil.erase(self._profile.connector_profiles, index)
970 
971  self.onDisconnected(self.getName(), prof, retval)
972  return retval
973 
974 
975 
996  def disconnect_all(self):
997  self._rtcout.RTC_TRACE("disconnect_all()")
999  plist = copy.deepcopy(self._profile.connector_profiles)
1000  del guard
1001 
1002  retcode = RTC.RTC_OK
1003  len_ = len(plist)
1004  self._rtcout.RTC_DEBUG("disconnecting %d connections.", len_)
1005 
1006  # disconnect all connections
1007  # Call disconnect() for each ConnectorProfile.
1008  for i in range(len_):
1009  tmpret = self.disconnect(plist[i].connector_id)
1010  if tmpret != RTC.RTC_OK:
1011  retcode = tmpret
1012 
1013  return retcode
1014 
1015 
1016  #============================================================
1017  # Local operations
1018  #============================================================
1019 
1020 
1040  def setName(self, name):
1041  self._rtcout.RTC_TRACE("setName(%s)", name)
1043  self._profile.name = name
1044  return
1045 
1046 
1055  def getName(self):
1056  self._rtcout.RTC_TRACE("getName() = %s", self._profile.name)
1057  return self._profile.name
1058 
1059 
1060 
1079  def getProfile(self):
1080  self._rtcout.RTC_TRACE("getProfile()")
1082  return self._profile
1083 
1084 
1085 
1107  def setPortRef(self, port_ref):
1108  self._rtcout.RTC_TRACE("setPortRef()")
1110  self._profile.port_ref = port_ref
1111 
1112 
1113 
1136  def getPortRef(self):
1137  self._rtcout.RTC_TRACE("getPortRef()")
1139  return self._profile.port_ref
1140 
1141 
1142 
1162  def setOwner(self, owner):
1163  prof = owner.get_component_profile()
1164  self._ownerInstanceName = prof.instance_name
1165  self._rtcout.RTC_TRACE("setOwner(%s)", self._ownerInstanceName)
1166 
1168  plist = self._profile.name.split(".")
1169  if not self._ownerInstanceName:
1170  self._rtcout.RTC_ERROR("Owner is not set.")
1171  self._rtcout.RTC_ERROR("addXXXPort() should be called in onInitialize().")
1172  portname = self._ownerInstanceName+"."+plist[-1]
1173 
1174  self._profile.owner = owner
1175  self._profile.name = portname
1176 
1177 
1178  #============================================================
1179  # callbacks
1180  #============================================================
1181 
1182 
1227  def setOnPublishInterfaces(self, on_publish):
1228  self._onPublishInterfaces = on_publish
1229  return
1230 
1231 
1232 
1277  def setOnSubscribeInterfaces(self, on_subscribe):
1278  self._onSubscribeInterfaces = on_subscribe
1279  return
1280 
1281 
1282 
1334  def setOnConnected(self, on_connected):
1335  self._onConnected = on_connected
1336  return
1337 
1338 
1339 
1385  def setOnUnsubscribeInterfaces(self, on_subscribe):
1386  self._onUnsubscribeInterfaces = on_subscribe
1387  return
1388 
1389 
1390 
1434  def setOnDisconnected(self, on_disconnected):
1435  self._onDisconnected = on_disconnected
1436  return
1437 
1438  # void setOnConnectionLost(ConnectionCallback* on_connection_lost);
1439  def setOnConnectionLost(self, on_connection_lost):
1440  self._onConnectionLost = on_connection_lost
1441  return
1442 
1443 
1444 
1465  def setPortConnectListenerHolder(self, portconnListeners):
1466  self._portconnListeners = portconnListeners
1467  return
1468 
1469 
1470 
1537  def publishInterfaces(self, connector_profile):
1538  pass
1539 
1540 
1541 
1568  def connectNext(self, connector_profile):
1569  index = OpenRTM_aist.CORBA_SeqUtil.find(connector_profile.ports,
1570  self.find_port_ref(self._profile.port_ref))
1571  if index < 0:
1572  return (RTC.BAD_PARAMETER, connector_profile)
1573 
1574  index += 1
1575  if index < len(connector_profile.ports):
1576  p = connector_profile.ports[index]
1577  return p.notify_connect(connector_profile)
1578 
1579  return (RTC.RTC_OK, connector_profile)
1580 
1581 
1582 
1609  def disconnectNext(self, connector_profile):
1610  index = OpenRTM_aist.CORBA_SeqUtil.find(connector_profile.ports,
1611  self.find_port_ref(self._profile.port_ref))
1612  if index < 0:
1613  return RTC.BAD_PARAMETER
1614 
1615  if index == (len(connector_profile.ports) - 1):
1616  return RTC.RTC_OK
1617 
1618  index += 1
1619 
1620  while index < len(connector_profile.ports):
1621  p = connector_profile.ports[index]
1622  index += 1
1623  try:
1624  return p.notify_disconnect(connector_profile.connector_id)
1625  except:
1626  self._rtcout.RTC_WARN(OpenRTM_aist.Logger.print_exception())
1627  continue
1628 
1629  return RTC.RTC_ERROR
1630 
1631 
1632 
1697  def subscribeInterfaces(self, connector_profile):
1698  pass
1699 
1700 
1701 
1739  def unsubscribeInterfaces(self, connector_profile):
1740  pass
1741 
1742 
1743 
1760  def setConnectionLimit(self, limit_value):
1761  self._connectionLimit = limit_value
1762  return
1763 
1764 
1765 
1787  if not (self._connectionLimit < 0) :
1788  if self._connectionLimit <= len(self._profile.connector_profiles):
1789  self._rtcout.RTC_PARANOID("Connected number has reached the limitation.")
1790  self._rtcout.RTC_PARANOID("Can connect the port up to %d ports.",
1791  self._connectionLimit)
1792  self._rtcout.RTC_PARANOID("%d connectors are existing",
1793  len(self._profile.connector_profiles))
1794  return RTC.RTC_ERROR
1795 
1796  return RTC.RTC_OK
1797 
1798 
1799 
1822  def isEmptyId(self, connector_profile):
1823  return connector_profile.connector_id == ""
1824 
1825 
1826 
1847  def getUUID(self):
1848  return str(OpenRTM_aist.uuid1())
1849 
1850 
1851 
1871  def setUUID(self, connector_profile):
1872  connector_profile.connector_id = self.getUUID()
1873  assert(connector_profile.connector_id != "")
1874 
1875 
1876 
1900  def isExistingConnId(self, id_):
1901  return OpenRTM_aist.CORBA_SeqUtil.find(self._profile.connector_profiles,
1902  self.find_conn_id(id_)) >= 0
1903 
1904 
1905 
1935  def findConnProfile(self, id_):
1936  index = OpenRTM_aist.CORBA_SeqUtil.find(self._profile.connector_profiles,
1937  self.find_conn_id(id_))
1938  if index < 0 or index >= len(self._profile.connector_profiles):
1939  return RTC.ConnectorProfile("","",[],[])
1940 
1941  return self._profile.connector_profiles[index]
1942 
1943 
1944 
1973  def findConnProfileIndex(self, id_):
1974  return OpenRTM_aist.CORBA_SeqUtil.find(self._profile.connector_profiles,
1975  self.find_conn_id(id_))
1976 
1977 
1978 
2006  def updateConnectorProfile(self, connector_profile):
2007  index = OpenRTM_aist.CORBA_SeqUtil.find(self._profile.connector_profiles,
2008  self.find_conn_id(connector_profile.connector_id))
2009 
2010  if index < 0:
2011  OpenRTM_aist.CORBA_SeqUtil.push_back(self._profile.connector_profiles,
2012  connector_profile)
2013  else:
2014  self._profile.connector_profiles[index] = connector_profile
2015 
2016 
2017 
2043  def eraseConnectorProfile(self, id_):
2045 
2046  index = OpenRTM_aist.CORBA_SeqUtil.find(self._profile.connector_profiles,
2047  self.find_conn_id(id_))
2048 
2049  if index < 0:
2050  return False
2051 
2052  OpenRTM_aist.CORBA_SeqUtil.erase(self._profile.connector_profiles, index)
2053 
2054  return True
2055 
2056 
2057 
2108  def appendInterface(self, instance_name, type_name, pol):
2109  index = OpenRTM_aist.CORBA_SeqUtil.find(self._profile.interfaces,
2110  self.find_interface(instance_name, pol))
2111 
2112  if index >= 0:
2113  return False
2114 
2115  # setup PortInterfaceProfile
2116  prof = RTC.PortInterfaceProfile(instance_name, type_name, pol)
2117  OpenRTM_aist.CORBA_SeqUtil.push_back(self._profile.interfaces, prof)
2118 
2119  return True
2120 
2121 
2122 
2151  def deleteInterface(self, name, pol):
2152  index = OpenRTM_aist.CORBA_SeqUtil.find(self._profile.interfaces,
2153  self.find_interface(name, pol))
2154 
2155  if index < 0:
2156  return False
2157 
2158  OpenRTM_aist.CORBA_SeqUtil.erase(self._profile.interfaces, index)
2159  return True
2160 
2161 
2162 
2184  def addProperty(self, key, value):
2186  OpenRTM_aist.NVUtil.newNV(key, value))
2187 
2188 
2209  def appendProperty(self, key, value):
2210  OpenRTM_aist.NVUtil.appendStringValue(self._profile.properties, key, value)
2211 
2212 
2213 
2214 
2225  def updateConnectors(self):
2227 
2228  connector_ids = []
2229  clist = self._profile.connector_profiles
2230 
2231  for cprof in clist:
2232  if not self.checkPorts(cprof.ports):
2233  connector_ids.append(cprof.connector_id)
2234  self._rtcout.RTC_WARN("Dead connection: %s", cprof.connector_id)
2235 
2236  for cid in connector_ids:
2237  self.disconnect(cid)
2238 
2239  return
2240 
2241 
2242 
2259  def checkPorts(self, ports):
2260  for port in ports:
2261  try:
2262  if port._non_existent():
2263  self._rtcout.RTC_WARN("Dead Port reference detected.")
2264  return False
2265  except:
2266  self._rtcout.RTC_WARN(OpenRTM_aist.Logger.print_exception())
2267  return False
2268 
2269  return True
2270 
2271 
2272  #inline void onNotifyConnect(const char* portname,
2273  # RTC::ConnectorProfile& profile)
2274  def onNotifyConnect(self, portname, profile):
2275  if self._portconnListeners != None:
2276  type = OpenRTM_aist.PortConnectListenerType.ON_NOTIFY_CONNECT
2277  self._portconnListeners.portconnect_[type].notify(portname, profile)
2278  return
2279 
2280 
2281  #inline void onNotifyDisconnect(const char* portname,
2282  # RTC::ConnectorProfile& profile)
2283  def onNotifyDisconnect(self, portname, profile):
2284  if self._portconnListeners != None:
2285  type = OpenRTM_aist.PortConnectListenerType.ON_NOTIFY_DISCONNECT
2286  self._portconnListeners.portconnect_[type].notify(portname, profile)
2287  return
2288 
2289 
2290  #inline void onUnsubscribeInterfaces(const char* portname,
2291  # RTC::ConnectorProfile& profile)
2292  def onUnsubscribeInterfaces(self, portname, profile):
2293  if self._portconnListeners != None:
2294  type = OpenRTM_aist.PortConnectListenerType.ON_UNSUBSCRIBE_INTERFACES
2295  self._portconnListeners.portconnect_[type].notify(portname, profile)
2296  return
2297 
2298 
2299  #inline void onPublishInterfaces(const char* portname,
2300  # RTC::ConnectorProfile& profile,
2301  # ReturnCode_t ret)
2302  def onPublishInterfaces(self, portname, profile, ret):
2303  if self._portconnListeners != None:
2304  type = OpenRTM_aist.PortConnectRetListenerType.ON_PUBLISH_INTERFACES
2305  self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2306  return
2307 
2308 
2309  #inline void onConnectNextport(const char* portname,
2310  # RTC::ConnectorProfile& profile,
2311  # ReturnCode_t ret)
2312  def onConnectNextport(self, portname, profile, ret):
2313  if self._portconnListeners != None:
2314  type = OpenRTM_aist.PortConnectRetListenerType.ON_CONNECT_NEXTPORT
2315  self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2316  return
2317 
2318 
2319  #inline void onSubscribeInterfaces(const char* portname,
2320  # RTC::ConnectorProfile& profile,
2321  # ReturnCode_t ret)
2322  def onSubscribeInterfaces(self, portname, profile, ret):
2323  if self._portconnListeners != None:
2324  type = OpenRTM_aist.PortConnectRetListenerType.ON_SUBSCRIBE_INTERFACES
2325  self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2326  return
2327 
2328 
2329  #inline void onConnected(const char* portname,
2330  # RTC::ConnectorProfile& profile,
2331  # ReturnCode_t ret)
2332  def onConnected(self, portname, profile, ret):
2333  if self._portconnListeners != None:
2334  type = OpenRTM_aist.PortConnectRetListenerType.ON_CONNECTED
2335  self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2336  return
2337 
2338 
2339  #inline void onDisconnectNextport(const char* portname,
2340  # RTC::ConnectorProfile& profile,
2341  # ReturnCode_t ret)
2342  def onDisconnectNextport(self, portname, profile, ret):
2343  if self._portconnListeners != None:
2344  type = OpenRTM_aist.PortConnectRetListenerType.ON_DISCONNECT_NEXT
2345  self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2346  return
2347 
2348 
2349  #inline void onDisconnected(const char* portname,
2350  # RTC::ConnectorProfile& profile,
2351  # ReturnCode_t ret)
2352  def onDisconnected(self, portname, profile, ret):
2353  if self._portconnListeners != None:
2354  type = OpenRTM_aist.PortConnectRetListenerType.ON_DISCONNECTED
2355  self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2356  return
2357 
2358 
2359 
2360  #============================================================
2361  # Functor
2362  #============================================================
2363 
2364 
2371  class if_name:
2372  def __init__(self, name):
2373  self._name = name
2374 
2375  def __call__(self, prof):
2376  return str(self._name) == str(prof.instance_name)
2377 
2378 
2379 
2387  def __init__(self, id_):
2388  """
2389  \param id_(string)
2390  """
2391  self._id = id_
2392 
2393  def __call__(self, cprof):
2394  """
2395  \param cprof(RTC.ConnectorProfile)
2396  """
2397  return str(self._id) == str(cprof.connector_id)
2398 
2399 
2407  def __init__(self, port_ref):
2408  """
2409  \param port_ref(RTC.PortService)
2410  """
2411  self._port_ref = port_ref
2412 
2413  def __call__(self, port_ref):
2414  """
2415  \param port_ref(RTC.PortService)
2416  """
2417  return self._port_ref._is_equivalent(port_ref)
2418 
2419 
2427  def __init__(self, p, prof):
2428  """
2429  \param p(RTC.PortService)
2430  \param prof(RTC.ConnectorProfile)
2431  """
2432  self._port_ref = p
2434  self.return_code = RTC.RTC_OK
2435 
2436  def __call__(self, p):
2437  """
2438  \param p(RTC.PortService)
2439  """
2440  if not self._port_ref._is_equivalent(p):
2441  retval = p.notify_connect(self._connector_profile)
2442  if retval != RTC.RTC_OK:
2443  self.return_code = retval
2444 
2445 
2453  def __init__(self, p, prof):
2454  """
2455  \param p(RTC.PortService)
2456  \param prof(RTC.ConnectorProfile)
2457  """
2458  self._port_ref = p
2460  self.return_code = RTC.RTC_OK
2461 
2462  def __call__(self, p):
2463  """
2464  \param p(RTC.PortService)
2465  """
2466  if not self._port_ref._is_equivalent(p):
2467  retval = p.disconnect(self._connector_profile.connector_id)
2468  if retval != RTC.RTC_OK:
2469  self.return_code = retval
2470 
2471 
2479  def __init__(self, p):
2480  """
2481  \param p(OpenRTM_aist.PortBase)
2482  """
2483  self.return_code = RTC.RTC_OK
2484  self._port = p
2485 
2486  def __call__(self, p):
2487  """
2488  \param p(RTC.ConnectorProfile)
2489  """
2490  retval = self._port.disconnect(p.connector_id)
2491  if retval != RTC.RTC_OK:
2492  self.return_code = retval
2493 
2494 
2502  def __init__(self, name, pol):
2503  """
2504  \param name(string)
2505  \param pol(RTC.PortInterfacePolarity)
2506  """
2507  self._name = name
2508  self._pol = pol
2509 
2510  def __call__(self, prof):
2511  """
2512  \param prof(RTC.PortInterfaceProfile)
2513  """
2514  name = prof.instance_name
2515  return (str(self._name) == str(name)) and (self._pol == prof.polarity)
def notify_connect(self, connector_profile)
[CORBA interface] Notify the Ports connection
Definition: PortBase.py:688
def connectNext(self, connector_profile)
Call notify_connect() of the next Port.
Definition: PortBase.py:1568
def erase(seq, index)
Erase the element of the specified index.
def checkPorts(self, ports)
Existence of ports.
Definition: PortBase.py:2259
def deleteInterface(self, name, pol)
Delete an interface from the PortInterfaceProfile.
Definition: PortBase.py:2151
def disconnect(self, connector_id)
[CORBA interface] Disconnect the Port
Definition: PortBase.py:815
def updateConnectorProfile(self, connector_profile)
Append or update the ConnectorProfile list.
Definition: PortBase.py:2006
def subscribeInterfaces(self, connector_profile)
Publish interface information.
Definition: PortBase.py:1697
def setOnUnsubscribeInterfaces(self, on_subscribe)
Setting callback called on unsubscribe interfaces.
Definition: PortBase.py:1385
def setOnDisconnected(self, on_disconnected)
Setting callback called on disconnected.
Definition: PortBase.py:1434
def addProperty(self, key, value)
Add NameValue data to PortProfile&#39;s properties.
Definition: PortBase.py:2184
def getUUID(self)
Get the UUID.
Definition: PortBase.py:1847
def push_back(seq, elem)
Push the new element back to the CORBA sequence.
def setPortConnectListenerHolder(self, portconnListeners)
Setting PortConnectListener holder.
Definition: PortBase.py:1465
def onDisconnectNextport(self, portname, profile, ret)
Definition: PortBase.py:2342
def setOnPublishInterfaces(self, on_publish)
Setting callback called on publish interfaces.
Definition: PortBase.py:1227
def get_connector_profile(self, connector_id)
[CORBA interface] Get the ConnectorProfile
Definition: PortBase.py:366
def setConnectionLimit(self, limit_value)
Set the maximum number of connections.
Definition: PortBase.py:1760
A functor to find a ConnectorProfile named id.
Definition: PortBase.py:2386
def onNotifyDisconnect(self, portname, profile)
Definition: PortBase.py:2283
def onUnsubscribeInterfaces(self, portname, profile)
Definition: PortBase.py:2292
def appendStringValue(nv, name, value)
Definition: NVUtil.py:352
def setName(self, name)
Set the name of this Port.
Definition: PortBase.py:1040
def __init__(self, name=None)
Constructor.
Definition: PortBase.py:146
def onSubscribeInterfaces(self, portname, profile, ret)
Definition: PortBase.py:2322
def onPublishInterfaces(self, portname, profile, ret)
Definition: PortBase.py:2302
def get_port_profile(self)
[CORBA interface] Get the PortProfile of the Port
Definition: PortBase.py:243
def onConnectNextport(self, portname, profile, ret)
Definition: PortBase.py:2312
def appendProperty(self, key, value)
Append NameValue data to PortProfile&#39;s properties.
Definition: PortBase.py:2209
def getName(self)
Get the name of this Port.
Definition: PortBase.py:1055
A functor to find interface from name and polarity.
Definition: PortBase.py:2501
def setOwner(self, owner)
Set the owner RTObject of the Port.
Definition: PortBase.py:1162
def isEmptyId(self, connector_profile)
Whether connector_id of ConnectorProfile is empty.
Definition: PortBase.py:1822
def disconnect_all(self)
[CORBA interface] Connect the Port
Definition: PortBase.py:996
def onDisconnected(self, portname, profile, ret)
Definition: PortBase.py:2352
def onConnected(self, portname, profile, ret)
Definition: PortBase.py:2332
def eraseConnectorProfile(self, id_)
Delete the ConnectorProfile.
Definition: PortBase.py:2043
def appendInterface(self, instance_name, type_name, pol)
Append an interface to the PortInterfaceProfile.
Definition: PortBase.py:2108
def setOnConnected(self, on_connected)
Setting callback called on connection established.
Definition: PortBase.py:1334
def findConnProfileIndex(self, id_)
Find ConnectorProfile with id.
Definition: PortBase.py:1973
def findConnProfile(self, id_)
Find ConnectorProfile with id.
Definition: PortBase.py:1935
def updateConnectors(self)
Disconnect ports that doesn&#39;t exist.
Definition: PortBase.py:2225
def notify_disconnect(self, connector_id)
[CORBA interface] Notify the Ports disconnection
Definition: PortBase.py:934
A functor to disconnect all Ports.
Definition: PortBase.py:2478
def getPortProfile(self)
Get the PortProfile of the Port.
Definition: PortBase.py:285
def unsubscribeInterfaces(self, connector_profile)
Disconnect interface connection.
Definition: PortBase.py:1739
A functor to find the object reference that is identical port_ref.
Definition: PortBase.py:2406
def _publishInterfaces(self)
Publish interface information.
Definition: PortBase.py:1786
def disconnectNext(self, connector_profile)
Call notify_disconnect() of the next Port.
Definition: PortBase.py:1609
def setPortRef(self, port_ref)
Set the object reference of this Port.
Definition: PortBase.py:1107
def find(seq, f)
Return the index of CORBA sequence element that functor matches.
A functor to find a PortInterfaceProfile named instance_name.
Definition: PortBase.py:2371
def isExistingConnId(self, id_)
Whether the given id exists in stored ConnectorProfiles.
Definition: PortBase.py:1900
A functor to disconnect Ports.
Definition: PortBase.py:2452
A functor to connect Ports.
Definition: PortBase.py:2426
def publishInterfaces(self, connector_profile)
Publish interface information.
Definition: PortBase.py:1537
def getProfile(self)
Get the PortProfile of the Port.
Definition: PortBase.py:1079
def setUUID(self, connector_profile)
Create and set the UUID to the ConnectorProfile.
Definition: PortBase.py:1871
def getPortRef(self)
Get the object reference of this Port.
Definition: PortBase.py:1136
def get_connector_profiles(self)
[CORBA interface] Get the ConnectorProfileList of the Port
Definition: PortBase.py:331
def onNotifyConnect(self, portname, profile)
Definition: PortBase.py:2274
def setOnSubscribeInterfaces(self, on_subscribe)
Setting callback called on publish interfaces.
Definition: PortBase.py:1277
def setOnConnectionLost(self, on_connection_lost)
Definition: PortBase.py:1439
def __del__(self)
Destructor.
Definition: PortBase.py:190
def newNV(name, value)
Create NameVale.
Definition: NVUtil.py:50
def connect(self, connector_profile)
[CORBA interface] Connect the Port
Definition: PortBase.py:543


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Feb 28 2022 23:01:06