From 5bb27fa70ae54f2b108f35d67c5ae565c3d9524a Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Thu, 11 Apr 2024 16:19:02 +0200 Subject: [PATCH] Back-port connect_to classmethod --- qupulse_hdawg_legacy/zihdawg.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/qupulse_hdawg_legacy/zihdawg.py b/qupulse_hdawg_legacy/zihdawg.py index 8e3b7e8..f77e958 100644 --- a/qupulse_hdawg_legacy/zihdawg.py +++ b/qupulse_hdawg_legacy/zihdawg.py @@ -142,6 +142,26 @@ def __init__(self, device_serial: str = None, # activates channel groups self.channel_grouping = grouping + @classmethod + def connect_to(cls, device_serial: str = None, **init_kwargs): + """ + :param device_serial: + :param init_kwargs: Forwarded to `HDAWGRepresentation.__init__` + :return: + """ + discovery = zhinst_core.ziDiscovery() + device_id = discovery.find(device_serial) + device_props = discovery.get(device_id) + return cls( + device_serial=device_serial, + device_interface=device_props['interfaces'][0], + data_server_addr=device_props['serveraddress'], + data_server_port=device_props['serverport'], + api_level_number=device_props['apilevel'], + **init_kwargs, + ) + + @property def waveform_file_system(self) -> WaveformFileSystem: return self._waveform_file_system