ZMQRemoteAdapter class

hardware_control.base.ZMQRemoteAdapter module

Code to enable running and connecting to instruments on a different computer.

class hardware_control.base.ZMQRemoteAdapter.ZMQRemoteAdapter(name, address, context, publisher)

Bases: object

A placeholder for a remote instrument that, for example, could be running on a remote computer.

To be able to connect to an instrument on a remote computer. The program on that computer needs to wrap the instrument driver in the ZMQSingleInstrument.

ZMQRemoteAdapter is used in the main app to connect to ZMQSingleInstrument and will handle all the REQ/REP commands that are needed.

This class then sets up the required communication by using a separate ZMQ REQ/REP channel.

The REQ/REP channel implements the following commands

APP <publisher ip:publisher port>

The ZMQ address the remote instrument needs to subscribe to. The remote end needs to respond with the remote ZMQ publisher that the app needs to connect to

LIST_PARAMETERS

List all available read and set parameters and command names

STOP

Unsubscribe the remote end and close the connection

join()

Duck type to make this class behave similar to a Thread.

At the end of the app, all instruments running in separate threads are ended and those threads are then joined back into the main app. This method provides the same interface and will disconnect the remote instrument from the app.

list_parameters()

Get a list of all available parameters from the remote instrument.

Needed so that the instrument can be registered with the app and the necessary app._data entries can be created.

class hardware_control.base.ZMQRemoteAdapter.ZMQSingleInstrument(instrument: Instrument, address: str)

Bases: object

Wraps an instrument so that another app can connect to it.

This is meant to be run outside the app, e.g., on another computer. The instrument driver in this case will create its own publisher, and we need to have the remote app subscribe to it and also subscribe to the publisher of the remote app.

To solve the problems of subscribing to a remote app, we add a request/reply ZMQ channel with a fixed port. The remote app can then use this channel to supply this class with the ip address and port to be used to listen to commands.

ZMQSingleInstrument is meant to wrap a single instrument driver. It creates a single REQ/REP channel that a main App can use to establish connection. It then creates the standard ZMQ publisher and subscriber to talk to the remote App.

Currently there is no way to end a ZMQSingleInstrument instance and one needs to exit via Ctrl-C.

Parameters:
  • instrument – An instrument driver

  • address – The ZMQ address for a REQ/REP socket that is used to estable the communication with a remote app. Should be in “<ipaddress>:<portnumber>” format