Source code for device_client.client_magnets_probes

from device_client import DeviceClient
from device.magnets_probes import MagnetsProbes

import glob


description = """
#### Measure
Measure integrated & raw current in coils and fetch the data.

- *duration* = total time in seconds.

- *dt* = time between two samples in seconds, min 0.001.

- Max 20,000 samples.

Fetching 1000+ samples may take several seconds or more. You may stop the
process using the **Stop** button. When finished, preview of fetched data from
one probe can be found in graphs.

#### View plot
View real-time plot of a signal from one probe.
- *probe_id* = can be one of: 1, 2, 3, ..., 8.

Use **Stop plot** button to stop updating the plot. Long hours of continuous
graphing may perhaps cause some issues with server or your browser (not tested).
"""

[docs] def connect(name, password, server): client = DeviceClient(name, password, title="Magnetic field: Probes", description=description) # buses = [] # for i in ["2", "3"]: # buses += glob.glob(f"/dev/ttyUSB-arduino-1.2.4.{i}*") buses = glob.glob("/dev/ttyUSB-arduino-*") hw = MagnetsProbes( buses=buses, log_callback=client.emit_log, ) client.register_command(hw.stop, "Stop") client.register_command(hw.measure, "Measure", pass_self=True, inputs=[ {"type": "text", "unit": "s"}, {"type": "text", "unit": "s"}, ]) client.register_command(hw.view_plot, "View plot") client.register_command(hw.stop_plot, "Stop plot") client.register_background_task(hw.update_frontend) client.keep_server_updated( check_readiness=hw.is_ready, check_readiness_interval=0.1, server_address=server, retry_on_error=True )