# 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](parameters.md), [Functions](functions.md) and [Standard Methods](standard_methods.md) — 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. ```python 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](parameters.md) 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: ```bash 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: ```python from plesty.lib.service import build_client with build_client("tcp://: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.(...)` works just like the local call, while `client.call("", ...)` dispatches the same operation by name.