Source code for device_client.client_resonance_controller

from device_client import DeviceClient
from device.resonance_controller import ResonanceController


description = """
1. Use **Generator** toggle to turn on the main powersupply for the generator.
2. Use **Output for** to turn on power output for a short period of time.
  Recommended: 60-80 W. Avoid overheating the generator. Check the relfected
  power feedback in values section.

#### Generator (on/off)
Switch on or switch off the generator power supply. Generator needs to be
switched on when using the **Output for** command.

#### Output for
Turn on the generator output for a limited time duration. Continuous power
output may result in generator overheating.

- *power* = output power in watts, recommended 60-80W.
- *duration* = time in seconds. Using more than 10s repeatedly might be unsafe,
  avoid continuous output of 60s+.

#### Spectral analyser (on/off)
Switch on or off the spectral analyser. When switched on, it should appear as
a new device in this experiment. *Not implemeted yet.*

#### Valve (open/close)
This device also controls the pumping valve. Typically, the command should be
ignored during the experiment.
"""

[docs] def connect(name, password, server): client = DeviceClient(name, password, title="Resonance cavity: output generator", description=description) hw = ResonanceController("/dev/ttyUSB0", log_callback=client.emit_log) def set_generator(enabled): hw.switch_generator_on() if enabled else hw.switch_generator_off() client.emit_command_state("set_generator", [enabled]) client.register_command(set_generator, "Generator", inputs=[{"type": "toggle"}]) client.register_command(hw.output_on_for, "Output for", group="Output", inputs=[{"unit": "W"}, {"unit": "W"}]) client.register_command(hw.stop, "Stop", group="Output") def set_spect(enabled): # hw.switch_spectral_on() if enabled else hw.switch_spectral_off() hw.log.warning("Not implemented, spectrum analyser needs to be switched on manually") client.emit_command_state("set_spect", [enabled]) client.register_command(set_spect, "Spectrum analyser", inputs=[{"type": "toggle"}]) 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, "Valve", inputs=[{"type": "toggle"}]) client.register_background_task(hw.update_frontend) client.keep_server_updated( check_readiness=hw.is_ready, check_readiness_interval=0.5, server_address=server, retry_on_error=True )