pyrcf.utils.data_io_utils.pyrcf_publisher

Attributes

DEFAULT_ZMQ_PUBLISH_PORT

DEFAULT_PLOTJUGGLER_PUBLISH_PORT

Classes

PyRCFTypesEncoder

Custom json encoding for handling datatypes in custom PyRCF datatypes.

PyRCFPublisherBase

Base publisher class.

PyRCFPublisherZMQ

A zero MQ publisher for publishing json serialised data to specified port.

PlotJugglerPublisher

PlotJugglerPublisher is used to stream data to PlotJuggler and plot them in real time.

Module Contents

pyrcf.utils.data_io_utils.pyrcf_publisher.DEFAULT_ZMQ_PUBLISH_PORT: int = 5001
pyrcf.utils.data_io_utils.pyrcf_publisher.DEFAULT_PLOTJUGGLER_PUBLISH_PORT: int = 9872
class pyrcf.utils.data_io_utils.pyrcf_publisher.PyRCFTypesEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: json.JSONEncoder

Custom json encoding for handling datatypes in custom PyRCF datatypes.

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)
class pyrcf.utils.data_io_utils.pyrcf_publisher.PyRCFPublisherBase

Bases: abc.ABC

Base publisher class.

abstract publish(data: dict)

Publish serialised data using this PyRCFPublisher.

close()

Close publisher cleanly.

class pyrcf.utils.data_io_utils.pyrcf_publisher.PyRCFPublisherZMQ(port: int = DEFAULT_ZMQ_PUBLISH_PORT)

Bases: PyRCFPublisherBase

A zero MQ publisher for publishing json serialised data to specified port.

socket
publish(data: dict)

Publish the provided dictionary data as a JSON string to the pre-defined port.

Parameters:

data (dict, optional) – Data as a dictionary.

close()

Close publisher cleanly.

__del__()
class pyrcf.utils.data_io_utils.pyrcf_publisher.PlotJugglerPublisher

Bases: 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).