Loading a Connector =================== .. py:currentmodule:: rticonnextdds_connector Importing the Connector package ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To use the ``rticonnextdds_connector`` package, import it. For example: .. testcode:: import rticonnextdds_connector as rti Creating a new Connector ~~~~~~~~~~~~~~~~~~~~~~~~ To create a new :class:`Connector`, pass an XML file and a configuration name: .. testcode:: connector = rti.Connector("MyParticipantLibrary::MyParticipant", "ShapeExample.xml"); The XML file defines your types, QoS profiles, and DDS Entities. *Connector* uses the XML schema of `RTI's XML-Based Application Creation `__. The previous code loads the ```` named *MyParticipant* in the ```` named *MyParticipantLibrary*, which is defined in the file ``ShapeExample.xml``:: ... See the full file here: `ShapeExample.xml `__. When you create a :class:`Connector`, the DDS *DomainParticipant* that you selected and all its contained entities (*Topics*, *Subscribers*, *DataReaders*, *Publishers*, *DataWriters*) are created. For more information about the DDS entities, see `Core Concepts `__ in the *RTI Connext DDS Core Libraries User's Manual*. .. note:: Operations on the same :class:`Connector` instance or its contained entities are not protected for multi-threaded access. See :ref:`Threading model` for more information. Closing a Connector ~~~~~~~~~~~~~~~~~~~ To destroy all the DDS entities that belong to a previously created :class:`Connector`, call :meth:`Connector.close()`: .. testcode:: connector = rti.Connector("MyParticipantLibrary::MyParticipant", "ShapeExample.xml") # ... connector.close() Alternatively, you can use the :meth:`open_connector` resource manager to open and automatically close the connector: .. testcode:: with rti.open_connector("MyParticipantLibrary::MyParticipant", "ShapeExample.xml") as connector: # Use connector input = connector.get_input("MySubscriber::MySquareReader") # ... Getting the Inputs and Outputs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Once you have created a :class:`Connector` instance, :meth:`Connector.get_output()` returns the :class:`Output` that allows writing data, and :meth:`Connector.get_input()` returns the :class:`Input` that allows reading data. .. note:: If the ```` you load contains both ```` (Output) and ```` (Input) tags for the same *Topic* and they have matching QoS, when you write data, the Inputs will receive the data even before you call :meth:`Connector.get_input()`. To avoid that, you can configure the ```` that contains the ```` with ``//`` set to ``false``. Then the Inputs will only receive data after you call :meth:`Connector.get_input()`. For more information see: * :ref:`Writing data (Output)` * :ref:`Reading data (Input)` Class reference: Connector ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: rticonnextdds_connector.Connector :members: .. autofunction:: rticonnextdds_connector.open_connector