Clients

Data/Image/Command clients: publish/subscribe communication (TCP/IPC), with connection targets set by the central configuration.

Overview

quatm/servers/clients.py provides the communication clients: the connection target is determined by the central configuration (Data / Image / Command Hub). GenericClient offers the standard send/receive interface and is suited to small data (<10k); use ImageClient for large payloads such as images.

Client classes

ClassConnectionDescription
GenericClientDetermined by configurationGeneral send/receive (including numpy arrays), subscribe/unsubscribe
DataClientData HubPublish and subscribe ordinary data
ImageClientImage HubSending large image-scale data (send takes a numpy array directly)
CommandClientCommand HubSends control commands to drivers (the command name is folded into the topic)
NpEncoder—JSON serialization of numpy types

Key methods (GenericClient)

MethodDescription
send(datadict, arr=None)Publish data (optionally with one numpy array)
recv()Receive one frame: (topic, dict[, array]); returns None on timeout
subscribe / unsubscribeSubscribe / unsubscribe a channel
has_new_dataNon-blocking check for new data
closeClose the PUB/SUB socket (idempotent)

Usage

from quatm.servers.clients import DataClient

dc = DataClient(name="pmt")
dc.send({"pmt": 1234}, arr=numpy_array)
topic, data = dc.recv()