pyrcf.utils.data_io_utils.pyrcf_publisher ========================================= .. py:module:: pyrcf.utils.data_io_utils.pyrcf_publisher Attributes ---------- .. autoapisummary:: pyrcf.utils.data_io_utils.pyrcf_publisher.DEFAULT_ZMQ_PUBLISH_PORT pyrcf.utils.data_io_utils.pyrcf_publisher.DEFAULT_PLOTJUGGLER_PUBLISH_PORT Classes ------- .. autoapisummary:: pyrcf.utils.data_io_utils.pyrcf_publisher.PyRCFTypesEncoder pyrcf.utils.data_io_utils.pyrcf_publisher.PyRCFPublisherBase pyrcf.utils.data_io_utils.pyrcf_publisher.PyRCFPublisherZMQ pyrcf.utils.data_io_utils.pyrcf_publisher.PlotJugglerPublisher Module Contents --------------- .. py:data:: DEFAULT_ZMQ_PUBLISH_PORT :type: int :value: 5001 .. py:data:: DEFAULT_PLOTJUGGLER_PUBLISH_PORT :type: int :value: 9872 .. py:class:: PyRCFTypesEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None) Bases: :py:obj:`json.JSONEncoder` Custom json encoding for handling datatypes in custom PyRCF datatypes. .. py:method:: default(o) Implement this method in a subclass such that it returns a serializable object for ``o``, or calls the base implementation (to raise a ``TypeError``). For example, to support arbitrary iterators, you could implement default like this:: def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o) .. py:class:: PyRCFPublisherBase Bases: :py:obj:`abc.ABC` Base publisher class. .. py:method:: publish(data: dict) :abstractmethod: Publish serialised data using this PyRCFPublisher. .. py:method:: close() Close publisher cleanly. .. py:class:: PyRCFPublisherZMQ(port: int = DEFAULT_ZMQ_PUBLISH_PORT) Bases: :py:obj:`PyRCFPublisherBase` A zero MQ publisher for publishing json serialised data to specified port. .. py:attribute:: socket .. py:method:: publish(data: dict) Publish the provided dictionary data as a JSON string to the pre-defined port. :param data: Data as a dictionary. :type data: dict, optional .. py:method:: close() Close publisher cleanly. .. py:method:: __del__() .. py:class:: PlotJugglerPublisher Bases: :py:obj:`PyRCFPublisherZMQ` PlotJugglerPublisher is used to stream data to PlotJuggler and plot them in real time. On PlotJuggler, choose ZMQ Subscriber for data streaming, the port is used to identify the data channel. Publishes data to tcp port 9872 (default for plotjuggler).