Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Keysight/Agilent N5183M microwave generator, NI-HSDIO devices, Yokogawa 7651 power supply, Anritsu68B microwave generator #159

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8576bf2
add driver for Keysight/Agilent N5183M
Jun 3, 2022
9921baf
Merge branch 'dev' of https://github.com/ty-zhao/Qcodes_contrib_drive…
Jun 3, 2022
71d4a6d
add NI-HSDIO dll wrapper
Jun 6, 2022
f4db7c1
add driver for NIHSDIO devices
Jun 8, 2022
3b2fb02
add ViUint32 type
Jun 8, 2022
e2619d9
Add Yokogawa 7651 driver
Aug 5, 2022
f26266c
Merge branch 'master' of https://github.com/ty-zhao/Qcodes_contrib_dr…
Aug 5, 2022
945cae4
finished HSDIO driver and add docstring
Sep 23, 2022
26fa20b
add Anritsu68B driver
Sep 23, 2022
a02b473
update Anritsu68B driver
Sep 23, 2022
45401ae
Merge branch 'master' of https://github.com/ty-zhao/Qcodes_contrib_dr…
Sep 23, 2022
e2554b1
fix typing
astafan8 Sep 26, 2022
ea86dac
fix typing
astafan8 Sep 26, 2022
91f15a3
update Yokogawa7651 driver
Nov 11, 2022
030287e
Merge branch 'master' into master
jenshnielsen Nov 15, 2022
7372e15
Merge branch 'main' into master
astafan8 Aug 23, 2023
85a1740
updated status inquiry return format
Sep 13, 2023
af493d0
added BBN APS2 driver
Sep 13, 2023
5df0ab1
added Holzworth HS9004A driver
Sep 13, 2023
564784d
fixed write_named_waveform_WDT
Sep 13, 2023
163e9df
added Keysight M8190A driver
Sep 13, 2023
92074b2
added ref_source parameter to N5183M class
Sep 13, 2023
f122fd9
added get_idn to GM349 class
Sep 13, 2023
50de883
finished Anritsu68B driver
Sep 13, 2023
fe02c89
updated Holzworth HS9008B driver
Sep 13, 2023
4552100
Merge branch 'master' of https://github.com/ty-zhao/Qcodes_contrib_dr…
Sep 13, 2023
3b80fa1
Merge branch 'main' into master
astafan8 Sep 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add NI-HSDIO dll wrapper
Tongyu Zhao committed Jun 6, 2022
commit 71d4a6dd395d394ac3feea3ea15e50f1e0706629
143 changes: 142 additions & 1 deletion qcodes_contrib_drivers/drivers/NationalInstruments/dll_wrapper.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
import warnings
from dataclasses import dataclass
from .visa_types import (
ViChar, ViStatus, ViRsrc, ViInt32, ViString, ViSession, ViBoolean, ViAttr,
ViChar, ViConstString, ViStatus, ViRsrc, ViInt32, ViString, ViSession, ViBoolean, ViAttr,
ViChar, ViReal64, VI_NULL
)

@@ -290,3 +290,144 @@ def error_message(self, session: Optional[ViSession] = None,
buf = ctypes.create_string_buffer(STRING_BUFFER_SIZE)
self._error_message(session or VI_NULL, error_code, buf)
return buf.value.decode()

class NIHSDIODLLWrapper(NIDLLWrapper):
"""
This class provides convenience functions for wrapping and checking a DLL
function call for NI-HSDIO devices. Other functions should be wrapped by
a library-specific class by calling ``wrap_dll_function_checked``.

This wrapped is defined separately because NI-HSDIO devices have
very different call functions from other NI devices (for example, there
isn't a 'niHSDIO_init' function).

Args:
dll_path: path to the DLL file containing the library
"""

def __init__(self, dll_path: str, session_type: str):
self._dll = ctypes.cdll.LoadLibrary(dll_path)
self._lib_prefix = 'niHSDIO'

self._session_type = session_type

self._dtype_map = {
ViBoolean: "ViBoolean",
ViInt32: "ViInt32",
ViReal64: "ViReal64",
ViString: "ViString"
}

# wrap standard functions that are the same in all libraries

# note: self.error_messsage is a convenience wrapper around this, with
# a different signature
self._error_message = self.wrap_dll_function(
name_in_library="error_message",
argtypes=[
NamedArgType("vi", ViSession),
NamedArgType("errorCode", ViStatus),
NamedArgType("errorMessage", POINTER(ViChar)),
]
)

self._init_gen = self.wrap_dll_function_checked(
name_in_library="InitGenerationSession",
argtypes=[
NamedArgType("resourceName", ViRsrc),
NamedArgType("idQuery", ViBoolean),
NamedArgType("resetDevice", ViBoolean),
NamedArgType("optionString", ViConstString),
]
)

self._init_acq = self.wrap_dll_function_checked(
name_in_library="InitAcquisitionSession",
argtypes=[
NamedArgType("resourceName", ViRsrc),
NamedArgType("idQuery", ViBoolean),
NamedArgType("resetDevice", ViBoolean),
NamedArgType("optionString", ViConstString),
]
)

# no special name is needed, the signature is the same
self.reset = self.wrap_dll_function_checked(
name_in_library="reset",
argtypes=[NamedArgType("vi", ViSession)]
)

self.reset_device = self.wrap_dll_function_checked(
name_in_library="ResetDevice",
argtypes=[NamedArgType("vi", ViSession)]
)

self.close = self.wrap_dll_function_checked(
name_in_library="close",
argtypes=[NamedArgType("vi", ViSession)]
)

# wrap GetAttribute<DataType> functions (see get_attribute method)
for dtype, dtype_name in self._dtype_map.items():

# argtypes for the GetAttribute<DataType> functions
getter_argtypes = [
NamedArgType("vi", ViSession),
NamedArgType("channelName", ViString),
NamedArgType("attributeID", ViAttr),
NamedArgType("attributeValue", POINTER(dtype))
]

# the argtypes for the corresponding SetAttribute<DataType>
# functions. note that the signature for SetAttributeViString is
# the same as for the other types even though GetAttributeViString
# has a unique signature
setter_argtypes = getter_argtypes.copy()

if dtype == ViString:
# replace last argument
getter_argtypes.pop()
getter_argtypes.append(NamedArgType("bufferSize", ViInt32))
# ViString is already a pointer, so no POINTER() here
getter_argtypes.append(NamedArgType("attributeValue", dtype))

getter_name = f"GetAttribute{dtype_name}"
getter_func = self.wrap_dll_function_checked(
getter_name,
argtypes=getter_argtypes)
setattr(self, getter_name, getter_func)

setter_argtypes[-1] = NamedArgType("attributeValue", dtype)

setter_name = f"SetAttribute{dtype_name}"
setter_func = self.wrap_dll_function_checked(
setter_name,
argtypes=setter_argtypes)
setattr(self, setter_name, setter_func)

def init(self, resource: str, id_query: bool = True,
reset_device: bool = False) -> ViSession:
"""
Convenience wrapper around niHSDIO_InitGenerationSession or
niHSDIO_InitAcquisitionSession. Returns the ViSession handle
of the initialized session. Note that this class is not
responsible for storing the handle, it should be managed by
the function or class that calls the functions wrapped by
this class.

Args:
resource: the resource name of the device to initialize, as given
by NI MAX.
id_query: whether to perform an ID query on initialization
reset_device: whether to reset the device during initialization
Returns:
the ViSession handle of the initialized device
"""
session = ViSession()
if self._session_type == 'Generation':
self._init_gen(ViRsrc(c_str(resource)), id_query, reset_device, b'',
ctypes.byref(session))
else:
self._init_acq(ViRsrc(c_str(resource)), id_query, reset_device, b'',
ctypes.byref(session))
return session