Source code for device_client.client_langmuir_motors
from device_client import DeviceClient
from device.langmuir_motors import LangmuirMotors
description = """
Start by running the **Homing** command. Use **Stop** anytime, including during
homing, to quickly terminate any motion. The position tracking, as seen in
values section, is reliable even after using the **Stop** command.
*Make sure to avoid collisions. No safety measures are implemented yet!*
#### Move to
Moves one of the probes/electrodes to a new position, beware of collisions.
- *motor_id* = one of: L, R, T, B. Stands for left, right (electrode) and top,
bottom (probe).
- *position* = absolute position in mm, current position can be seen in the
values section.
#### Pumping valve (off=closed)
This device also controls the pumping valve. Typically, the command should be
ignored during the experiment.
"""
[docs]
def connect(name, password, server, serial1, serial2, serial3, serial4):
client = DeviceClient(name, password,
title="Langmuir: Motors", description=description)
hw = LangmuirMotors(
"./configurations/calib_langmuir.cfg",
buses=[serial1, serial2, serial3, serial4],
limits_enabled=False, # Do not use software limits from .cfg file
log_callback=client.emit_log,
)
client.register_command(hw.stop, "Stop")
def set_valve(open):
hw.open_valve() if open else hw.close_valve()
client.emit_command_state("set_valve", [open])
client.register_command(set_valve, "Pumping valve", inputs=[{"type": "toggle"}])
client.register_command(hw.homing, "Homing")
client.register_command(hw.moveto, "Move to", inputs=[
{"type": "select", "options": ["L", "R", "T", "B"]},
{"type": "text", "unit": "mm"},
])
client.register_background_task(hw.update_frontend)
client.keep_server_updated(
check_readiness=hw.is_ready,
check_readiness_interval=1,
server_address=server,
retry_on_error=True
)