Source code for device_client.client_resonance_spectanalyser
from device_client import DeviceClient
from device.spectral_dsa800 import SpectralAnalyser_DSA800
# Oscilloscope IP and settings at: Utility > IO Setting > LAN Conf.
IP_ADDRESS = "192.168.0.100"
description = """
#### Multi scan
Scan and save several spectrum slices.
- *ranges* = 2d array of the frequency ranges [f_min, f_max],
units are Hz but scientific number format (e.g. 2.1e9) is accepted.
Use following (json) format, indentation and linebreaks are optional:
```
[
[2.0e9, 2.1e9],
[3.0e9, 3.1e9],
[4.0e9, 4.1e9]
]
```
One output file is generated for each pair of the frequency values. The files
share an identical timestamp in the name and are appended with `_scan_{i+1:03d}`.
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 data in a text file
outside of this app and then just copy it over.
"""
[docs]
def connect(name, password, server):
client = DeviceClient(name, password,
title="Spectrum analyser RIGOL DSA800", description=description)
hw = SpectralAnalyser_DSA800(IP_ADDRESS, log_callback=client.emit_log)
# TODO Add client.register_property to avoid using __setattr__
client.register_command(hw.set_freqaxis, "X-axis [Hz]")
# client.register_command(hw.set_amplitaxis, "Y-axis [dBm]")
def set_track_gen(enabled):
hw.set_tracking_generator(enabled)
client.emit_command_state("set_track_gen", [enabled])
client.register_command(
set_track_gen,
"Tracking generator",
inputs=[{"type": "toggle"}]
)
client.register_command(hw.fetch_data, "Fetch data")
def save_data():
filepath = hw.save_data()
client.emit_datafile(filepath, filepath.split("/")[-1])
client.register_command(save_data, "Save data")
client.register_command(
hw.multi_scan,
"Multi scan",
pass_self=True,
inputs=[{"type": "textArea", "unit": "Hz"}]
)
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
)