150 self.
_profile = RTC.PortProfile(
"", [], RTC.PortService._nil, [], RTC.RTObject._nil,[])
153 self._profile.name =
"unknown.unknown" 157 self._profile.port_ref = self.
_objref 158 self._profile.owner = RTC.RTObject._nil
161 self.
_rtcout = OpenRTM_aist.Manager.instance().getLogbuf(name)
191 self._rtcout.RTC_TRACE(
"PortBase.__del__()")
193 mgr = OpenRTM_aist.Manager.instance().getPOA()
194 oid = mgr.servant_to_id(self)
195 mgr.deactivate_object(oid)
197 self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
244 self._rtcout.RTC_TRACE(
"get_port_profile()")
250 prof = RTC.PortProfile(self._profile.name,
251 self._profile.interfaces,
252 self._profile.port_ref,
253 self._profile.connector_profiles,
255 self._profile.properties)
286 self._rtcout.RTC_TRACE(
"getPortProfile()")
332 self._rtcout.RTC_TRACE(
"get_connector_profiles()")
337 return self._profile.connector_profiles
367 self._rtcout.RTC_TRACE(
"get_connector_profile(%s)", connector_id)
375 conn_prof = RTC.ConnectorProfile(
"",
"",[],[])
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)
544 self._rtcout.RTC_TRACE(
"connect()")
547 self.
setUUID(connector_profile)
553 self._rtcout.RTC_ERROR(
"Connection already exists.")
554 return (RTC.PRECONDITION_NOT_MET,connector_profile)
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)
563 return (retval, connector_profile)
566 self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
567 return (RTC.BAD_PARAMETER, connector_profile)
569 return (RTC.RTC_ERROR, connector_profile)
689 self._rtcout.RTC_TRACE(
"notify_connect()")
694 retval = [RTC.RTC_OK
for i
in range(3)]
698 if retval[0] != RTC.RTC_OK:
699 self._rtcout.RTC_ERROR(
"publishInterfaces() in notify_connect() failed.")
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.")
716 if retval[2] != RTC.RTC_OK:
717 self._rtcout.RTC_ERROR(
"subscribeInterfaces() in notify_connect() failed.")
722 self._rtcout.RTC_PARANOID(
"%d connectors are existing",
723 len(self._profile.connector_profiles))
731 self._rtcout.RTC_PARANOID(
"New connector_id. Push backed.")
734 self._profile.connector_profiles[index] = connector_profile
735 self._rtcout.RTC_PARANOID(
"Existing connector_id. Updated.")
738 if ret != RTC.RTC_OK:
740 return (ret, connector_profile)
746 return (RTC.RTC_OK, connector_profile)
816 self._rtcout.RTC_TRACE(
"disconnect(%s)", connector_id)
821 self._rtcout.RTC_ERROR(
"Invalid connector id: %s", connector_id)
822 return RTC.BAD_PARAMETER
825 if index < len(self._profile.connector_profiles):
826 prof = self._profile.connector_profiles[index]
829 if len(prof.ports) < 1:
830 self._rtcout.RTC_FATAL(
"ConnectorProfile has empty port list.")
831 return RTC.PRECONDITION_NOT_MET
833 for i
in range(len(prof.ports)):
836 return p.notify_disconnect(connector_id)
838 self._rtcout.RTC_WARN(OpenRTM_aist.Logger.print_exception())
841 self._rtcout.RTC_ERROR(
"notify_disconnect() for all ports failed.")
935 self._rtcout.RTC_TRACE(
"notify_disconnect(%s)", connector_id)
949 self._rtcout.RTC_ERROR(
"Invalid connector id: %s", connector_id)
950 return RTC.BAD_PARAMETER
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)
997 self._rtcout.RTC_TRACE(
"disconnect_all()")
999 plist = copy.deepcopy(self._profile.connector_profiles)
1002 retcode = RTC.RTC_OK
1004 self._rtcout.RTC_DEBUG(
"disconnecting %d connections.", len_)
1008 for i
in range(len_):
1009 tmpret = self.
disconnect(plist[i].connector_id)
1010 if tmpret != RTC.RTC_OK:
1041 self._rtcout.RTC_TRACE(
"setName(%s)", name)
1043 self._profile.name = name
1056 self._rtcout.RTC_TRACE(
"getName() = %s", self._profile.name)
1057 return self._profile.name
1080 self._rtcout.RTC_TRACE(
"getProfile()")
1108 self._rtcout.RTC_TRACE(
"setPortRef()")
1110 self._profile.port_ref = port_ref
1137 self._rtcout.RTC_TRACE(
"getPortRef()")
1139 return self._profile.port_ref
1163 prof = owner.get_component_profile()
1168 plist = self._profile.name.split(
".")
1170 self._rtcout.RTC_ERROR(
"Owner is not set.")
1171 self._rtcout.RTC_ERROR(
"addXXXPort() should be called in onInitialize().")
1174 self._profile.owner = owner
1175 self._profile.name = portname
1572 return (RTC.BAD_PARAMETER, connector_profile)
1575 if index < len(connector_profile.ports):
1576 p = connector_profile.ports[index]
1577 return p.notify_connect(connector_profile)
1579 return (RTC.RTC_OK, connector_profile)
1613 return RTC.BAD_PARAMETER
1615 if index == (len(connector_profile.ports) - 1):
1620 while index < len(connector_profile.ports):
1621 p = connector_profile.ports[index]
1624 return p.notify_disconnect(connector_profile.connector_id)
1626 self._rtcout.RTC_WARN(OpenRTM_aist.Logger.print_exception())
1629 return RTC.RTC_ERROR
1789 self._rtcout.RTC_PARANOID(
"Connected number has reached the limitation.")
1790 self._rtcout.RTC_PARANOID(
"Can connect the port up to %d ports.",
1792 self._rtcout.RTC_PARANOID(
"%d connectors are existing",
1793 len(self._profile.connector_profiles))
1794 return RTC.RTC_ERROR
1823 return connector_profile.connector_id ==
"" 1848 return str(OpenRTM_aist.uuid1())
1872 connector_profile.connector_id = self.
getUUID()
1873 assert(connector_profile.connector_id !=
"")
1938 if index < 0
or index >= len(self._profile.connector_profiles):
1939 return RTC.ConnectorProfile(
"",
"",[],[])
1941 return self._profile.connector_profiles[index]
2014 self._profile.connector_profiles[index] = connector_profile
2116 prof = RTC.PortInterfaceProfile(instance_name, type_name, pol)
2229 clist = self._profile.connector_profiles
2233 connector_ids.append(cprof.connector_id)
2234 self._rtcout.RTC_WARN(
"Dead connection: %s", cprof.connector_id)
2236 for cid
in connector_ids:
2262 if port._non_existent():
2263 self._rtcout.RTC_WARN(
"Dead Port reference detected.")
2266 self._rtcout.RTC_WARN(OpenRTM_aist.Logger.print_exception())
2276 type = OpenRTM_aist.PortConnectListenerType.ON_NOTIFY_CONNECT
2277 self._portconnListeners.portconnect_[type].notify(portname, profile)
2285 type = OpenRTM_aist.PortConnectListenerType.ON_NOTIFY_DISCONNECT
2286 self._portconnListeners.portconnect_[type].notify(portname, profile)
2294 type = OpenRTM_aist.PortConnectListenerType.ON_UNSUBSCRIBE_INTERFACES
2295 self._portconnListeners.portconnect_[type].notify(portname, profile)
2304 type = OpenRTM_aist.PortConnectRetListenerType.ON_PUBLISH_INTERFACES
2305 self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2314 type = OpenRTM_aist.PortConnectRetListenerType.ON_CONNECT_NEXTPORT
2315 self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2324 type = OpenRTM_aist.PortConnectRetListenerType.ON_SUBSCRIBE_INTERFACES
2325 self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2334 type = OpenRTM_aist.PortConnectRetListenerType.ON_CONNECTED
2335 self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2344 type = OpenRTM_aist.PortConnectRetListenerType.ON_DISCONNECT_NEXT
2345 self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2354 type = OpenRTM_aist.PortConnectRetListenerType.ON_DISCONNECTED
2355 self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
2376 return str(self.
_name) == str(prof.instance_name)
2395 \param cprof(RTC.ConnectorProfile) 2397 return str(self.
_id) == str(cprof.connector_id)
2409 \param port_ref(RTC.PortService) 2415 \param port_ref(RTC.PortService) 2417 return self._port_ref._is_equivalent(port_ref)
2429 \param p(RTC.PortService) 2430 \param prof(RTC.ConnectorProfile) 2438 \param p(RTC.PortService) 2440 if not self._port_ref._is_equivalent(p):
2442 if retval != RTC.RTC_OK:
2455 \param p(RTC.PortService) 2456 \param prof(RTC.ConnectorProfile) 2464 \param p(RTC.PortService) 2466 if not self._port_ref._is_equivalent(p):
2467 retval = p.disconnect(self._connector_profile.connector_id)
2468 if retval != RTC.RTC_OK:
2481 \param p(OpenRTM_aist.PortBase) 2488 \param p(RTC.ConnectorProfile) 2490 retval = self._port.disconnect(p.connector_id)
2491 if retval != RTC.RTC_OK:
2505 \param pol(RTC.PortInterfacePolarity) 2512 \param prof(RTC.PortInterfaceProfile) 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
def connectNext(self, connector_profile)
Call notify_connect() of the next Port.
def erase(seq, index)
Erase the element of the specified index.
def checkPorts(self, ports)
Existence of ports.
def deleteInterface(self, name, pol)
Delete an interface from the PortInterfaceProfile.
def disconnect(self, connector_id)
[CORBA interface] Disconnect the Port
def __init__(self, p, prof)
def updateConnectorProfile(self, connector_profile)
Append or update the ConnectorProfile list.
def subscribeInterfaces(self, connector_profile)
Publish interface information.
def setOnUnsubscribeInterfaces(self, on_subscribe)
Setting callback called on unsubscribe interfaces.
def setOnDisconnected(self, on_disconnected)
Setting callback called on disconnected.
def addProperty(self, key, value)
Add NameValue data to PortProfile's properties.
def getUUID(self)
Get the UUID.
def push_back(seq, elem)
Push the new element back to the CORBA sequence.
def setPortConnectListenerHolder(self, portconnListeners)
Setting PortConnectListener holder.
def onDisconnectNextport(self, portname, profile, ret)
def setOnPublishInterfaces(self, on_publish)
Setting callback called on publish interfaces.
def get_connector_profile(self, connector_id)
[CORBA interface] Get the ConnectorProfile
def setConnectionLimit(self, limit_value)
Set the maximum number of connections.
A functor to find a ConnectorProfile named id.
def onNotifyDisconnect(self, portname, profile)
def onUnsubscribeInterfaces(self, portname, profile)
def __call__(self, port_ref)
def appendStringValue(nv, name, value)
def setName(self, name)
Set the name of this Port.
def __init__(self, name=None)
Constructor.
def onSubscribeInterfaces(self, portname, profile, ret)
def onPublishInterfaces(self, portname, profile, ret)
def get_port_profile(self)
[CORBA interface] Get the PortProfile of the Port
def onConnectNextport(self, portname, profile, ret)
def appendProperty(self, key, value)
Append NameValue data to PortProfile's properties.
def getName(self)
Get the name of this Port.
A functor to find interface from name and polarity.
def setOwner(self, owner)
Set the owner RTObject of the Port.
def isEmptyId(self, connector_profile)
Whether connector_id of ConnectorProfile is empty.
def disconnect_all(self)
[CORBA interface] Connect the Port
def onDisconnected(self, portname, profile, ret)
def onConnected(self, portname, profile, ret)
def eraseConnectorProfile(self, id_)
Delete the ConnectorProfile.
def appendInterface(self, instance_name, type_name, pol)
Append an interface to the PortInterfaceProfile.
def __init__(self, port_ref)
def setOnConnected(self, on_connected)
Setting callback called on connection established.
def findConnProfileIndex(self, id_)
Find ConnectorProfile with id.
def findConnProfile(self, id_)
Find ConnectorProfile with id.
def updateConnectors(self)
Disconnect ports that doesn't exist.
def notify_disconnect(self, connector_id)
[CORBA interface] Notify the Ports disconnection
def __call__(self, cprof)
A functor to disconnect all Ports.
def getPortProfile(self)
Get the PortProfile of the Port.
def unsubscribeInterfaces(self, connector_profile)
Disconnect interface connection.
A functor to find the object reference that is identical port_ref.
def _publishInterfaces(self)
Publish interface information.
def disconnectNext(self, connector_profile)
Call notify_disconnect() of the next Port.
def setPortRef(self, port_ref)
Set the object reference of this Port.
def find(seq, f)
Return the index of CORBA sequence element that functor matches.
A functor to find a PortInterfaceProfile named instance_name.
def isExistingConnId(self, id_)
Whether the given id exists in stored ConnectorProfiles.
def __init__(self, name, pol)
A functor to disconnect Ports.
A functor to connect Ports.
def publishInterfaces(self, connector_profile)
Publish interface information.
def getProfile(self)
Get the PortProfile of the Port.
def setUUID(self, connector_profile)
Create and set the UUID to the ConnectorProfile.
def getPortRef(self)
Get the object reference of this Port.
def get_connector_profiles(self)
[CORBA interface] Get the ConnectorProfileList of the Port
def onNotifyConnect(self, portname, profile)
def setOnSubscribeInterfaces(self, on_subscribe)
Setting callback called on publish interfaces.
def __init__(self, p, prof)
def setOnConnectionLost(self, on_connection_lost)
def __del__(self)
Destructor.
def newNV(name, value)
Create NameVale.
def connect(self, connector_profile)
[CORBA interface] Connect the Port