From 39b664a639d9add7ac7dc330fecc5aefd93ba627 Mon Sep 17 00:00:00 2001 From: Tobias Ahrens Date: Tue, 17 Dec 2024 14:15:10 +0100 Subject: [PATCH] Add direct support for SHFLI and GHFLI This commit explicitly exposes the device classes for the SHFLI and GHFLI. This simplifies the connection setup and makes the support clearly visible. --- CHANGELOG.md | 1 + docs/source/package_documentation.rst | 2 + src/zhinst/qcodes/__init__.py | 4 ++ src/zhinst/qcodes/device_creator.py | 83 +++++++++++++++++++++++++++ 4 files changed, 90 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d95d6ad..d775c15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # zhinst-qcodes Changelog ## Version 0.6.0 +* Add explicit Insturment wrappers for SHFLI and GHFLI * The constructor of `Session` fails when attempting to connect to a data-server on a different LabOne version. This behavior can be overridden by setting the newly added allow_version_mismatch keyword argument to True. When allow_version_mismatch=True is passed to the `Session` constructor the connection to the data-server succeeds even if the version doesn't match. ## Version 0.5.5 diff --git a/docs/source/package_documentation.rst b/docs/source/package_documentation.rst index 7ccfb74..ac6377e 100644 --- a/docs/source/package_documentation.rst +++ b/docs/source/package_documentation.rst @@ -19,6 +19,8 @@ zhinst-qcodes exposes the following classes: ~zhinst.qcodes.device_creator.UHFQA ~zhinst.qcodes.device_creator.HF2 ~zhinst.qcodes.device_creator.ZIDevice + ~zhinst.qcodes.device_creator.SHFLI + ~zhinst.qcodes.device_creator.GHFLI In addition the following classes are imported from `zhinst-toolkit `_: diff --git a/src/zhinst/qcodes/__init__.py b/src/zhinst/qcodes/__init__.py index 9cf7093..bf9c650 100644 --- a/src/zhinst/qcodes/__init__.py +++ b/src/zhinst/qcodes/__init__.py @@ -13,6 +13,8 @@ UHFQA, ZIDevice, HF2, + SHFLI, + GHFLI, ) from zhinst.toolkit import ( @@ -42,6 +44,8 @@ "UHFQA", "ZIDevice", "HF2", + "SHFLI", + "GHFLI", "Waveforms", "CommandTable", "Sequence", diff --git a/src/zhinst/qcodes/device_creator.py b/src/zhinst/qcodes/device_creator.py index 4b1d28d..54d342c 100644 --- a/src/zhinst/qcodes/device_creator.py +++ b/src/zhinst/qcodes/device_creator.py @@ -2,6 +2,7 @@ The classes can be used without creating as session to a data server. """ + import typing as t from zhinst.qcodes.driver.devices.base import ZIBaseInstrument @@ -354,6 +355,88 @@ def __init__( session.devices[self.serial] = self +class SHFLI(ZIBaseInstrument): + """QCoDeS driver for the Zurich Instruments SHFLI. + + Args: + serial: Serial number of the device, e.g. *'dev12000'*. + The serial number can be found on the back panel of the instrument. + server_host: Host address of the data server (e.g. localhost) + server_port: Port number of the data server. If not specified the session + uses the default port. (default = 8004) + interface: Device interface (e.g. = "1GbE"). If not specified + the default interface from the discover is used. + name: Name of the instrument in qcodes. + raw: Flag if qcodes instance should only created with the nodes and + not forwarding the toolkit functions. (default = False) + new_session: By default zhinst-qcodes reuses already existing data + server session (within itself only), meaning only one session to a + data server exists. Setting the flag will create a new session. + + Warning: + Creating a new session should be done carefully and reusing + the created session is not possible. Consider instantiating a + new session directly. + """ + + def __init__( + self, + serial: str, + host: str, + port: int = 8004, + *, + interface: t.Optional[str] = None, + name=None, + raw=False, + new_session: bool = False, + ): + session = ZISession(host, port, hf2=False, new_session=new_session) + tk_device = session.toolkit_session.connect_device(serial, interface=interface) + super().__init__(tk_device, session, name=name, raw=raw) + session.devices[self.serial] = self + + +class GHFLI(ZIBaseInstrument): + """QCoDeS driver for the Zurich Instruments GHFLI. + + Args: + serial: Serial number of the device, e.g. *'dev12000'*. + The serial number can be found on the back panel of the instrument. + server_host: Host address of the data server (e.g. localhost) + server_port: Port number of the data server. If not specified the session + uses the default port. (default = 8004) + interface: Device interface (e.g. = "1GbE"). If not specified + the default interface from the discover is used. + name: Name of the instrument in qcodes. + raw: Flag if qcodes instance should only created with the nodes and + not forwarding the toolkit functions. (default = False) + new_session: By default zhinst-qcodes reuses already existing data + server session (within itself only), meaning only one session to a + data server exists. Setting the flag will create a new session. + + Warning: + Creating a new session should be done carefully and reusing + the created session is not possible. Consider instantiating a + new session directly. + """ + + def __init__( + self, + serial: str, + host: str, + port: int = 8004, + *, + interface: t.Optional[str] = None, + name=None, + raw=False, + new_session: bool = False, + ): + session = ZISession(host, port, hf2=False, new_session=new_session) + tk_device = session.toolkit_session.connect_device(serial, interface=interface) + super().__init__(tk_device, session, name=name, raw=raw) + session.devices[self.serial] = self + + class MFLI(ZIBaseInstrument): """QCoDeS driver for the Zurich Instruments MFLI.