InPortBase.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
18 
19 import copy
20 import threading
21 import OpenRTM_aist
22 import RTC
23 
24 
38 
39 
59  """
60  """
61 
62 
87  def __init__(self, name, data_type):
88  OpenRTM_aist.PortBase.__init__(self,name)
89  self._rtcout.RTC_DEBUG("Port name: %s", name)
90  self._singlebuffer = True
91  self._thebuffer = None
93  self._providerTypes = ""
94  self._consumerTypes = ""
95  self._connectors = []
96  self._connector_mutex = threading.RLock()
97 
98  # PortProfile::properties を設定 self._rtcout.RTC_DEBUG("setting port.port_type: DataInPort") self.addProperty("port.port_type", "DataInPort") self._rtcout.RTC_DEBUG("setting port.data_type: %s", data_type) self.addProperty("dataport.data_type", data_type) self.addProperty("dataport.subscription_type", "Any") self._value = None self._listeners = OpenRTM_aist.ConnectorListeners() ## # @if jp # @brief デストラクタ # # デストラクタ # # @else # @brief Destructor # # Destructor # # @endif # def __del__(self, PortBase=OpenRTM_aist.PortBase): self._rtcout.RTC_TRACE("InPortBase destructor") if len(self._connectors) != 0: self._rtcout.RTC_ERROR("connector.size should be 0 in InPortBase's dtor.") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) for connector in self._connectors: connector.disconnect() if self._thebuffer is not None: OpenRTM_aist.CdrBufferFactory.instance().deleteObject(self._thebuffer) if not self._singlebuffer: self._rtcout.RTC_ERROR("Although singlebuffer flag is true, the buffer != 0") PortBase.__del__(self) return ## # @if jp # @brief プロパティの初期化 # # 指定されたプロパティで初期化する。 # # @param prop 設定するプロパティ # @else # @brief Initializing properties # # This method initializes the port in the specified property. # # @param prop Property for setting ports # @endif # # void init(coil::Properties& prop); def init(self,prop): self._rtcout.RTC_TRACE("init()") self._properties.mergeProperties(prop) if self._singlebuffer: self._rtcout.RTC_DEBUG("single buffer mode.") self._thebuffer = OpenRTM_aist.CdrBufferFactory.instance().createObject("ring_buffer") if self._thebuffer is None: self._rtcout.RTC_ERROR("default buffer creation failed") else: self._rtcout.RTC_DEBUG("multi buffer mode.") self.initProviders() self.initConsumers() num = [-1] if not OpenRTM_aist.stringTo(num, self._properties.getProperty("connection_limit","-1")): self._rtcout.RTC_ERROR("invalid connection_limit value: %s", self._properties.getProperty("connection_limit")) self.setConnectionLimit(num[0]) return ## # @if jp # @brief RTObject_impl::readAll()から呼ばれる仮想関数 # # DataPort からデータを読み出す # # @return true:成功,false:失敗 # @else # @brief It is a virtual method that is called from RTObject_impl::readAll(). # This method reads out data from DataPort. # # @return true:Success,false:Failure # @endif # # virtual bool read() = 0; def read(self): pass ## # @if jp # @brief プロパティを取得する # # InPortのプロパティを取得する。 # # @return プロパティ # # @else # # @brief Get properties # # Getting properties of this InPort # # @return InPort's properties # # @endif # def properties(self): self._rtcout.RTC_TRACE("properties()") return self._properties ## # @if jp # @brief Connector を取得 # # 現在所有しているコネクタを取得する。 # # @return connector のリスト # # @else # # @brief Connector list # # This operation returns connector list # # @return connector list # # @endif # # const std::vector<InPortConnector*>& connectors(); def connectors(self): self._rtcout.RTC_TRACE("connectors(): size = %d", len(self._connectors)) # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) return self._connectors ## # @if jp # @brief ConnectorProfile を取得 # # 現在所有しているコネクタのProfileを取得する。 # # @return ConnectorProfile のリスト # # @else # # @brief ConnectorProfile list # # This operation returns ConnectorProfile list # # @return connector list # # @endif # # ConnectorInfoList getConnectorProfiles(); def getConnectorProfiles(self): self._rtcout.RTC_TRACE("getConnectorProfiles(): size = %d", len(self._connectors)) profs = [] # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) for con in self._connectors: profs.append(con.profile()) return profs ## # @if jp # @brief ConnectorId を取得 # # 現在所有しているコネクタのIDを取得する。 # # @return ConnectorId のリスト # # @else # # @brief ConnectorId list # # This operation returns ConnectorId list # # @return connector list # # @endif # # coil::vstring getConnectorIds(); def getConnectorIds(self): ids = [] # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) for con in self._connectors: ids.append(con.id()) self._rtcout.RTC_TRACE("getConnectorIds(): %s", OpenRTM_aist.flatten(ids)) return ids ## # @if jp # @brief Connectorの名前を取得 # # 現在所有しているコネクタの名前を取得する。 # # @return Connector名のリスト # # @else # # @brief Connector name list # # This operation returns Connector name list # # @return connector name list # # @endif # # coil::vstring getConnectorNames(); def getConnectorNames(self): names = [] # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) for con in self._connectors: names.append(con.name()) self._rtcout.RTC_TRACE("getConnectorNames(): %s", OpenRTM_aist.flatten(names)) return names ## # @if jp # @brief ConnectorProfileをIDで取得 # # 現在所有しているコネクタをIDで取得する。 # # @param id Connector ID # @return コネクタへのポインタ # # @else # # @brief Getting ConnectorProfile by ID # # This operation returns Connector specified by ID. # # @param id Connector ID # @return A pointer to connector # # @endif # # InPortConnector* getConnectorById(const char* id); def getConnectorById(self, id): self._rtcout.RTC_TRACE("getConnectorById(id = %s)", id) for con in self._connectors: if id == con.id(): return con self._rtcout.RTC_WARN("ConnectorProfile with the id(%s) not found.", id) return None ## # @if jp # @brief ConnectorProfileを名前で取得 # # 現在所有しているコネクタを名前で取得する。 # # @param name Connector name # @return コネクタへのポインタ # # @else # # @brief Getting Connector by name # # This operation returns Connector specified by name. # # @param id Connector ID # @return A pointer to connector # # @endif # # InPortConnector* getConnectorByName(const char* name); def getConnectorByName(self, name): self._rtcout.RTC_TRACE("getConnectorByName(name = %s)", name) for con in self._connectors: if name == con.name(): return con self._rtcout.RTC_WARN("ConnectorProfile with the name(%s) not found.", name) return None ## # @if jp # @brief ConnectorProfileをIDで取得 # # 現在所有しているコネクタをIDで取得する。 # # @param id Connector ID # @param prof ConnectorProfile # @return false 指定したIDがない # # @else # # @brief Getting ConnectorProfile by name # # This operation returns ConnectorProfile specified by name # # @param id Connector ID # @param prof ConnectorProfile # @return false specified ID does not exist # # @endif # # bool getConnectorProfileById(const char* id, # ConnectorInfo& prof); def getConnectorProfileById(self, id, prof): self._rtcout.RTC_TRACE("getConnectorProfileById(id = %s)", id) # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) conn = self.getConnectorById(id) if not conn: return False prof[0] = conn.profile() return True ## # @if jp # @brief ConnectorProfileを名前で取得 # # 現在所有しているコネクタを名前で取得する。 # # @param name Connector name # @param prof ConnectorProfile # @return false 指定した名前がない # # @else # # @brief Getting ConnectorProfile by name # # This operation returns ConnectorProfile specified by name # # @param id Connector ID # @param prof ConnectorProfile # @return false specified name does not exist # # @endif # # bool getConnectorProfileByName(const char* name, # ConnectorInfo& prof); def getConnectorProfileByName(self, name, prof): self._rtcout.RTC_TRACE("getConnectorProfileByName(name = %s)", name) # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) conn = self.getConnectorByName(name) if not conn: return False prof[0] = conn.profile() return True ## # @if jp # # @brief [CORBA interface] Port の接続を行う # # 与えられた ConnectoionProfile の情報に基づき、Port間の接続を確立 # する。この関数は主にアプリケーションプログラムやツールから呼び出 # すことを前提としている。 # # @param connector_profile ConnectorProfile # @return ReturnCode_t 型のリターンコード # # @else # # @brief [CORBA interface] Connect the Port # # This operation establishes connection according to the given # ConnectionProfile inforamtion. This function is premised on # calling from mainly application program or tools. # # @param connector_profile The ConnectorProfile. # @return ReturnCode_t The return code of ReturnCode_t type. # # @endif # def connect(self, connector_profile): self._rtcout.RTC_TRACE("InPortBase.connect()") if OpenRTM_aist.NVUtil.find_index(connector_profile.properties, "dataport.serializer.cdr.endian") is -1: self._rtcout.RTC_TRACE("ConnectorProfile dataport.serializer.cdr.endian set.") connector_profile.properties.append(OpenRTM_aist.NVUtil.newNV("dataport.serializer.cdr.endian","little,big")) return OpenRTM_aist.PortBase.connect(self, connector_profile) ## # @if jp # # @brief InPortを activates する # # InPortを activate する。 # # @else # # @brief Activate all Port interfaces # # This operation activate all interfaces that is registered in the # ports. # # @endif # # void activateInterfaces(); def activateInterfaces(self): self._rtcout.RTC_TRACE("activateInterfaces()") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) for connector in self._connectors: connector.activate() self._rtcout.RTC_DEBUG("activate connector: %s %s", (connector.name(),connector.id())) return ## # @if jp # # @brief 全ての Port のインターフェースを deactivates する # # Port に登録されている全てのインターフェースを deactivate する。 # # @else # # @brief Deactivate all Port interfaces # # This operation deactivate all interfaces that is registered in the # ports. # # @endif # # void deactivateInterfaces(); def deactivateInterfaces(self): self._rtcout.RTC_TRACE("deactivateInterfaces()") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) for connector in self._connectors: connector.deactivate() self._rtcout.RTC_DEBUG("deactivate connector: %s %s", (connector.name(),connector.id())) return ## # @if jp # @brief ConnectorDataListener リスナを追加する # # バッファ書き込みまたは読み出しイベントに関連する各種リスナを設定する。 # # 設定できるリスナのタイプとコールバックイベントは以下の通り # # - ON_BUFFER_WRITE: バッファ書き込み時 # - ON_BUFFER_FULL: バッファフル時 # - ON_BUFFER_WRITE_TIMEOUT: バッファ書き込みタイムアウト時 # - ON_BUFFER_OVERWRITE: バッファ上書き時 # - ON_BUFFER_READ: バッファ読み出し時 # - ON_SEND: InProtへの送信時 # - ON_RECEIVED: InProtへの送信完了時 # - ON_SEND_ERTIMEOUT: OutPort側タイムアウト時 # - ON_SEND_ERERROR: OutPort側エラー時 # - ON_RECEIVER_FULL: InProt側バッファフル時 # - ON_RECEIVER_TIMEOUT: InProt側バッファタイムアウト時 # - ON_RECEIVER_ERROR: InProt側エラー時 # # リスナは ConnectorDataListener を継承し、以下のシグニチャを持つ # operator() を実装している必要がある。 # # ConnectorDataListener:: # operator()(const ConnectorProfile&, const cdrStream&) # # デフォルトでは、この関数に与えたリスナオブジェクトの所有権は # OutPortに移り、OutPort解体時もしくは、 # removeConnectorDataListener() により削除時に自動的に解体される。 # リスナオブジェクトの所有権を呼び出し側で維持したい場合は、第3引 # 数に false を指定し、自動的な解体を抑制することができる。 # # @param listener_type リスナタイプ # @param listener リスナオブジェクトへのポインタ # @param autoclean リスナオブジェクトの自動的解体を行うかどうかのフラグ # # @else # @brief Adding BufferDataListener type listener # # This operation adds certain listeners related to buffer writing and # reading events. # The following listener types are available. # # - ON_BUFFER_WRITE: At the time of buffer write # - ON_BUFFER_FULL: At the time of buffer full # - ON_BUFFER_WRITE_TIMEOUT: At the time of buffer write timeout # - ON_BUFFER_OVERWRITE: At the time of buffer overwrite # - ON_BUFFER_READ: At the time of buffer read # - ON_SEND: At the time of sending to InPort # - ON_RECEIVED: At the time of finishing sending to InPort # - ON_SENDER_TIMEOUT: At the time of timeout of OutPort # - ON_SENDER_ERROR: At the time of error of OutPort # - ON_RECEIVER_FULL: At the time of bufferfull of InPort # - ON_RECEIVER_TIMEOUT: At the time of timeout of InPort # - ON_RECEIVER_ERROR: At the time of error of InPort # # Listeners should have the following function operator(). # # ConnectorDataListener:: # operator()(const ConnectorProfile&, const cdrStream&) # # The ownership of the given listener object is transferred to # this OutPort object in default. The given listener object will # be destroied automatically in the OutPort's dtor or if the # listener is deleted by removeConnectorDataListener() function. # If you want to keep ownership of the listener object, give # "false" value to 3rd argument to inhibit automatic destruction. # # @param listener_type A listener type # @param listener A pointer to a listener object # @param autoclean A flag for automatic listener destruction # # @endif # # void # addConnectorDataListener(ConnectorDataListenerType type, # ConnectorDataListener* listener, # bool autoclean) def addConnectorDataListener(self, listener_type, listener, autoclean = True): self._rtcout.RTC_TRACE("addConnectorDataListener()") if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM: self._listeners.connectorData_[listener_type].addListener(listener, autoclean) return self._rtcout.RTC_ERROR("addConnectorDataListener(): Invalid listener type.") return ## # @if jp # @brief ConnectorDataListener リスナを削除する # # 設定した各種リスナを削除する。 # # @param listener_type リスナタイプ # @param listener リスナオブジェクトへのポインタ # # @else # @brief Removing BufferDataListener type listener # # This operation removes a specified listener. # # @param listener_type A listener type # @param listener A pointer to a listener object # # @endif # # void removeConnectorDataListener(ConnectorDataListenerType type, # ConnectorDataListener* listener) def removeConnectorDataListener(self, listener_type, listener): self._rtcout.RTC_TRACE("removeConnectorDataListener()") if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM: self._listeners.connectorData_[listener_type].removeListener(listener) return self._rtcout.RTC_ERROR("removeConnectorDataListener(): Invalid listener type.") return ## # @if jp # @brief ConnectorListener リスナを追加する # # バッファ書き込みまたは読み出しイベントに関連する各種リスナを設定する。 # # 設定できるリスナのタイプは # # - ON_BUFFER_EMPTY: バッファが空の場合 # - ON_BUFFER_READTIMEOUT: バッファが空でタイムアウトした場合 # # リスナは以下のシグニチャを持つ operator() を実装している必要がある。 # # ConnectorListener::operator()(const ConnectorProfile&) # # デフォルトでは、この関数に与えたリスナオブジェクトの所有権は # OutPortに移り、OutPort解体時もしくは、 # removeConnectorListener() により削除時に自動的に解体される。 # リスナオブジェクトの所有権を呼び出し側で維持したい場合は、第3引 # 数に false を指定し、自動的な解体を抑制することができる。 # # @param listener_type リスナタイプ # @param listener リスナオブジェクトへのポインタ # @param autoclean リスナオブジェクトの自動的解体を行うかどうかのフラグ # # @else # @brief Adding ConnectorListener type listener # # This operation adds certain listeners related to buffer writing and # reading events. # The following listener types are available. # # - ON_BUFFER_EMPTY: At the time of buffer empty # - ON_BUFFER_READTIMEOUT: At the time of buffer read timeout # # Listeners should have the following function operator(). # # ConnectorListener::operator()(const ConnectorProfile&) # # The ownership of the given listener object is transferred to # this OutPort object in default. The given listener object will # be destroied automatically in the OutPort's dtor or if the # listener is deleted by removeConnectorListener() function. # If you want to keep ownership of the listener object, give # "false" value to 3rd argument to inhibit automatic destruction. # # @param listener_type A listener type # @param listener A pointer to a listener object # @param autoclean A flag for automatic listener destruction # # @endif # # void addConnectorListener(ConnectorListenerType type, # ConnectorListener* listener, # bool autoclean) def addConnectorListener(self, listener_type, listener, autoclean = True): self._rtcout.RTC_TRACE("addConnectorListener()") if listener_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM: self._listeners.connector_[listener_type].addListener(listener, autoclean) return self._rtcout.RTC_ERROR("addConnectorListener(): Invalid listener type.") return ## # @if jp # @brief ConnectorDataListener リスナを削除する # # 設定した各種リスナを削除する。 # # @param listener_type リスナタイプ # @param listener リスナオブジェクトへのポインタ # # @else # @brief Removing BufferDataListener type listener # # This operation removes a specified listener. # # @param listener_type A listener type # @param listener A pointer to a listener object # # @endif # # void removeConnectorListener(ConnectorListenerType type, # ConnectorListener* listener) def removeConnectorListener(self, listener_type, listener): self._rtcout.RTC_TRACE("removeConnectorListener()") if listener_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM: self._listeners.connector_[listener_type].removeListener(listener) return self._rtcout.RTC_ERROR("removeConnectorListener(): Invalid listener type.") return ## # @if jp # @brief Interface情報を公開する # # Interface情報を公開する。 # 引数の ConnectorProfile に格納されている dataflow_type が push 型 # の場合は、指定された interface_type の InPortProvider に関する情報 # を ConnectorProfile::properties に書込み呼び出し側に戻す。 # # dataport.dataflow_type # # @param connector_profile コネクタプロファイル # # @return ReturnCode_t 型のリターンコード # # @else # @brief Publish interface information # # Publish interface information. # Assign the Provider information that owned by this port # to ConnectorProfile#properties # # @param connector_profile The connector profile # # @return The return code of ReturnCode_t type # # @endif # # ReturnCode_t publishInterfaces(ConnectorProfile& connector_profile); def publishInterfaces(self, cprof): self._rtcout.RTC_TRACE("publishInterfaces()") retval = self._publishInterfaces() if retval != RTC.RTC_OK: return retval # prop: [port.outport]. prop = copy.deepcopy(self._properties) conn_prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties) prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile # marge ConnectorProfile for buffer property. prop.mergeProperties(conn_prop.getNode("dataport.inport")) # # ここで, ConnectorProfile からの properties がマージされたため、 # prop["dataflow_type"]: データフロータイプ # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dflow_type = OpenRTM_aist.normalize([dflow_type]) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... create PushConnector") # create InPortProvider provider = self.createProvider(cprof, prop) if not provider: self._rtcout.RTC_ERROR("InPort provider creation failed.") return RTC.BAD_PARAMETER # create InPortPushConnector connector = self.createConnector(cprof, prop, provider_=provider) if not connector: self._rtcout.RTC_ERROR("PushConnector creation failed.") return RTC.RTC_ERROR connector.setDataType(self._value) provider.setConnector(connector) # So that a provider gets endian information from a connector. self._rtcout.RTC_DEBUG("publishInterfaces() successfully finished.") return RTC.RTC_OK elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... do nothing") return RTC.RTC_OK self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceに接続する # # Interfaceに接続する。 # Portが所有するConsumerに適合するProviderに関する情報を # ConnectorProfile#properties から抽出し、 # ConsumerにCORBAオブジェクト参照を設定する。 # # @param connector_profile コネクタ・プロファイル # # @return ReturnCode_t 型のリターンコード # # @else # @brief Subscribe to the interface # # Subscribe to interface. # Derive Provider information that matches Consumer owned by the Port # from ConnectorProfile#properties and # set the Consumer to the reference of the CORBA object. # # @param connector_profile The connector profile # # @return ReturnCode_t The return code of ReturnCode_t type # # @endif # # ReturnCode_t subscribeInterfaces(const ConnectorProfile& connector_profile); def subscribeInterfaces(self, cprof): self._rtcout.RTC_TRACE("subscribeInterfaces()") # prop: [port.outport]. prop = copy.deepcopy(self._properties) conn_prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties) prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile prop.mergeProperties(conn_prop.getNode("dataport.inport")) # marge ConnectorProfile for buffer property. # # ここで, ConnectorProfile からの properties がマージされたため、 # prop["dataflow_type"]: データフロータイプ # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dtype = [dflow_type] OpenRTM_aist.normalize(dtype) dflow_type = dtype[0] profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... do nothing") conn = self.getConnectorById(cprof.connector_id) if not conn: self._rtcout.RTC_ERROR("specified connector not found: %s", cprof.connector_id) return RTC.RTC_ERROR ret = conn.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("subscribeInterfaces() successfully finished.") return ret elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... create PullConnector") # create OutPortConsumer consumer = self.createConsumer(cprof, prop) if not consumer: return RTC.BAD_PARAMETER # create InPortPullConnector connector = self.createConnector(cprof, prop, consumer_=consumer) if not connector: return RTC.RTC_ERROR ret = connector.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("publishInterface() successfully finished.") return ret self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceへの接続を解除する # # Interfaceへの接続を解除する。 # 与えられたConnectorProfileに関連するConsumerに設定された全てのObjectを # 解放し接続を解除する。 # # @param connector_profile コネクタ・プロファイル # # @else # @brief Disconnect the interface connection # # Disconnect the interface connection. # Release all objects set in Consumer associated with # given ConnectorProfile and unscribe the interface. # # @param connector_profile The connector profile # # @endif # # void unsubscribeInterfaces(const ConnectorProfile& connector_profile); def unsubscribeInterfaces(self, connector_profile): self._rtcout.RTC_TRACE("unsubscribeInterfaces()") id = connector_profile.connector_id self._rtcout.RTC_PARANOID("connector_id: %s", id) len_ = len(self._connectors) for i in range(len_): idx = (len_ - 1) - i # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) if id == self._connectors[idx].id(): # Connector's dtor must call disconnect() self._connectors[idx].deactivate() self._connectors[idx].disconnect() del self._connectors[idx] self._rtcout.RTC_TRACE("delete connector: %s", id) return self._rtcout.RTC_ERROR("specified connector not found: %s", id) return ## # @if jp # @brief InPort provider の初期化 # @else # @brief InPort provider initialization # @endif # # void initProviders(); def initProviders(self): self._rtcout.RTC_TRACE("initProviders()") # create InPort providers factory = OpenRTM_aist.InPortProviderFactory.instance() provider_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available providers: %s", OpenRTM_aist.flatten(provider_types)) if self._properties.hasKey("provider_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("provider_types")) != "all": self._rtcout.RTC_DEBUG("allowed providers: %s", self._properties.getProperty("provider_types")) temp_types = provider_types provider_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",") temp_types.sort() active_types.sort() set_ptypes = set(temp_types).intersection(set(active_types)) provider_types = provider_types + list(set_ptypes) # InPortProvider supports "push" dataflow type if len(provider_types) > 0: self._rtcout.RTC_DEBUG("dataflow_type push is supported") self.appendProperty("dataport.dataflow_type", "push") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(provider_types)) self._providerTypes = provider_types return ## # @if jp # @brief OutPort consumer の初期化 # @else # @brief OutPort consumer initialization # @endif # # void initConsumers(); def initConsumers(self): self._rtcout.RTC_TRACE("initConsumers()") # create OuPort consumers factory = OpenRTM_aist.OutPortConsumerFactory.instance() consumer_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available consumers: %s", OpenRTM_aist.flatten(consumer_types)) if self._properties.hasKey("consumer_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("consumer_types")) != "all": self._rtcout.RTC_DEBUG("allowed consumers: %s", self._properties.getProperty("consumer_types")) temp_types = consumer_types consumer_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",") temp_types.sort() active_types.sort() set_ctypes = set(temp_types).intersection(set(active_types)) consumer_types = consumer_types + list(set_ctypes) # OutPortConsumer supports "pull" dataflow type if len(consumer_types) > 0: self._rtcout.RTC_PARANOID("dataflow_type pull is supported") self.appendProperty("dataport.dataflow_type", "pull") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(consumer_types)) self._consumerTypes = consumer_types return ## # @if jp # @brief InPort provider の生成 # # InPortProvider を生成し、情報を ConnectorProfile に公開する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # InPortProvider* # createProvider(ConnectorProfile& cprof, coil::Properties& prop); def createProvider(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._providerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no provider found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._providerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty("interface_type")) if provider != 0: self._rtcout.RTC_DEBUG("provider created") provider.init(prop.getNode("provider")) if not provider.publishInterface(cprof.properties): self._rtcout.RTC_ERROR("publishing interface information error") OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider) return 0 return provider self._rtcout.RTC_ERROR("provider creation failed") return 0 ## # @if jp # @brief OutPort consumer の生成 # # OutPortConsumer を生成する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # OutPortConsumer* # createConsumer(const ConnectorProfile& cprof, coil::Properties& prop); def createConsumer(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._consumerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no consumer found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._consumerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) consumer = OpenRTM_aist.OutPortConsumerFactory.instance().createObject(prop.getProperty("interface_type")) if consumer != 0: self._rtcout.RTC_DEBUG("consumer created") consumer.init(prop.getNode("consumer")) if not consumer.subscribeInterface(cprof.properties): self._rtcout.RTC_ERROR("interface subscription failed.") OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(consumer) return 0 return consumer self._rtcout.RTC_ERROR("consumer creation failed") return 0 ## # @if jp # @brief InPortPushConnector の生成 # # Connector を生成し、生成が成功すれば m_connectors に保存する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPortPushConnector creation # @endif # # InPortConnector* # createConnector(ConnectorProfile& cprof, coil::Properties& prop, # InPortProvider* provider); def createConnector(self, cprof, prop, provider_=None, consumer_=None): profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) connector = None try: if provider_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners) elif consumer_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners) else: self._rtcout.RTC_ERROR("provider or consumer is not passed. returned 0;") return 0 if connector is None: self._rtcout.RTC_ERROR("InPortConnector creation failed") return 0 if provider_ is not None: self._rtcout.RTC_TRACE("InPortPushConnector created") elif consumer_ is not None: self._rtcout.RTC_TRACE("InPortPullConnector created") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) self._connectors.append(connector) self._rtcout.RTC_PARANOID("connector push backed: %d", len(self._connectors)) return connector except: self._rtcout.RTC_ERROR("InPortPushConnector creation failed") self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) return 0 self._rtcout.RTC_FATAL("never comes here: createConnector()") return 0
99  self._rtcout.RTC_DEBUG("setting port.port_type: DataInPort")
100  self.addProperty("port.port_type", "DataInPort")
101 
102  self._rtcout.RTC_DEBUG("setting port.data_type: %s", data_type)
103  self.addProperty("dataport.data_type", data_type)
104 
105  self.addProperty("dataport.subscription_type", "Any")
106  self._value = None
108 
109 
110 
123  def __del__(self, PortBase=OpenRTM_aist.PortBase):
124  self._rtcout.RTC_TRACE("InPortBase destructor")
125 
126  if len(self._connectors) != 0:
127  self._rtcout.RTC_ERROR("connector.size should be 0 in InPortBase's dtor.")
128  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
129  for connector in self._connectors:
130  connector.disconnect()
131 
132  if self._thebuffer is not None:
133  OpenRTM_aist.CdrBufferFactory.instance().deleteObject(self._thebuffer)
134  if not self._singlebuffer:
135  self._rtcout.RTC_ERROR("Although singlebuffer flag is true, the buffer != 0")
136 
137  PortBase.__del__(self)
138  return
139 
140 
141 
157  def init(self,prop):
158  self._rtcout.RTC_TRACE("init()")
159  self._properties.mergeProperties(prop)
160  if self._singlebuffer:
161  self._rtcout.RTC_DEBUG("single buffer mode.")
162  self._thebuffer = OpenRTM_aist.CdrBufferFactory.instance().createObject("ring_buffer")
163 
164  if self._thebuffer is None:
165  self._rtcout.RTC_ERROR("default buffer creation failed")
166  else:
167  self._rtcout.RTC_DEBUG("multi buffer mode.")
168 
169  self.initProviders()
170  self.initConsumers()
171 
172  num = [-1]
173  if not OpenRTM_aist.stringTo(num, self._properties.getProperty("connection_limit","-1")):
174  self._rtcout.RTC_ERROR("invalid connection_limit value: %s",
175  self._properties.getProperty("connection_limit"))
176 
177  self.setConnectionLimit(num[0])
178  return
179 
180 
181 
196  def read(self):
197  pass
198 
199 
217  def properties(self):
218  self._rtcout.RTC_TRACE("properties()")
219  return self._properties
220 
221 
222 
241  def connectors(self):
242  self._rtcout.RTC_TRACE("connectors(): size = %d", len(self._connectors))
243  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
244  return self._connectors
245 
246 
247 
267  self._rtcout.RTC_TRACE("getConnectorProfiles(): size = %d", len(self._connectors))
268  profs = []
269  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
270  for con in self._connectors:
271  profs.append(con.profile())
272 
273  return profs
274 
275 
294  def getConnectorIds(self):
295  ids = []
296 
297  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
298  for con in self._connectors:
299  ids.append(con.id())
300 
301  self._rtcout.RTC_TRACE("getConnectorIds(): %s", OpenRTM_aist.flatten(ids))
302  return ids
303 
304 
323  def getConnectorNames(self):
324  names = []
325  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
326  for con in self._connectors:
327  names.append(con.name())
328 
329  self._rtcout.RTC_TRACE("getConnectorNames(): %s", OpenRTM_aist.flatten(names))
330  return names
331 
332 
353  def getConnectorById(self, id):
354  self._rtcout.RTC_TRACE("getConnectorById(id = %s)", id)
355 
356  for con in self._connectors:
357  if id == con.id():
358  return con
359 
360  self._rtcout.RTC_WARN("ConnectorProfile with the id(%s) not found.", id)
361  return None
362 
363 
384  def getConnectorByName(self, name):
385  self._rtcout.RTC_TRACE("getConnectorByName(name = %s)", name)
386 
387  for con in self._connectors:
388  if name == con.name():
389  return con
390 
391  self._rtcout.RTC_WARN("ConnectorProfile with the name(%s) not found.", name)
392  return None
393 
394 
418  def getConnectorProfileById(self, id, prof):
419  self._rtcout.RTC_TRACE("getConnectorProfileById(id = %s)", id)
420 
421  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
422  conn = self.getConnectorById(id)
423  if not conn:
424  return False
425  prof[0] = conn.profile()
426  return True
427 
428 
429 
453  def getConnectorProfileByName(self, name, prof):
454  self._rtcout.RTC_TRACE("getConnectorProfileByName(name = %s)", name)
455 
456  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
457  conn = self.getConnectorByName(name)
458  if not conn:
459  return False
460  prof[0] = conn.profile()
461  return True
462 
463 
464 
489  def connect(self, connector_profile):
490  self._rtcout.RTC_TRACE("InPortBase.connect()")
491 
492  if OpenRTM_aist.NVUtil.find_index(connector_profile.properties,
493  "dataport.serializer.cdr.endian") is -1:
494  self._rtcout.RTC_TRACE("ConnectorProfile dataport.serializer.cdr.endian set.")
495  connector_profile.properties.append(OpenRTM_aist.NVUtil.newNV("dataport.serializer.cdr.endian","little,big"))
496 
497  return OpenRTM_aist.PortBase.connect(self, connector_profile)
498 
499 
517  self._rtcout.RTC_TRACE("activateInterfaces()")
518 
519  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
520  for connector in self._connectors:
521  connector.activate()
522  self._rtcout.RTC_DEBUG("activate connector: %s %s",
523  (connector.name(),connector.id()))
524 
525  return
526 
527 
528 
546  self._rtcout.RTC_TRACE("deactivateInterfaces()")
547 
548  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
549  for connector in self._connectors:
550  connector.deactivate()
551  self._rtcout.RTC_DEBUG("deactivate connector: %s %s",
552  (connector.name(),connector.id()))
553  return
554 
555 
556 
635  def addConnectorDataListener(self, listener_type, listener, autoclean = True):
636  self._rtcout.RTC_TRACE("addConnectorDataListener()")
637 
638  if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM:
639  self._listeners.connectorData_[listener_type].addListener(listener, autoclean)
640  return
641 
642  self._rtcout.RTC_ERROR("addConnectorDataListener(): Invalid listener type.")
643  return
644 
645 
646 
667  def removeConnectorDataListener(self, listener_type, listener):
668  self._rtcout.RTC_TRACE("removeConnectorDataListener()")
669 
670  if listener_type < OpenRTM_aist.ConnectorDataListenerType.CONNECTOR_DATA_LISTENER_NUM:
671  self._listeners.connectorData_[listener_type].removeListener(listener)
672  return
673 
674  self._rtcout.RTC_ERROR("removeConnectorDataListener(): Invalid listener type.")
675  return
676 
677 
678 
733  def addConnectorListener(self, listener_type, listener, autoclean = True):
734  self._rtcout.RTC_TRACE("addConnectorListener()")
735 
736  if listener_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM:
737  self._listeners.connector_[listener_type].addListener(listener, autoclean)
738  return
739 
740  self._rtcout.RTC_ERROR("addConnectorListener(): Invalid listener type.")
741  return
742 
743 
744 
765  def removeConnectorListener(self, listener_type, listener):
766  self._rtcout.RTC_TRACE("removeConnectorListener()")
767 
768  if listener_type < OpenRTM_aist.ConnectorListenerType.CONNECTOR_LISTENER_NUM:
769  self._listeners.connector_[listener_type].removeListener(listener)
770  return
771 
772  self._rtcout.RTC_ERROR("removeConnectorListener(): Invalid listener type.")
773  return
774 
775 
776 
805  def publishInterfaces(self, cprof):
806  self._rtcout.RTC_TRACE("publishInterfaces()")
807 
808  retval = self._publishInterfaces()
809  if retval != RTC.RTC_OK:
810  return retval
811 
812  # prop: [port.outport].
813  prop = copy.deepcopy(self._properties)
814 
815  conn_prop = OpenRTM_aist.Properties()
816  OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties)
817  prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile
818 
819  # marge ConnectorProfile for buffer property.
820  prop.mergeProperties(conn_prop.getNode("dataport.inport"))
821 
822  #
823  # ここで, ConnectorProfile からの properties がマージされたため、
824  # prop["dataflow_type"]: データフロータイプ # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dflow_type = OpenRTM_aist.normalize([dflow_type]) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... create PushConnector") # create InPortProvider provider = self.createProvider(cprof, prop) if not provider: self._rtcout.RTC_ERROR("InPort provider creation failed.") return RTC.BAD_PARAMETER # create InPortPushConnector connector = self.createConnector(cprof, prop, provider_=provider) if not connector: self._rtcout.RTC_ERROR("PushConnector creation failed.") return RTC.RTC_ERROR connector.setDataType(self._value) provider.setConnector(connector) # So that a provider gets endian information from a connector. self._rtcout.RTC_DEBUG("publishInterfaces() successfully finished.") return RTC.RTC_OK elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... do nothing") return RTC.RTC_OK self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceに接続する # # Interfaceに接続する。 # Portが所有するConsumerに適合するProviderに関する情報を # ConnectorProfile#properties から抽出し、 # ConsumerにCORBAオブジェクト参照を設定する。 # # @param connector_profile コネクタ・プロファイル # # @return ReturnCode_t 型のリターンコード # # @else # @brief Subscribe to the interface # # Subscribe to interface. # Derive Provider information that matches Consumer owned by the Port # from ConnectorProfile#properties and # set the Consumer to the reference of the CORBA object. # # @param connector_profile The connector profile # # @return ReturnCode_t The return code of ReturnCode_t type # # @endif # # ReturnCode_t subscribeInterfaces(const ConnectorProfile& connector_profile); def subscribeInterfaces(self, cprof): self._rtcout.RTC_TRACE("subscribeInterfaces()") # prop: [port.outport]. prop = copy.deepcopy(self._properties) conn_prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties) prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile prop.mergeProperties(conn_prop.getNode("dataport.inport")) # marge ConnectorProfile for buffer property. # # ここで, ConnectorProfile からの properties がマージされたため、 # prop["dataflow_type"]: データフロータイプ # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dtype = [dflow_type] OpenRTM_aist.normalize(dtype) dflow_type = dtype[0] profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... do nothing") conn = self.getConnectorById(cprof.connector_id) if not conn: self._rtcout.RTC_ERROR("specified connector not found: %s", cprof.connector_id) return RTC.RTC_ERROR ret = conn.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("subscribeInterfaces() successfully finished.") return ret elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... create PullConnector") # create OutPortConsumer consumer = self.createConsumer(cprof, prop) if not consumer: return RTC.BAD_PARAMETER # create InPortPullConnector connector = self.createConnector(cprof, prop, consumer_=consumer) if not connector: return RTC.RTC_ERROR ret = connector.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("publishInterface() successfully finished.") return ret self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceへの接続を解除する # # Interfaceへの接続を解除する。 # 与えられたConnectorProfileに関連するConsumerに設定された全てのObjectを # 解放し接続を解除する。 # # @param connector_profile コネクタ・プロファイル # # @else # @brief Disconnect the interface connection # # Disconnect the interface connection. # Release all objects set in Consumer associated with # given ConnectorProfile and unscribe the interface. # # @param connector_profile The connector profile # # @endif # # void unsubscribeInterfaces(const ConnectorProfile& connector_profile); def unsubscribeInterfaces(self, connector_profile): self._rtcout.RTC_TRACE("unsubscribeInterfaces()") id = connector_profile.connector_id self._rtcout.RTC_PARANOID("connector_id: %s", id) len_ = len(self._connectors) for i in range(len_): idx = (len_ - 1) - i # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) if id == self._connectors[idx].id(): # Connector's dtor must call disconnect() self._connectors[idx].deactivate() self._connectors[idx].disconnect() del self._connectors[idx] self._rtcout.RTC_TRACE("delete connector: %s", id) return self._rtcout.RTC_ERROR("specified connector not found: %s", id) return ## # @if jp # @brief InPort provider の初期化 # @else # @brief InPort provider initialization # @endif # # void initProviders(); def initProviders(self): self._rtcout.RTC_TRACE("initProviders()") # create InPort providers factory = OpenRTM_aist.InPortProviderFactory.instance() provider_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available providers: %s", OpenRTM_aist.flatten(provider_types)) if self._properties.hasKey("provider_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("provider_types")) != "all": self._rtcout.RTC_DEBUG("allowed providers: %s", self._properties.getProperty("provider_types")) temp_types = provider_types provider_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",") temp_types.sort() active_types.sort() set_ptypes = set(temp_types).intersection(set(active_types)) provider_types = provider_types + list(set_ptypes) # InPortProvider supports "push" dataflow type if len(provider_types) > 0: self._rtcout.RTC_DEBUG("dataflow_type push is supported") self.appendProperty("dataport.dataflow_type", "push") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(provider_types)) self._providerTypes = provider_types return ## # @if jp # @brief OutPort consumer の初期化 # @else # @brief OutPort consumer initialization # @endif # # void initConsumers(); def initConsumers(self): self._rtcout.RTC_TRACE("initConsumers()") # create OuPort consumers factory = OpenRTM_aist.OutPortConsumerFactory.instance() consumer_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available consumers: %s", OpenRTM_aist.flatten(consumer_types)) if self._properties.hasKey("consumer_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("consumer_types")) != "all": self._rtcout.RTC_DEBUG("allowed consumers: %s", self._properties.getProperty("consumer_types")) temp_types = consumer_types consumer_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",") temp_types.sort() active_types.sort() set_ctypes = set(temp_types).intersection(set(active_types)) consumer_types = consumer_types + list(set_ctypes) # OutPortConsumer supports "pull" dataflow type if len(consumer_types) > 0: self._rtcout.RTC_PARANOID("dataflow_type pull is supported") self.appendProperty("dataport.dataflow_type", "pull") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(consumer_types)) self._consumerTypes = consumer_types return ## # @if jp # @brief InPort provider の生成 # # InPortProvider を生成し、情報を ConnectorProfile に公開する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # InPortProvider* # createProvider(ConnectorProfile& cprof, coil::Properties& prop); def createProvider(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._providerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no provider found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._providerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty("interface_type")) if provider != 0: self._rtcout.RTC_DEBUG("provider created") provider.init(prop.getNode("provider")) if not provider.publishInterface(cprof.properties): self._rtcout.RTC_ERROR("publishing interface information error") OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider) return 0 return provider self._rtcout.RTC_ERROR("provider creation failed") return 0 ## # @if jp # @brief OutPort consumer の生成 # # OutPortConsumer を生成する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # OutPortConsumer* # createConsumer(const ConnectorProfile& cprof, coil::Properties& prop); def createConsumer(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._consumerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no consumer found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._consumerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) consumer = OpenRTM_aist.OutPortConsumerFactory.instance().createObject(prop.getProperty("interface_type")) if consumer != 0: self._rtcout.RTC_DEBUG("consumer created") consumer.init(prop.getNode("consumer")) if not consumer.subscribeInterface(cprof.properties): self._rtcout.RTC_ERROR("interface subscription failed.") OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(consumer) return 0 return consumer self._rtcout.RTC_ERROR("consumer creation failed") return 0 ## # @if jp # @brief InPortPushConnector の生成 # # Connector を生成し、生成が成功すれば m_connectors に保存する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPortPushConnector creation # @endif # # InPortConnector* # createConnector(ConnectorProfile& cprof, coil::Properties& prop, # InPortProvider* provider); def createConnector(self, cprof, prop, provider_=None, consumer_=None): profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) connector = None try: if provider_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners) elif consumer_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners) else: self._rtcout.RTC_ERROR("provider or consumer is not passed. returned 0;") return 0 if connector is None: self._rtcout.RTC_ERROR("InPortConnector creation failed") return 0 if provider_ is not None: self._rtcout.RTC_TRACE("InPortPushConnector created") elif consumer_ is not None: self._rtcout.RTC_TRACE("InPortPullConnector created") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) self._connectors.append(connector) self._rtcout.RTC_PARANOID("connector push backed: %d", len(self._connectors)) return connector except: self._rtcout.RTC_ERROR("InPortPushConnector creation failed") self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) return 0 self._rtcout.RTC_FATAL("never comes here: createConnector()") return 0
825  # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dflow_type = OpenRTM_aist.normalize([dflow_type]) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... create PushConnector") # create InPortProvider provider = self.createProvider(cprof, prop) if not provider: self._rtcout.RTC_ERROR("InPort provider creation failed.") return RTC.BAD_PARAMETER # create InPortPushConnector connector = self.createConnector(cprof, prop, provider_=provider) if not connector: self._rtcout.RTC_ERROR("PushConnector creation failed.") return RTC.RTC_ERROR connector.setDataType(self._value) provider.setConnector(connector) # So that a provider gets endian information from a connector. self._rtcout.RTC_DEBUG("publishInterfaces() successfully finished.") return RTC.RTC_OK elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... do nothing") return RTC.RTC_OK self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceに接続する # # Interfaceに接続する。 # Portが所有するConsumerに適合するProviderに関する情報を # ConnectorProfile#properties から抽出し、 # ConsumerにCORBAオブジェクト参照を設定する。 # # @param connector_profile コネクタ・プロファイル # # @return ReturnCode_t 型のリターンコード # # @else # @brief Subscribe to the interface # # Subscribe to interface. # Derive Provider information that matches Consumer owned by the Port # from ConnectorProfile#properties and # set the Consumer to the reference of the CORBA object. # # @param connector_profile The connector profile # # @return ReturnCode_t The return code of ReturnCode_t type # # @endif # # ReturnCode_t subscribeInterfaces(const ConnectorProfile& connector_profile); def subscribeInterfaces(self, cprof): self._rtcout.RTC_TRACE("subscribeInterfaces()") # prop: [port.outport]. prop = copy.deepcopy(self._properties) conn_prop = OpenRTM_aist.Properties() OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties) prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile prop.mergeProperties(conn_prop.getNode("dataport.inport")) # marge ConnectorProfile for buffer property. # # ここで, ConnectorProfile からの properties がマージされたため、 # prop["dataflow_type"]: データフロータイプ # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dtype = [dflow_type] OpenRTM_aist.normalize(dtype) dflow_type = dtype[0] profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... do nothing") conn = self.getConnectorById(cprof.connector_id) if not conn: self._rtcout.RTC_ERROR("specified connector not found: %s", cprof.connector_id) return RTC.RTC_ERROR ret = conn.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("subscribeInterfaces() successfully finished.") return ret elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... create PullConnector") # create OutPortConsumer consumer = self.createConsumer(cprof, prop) if not consumer: return RTC.BAD_PARAMETER # create InPortPullConnector connector = self.createConnector(cprof, prop, consumer_=consumer) if not connector: return RTC.RTC_ERROR ret = connector.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("publishInterface() successfully finished.") return ret self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceへの接続を解除する # # Interfaceへの接続を解除する。 # 与えられたConnectorProfileに関連するConsumerに設定された全てのObjectを # 解放し接続を解除する。 # # @param connector_profile コネクタ・プロファイル # # @else # @brief Disconnect the interface connection # # Disconnect the interface connection. # Release all objects set in Consumer associated with # given ConnectorProfile and unscribe the interface. # # @param connector_profile The connector profile # # @endif # # void unsubscribeInterfaces(const ConnectorProfile& connector_profile); def unsubscribeInterfaces(self, connector_profile): self._rtcout.RTC_TRACE("unsubscribeInterfaces()") id = connector_profile.connector_id self._rtcout.RTC_PARANOID("connector_id: %s", id) len_ = len(self._connectors) for i in range(len_): idx = (len_ - 1) - i # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) if id == self._connectors[idx].id(): # Connector's dtor must call disconnect() self._connectors[idx].deactivate() self._connectors[idx].disconnect() del self._connectors[idx] self._rtcout.RTC_TRACE("delete connector: %s", id) return self._rtcout.RTC_ERROR("specified connector not found: %s", id) return ## # @if jp # @brief InPort provider の初期化 # @else # @brief InPort provider initialization # @endif # # void initProviders(); def initProviders(self): self._rtcout.RTC_TRACE("initProviders()") # create InPort providers factory = OpenRTM_aist.InPortProviderFactory.instance() provider_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available providers: %s", OpenRTM_aist.flatten(provider_types)) if self._properties.hasKey("provider_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("provider_types")) != "all": self._rtcout.RTC_DEBUG("allowed providers: %s", self._properties.getProperty("provider_types")) temp_types = provider_types provider_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",") temp_types.sort() active_types.sort() set_ptypes = set(temp_types).intersection(set(active_types)) provider_types = provider_types + list(set_ptypes) # InPortProvider supports "push" dataflow type if len(provider_types) > 0: self._rtcout.RTC_DEBUG("dataflow_type push is supported") self.appendProperty("dataport.dataflow_type", "push") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(provider_types)) self._providerTypes = provider_types return ## # @if jp # @brief OutPort consumer の初期化 # @else # @brief OutPort consumer initialization # @endif # # void initConsumers(); def initConsumers(self): self._rtcout.RTC_TRACE("initConsumers()") # create OuPort consumers factory = OpenRTM_aist.OutPortConsumerFactory.instance() consumer_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available consumers: %s", OpenRTM_aist.flatten(consumer_types)) if self._properties.hasKey("consumer_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("consumer_types")) != "all": self._rtcout.RTC_DEBUG("allowed consumers: %s", self._properties.getProperty("consumer_types")) temp_types = consumer_types consumer_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",") temp_types.sort() active_types.sort() set_ctypes = set(temp_types).intersection(set(active_types)) consumer_types = consumer_types + list(set_ctypes) # OutPortConsumer supports "pull" dataflow type if len(consumer_types) > 0: self._rtcout.RTC_PARANOID("dataflow_type pull is supported") self.appendProperty("dataport.dataflow_type", "pull") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(consumer_types)) self._consumerTypes = consumer_types return ## # @if jp # @brief InPort provider の生成 # # InPortProvider を生成し、情報を ConnectorProfile に公開する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # InPortProvider* # createProvider(ConnectorProfile& cprof, coil::Properties& prop); def createProvider(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._providerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no provider found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._providerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty("interface_type")) if provider != 0: self._rtcout.RTC_DEBUG("provider created") provider.init(prop.getNode("provider")) if not provider.publishInterface(cprof.properties): self._rtcout.RTC_ERROR("publishing interface information error") OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider) return 0 return provider self._rtcout.RTC_ERROR("provider creation failed") return 0 ## # @if jp # @brief OutPort consumer の生成 # # OutPortConsumer を生成する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # OutPortConsumer* # createConsumer(const ConnectorProfile& cprof, coil::Properties& prop); def createConsumer(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._consumerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no consumer found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._consumerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) consumer = OpenRTM_aist.OutPortConsumerFactory.instance().createObject(prop.getProperty("interface_type")) if consumer != 0: self._rtcout.RTC_DEBUG("consumer created") consumer.init(prop.getNode("consumer")) if not consumer.subscribeInterface(cprof.properties): self._rtcout.RTC_ERROR("interface subscription failed.") OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(consumer) return 0 return consumer self._rtcout.RTC_ERROR("consumer creation failed") return 0 ## # @if jp # @brief InPortPushConnector の生成 # # Connector を生成し、生成が成功すれば m_connectors に保存する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPortPushConnector creation # @endif # # InPortConnector* # createConnector(ConnectorProfile& cprof, coil::Properties& prop, # InPortProvider* provider); def createConnector(self, cprof, prop, provider_=None, consumer_=None): profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) connector = None try: if provider_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners) elif consumer_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners) else: self._rtcout.RTC_ERROR("provider or consumer is not passed. returned 0;") return 0 if connector is None: self._rtcout.RTC_ERROR("InPortConnector creation failed") return 0 if provider_ is not None: self._rtcout.RTC_TRACE("InPortPushConnector created") elif consumer_ is not None: self._rtcout.RTC_TRACE("InPortPullConnector created") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) self._connectors.append(connector) self._rtcout.RTC_PARANOID("connector push backed: %d", len(self._connectors)) return connector except: self._rtcout.RTC_ERROR("InPortPushConnector creation failed") self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) return 0 self._rtcout.RTC_FATAL("never comes here: createConnector()") return 0
826  # などがアクセス可能になる。
827  #
828  dflow_type = prop.getProperty("dataflow_type")
829  dflow_type = OpenRTM_aist.normalize([dflow_type])
830 
831  if dflow_type == "push":
832  self._rtcout.RTC_DEBUG("dataflow_type = push .... create PushConnector")
833 
834  # create InPortProvider
835  provider = self.createProvider(cprof, prop)
836 
837  if not provider:
838  self._rtcout.RTC_ERROR("InPort provider creation failed.")
839  return RTC.BAD_PARAMETER
840 
841  # create InPortPushConnector
842  connector = self.createConnector(cprof, prop, provider_=provider)
843  if not connector:
844  self._rtcout.RTC_ERROR("PushConnector creation failed.")
845  return RTC.RTC_ERROR
846 
847  connector.setDataType(self._value)
848  provider.setConnector(connector) # So that a provider gets endian information from a connector.
849 
850  self._rtcout.RTC_DEBUG("publishInterfaces() successfully finished.")
851  return RTC.RTC_OK
852 
853  elif dflow_type == "pull":
854  self._rtcout.RTC_DEBUG("dataflow_type = pull .... do nothing")
855  return RTC.RTC_OK
856 
857  self._rtcout.RTC_ERROR("unsupported dataflow_type")
858  return RTC.BAD_PARAMETER
859 
860 
861 
889  def subscribeInterfaces(self, cprof):
890  self._rtcout.RTC_TRACE("subscribeInterfaces()")
891 
892  # prop: [port.outport].
893  prop = copy.deepcopy(self._properties)
894  conn_prop = OpenRTM_aist.Properties()
895  OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties)
896  prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile
897  prop.mergeProperties(conn_prop.getNode("dataport.inport")) # marge ConnectorProfile for buffer property.
898 
899  #
900  # ここで, ConnectorProfile からの properties がマージされたため、
901  # prop["dataflow_type"]: データフロータイプ # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dtype = [dflow_type] OpenRTM_aist.normalize(dtype) dflow_type = dtype[0] profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... do nothing") conn = self.getConnectorById(cprof.connector_id) if not conn: self._rtcout.RTC_ERROR("specified connector not found: %s", cprof.connector_id) return RTC.RTC_ERROR ret = conn.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("subscribeInterfaces() successfully finished.") return ret elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... create PullConnector") # create OutPortConsumer consumer = self.createConsumer(cprof, prop) if not consumer: return RTC.BAD_PARAMETER # create InPortPullConnector connector = self.createConnector(cprof, prop, consumer_=consumer) if not connector: return RTC.RTC_ERROR ret = connector.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("publishInterface() successfully finished.") return ret self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceへの接続を解除する # # Interfaceへの接続を解除する。 # 与えられたConnectorProfileに関連するConsumerに設定された全てのObjectを # 解放し接続を解除する。 # # @param connector_profile コネクタ・プロファイル # # @else # @brief Disconnect the interface connection # # Disconnect the interface connection. # Release all objects set in Consumer associated with # given ConnectorProfile and unscribe the interface. # # @param connector_profile The connector profile # # @endif # # void unsubscribeInterfaces(const ConnectorProfile& connector_profile); def unsubscribeInterfaces(self, connector_profile): self._rtcout.RTC_TRACE("unsubscribeInterfaces()") id = connector_profile.connector_id self._rtcout.RTC_PARANOID("connector_id: %s", id) len_ = len(self._connectors) for i in range(len_): idx = (len_ - 1) - i # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) if id == self._connectors[idx].id(): # Connector's dtor must call disconnect() self._connectors[idx].deactivate() self._connectors[idx].disconnect() del self._connectors[idx] self._rtcout.RTC_TRACE("delete connector: %s", id) return self._rtcout.RTC_ERROR("specified connector not found: %s", id) return ## # @if jp # @brief InPort provider の初期化 # @else # @brief InPort provider initialization # @endif # # void initProviders(); def initProviders(self): self._rtcout.RTC_TRACE("initProviders()") # create InPort providers factory = OpenRTM_aist.InPortProviderFactory.instance() provider_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available providers: %s", OpenRTM_aist.flatten(provider_types)) if self._properties.hasKey("provider_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("provider_types")) != "all": self._rtcout.RTC_DEBUG("allowed providers: %s", self._properties.getProperty("provider_types")) temp_types = provider_types provider_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",") temp_types.sort() active_types.sort() set_ptypes = set(temp_types).intersection(set(active_types)) provider_types = provider_types + list(set_ptypes) # InPortProvider supports "push" dataflow type if len(provider_types) > 0: self._rtcout.RTC_DEBUG("dataflow_type push is supported") self.appendProperty("dataport.dataflow_type", "push") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(provider_types)) self._providerTypes = provider_types return ## # @if jp # @brief OutPort consumer の初期化 # @else # @brief OutPort consumer initialization # @endif # # void initConsumers(); def initConsumers(self): self._rtcout.RTC_TRACE("initConsumers()") # create OuPort consumers factory = OpenRTM_aist.OutPortConsumerFactory.instance() consumer_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available consumers: %s", OpenRTM_aist.flatten(consumer_types)) if self._properties.hasKey("consumer_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("consumer_types")) != "all": self._rtcout.RTC_DEBUG("allowed consumers: %s", self._properties.getProperty("consumer_types")) temp_types = consumer_types consumer_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",") temp_types.sort() active_types.sort() set_ctypes = set(temp_types).intersection(set(active_types)) consumer_types = consumer_types + list(set_ctypes) # OutPortConsumer supports "pull" dataflow type if len(consumer_types) > 0: self._rtcout.RTC_PARANOID("dataflow_type pull is supported") self.appendProperty("dataport.dataflow_type", "pull") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(consumer_types)) self._consumerTypes = consumer_types return ## # @if jp # @brief InPort provider の生成 # # InPortProvider を生成し、情報を ConnectorProfile に公開する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # InPortProvider* # createProvider(ConnectorProfile& cprof, coil::Properties& prop); def createProvider(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._providerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no provider found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._providerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty("interface_type")) if provider != 0: self._rtcout.RTC_DEBUG("provider created") provider.init(prop.getNode("provider")) if not provider.publishInterface(cprof.properties): self._rtcout.RTC_ERROR("publishing interface information error") OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider) return 0 return provider self._rtcout.RTC_ERROR("provider creation failed") return 0 ## # @if jp # @brief OutPort consumer の生成 # # OutPortConsumer を生成する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # OutPortConsumer* # createConsumer(const ConnectorProfile& cprof, coil::Properties& prop); def createConsumer(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._consumerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no consumer found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._consumerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) consumer = OpenRTM_aist.OutPortConsumerFactory.instance().createObject(prop.getProperty("interface_type")) if consumer != 0: self._rtcout.RTC_DEBUG("consumer created") consumer.init(prop.getNode("consumer")) if not consumer.subscribeInterface(cprof.properties): self._rtcout.RTC_ERROR("interface subscription failed.") OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(consumer) return 0 return consumer self._rtcout.RTC_ERROR("consumer creation failed") return 0 ## # @if jp # @brief InPortPushConnector の生成 # # Connector を生成し、生成が成功すれば m_connectors に保存する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPortPushConnector creation # @endif # # InPortConnector* # createConnector(ConnectorProfile& cprof, coil::Properties& prop, # InPortProvider* provider); def createConnector(self, cprof, prop, provider_=None, consumer_=None): profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) connector = None try: if provider_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners) elif consumer_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners) else: self._rtcout.RTC_ERROR("provider or consumer is not passed. returned 0;") return 0 if connector is None: self._rtcout.RTC_ERROR("InPortConnector creation failed") return 0 if provider_ is not None: self._rtcout.RTC_TRACE("InPortPushConnector created") elif consumer_ is not None: self._rtcout.RTC_TRACE("InPortPullConnector created") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) self._connectors.append(connector) self._rtcout.RTC_PARANOID("connector push backed: %d", len(self._connectors)) return connector except: self._rtcout.RTC_ERROR("InPortPushConnector creation failed") self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) return 0 self._rtcout.RTC_FATAL("never comes here: createConnector()") return 0
902  # prop["interface_type"]: インターフェースタイプ # などがアクセス可能になる。 # dflow_type = prop.getProperty("dataflow_type") dtype = [dflow_type] OpenRTM_aist.normalize(dtype) dflow_type = dtype[0] profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) if dflow_type == "push": self._rtcout.RTC_DEBUG("dataflow_type = push .... do nothing") conn = self.getConnectorById(cprof.connector_id) if not conn: self._rtcout.RTC_ERROR("specified connector not found: %s", cprof.connector_id) return RTC.RTC_ERROR ret = conn.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("subscribeInterfaces() successfully finished.") return ret elif dflow_type == "pull": self._rtcout.RTC_DEBUG("dataflow_type = pull .... create PullConnector") # create OutPortConsumer consumer = self.createConsumer(cprof, prop) if not consumer: return RTC.BAD_PARAMETER # create InPortPullConnector connector = self.createConnector(cprof, prop, consumer_=consumer) if not connector: return RTC.RTC_ERROR ret = connector.setConnectorInfo(profile) if ret == RTC.RTC_OK: self._rtcout.RTC_DEBUG("publishInterface() successfully finished.") return ret self._rtcout.RTC_ERROR("unsupported dataflow_type") return RTC.BAD_PARAMETER ## # @if jp # @brief Interfaceへの接続を解除する # # Interfaceへの接続を解除する。 # 与えられたConnectorProfileに関連するConsumerに設定された全てのObjectを # 解放し接続を解除する。 # # @param connector_profile コネクタ・プロファイル # # @else # @brief Disconnect the interface connection # # Disconnect the interface connection. # Release all objects set in Consumer associated with # given ConnectorProfile and unscribe the interface. # # @param connector_profile The connector profile # # @endif # # void unsubscribeInterfaces(const ConnectorProfile& connector_profile); def unsubscribeInterfaces(self, connector_profile): self._rtcout.RTC_TRACE("unsubscribeInterfaces()") id = connector_profile.connector_id self._rtcout.RTC_PARANOID("connector_id: %s", id) len_ = len(self._connectors) for i in range(len_): idx = (len_ - 1) - i # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) if id == self._connectors[idx].id(): # Connector's dtor must call disconnect() self._connectors[idx].deactivate() self._connectors[idx].disconnect() del self._connectors[idx] self._rtcout.RTC_TRACE("delete connector: %s", id) return self._rtcout.RTC_ERROR("specified connector not found: %s", id) return ## # @if jp # @brief InPort provider の初期化 # @else # @brief InPort provider initialization # @endif # # void initProviders(); def initProviders(self): self._rtcout.RTC_TRACE("initProviders()") # create InPort providers factory = OpenRTM_aist.InPortProviderFactory.instance() provider_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available providers: %s", OpenRTM_aist.flatten(provider_types)) if self._properties.hasKey("provider_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("provider_types")) != "all": self._rtcout.RTC_DEBUG("allowed providers: %s", self._properties.getProperty("provider_types")) temp_types = provider_types provider_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",") temp_types.sort() active_types.sort() set_ptypes = set(temp_types).intersection(set(active_types)) provider_types = provider_types + list(set_ptypes) # InPortProvider supports "push" dataflow type if len(provider_types) > 0: self._rtcout.RTC_DEBUG("dataflow_type push is supported") self.appendProperty("dataport.dataflow_type", "push") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(provider_types)) self._providerTypes = provider_types return ## # @if jp # @brief OutPort consumer の初期化 # @else # @brief OutPort consumer initialization # @endif # # void initConsumers(); def initConsumers(self): self._rtcout.RTC_TRACE("initConsumers()") # create OuPort consumers factory = OpenRTM_aist.OutPortConsumerFactory.instance() consumer_types = factory.getIdentifiers() self._rtcout.RTC_DEBUG("available consumers: %s", OpenRTM_aist.flatten(consumer_types)) if self._properties.hasKey("consumer_types") and \ OpenRTM_aist.normalize(self._properties.getProperty("consumer_types")) != "all": self._rtcout.RTC_DEBUG("allowed consumers: %s", self._properties.getProperty("consumer_types")) temp_types = consumer_types consumer_types = [] active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",") temp_types.sort() active_types.sort() set_ctypes = set(temp_types).intersection(set(active_types)) consumer_types = consumer_types + list(set_ctypes) # OutPortConsumer supports "pull" dataflow type if len(consumer_types) > 0: self._rtcout.RTC_PARANOID("dataflow_type pull is supported") self.appendProperty("dataport.dataflow_type", "pull") self.appendProperty("dataport.interface_type", OpenRTM_aist.flatten(consumer_types)) self._consumerTypes = consumer_types return ## # @if jp # @brief InPort provider の生成 # # InPortProvider を生成し、情報を ConnectorProfile に公開する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # InPortProvider* # createProvider(ConnectorProfile& cprof, coil::Properties& prop); def createProvider(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._providerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no provider found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._providerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty("interface_type")) if provider != 0: self._rtcout.RTC_DEBUG("provider created") provider.init(prop.getNode("provider")) if not provider.publishInterface(cprof.properties): self._rtcout.RTC_ERROR("publishing interface information error") OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider) return 0 return provider self._rtcout.RTC_ERROR("provider creation failed") return 0 ## # @if jp # @brief OutPort consumer の生成 # # OutPortConsumer を生成する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPort provider creation # @endif # # OutPortConsumer* # createConsumer(const ConnectorProfile& cprof, coil::Properties& prop); def createConsumer(self, cprof, prop): if not prop.getProperty("interface_type") and \ not OpenRTM_aist.includes(self._consumerTypes, prop.getProperty("interface_type")): self._rtcout.RTC_ERROR("no consumer found") self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) self._rtcout.RTC_DEBUG("interface_types: %s", OpenRTM_aist.flatten(self._consumerTypes)) return 0 self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type")) consumer = OpenRTM_aist.OutPortConsumerFactory.instance().createObject(prop.getProperty("interface_type")) if consumer != 0: self._rtcout.RTC_DEBUG("consumer created") consumer.init(prop.getNode("consumer")) if not consumer.subscribeInterface(cprof.properties): self._rtcout.RTC_ERROR("interface subscription failed.") OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(consumer) return 0 return consumer self._rtcout.RTC_ERROR("consumer creation failed") return 0 ## # @if jp # @brief InPortPushConnector の生成 # # Connector を生成し、生成が成功すれば m_connectors に保存する。 # 生成に失敗した場合 0 を返す。 # # @else # @brief InPortPushConnector creation # @endif # # InPortConnector* # createConnector(ConnectorProfile& cprof, coil::Properties& prop, # InPortProvider* provider); def createConnector(self, cprof, prop, provider_=None, consumer_=None): profile = OpenRTM_aist.ConnectorInfo(cprof.name, cprof.connector_id, OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports), prop) connector = None try: if provider_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPushConnector(profile, provider_, self._listeners) elif consumer_ is not None: if self._singlebuffer: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners, self._thebuffer) else: connector = OpenRTM_aist.InPortPullConnector(profile, consumer_, self._listeners) else: self._rtcout.RTC_ERROR("provider or consumer is not passed. returned 0;") return 0 if connector is None: self._rtcout.RTC_ERROR("InPortConnector creation failed") return 0 if provider_ is not None: self._rtcout.RTC_TRACE("InPortPushConnector created") elif consumer_ is not None: self._rtcout.RTC_TRACE("InPortPullConnector created") # guard = OpenRTM_aist.ScopedLock(self._connector_mutex) self._connectors.append(connector) self._rtcout.RTC_PARANOID("connector push backed: %d", len(self._connectors)) return connector except: self._rtcout.RTC_ERROR("InPortPushConnector creation failed") self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) return 0 self._rtcout.RTC_FATAL("never comes here: createConnector()") return 0
903  # などがアクセス可能になる。
904  #
905  dflow_type = prop.getProperty("dataflow_type")
906  dtype = [dflow_type]
907  OpenRTM_aist.normalize(dtype)
908  dflow_type = dtype[0]
909 
910  profile = OpenRTM_aist.ConnectorInfo(cprof.name,
911  cprof.connector_id,
913  prop)
914  if dflow_type == "push":
915  self._rtcout.RTC_DEBUG("dataflow_type = push .... do nothing")
916 
917  conn = self.getConnectorById(cprof.connector_id)
918 
919  if not conn:
920  self._rtcout.RTC_ERROR("specified connector not found: %s",
921  cprof.connector_id)
922  return RTC.RTC_ERROR
923 
924  ret = conn.setConnectorInfo(profile)
925  if ret == RTC.RTC_OK:
926  self._rtcout.RTC_DEBUG("subscribeInterfaces() successfully finished.")
927 
928  return ret
929 
930  elif dflow_type == "pull":
931  self._rtcout.RTC_DEBUG("dataflow_type = pull .... create PullConnector")
932 
933  # create OutPortConsumer
934  consumer = self.createConsumer(cprof, prop)
935  if not consumer:
936  return RTC.BAD_PARAMETER
937 
938  # create InPortPullConnector
939  connector = self.createConnector(cprof, prop, consumer_=consumer)
940  if not connector:
941  return RTC.RTC_ERROR
942 
943  ret = connector.setConnectorInfo(profile)
944 
945  if ret == RTC.RTC_OK:
946  self._rtcout.RTC_DEBUG("publishInterface() successfully finished.")
947 
948  return ret
949 
950  self._rtcout.RTC_ERROR("unsupported dataflow_type")
951  return RTC.BAD_PARAMETER
952 
953 
954 
976  def unsubscribeInterfaces(self, connector_profile):
977  self._rtcout.RTC_TRACE("unsubscribeInterfaces()")
978 
979  id = connector_profile.connector_id
980  self._rtcout.RTC_PARANOID("connector_id: %s", id)
981 
982  len_ = len(self._connectors)
983  for i in range(len_):
984  idx = (len_ - 1) - i
985  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
986  if id == self._connectors[idx].id():
987  # Connector's dtor must call disconnect()
988  self._connectors[idx].deactivate()
989  self._connectors[idx].disconnect()
990  del self._connectors[idx]
991  self._rtcout.RTC_TRACE("delete connector: %s", id)
992  return
993 
994  self._rtcout.RTC_ERROR("specified connector not found: %s", id)
995  return
996 
997 
998 
1006  def initProviders(self):
1007  self._rtcout.RTC_TRACE("initProviders()")
1008 
1009  # create InPort providers
1010  factory = OpenRTM_aist.InPortProviderFactory.instance()
1011  provider_types = factory.getIdentifiers()
1012 
1013  self._rtcout.RTC_DEBUG("available providers: %s",
1014  OpenRTM_aist.flatten(provider_types))
1015 
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",
1019  self._properties.getProperty("provider_types"))
1020 
1021  temp_types = provider_types
1022  provider_types = []
1023  active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",")
1024 
1025  temp_types.sort()
1026  active_types.sort()
1027 
1028  set_ptypes = set(temp_types).intersection(set(active_types))
1029  provider_types = provider_types + list(set_ptypes)
1030 
1031  # InPortProvider supports "push" dataflow type
1032  if len(provider_types) > 0:
1033  self._rtcout.RTC_DEBUG("dataflow_type push is supported")
1034  self.appendProperty("dataport.dataflow_type", "push")
1035  self.appendProperty("dataport.interface_type",
1036  OpenRTM_aist.flatten(provider_types))
1037 
1038  self._providerTypes = provider_types
1039  return
1040 
1041 
1042 
1050  def initConsumers(self):
1051  self._rtcout.RTC_TRACE("initConsumers()")
1052 
1053  # create OuPort consumers
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))
1058 
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",
1062  self._properties.getProperty("consumer_types"))
1063 
1064  temp_types = consumer_types
1065  consumer_types = []
1066  active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",")
1067 
1068  temp_types.sort()
1069  active_types.sort()
1070 
1071  set_ctypes = set(temp_types).intersection(set(active_types))
1072  consumer_types = consumer_types + list(set_ctypes)
1073 
1074  # OutPortConsumer supports "pull" dataflow type
1075  if len(consumer_types) > 0:
1076  self._rtcout.RTC_PARANOID("dataflow_type pull is supported")
1077  self.appendProperty("dataport.dataflow_type", "pull")
1078  self.appendProperty("dataport.interface_type",
1079  OpenRTM_aist.flatten(consumer_types))
1080 
1081  self._consumerTypes = consumer_types
1082  return
1083 
1084 
1085 
1098  def createProvider(self, cprof, prop):
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",
1104  OpenRTM_aist.flatten(self._providerTypes))
1105  return 0
1106 
1107 
1108  self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type"))
1109  provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty("interface_type"))
1110 
1111  if provider != 0:
1112  self._rtcout.RTC_DEBUG("provider created")
1113  provider.init(prop.getNode("provider"))
1114 
1115  if not provider.publishInterface(cprof.properties):
1116  self._rtcout.RTC_ERROR("publishing interface information error")
1117  OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider)
1118  return 0
1119  return provider
1120 
1121  self._rtcout.RTC_ERROR("provider creation failed")
1122  return 0
1123 
1124 
1125 
1138  def createConsumer(self, cprof, prop):
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",
1144  OpenRTM_aist.flatten(self._consumerTypes))
1145  return 0
1146 
1147  self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type"))
1148  consumer = OpenRTM_aist.OutPortConsumerFactory.instance().createObject(prop.getProperty("interface_type"))
1149 
1150  if consumer != 0:
1151  self._rtcout.RTC_DEBUG("consumer created")
1152  consumer.init(prop.getNode("consumer"))
1153 
1154  if not consumer.subscribeInterface(cprof.properties):
1155  self._rtcout.RTC_ERROR("interface subscription failed.")
1156  OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(consumer)
1157  return 0
1158  return consumer
1159 
1160  self._rtcout.RTC_ERROR("consumer creation failed")
1161  return 0
1162 
1163 
1164 
1178  def createConnector(self, cprof, prop, provider_=None, consumer_=None):
1179  profile = OpenRTM_aist.ConnectorInfo(cprof.name,
1180  cprof.connector_id,
1182  prop)
1183  connector = None
1184 
1185 
1186  try:
1187  if provider_ is not None:
1188  if self._singlebuffer:
1189  connector = OpenRTM_aist.InPortPushConnector(profile, provider_,
1190  self._listeners,
1191  self._thebuffer)
1192  else:
1193  connector = OpenRTM_aist.InPortPushConnector(profile, provider_,
1194  self._listeners)
1195 
1196  elif consumer_ is not None:
1197  if self._singlebuffer:
1198  connector = OpenRTM_aist.InPortPullConnector(profile, consumer_,
1199  self._listeners,
1200  self._thebuffer)
1201  else:
1202  connector = OpenRTM_aist.InPortPullConnector(profile, consumer_,
1203  self._listeners)
1204 
1205  else:
1206  self._rtcout.RTC_ERROR("provider or consumer is not passed. returned 0;")
1207  return 0
1208 
1209 
1210  if connector is None:
1211  self._rtcout.RTC_ERROR("InPortConnector creation failed")
1212  return 0
1213 
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")
1218 
1219  # guard = OpenRTM_aist.ScopedLock(self._connector_mutex)
1220  self._connectors.append(connector)
1221  self._rtcout.RTC_PARANOID("connector push backed: %d", len(self._connectors))
1222  return connector
1223  except:
1224  self._rtcout.RTC_ERROR("InPortPushConnector creation failed")
1225  self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
1226  return 0
1227 
1228  self._rtcout.RTC_FATAL("never comes here: createConnector()")
1229  return 0
def activateInterfaces(self)
Activate all Port interfaces.
Definition: InPortBase.py:516
def refToVstring(objlist)
coil::vstring refToVstring(const CorbaRefSequence& objlist)
def removeConnectorDataListener(self, listener_type, listener)
Removing BufferDataListener type listener.
Definition: InPortBase.py:667
def disconnect(self, connector_id)
[CORBA interface] Disconnect the Port
Definition: PortBase.py:815
def addProperty(self, key, value)
Add NameValue data to PortProfile&#39;s properties.
Definition: PortBase.py:2184
def unsubscribeInterfaces(self, connector_profile)
Disconnect the interface connection.
Definition: InPortBase.py:976
def getConnectorByName(self, name)
Getting Connector by name.
Definition: InPortBase.py:384
def deactivateInterfaces(self)
Deactivate all Port interfaces.
Definition: InPortBase.py:545
def setConnectionLimit(self, limit_value)
Set the maximum number of connections.
Definition: PortBase.py:1760
def copyToProperties(prop, nvlist)
Copy to Proeprties from NVList.
Definition: NVUtil.py:118
The Properties class represents a persistent set of properties.
Definition: Properties.py:83
def read(self)
It is a virtual method that is called from RTObject_impl::readAll().
Definition: InPortBase.py:196
def initConsumers(self)
OutPort consumer initializationvoid initConsumers();.
Definition: InPortBase.py:1050
def getConnectorIds(self)
ConnectorId list.
Definition: InPortBase.py:294
def init(self, prop)
Initializing properties.
Definition: InPortBase.py:157
def getConnectorNames(self)
Connector name list.
Definition: InPortBase.py:323
def __init__(self, name, data_type)
Constructor.
Definition: InPortBase.py:87
def appendProperty(self, key, value)
Append NameValue data to PortProfile&#39;s properties.
Definition: PortBase.py:2209
def initProviders(self)
InPort provider initializationvoid initProviders();.
Definition: InPortBase.py:1006
def connect(self, connector_profile)
[CORBA interface] Connect the Port
Definition: InPortBase.py:489
def createConnector(self, cprof, prop, provider_=None, consumer_=None)
InPortPushConnector creationInPortConnector* createConnector(ConnectorProfile& cprof, coil::Properties& prop, InPortProvider* provider);.
Definition: InPortBase.py:1178
def find_index(nv, name)
Definition: NVUtil.py:229
def addConnectorListener(self, listener_type, listener, autoclean=True)
Adding ConnectorListener type listener.
Definition: InPortBase.py:733
def getConnectorProfileById(self, id, prof)
Getting ConnectorProfile by name.
Definition: InPortBase.py:418
def removeConnectorListener(self, listener_type, listener)
Removing BufferDataListener type listener.
Definition: InPortBase.py:765
def createConsumer(self, cprof, prop)
InPort provider creationOutPortConsumer* createConsumer(const ConnectorProfile& cprof, coil::Properties& prop);.
Definition: InPortBase.py:1138
def getConnectorById(self, id)
Getting ConnectorProfile by ID.
Definition: InPortBase.py:353
def getConnectorProfileByName(self, name, prof)
Getting ConnectorProfile by name.
Definition: InPortBase.py:453
def connectors(self)
Connector list.
Definition: InPortBase.py:241
def subscribeInterfaces(self, cprof)
Subscribe to the interface.
Definition: InPortBase.py:889
def _publishInterfaces(self)
Publish interface information.
Definition: PortBase.py:1786
def addConnectorDataListener(self, listener_type, listener, autoclean=True)
Adding BufferDataListener type listener.
Definition: InPortBase.py:635
def __del__(self, PortBase=OpenRTM_aist.PortBase)
Destructor.
Definition: InPortBase.py:123
def append(dest, src)
Definition: NVUtil.py:386
def getConnectorProfiles(self)
ConnectorProfile list.
Definition: InPortBase.py:266
def createProvider(self, cprof, prop)
InPort provider creationInPortProvider* createProvider(ConnectorProfile& cprof, coil::Properties& pro...
Definition: InPortBase.py:1098
def publishInterfaces(self, cprof)
Publish interface information.
Definition: InPortBase.py:805
def newNV(name, value)
Create NameVale.
Definition: NVUtil.py:50
def properties(self)
Get properties.
Definition: InPortBase.py:217


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