Usage

There are two ways to drive this device, both exposing the same parameters and operations: locally (in-process, on the machine physically connected to the instrument) or remotely (over TCP through a client). The reference pages — Parameters, Functions and Standard Methods — list everything you can read, write and call.

Local (in-process)

Construct the device and use it as a context manager: it connects on entry and disconnects on exit. Read and write parameters by name, and call operations as methods.

from plesty.pm100d import Device

with Device() as device:  # pass address=... / connection args as needed
    device.write("wavelength", value)   # set a parameter
    reading = device.query("wavelength")  # read a parameter
    result = device.measure_power(...)  # call an operation
    snapshot = device.get_state()  # every parameter at once

Writes are validated against the type and range shown on the Parameters page; read-only parameters reject writes.

Remote (over TCP, via a client)

On the machine connected to the instrument, run the device as a server:

uv run python -m plesty.pm100d --tcp-port 5555

From anywhere else, connect a client to that server and use the same API — parameter reads/writes and operation calls are proxied over the network:

from plesty.lib.service import build_client

with build_client("tcp://<host>:5555") as client:
    client.write("wavelength", value)
    reading = client.query("wavelength")
    result = client.measure_power(...)  # bound as a method after connect
    result = client.call("measure_power", ...)  # or dispatch by name
    info = client.describe()  # discover parameters and operations

After connect(), registered operations are bound directly as client methods, so calling client.<operation>(...) works just like the local call, while client.call("<operation>", ...) dispatches the same operation by name.