Source code for device_client.client_magnets_psbig
from device_client import DeviceClient
from device.power_supply_magnets import PowerSupply_Magnets
description_template = """
Power supply {amps}A | {volts}V | {kwatts}kW
Start by using the **Set MAX** command (e.g. {amps}A, {volts}V) to set max limits of
current and voltage. If ever in the future the output gets stuck at 0A current,
try running the **Set MAX** command again.
#### Set current
Manually set a current value, see output feedback in values.
- *current* = value in amperes.
Use **Safety I=0A** to quickly cut off the current. At the moment, command
**Stop** does the same thing, but its primary use is to stop the waveform
output (see below).
#### Set waveform + Run waveform
Set a current waveform and they play it using **Run Waveform**. Actual output
is measured and returned as a datafile.
- *data* = 2d array of the waveform points [t, I], time values in seconds,
current values in amperes. Use following (json) format, indentation and
linebreaks are optional:
```
[
[0.0, 0.0],
[0.2, 10.0],
[0.3, 30.0]
]
```
Previews of the waveform and measured output can be viewed in graphs section.
Use **Stop** to stop the waveform output.
Tip: When you refresh the page, anything in the input box disappears. So
sometimes it might be a good idea to prepare the waveform in a text file
outside of this app and then just copy it over.
"""
[docs]
def connect(name, password, server, serial):
client = DeviceClient(name, password, logger="big",
title="Magnetic field: PS Wire",
description=description_template.format(amps=100, volts=60, kwatts=6))
hw = PowerSupply_Magnets(
bus=serial,
model_name="PCL6000-60",
log_callback=client.emit_log,
logger="big",
)
def set_max(voltage, current):
hw.set_maxvoltage(voltage)
hw.set_maxcurrent(current)
hw.set_voltage(voltage)
client.register_command(set_max, "Set MAX", inputs=[{"unit": "V"}, {"unit": "A"}])
client.register_command(hw.set_current, "Set current", inputs=[{"unit": "A"}])
# client.register_command(hw.set_voltage, "Set [V]")
client.register_command(hw.set_waveform, "Set I(t) waveform",
pass_self=True, inputs=[{"type": "textArea"}])
client.register_command(hw.run_waveform, "Run I(t) waveform", pass_self=True)
def safety_button():
hw.set_current(0)
client.register_command(safety_button, "Safety I=0A")
client.register_command(hw.stop, "Stop")
client.register_background_task(hw.update_frontend)
client.keep_server_updated(
hw.is_ready, 0.2, server, retry_on_error=True
)