from device_client import DeviceClient
from device.langmuir_probe import LangmuirProbe
description = """
Measure the I-V characteristic of a Langmuir probe using the *Sweep I-V*
command.
#### Sweep I-V
Start the probe measurement. The probe voltage is swept with an approximation
of a triangle wave.
- *frequency* = frequency of the triangle wave
- *amplitude* = amplitude of the triangle wave in percentage of max (0-100%)
#### Needle valve (0-100%)
This device also controls the valve between the recipient and the gas source
(ValveBoard). Leaving it closed (0%) helps to achieve higher vacuum.
"""
"""
#### Gas valve (off=closed)
This device also controls the valve between the recipient and the gas source
(ValveBoard). Leaving it closed helps to achieve higher vacuum.
"""
[docs]
def connect(name, password, server, serial):
client = DeviceClient(name, password,
title="Langmuir: Probe", description=description)
hw = LangmuirProbe(
bus=serial,
log_callback=client.emit_log,
)
# def set_valve_openclosed(open):
# hw.open_valve() if open else hw.close_valve()
# client.emit_command_state("set_valve", [open])
# client.register_command(set_valve_openclosed, "Gas valve", inputs=[{"type": "toggle"}])
def set_needle(percent):
value = hw.set_needle(percent)
client.emit("value", {
"value": value,
"formatted": "{:.1f} %".format(value),
"label": "Needle valve",
"min": 0,
"max": 100,
"id": "needle"
})
client.register_command(set_needle, "Set needle", inputs=[
{"type": "text", "unit": "0-100%"},
])
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"},
])
client.register_command(hw.measure_sweep, "Sweep I-V", inputs=[
{"type": "select", "options": [1, 2, 5, 10, 20, 50, 100], "unit": "kHz"},
{"type": "select", "options": [25, 50, 60, 70, 80, 90, 100], "unit": "%"},
], pass_self=True)
client.keep_server_updated(
check_readiness=hw.is_ready,
check_readiness_interval=0.2,
server_address=server,
retry_on_error=True
)