Skip to content

zmq_qt

ZMQ utilities to receive data from OnDA Monitors.

This module contains classes and functions that allow external programs to receive data from an OnDA Monitor over a ZMQ socket.

ZmqDataListener

Bases: QtCore.QObject

See documentation for the __init__ function.

zmqmessage: Any = QtCore.pyqtSignal(dict) class-attribute instance-attribute

Qt signal emitted when data is received.

This signal is emitted by this class when it receives data from an OnDA Monitor. It brings the received data as payload.

__init__(*, url, tag)

Data receiving socket for external programs.

This class manages a listening socket that can receive data broadcast by an OnDA Monitor. The class must be initialized with the URL address, in ZeroMQ format, of the broadcasting socket of the monitor. It then creates a receiving socket that listens for data, but only when is tagged with a specific label, provided to the class when it is initialized. Every time the socket receives data, this class emits a Qt signal carrying the received data as payload. This class is designed to be run in a separate thread from the main graphical interface program. The main program can listen for the signal emitted by this class to determine when new data has been received.

This class is designed to be executed in a Qt thread. It creates a ZMQ SUB socket that connects to an OM's PUB socket, subscribing to a single specific topic. When the socket receives data, this class emits a zmqmessage Qt signal that other threads can listen to. The signal carries the received data.

Parameters:

Name Type Description Default
url str

The URL to which the PUB socket will connect. It must be a URL string in the format used by ZeroMQ.

required
tag str

The label used by the socket to filter incoming data. Only data whose label matches this argument will be accepted and received.

required

start_listening()

Connects to a OM's broadcasting socket and starts listening for data.

This function connects the listening socket to a data source broadcasting at the URL provided to the class at initialization. The socket starts receiving data immediately.

Raises:

Type Description
OmInvalidZmqUrl

Raised if any error happens while the socket is being connected to the data broadcasting source.

stop_listening()

Stops listening to an OM's broadcasting socket and disconnects.

This function completely disconnects the listening socket from the broadcasting source. The socket needs to be reconnected (using the start_listening function) to start receiving data again.