Skip to main content

Python interface to the caenhv-client GUI: fire/raise the application from other Python projects (e.g. labscript BLACS)

Project description

caenhv-client-python

Python interface to the caenhv-client GUI (CAEN HV control with channel linking). Zero dependencies; the GUI itself is distributed as a standalone executable.

Two capabilities:

  1. Fire the GUI — raise its window if running, launch it otherwise.
  2. Control HV through the GUI — the GUI is the single gateway to the devman server, so remote setpoints are executed by it and pass through its channel-link engine and safeguards (ramp/PDwn sync, SVMax validation, trip protection). Control requires a token configured on the GUI; without one the channel is show/raise-only.
from caenhv_client_python import fire_gui, notify_gui

fire_gui()      # raise the window if running, otherwise launch the GUI
notify_gui()    # raise only; returns False if the GUI is not running

Remote HV control (the GUI must have CAENHV_CLIENT_TCP_PORT and a CAENHV_CLIENT_TCP_TOKEN set, and be running on the target host).

Recommended — a bound client, set host/port/token once:

from caenhv_client_python import RemoteClient

hv = RemoteClient("hv-pc", 50251, token="labsecret")   # or RemoteClient.from_env()
hv.set_vset(0, 0, 5.0)          # slot 0, channel 0 -> 5.0 V (linked + safeguarded)
hv.set_power(0, 0, True)
print(hv.get_channel(0, 0))     # readings + settings
hv.set_param(0, 0, "rup", 10.0) # rup, rdown, iset, trip, svmax, pdown
hv.raise_window()               # bring the GUI forward (no focus steal)

Typed getters mirror the setters (each returns one value, raising a clear error if the parameter could not be read):

hv.get_vset(0, 0)          # float, volts (signed by polarity)
hv.get_vmon(0, 0)          # float, measured voltage (signed)
hv.get_imon(0, 0)          # float, measured current
hv.get_power(0, 0)         # bool
hv.get_status(0, 0)        # int, CAEN Status bitmask
hv.get_param(0, 0, "svmax")  # rup, rdown, iset, trip, svmax, pdown

Channel-link relationship and offset:

hv.get_link(0, 1)          # {'reference': '0:0', 'offset': -200.0} (or None when unlinked)
hv.get_offset(0, 1)        # -200.0
hv.set_offset(0, 1, -150.0)  # change the relative level (linked + safeguarded)
hv.get_links()             # {'0:1': {'reference': '0:0', 'offset': -200.0}, ...} for the whole crate

For several fields at once, get_channel(0, 0) returns them all in one round-trip: keys vset, vmon, imon, power, status, rup, rdown, iset, trip, svmax, pdown, label (a key is absent if that parameter could not be read).

The module-level functions (set_vset, set_power, get_channel, set_offset, set_param, send_command) remain available if you prefer passing host=, port=, token= per call. Any safeguard rejection (e.g. exceeding SVMax) raises RuntimeError with the reason, and nothing moves.

Remote hosts: with fire_gui(host="hv-pc", port=50251) (or CAENHV_CLIENT_REMOTE=hv-pc:50251) the show request goes over TCP to a GUI on another machine. The GUI must enable its listener (CAENHV_CLIENT_TCP_PORT=50251, optional CAENHV_CLIENT_TCP_BIND / CAENHV_CLIENT_TCP_TOKEN) and must already be running there — remote launch is impossible, so auto-start the GUI at login on that host. This channel can only show/raise the window, never change HV state.

Configuration via environment variables:

  • CAENHV_CLIENT_COMMAND — path (or command line) of the caenhv-client executable, used when it is not on PATH.
  • CAENHV_CLIENT_IPC_NAME — IPC server name (default caenhv-client), must match the GUI's setting when overridden.
  • CAENHV_CLIENT_REMOTEhost:port of a remote GUI's TCP listener.
  • CAENHV_CLIENT_TCP_TOKEN — shared token when the remote listener requires one.

Works from any Python process, including labscript BLACS tabs and workers; no Qt required (a Unix-socket / named-pipe transport is used, with PyQt5 as an optional fallback).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caenhv_client_python-0.6.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caenhv_client_python-0.6.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file caenhv_client_python-0.6.0.tar.gz.

File metadata

  • Download URL: caenhv_client_python-0.6.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for caenhv_client_python-0.6.0.tar.gz
Algorithm Hash digest
SHA256 8c022987e194b30bc3713ef1611490d5bd8e418c2ed62d0c54b8ea4a9ffec8c9
MD5 95f602e99eb0d5eb458d442a98d94151
BLAKE2b-256 db18570a2c3140f87739cc406104fbdfe54aed11bdcc57fe044705913ac66e1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for caenhv_client_python-0.6.0.tar.gz:

Publisher: publish-python.yml on kenji0923/caenhv-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file caenhv_client_python-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for caenhv_client_python-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55ce9a7cfdbae04fb477ae6de41310865be58370daa97a433568d0376a85664b
MD5 9cddabb8b06af93057e48a15dd1b2834
BLAKE2b-256 726a8188b984d3d29c7ee941654f4d2b180783a1ae388ae624bc80d16b7a8070

See more details on using hashes here.

Provenance

The following attestation bundles were made for caenhv_client_python-0.6.0-py3-none-any.whl:

Publisher: publish-python.yml on kenji0923/caenhv-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page