88 OpenRTM_aist.PortBase.__init__(self,name)
89 self.
_rtcout.RTC_DEBUG(
"Port name: %s", name)
99 self.
_rtcout.RTC_DEBUG(
"setting port.port_type: DataInPort")
102 self.
_rtcout.RTC_DEBUG(
"setting port.data_type: %s", data_type)
105 self.
addProperty(
"dataport.subscription_type",
"Any")
123 def __del__(self, PortBase=OpenRTM_aist.PortBase):
124 self.
_rtcout.RTC_TRACE(
"InPortBase destructor")
127 self.
_rtcout.RTC_ERROR(
"connector.size should be 0 in InPortBase's dtor.")
130 connector.disconnect()
133 OpenRTM_aist.CdrBufferFactory.instance().deleteObject(self.
_thebuffer)
135 self.
_rtcout.RTC_ERROR(
"Although singlebuffer flag is true, the buffer != 0")
137 PortBase.__del__(self)
158 self.
_rtcout.RTC_TRACE(
"init()")
161 self.
_rtcout.RTC_DEBUG(
"single buffer mode.")
162 self.
_thebuffer = OpenRTM_aist.CdrBufferFactory.instance().createObject(
"ring_buffer")
165 self.
_rtcout.RTC_ERROR(
"default buffer creation failed")
167 self.
_rtcout.RTC_DEBUG(
"multi buffer mode.")
173 if not OpenRTM_aist.stringTo(num, self.
_properties.getProperty(
"connection_limit",
"-1")):
174 self.
_rtcout.RTC_ERROR(
"invalid connection_limit value: %s",
218 self.
_rtcout.RTC_TRACE(
"properties()")
271 profs.append(con.profile())
301 self.
_rtcout.RTC_TRACE(
"getConnectorIds(): %s", OpenRTM_aist.flatten(ids))
327 names.append(con.name())
329 self.
_rtcout.RTC_TRACE(
"getConnectorNames(): %s", OpenRTM_aist.flatten(names))
354 self.
_rtcout.RTC_TRACE(
"getConnectorById(id = %s)", id)
360 self.
_rtcout.RTC_WARN(
"ConnectorProfile with the id(%s) not found.", id)
385 self.
_rtcout.RTC_TRACE(
"getConnectorByName(name = %s)", name)
388 if name == con.name():
391 self.
_rtcout.RTC_WARN(
"ConnectorProfile with the name(%s) not found.", name)
419 self.
_rtcout.RTC_TRACE(
"getConnectorProfileById(id = %s)", id)
425 prof[0] = conn.profile()
454 self.
_rtcout.RTC_TRACE(
"getConnectorProfileByName(name = %s)", name)
460 prof[0] = conn.profile()
490 self.
_rtcout.RTC_TRACE(
"InPortBase.connect()")
493 "dataport.serializer.cdr.endian")
is -1:
494 self.
_rtcout.RTC_TRACE(
"ConnectorProfile dataport.serializer.cdr.endian set.")
497 return OpenRTM_aist.PortBase.connect(self, connector_profile)
517 self.
_rtcout.RTC_TRACE(
"activateInterfaces()")
522 self.
_rtcout.RTC_DEBUG(
"activate connector: %s %s",
523 (connector.name(),connector.id()))
546 self.
_rtcout.RTC_TRACE(
"deactivateInterfaces()")
550 connector.deactivate()
551 self.
_rtcout.RTC_DEBUG(
"deactivate connector: %s %s",
552 (connector.name(),connector.id()))
636 self.
_rtcout.RTC_TRACE(
"addConnectorDataListener()")
638 if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM:
639 self.
_listeners.connectorData_[listener_type].addListener(listener, autoclean)
642 self.
_rtcout.RTC_ERROR(
"addConnectorDataListener(): Invalid listener type.")
668 self.
_rtcout.RTC_TRACE(
"removeConnectorDataListener()")
670 if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM:
671 self.
_listeners.connectorData_[listener_type].removeListener(listener)
674 self.
_rtcout.RTC_ERROR(
"removeConnectorDataListener(): Invalid listener type.")
734 self.
_rtcout.RTC_TRACE(
"addConnectorListener()")
736 if listener_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM:
737 self.
_listeners.connector_[listener_type].addListener(listener, autoclean)
740 self.
_rtcout.RTC_ERROR(
"addConnectorListener(): Invalid listener type.")
766 self.
_rtcout.RTC_TRACE(
"removeConnectorListener()")
768 if listener_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM:
769 self.
_listeners.connector_[listener_type].removeListener(listener)
772 self.
_rtcout.RTC_ERROR(
"removeConnectorListener(): Invalid listener type.")
806 self.
_rtcout.RTC_TRACE(
"publishInterfaces()")
809 if retval != RTC.RTC_OK:
817 prop.mergeProperties(conn_prop.getNode(
"dataport"))
820 prop.mergeProperties(conn_prop.getNode(
"dataport.inport"))
828 dflow_type = prop.getProperty(
"dataflow_type")
829 dflow_type = OpenRTM_aist.normalize([dflow_type])
831 if dflow_type ==
"push":
832 self.
_rtcout.RTC_DEBUG(
"dataflow_type = push .... create PushConnector")
838 self.
_rtcout.RTC_ERROR(
"InPort provider creation failed.")
839 return RTC.BAD_PARAMETER
844 self.
_rtcout.RTC_ERROR(
"PushConnector creation failed.")
847 connector.setDataType(self.
_value)
848 provider.setConnector(connector)
850 self.
_rtcout.RTC_DEBUG(
"publishInterfaces() successfully finished.")
853 elif dflow_type ==
"pull":
854 self.
_rtcout.RTC_DEBUG(
"dataflow_type = pull .... do nothing")
857 self.
_rtcout.RTC_ERROR(
"unsupported dataflow_type")
858 return RTC.BAD_PARAMETER
890 self.
_rtcout.RTC_TRACE(
"subscribeInterfaces()")
896 prop.mergeProperties(conn_prop.getNode(
"dataport"))
897 prop.mergeProperties(conn_prop.getNode(
"dataport.inport"))
905 dflow_type = prop.getProperty(
"dataflow_type")
907 OpenRTM_aist.normalize(dtype)
908 dflow_type = dtype[0]
914 if dflow_type ==
"push":
915 self.
_rtcout.RTC_DEBUG(
"dataflow_type = push .... do nothing")
920 self.
_rtcout.RTC_ERROR(
"specified connector not found: %s",
924 ret = conn.setConnectorInfo(profile)
925 if ret == RTC.RTC_OK:
926 self.
_rtcout.RTC_DEBUG(
"subscribeInterfaces() successfully finished.")
930 elif dflow_type ==
"pull":
931 self.
_rtcout.RTC_DEBUG(
"dataflow_type = pull .... create PullConnector")
936 return RTC.BAD_PARAMETER
943 ret = connector.setConnectorInfo(profile)
945 if ret == RTC.RTC_OK:
946 self.
_rtcout.RTC_DEBUG(
"publishInterface() successfully finished.")
950 self.
_rtcout.RTC_ERROR(
"unsupported dataflow_type")
951 return RTC.BAD_PARAMETER
977 self.
_rtcout.RTC_TRACE(
"unsubscribeInterfaces()")
979 id = connector_profile.connector_id
980 self.
_rtcout.RTC_PARANOID(
"connector_id: %s", id)
983 for i
in range(len_):
991 self.
_rtcout.RTC_TRACE(
"delete connector: %s", id)
994 self.
_rtcout.RTC_ERROR(
"specified connector not found: %s", id)
1007 self.
_rtcout.RTC_TRACE(
"initProviders()")
1010 factory = OpenRTM_aist.InPortProviderFactory.instance()
1011 provider_types = factory.getIdentifiers()
1013 self.
_rtcout.RTC_DEBUG(
"available providers: %s",
1014 OpenRTM_aist.flatten(provider_types))
1016 if self.
_properties.hasKey(
"provider_types")
and \
1017 OpenRTM_aist.normalize(self.
_properties.getProperty(
"provider_types")) !=
"all":
1018 self.
_rtcout.RTC_DEBUG(
"allowed providers: %s",
1021 temp_types = provider_types
1023 active_types = OpenRTM_aist.split(self.
_properties.getProperty(
"provider_types"),
",")
1028 set_ptypes = set(temp_types).intersection(set(active_types))
1029 provider_types = provider_types + list(set_ptypes)
1032 if len(provider_types) > 0:
1033 self.
_rtcout.RTC_DEBUG(
"dataflow_type push is supported")
1036 OpenRTM_aist.flatten(provider_types))
1051 self.
_rtcout.RTC_TRACE(
"initConsumers()")
1054 factory = OpenRTM_aist.OutPortConsumerFactory.instance()
1055 consumer_types = factory.getIdentifiers()
1056 self.
_rtcout.RTC_DEBUG(
"available consumers: %s",
1057 OpenRTM_aist.flatten(consumer_types))
1059 if self.
_properties.hasKey(
"consumer_types")
and \
1060 OpenRTM_aist.normalize(self.
_properties.getProperty(
"consumer_types")) !=
"all":
1061 self.
_rtcout.RTC_DEBUG(
"allowed consumers: %s",
1064 temp_types = consumer_types
1066 active_types = OpenRTM_aist.split(self.
_properties.getProperty(
"consumer_types"),
",")
1071 set_ctypes = set(temp_types).intersection(set(active_types))
1072 consumer_types = consumer_types + list(set_ctypes)
1075 if len(consumer_types) > 0:
1076 self.
_rtcout.RTC_PARANOID(
"dataflow_type pull is supported")
1079 OpenRTM_aist.flatten(consumer_types))
1099 if not prop.getProperty(
"interface_type")
and \
1100 not OpenRTM_aist.includes(self.
_providerTypes, prop.getProperty(
"interface_type")):
1101 self.
_rtcout.RTC_ERROR(
"no provider found")
1102 self.
_rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1103 self.
_rtcout.RTC_DEBUG(
"interface_types: %s",
1108 self.
_rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1109 provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty(
"interface_type"))
1112 self.
_rtcout.RTC_DEBUG(
"provider created")
1113 provider.init(prop.getNode(
"provider"))
1115 if not provider.publishInterface(cprof.properties):
1116 self.
_rtcout.RTC_ERROR(
"publishing interface information error")
1117 OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider)
1121 self.
_rtcout.RTC_ERROR(
"provider creation failed")
1139 if not prop.getProperty(
"interface_type")
and \
1140 not OpenRTM_aist.includes(self.
_consumerTypes, prop.getProperty(
"interface_type")):
1141 self.
_rtcout.RTC_ERROR(
"no consumer found")
1142 self.
_rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1143 self.
_rtcout.RTC_DEBUG(
"interface_types: %s",
1147 self.
_rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1148 consumer = OpenRTM_aist.OutPortConsumerFactory.instance().createObject(prop.getProperty(
"interface_type"))
1151 self.
_rtcout.RTC_DEBUG(
"consumer created")
1152 consumer.init(prop.getNode(
"consumer"))
1154 if not consumer.subscribeInterface(cprof.properties):
1155 self.
_rtcout.RTC_ERROR(
"interface subscription failed.")
1156 OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(consumer)
1160 self.
_rtcout.RTC_ERROR(
"consumer creation failed")
1187 if provider_
is not None:
1196 elif consumer_
is not None:
1206 self.
_rtcout.RTC_ERROR(
"provider or consumer is not passed. returned 0;")
1210 if connector
is None:
1211 self.
_rtcout.RTC_ERROR(
"InPortConnector creation failed")
1214 if provider_
is not None:
1215 self.
_rtcout.RTC_TRACE(
"InPortPushConnector created")
1216 elif consumer_
is not None:
1217 self.
_rtcout.RTC_TRACE(
"InPortPullConnector created")
1224 self.
_rtcout.RTC_ERROR(
"InPortPushConnector creation failed")
1225 self.
_rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
1228 self.
_rtcout.RTC_FATAL(
"never comes here: createConnector()")
def activateInterfaces(self)
Activate all Port interfaces.
def refToVstring(objlist)
coil::vstring refToVstring(const CorbaRefSequence& objlist)
def removeConnectorDataListener(self, listener_type, listener)
Removing BufferDataListener type listener.
def disconnect(self, connector_id)
[CORBA interface] Disconnect the Port
def addProperty(self, key, value)
Add NameValue data to PortProfile's properties.
def unsubscribeInterfaces(self, connector_profile)
Disconnect the interface connection.
def getConnectorByName(self, name)
Getting Connector by name.
def deactivateInterfaces(self)
Deactivate all Port interfaces.
def setConnectionLimit(self, limit_value)
Set the maximum number of connections.
DataPortStatus mixin class.
def copyToProperties(prop, nvlist)
Copy to Proeprties from NVList.
The Properties class represents a persistent set of properties.
def read(self)
It is a virtual method that is called from RTObject_impl::readAll().
def initConsumers(self)
OutPort consumer initializationvoid initConsumers();.
def getConnectorIds(self)
ConnectorId list.
def init(self, prop)
Initializing properties.
def getConnectorNames(self)
Connector name list.
InPortPushConnector class.
def __init__(self, name, data_type)
Constructor.
def appendProperty(self, key, value)
Append NameValue data to PortProfile's properties.
def initProviders(self)
InPort provider initializationvoid initProviders();.
def connect(self, connector_profile)
[CORBA interface] Connect the Port
def createConnector(self, cprof, prop, provider_=None, consumer_=None)
InPortPushConnector creationInPortConnector* createConnector(ConnectorProfile& cprof, coil::Properties& prop, InPortProvider* provider);.
def addConnectorListener(self, listener_type, listener, autoclean=True)
Adding ConnectorListener type listener.
def getConnectorProfileById(self, id, prof)
Getting ConnectorProfile by name.
def removeConnectorListener(self, listener_type, listener)
Removing BufferDataListener type listener.
def createConsumer(self, cprof, prop)
InPort provider creationOutPortConsumer* createConsumer(const ConnectorProfile& cprof, coil::Properties& prop);.
def getConnectorById(self, id)
Getting ConnectorProfile by ID.
def getConnectorProfileByName(self, name, prof)
Getting ConnectorProfile by name.
def connectors(self)
Connector list.
def subscribeInterfaces(self, cprof)
Subscribe to the interface.
def _publishInterfaces(self)
Publish interface information.
def addConnectorDataListener(self, listener_type, listener, autoclean=True)
Adding BufferDataListener type listener.
def __del__(self, PortBase=OpenRTM_aist.PortBase)
Destructor.
def getConnectorProfiles(self)
ConnectorProfile list.
def createProvider(self, cprof, prop)
InPort provider creationInPortProvider* createProvider(ConnectorProfile& cprof, coil::Properties& pro...
def publishInterfaces(self, cprof)
Publish interface information.
def newNV(name, value)
Create NameVale.
def properties(self)
Get properties.
InPortPullConnector class.