219 self.
_factory = OpenRTM_aist.OutPortProviderFactory.instance()
222 self._factory.deleteObject(p)
257 OpenRTM_aist.PortBase.__init__(self,name)
258 self._rtcout.RTC_DEBUG(
"Port name: %s", name)
260 self._rtcout.RTC_DEBUG(
"setting port.port_type: DataOutPort")
263 self._rtcout.RTC_DEBUG(
"setting dataport.data_type: %s", data_type)
267 factory = OpenRTM_aist.PublisherFactory.instance()
268 pubs = OpenRTM_aist.flatten(factory.getIdentifiers())
273 self._rtcout.RTC_DEBUG(
"available subscription_type: %s", pubs)
274 self.
addProperty(
"dataport.subscription_type", pubs)
304 def __del__(self, PortBase=OpenRTM_aist.PortBase):
305 self._rtcout.RTC_TRACE(
"OutPortBase destructor")
309 PortBase.__del__(self)
329 self._rtcout.RTC_TRACE(
"init()")
331 self._properties.mergeProperties(prop)
339 if not OpenRTM_aist.stringTo(num, self._properties.getProperty(
"connection_limit",
"-1")):
340 self._rtcout.RTC_ERROR(
"invalid connection_limit value: %s",
341 self._properties.getProperty(
"connection_limit"))
398 self._rtcout.RTC_TRACE(
"OutPortBase.connect()")
401 "dataport.serializer.cdr.endian")
is -1:
402 self._rtcout.RTC_TRACE(
"ConnectorProfile dataport.serializer.cdr.endian set.")
405 return OpenRTM_aist.PortBase.connect(self, connector_profile)
428 self._rtcout.RTC_TRACE(
"properties()")
441 self._rtcout.RTC_TRACE(
"connectors(): size = %d", len(self.
_connectors))
454 self._rtcout.RTC_TRACE(
"getConnectorProfiles(): size = %d", len(self.
_connectors))
457 profs.append(con.profile())
476 self._rtcout.RTC_TRACE(
"getConnectorIds(): %s", OpenRTM_aist.flatten(ids))
491 names.append(con.name())
493 self._rtcout.RTC_TRACE(
"getConnectorNames(): %s", OpenRTM_aist.flatten(names))
519 self._rtcout.RTC_TRACE(
"getConnectorById(id = %s)", id)
525 self._rtcout.RTC_WARN(
"ConnectorProfile with the id(%s) not found.", id)
550 self._rtcout.RTC_TRACE(
"getConnectorByName(name = %s)", name)
553 if name == con.name():
556 self._rtcout.RTC_WARN(
"ConnectorProfile with the name(%s) not found.", name)
570 self._rtcout.RTC_TRACE(
"getConnectorProfileById(id = %s)", id)
577 prof[0] = conn.profile()
591 self._rtcout.RTC_TRACE(
"getConnectorProfileByName(name = %s)", name)
598 prof[0] = conn.profile()
611 self._rtcout.RTC_TRACE(
"activateInterfaces()")
625 self._rtcout.RTC_TRACE(
"deactivateInterfaces()")
709 self._rtcout.RTC_TRACE(
"addConnectorDataListener()")
710 if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM:
711 self._rtcout.RTC_TRACE(
"addConnectorDataListener(%s)",
712 OpenRTM_aist.ConnectorDataListener.toString(listener_type))
713 self._listeners.connectorData_[listener_type].addListener(listener, autoclean)
716 self._rtcout.RTC_ERROR(
"addConnectorDataListener(): Unknown Listener Type")
742 self._rtcout.RTC_TRACE(
"removeConnectorDataListener()")
744 if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM:
745 self._rtcout.RTC_TRACE(
"removeConnectorDataListener(%s)",
746 OpenRTM_aist.ConnectorDataListener.toString(listener_type))
747 self._listeners.connectorData_[listener_type].removeListener(listener)
750 self._rtcout.RTC_ERROR(
"removeConnectorDataListener(): Unknown Listener Type")
810 self._rtcout.RTC_TRACE(
"addConnectorListener()")
812 if callback_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM:
813 self._rtcout.RTC_TRACE(
"addConnectorListener(%s)",
814 OpenRTM_aist.ConnectorListener.toString(callback_type))
815 self._listeners.connector_[callback_type].addListener(listener, autoclean)
817 self._rtcout.RTC_ERROR(
"addConnectorListener(): Unknown Listener Type")
843 self._rtcout.RTC_TRACE(
"removeConnectorListener()")
845 if callback_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM:
846 self._rtcout.RTC_TRACE(
"removeConnectorListener(%s)",
847 OpenRTM_aist.ConnectorListener.toString(callback_type))
848 self._listeners.connector_[callback_type].removeListener(listener)
850 self._rtcout.RTC_ERROR(
"removeConnectorListener(): Unknown Listener Type")
875 self._rtcout.RTC_TRACE(
"publishInterfaces()")
878 if retval != RTC.RTC_OK:
887 prop.mergeProperties(conn_prop.getNode(
"dataport"))
890 # marge ConnectorProfile for buffer property. 892 # prof[buffer.write.full_policy] 893 # << cprof[dataport.outport.buffer.write.full_policy] 896 prop.mergeProperties(conn_prop.getNode(
"dataport.outport"))
904 dflow_type = OpenRTM_aist.normalize([prop.getProperty(
"dataflow_type")])
906 if dflow_type ==
"push":
907 self._rtcout.RTC_PARANOID(
"dataflow_type = push .... do nothing")
910 elif dflow_type ==
"pull":
911 self._rtcout.RTC_PARANOID(
"dataflow_type = pull .... create PullConnector")
915 return RTC.BAD_PARAMETER
923 provider.setConnector(connector)
925 self._rtcout.RTC_DEBUG(
"publishInterface() successfully finished.")
928 self._rtcout.RTC_ERROR(
"unsupported dataflow_type")
930 return RTC.BAD_PARAMETER
942 self._rtcout.RTC_TRACE(
"subscribeInterfaces()")
949 prop.mergeProperties(conn_prop.getNode(
"dataport"))
951 # marge ConnectorProfile for buffer property. 953 # prof[buffer.write.full_policy] 954 # << cprof[dataport.outport.buffer.write.full_policy] 956 prop.mergeProperties(conn_prop.getNode(
"dataport.outport"))
964 dflow_type = OpenRTM_aist.normalize([prop.getProperty(
"dataflow_type")])
970 if dflow_type ==
"push":
971 self._rtcout.RTC_PARANOID(
"dataflow_type = push .... create PushConnector")
976 return RTC.BAD_PARAMETER
983 ret = connector.setConnectorInfo(profile)
985 if ret == RTC.RTC_OK:
986 self._rtcout.RTC_DEBUG(
"subscribeInterfaces() successfully finished.")
990 elif dflow_type ==
"pull":
991 self._rtcout.RTC_PARANOID(
"dataflow_type = pull.")
995 self._rtcout.RTC_ERROR(
"specified connector not found: %s",
999 ret = conn.setConnectorInfo(profile)
1001 if ret == RTC.RTC_OK:
1002 self._rtcout.RTC_DEBUG(
"subscribeInterfaces() successfully finished.")
1006 self._rtcout.RTC_ERROR(
"unsupported dataflow_type")
1007 return RTC.BAD_PARAMETER
1020 self._rtcout.RTC_TRACE(
"unsubscribeInterfaces()")
1022 id = connector_profile.connector_id
1023 self._rtcout.RTC_PARANOID(
"connector_id: %s", id)
1026 for i
in range(len_):
1027 idx = (len_ - 1) - i
1033 self._rtcout.RTC_TRACE(
"delete connector: %s", id)
1036 self._rtcout.RTC_ERROR(
"specified connector not found: %s", id)
1049 self._rtcout.RTC_TRACE(
"initProviders()")
1052 factory = OpenRTM_aist.OutPortProviderFactory.instance()
1053 provider_types = factory.getIdentifiers()
1054 self._rtcout.RTC_PARANOID(
"available OutPortProviders: %s",
1055 OpenRTM_aist.flatten(provider_types))
1057 if self._properties.hasKey(
"provider_types")
and \
1058 OpenRTM_aist.normalize(self._properties.getProperty(
"provider_types")) !=
"all":
1059 self._rtcout.RTC_DEBUG(
"allowed providers: %s",
1060 self._properties.getProperty(
"provider_types"))
1062 temp_types = provider_types
1064 active_types = OpenRTM_aist.split(self._properties.getProperty(
"provider_types"),
",")
1069 set_ptypes = set(temp_types).intersection(set(active_types))
1070 provider_types = provider_types + list(set_ptypes)
1073 if len(provider_types) > 0:
1074 self._rtcout.RTC_DEBUG(
"dataflow_type pull is supported")
1077 OpenRTM_aist.flatten(provider_types))
1091 self._rtcout.RTC_TRACE(
"initConsumers()")
1094 factory = OpenRTM_aist.InPortConsumerFactory.instance()
1095 consumer_types = factory.getIdentifiers()
1096 self._rtcout.RTC_PARANOID(
"available InPortConsumer: %s",
1097 OpenRTM_aist.flatten(consumer_types))
1099 if self._properties.hasKey(
"consumer_types")
and \
1100 OpenRTM_aist.normalize(self._properties.getProperty(
"consumer_types")) !=
"all":
1101 self._rtcout.RTC_DEBUG(
"allowed consumers: %s",
1102 self._properties.getProperty(
"consumer_types"))
1104 temp_types = consumer_types
1106 active_types = OpenRTM_aist.split(self._properties.getProperty(
"consumer_types"),
",")
1111 set_ctypes = set(temp_types).intersection(set(active_types))
1112 consumer_types = consumer_types + list(set_ctypes)
1115 if len(consumer_types) > 0:
1116 self._rtcout.RTC_PARANOID(
"dataflow_type push is supported")
1119 OpenRTM_aist.flatten(consumer_types))
1134 if prop.getProperty(
"interface_type")
and \
1135 not OpenRTM_aist.includes(self.
_providerTypes, prop.getProperty(
"interface_type")):
1136 self._rtcout.RTC_ERROR(
"no provider found")
1137 self._rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1138 self._rtcout.RTC_DEBUG(
"interface_types: %s",
1142 self._rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1143 provider = OpenRTM_aist.OutPortProviderFactory.instance().createObject(prop.getProperty(
"interface_type"))
1146 self._rtcout.RTC_DEBUG(
"provider created")
1147 provider.init(prop.getNode(
"provider"))
1149 if not provider.publishInterface(cprof.properties):
1150 self._rtcout.RTC_ERROR(
"publishing interface information error")
1151 OpenRTM_aist.OutPortProviderFactory.instance().deleteObject(provider)
1156 self._rtcout.RTC_ERROR(
"provider creation failed")
1170 if prop.getProperty(
"interface_type")
and \
1171 not self._consumerTypes.count(prop.getProperty(
"interface_type")):
1172 self._rtcout.RTC_ERROR(
"no consumer found")
1173 self._rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1174 self._rtcout.RTC_DEBUG(
"interface_types: %s",
1178 self._rtcout.RTC_DEBUG(
"interface_type: %s", prop.getProperty(
"interface_type"))
1179 consumer = OpenRTM_aist.InPortConsumerFactory.instance().createObject(prop.getProperty(
"interface_type"))
1182 self._rtcout.RTC_DEBUG(
"consumer created")
1183 consumer.init(prop.getNode(
"consumer"))
1185 if not consumer.subscribeInterface(cprof.properties):
1186 self._rtcout.RTC_ERROR(
"interface subscription failed.")
1187 OpenRTM_aist.InPortConsumerFactory.instance().deleteObject(consumer)
1192 self._rtcout.RTC_ERROR(
"consumer creation failed")
1216 if consumer_
is not None:
1218 elif provider_
is not None:
1222 self._rtcout.RTC_ERROR(
"provider or consumer is not passed. returned 0;")
1225 if connector
is None:
1226 self._rtcout.RTC_ERROR(
"OutPortConnector creation failed")
1229 if consumer_
is not None:
1230 self._rtcout.RTC_TRACE(
"OutPortPushConnector created")
1231 elif provider_
is not None:
1232 self._rtcout.RTC_TRACE(
"OutPortPullConnector created")
1234 self._connectors.append(connector)
1235 self._rtcout.RTC_PARANOID(
"connector push backed: %d", len(self.
_connectors))
1239 self._rtcout.RTC_ERROR(
"Exeption: OutPortPushConnector creation failed")
1240 self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
1244 self._rtcout.RTC_FATAL(
"never comes here: createConnector()")
def refToVstring(objlist)
coil::vstring refToVstring(const CorbaRefSequence& objlist)
def deactivateInterfaces(self)
Deactivate all Port interfacesvoid OutPortBase::deactivateInterfaces()
def disconnect(self, connector_id)
[CORBA interface] Disconnect the Port
def removeConnectorListener(self, callback_type, listener)
Removing BufferDataListener type listener.
def initConsumers(self)
InPort consumer initializationvoid OutPortBase::initConsumers()
def getConnectorIds(self)
ConnectorId listcoil::vstring OutPortBase::getConnectorIds()
def addConnectorListener(self, callback_type, listener, autoclean=True)
Adding ConnectorListener type listener.
def addProperty(self, key, value)
Add NameValue data to PortProfile's properties.
def setConnectionLimit(self, limit_value)
Set the maximum number of connections.
def for_each(seq, f)
Apply the functor to all CORBA sequence elements.
DataPortStatus mixin class.
def getConnectorById(self, id)
Getting ConnectorProfile by ID.
def copyToProperties(prop, nvlist)
Copy to Proeprties from NVList.
def connect(self, connector_profile)
[CORBA interface] Connect the Port
The Properties class represents a persistent set of properties.
def initProviders(self)
OutPort provider initializationvoid OutPortBase::initProviders()
def removeConnectorDataListener(self, listener_type, listener)
Removing BufferDataListener type listener.
def unsubscribeInterfaces(self, connector_profile)
Unsubscribe interfacevoid OutPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profil...
def getConnectorProfileByName(self, name, prof)
Getting ConnectorProfile by namebool OutPortBase::getConnectorProfileByName(const char* name...
Functor to delete Connectors.
OutPortPushConnector class.
def subscribeInterfaces(self, cprof)
Subscribe interfaceReturnCode_t OutPortBase::subscribeInterfaces(const ConnectorProfile& cprof) ...
def appendProperty(self, key, value)
Append NameValue data to PortProfile's properties.
def createProvider(self, cprof, prop)
OutPort provider creationOutPortProvider* OutPortBase::createProvider(ConnectorProfile& cprof...
def getConnectorNames(self)
Connector name listcoil::vstring OutPortBase::getConnectorNames()
def activateInterfaces(self)
Activate all Port interfacesvoid OutPortBase::activateInterfaces()
def addConnectorDataListener(self, listener_type, listener, autoclean=True)
Adding BufferDataListener type listener.
def getConnectorProfiles(self)
ConnectorProfile listConnectorBase::ConnectorInfoList OutPortBase::getConnectorProfiles() ...
def connectors(self)
Connector listconst std::vector<OutPortConnector*>& OutPortBase::connectors()
def getConnectorProfileById(self, id, prof)
Getting ConnectorProfile by namebool OutPortBase::getConnectorProfileById(const char* id...
def configure(self)
Configureing outportvoid OutPortBase::configure()
def createConnector(self, cprof, prop, provider_=None, consumer_=None)
OutPortPushConnector creationOutPortConnector* OutPortBase::createConnector(const ConnectorProfile& c...
def properties(self)
Get properties.
Functor to delete Providers.
def __init__(self, name, data_type)
A constructor of OutPortBase class.
def createConsumer(self, cprof, prop)
InPort consumer creationInPortConsumer* OutPortBase::createConsumer(const ConnectorProfile& cprof...
def getConnectorByName(self, name)
Getting Connector by name.
def _publishInterfaces(self)
Publish interface information.
def init(self, prop)
Initializing properties.
def publishInterfaces(self, cprof)
Publish interface informationReturnCode_t OutPortBase::publishInterfaces(ConnectorProfile& cprof) ...
def __del__(self, PortBase=OpenRTM_aist.PortBase)
destructor
OutPortPullConnector class.
def newNV(name, value)
Create NameVale.
def write(self)
Write data.