Source code for device_client.client_trap_diagnostics
from device_client import DeviceClient
from device.trap_diganostics import TrapDiagnostics
description = """
Main functionality:
- Measure the magnetic field induced by the coils and their temperature.
Additionally:
- Turn on the power supply for coils using the **PS Switch**.
- Inject gas into the chamber by controlling the needle valve (**Set needle**).
"""
[docs]
def connect(name, password, server, serial, serial_switch):
client = DeviceClient(name, password,
title="Trap: Coils and Valve", description=description)
hw = TrapDiagnostics(
bus=serial,
bus_switch=serial_switch,
log_callback=client.emit_log,
)
client.register_command(hw.stop, "Stop")
client.register_command(hw.set_needle, "Set needle", inputs=[
{"type": "text", "unit": "%"}
])
client.register_command(hw.set_needle_for, "Needle puff", inputs=[
{"type": "select", "options": [25, 50, 60, 70, 80, 90, 100], "unit": "%"},
{"type": "select", "options": [0.1, 0.2, 0.5, 1.0, 2.0], "unit": "s"},
])
def set_ps_switch(enabled):
hw.main_switch_on() if enabled else hw.main_switch_off()
client.emit_command_state("set_ps_switch", [enabled])
client.register_command(set_ps_switch, "PS Switch", inputs=[{"type": "toggle"}])
client.register_background_task(hw.update_frontend)
client.keep_server_updated(
check_readiness=hw.is_ready,
check_readiness_interval=0.2,
server_address=server,
retry_on_error=True
)