Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ae1d115
Adding setup.py
brandonaltieri1 Jun 21, 2022
588c759
Merge branch 'master' of https://github.com/XanaduAI/pymeasure into o…
brandonaltieri1 Jun 23, 2022
7c2169c
formatting
brandonaltieri1 Jun 23, 2022
74b3b6e
formatting
brandonaltieri1 Jun 27, 2022
f82d140
Move test files
brandonaltieri1 Jun 27, 2022
ae92476
move test files
brandonaltieri1 Jun 27, 2022
cc4f9eb
comments
brandonaltieri1 Jun 27, 2022
8c4814e
Apply code review changes
brandonaltieri1 Jun 28, 2022
fb36139
decorator func name
brandonaltieri1 Jun 28, 2022
30fe734
decorator docstring fix
brandonaltieri1 Jun 28, 2022
5b8969f
Merge pull request #2 from XanaduAI/add-thread-safety-and-error-checking
brandonaltieri1 Jul 4, 2022
f2737af
Initial commit
brandonaltieri1 Jul 20, 2022
bd76888
code review
brandonaltieri1 Jul 20, 2022
55edcaa
Merge pull request #3 from XanaduAI/add-thread-safety-and-error-checking
brandonaltieri1 Jul 20, 2022
3509bb5
name conflict
brandonaltieri1 Jul 21, 2022
605d25f
typo
brandonaltieri1 Jul 21, 2022
af0344c
typos
brandonaltieri1 Sep 23, 2022
8316d21
docstring
brandonaltieri1 Feb 14, 2023
8af14e7
docstring
brandonaltieri1 Feb 14, 2023
0543fe6
autorange when sweeping by default
brandonaltieri1 Jun 28, 2023
658e1ac
pydantic V2
heltluke Jun 13, 2024
441ce74
isort
heltluke Jun 13, 2024
cf75c05
Merge pull request #4 from XanaduAI/sc-60961-review-warnings-visible-…
heltluke Jun 13, 2024
2ea96b0
limit numpy
heltluke Jun 19, 2024
a67ae61
Merge pull request #5 from XanaduAI/limit-numpy
heltluke Jun 20, 2024
2d651e2
Update pymeasure_CI.yml
lneuhaus May 8, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/pymeasure_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- master
- develop
- og-pymeasure
pull_request:

jobs:
Expand Down
43 changes: 21 additions & 22 deletions pymeasure/adapters/visa.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import logging

import pyvisa
import numpy as np
import pyvisa
from pkg_resources import parse_version

from .adapter import Adapter
Expand All @@ -36,7 +36,7 @@

# noinspection PyPep8Naming,PyUnresolvedReferences
class VISAAdapter(Adapter):
""" Adapter class for the VISA library, using PyVISA to communicate with instruments.
"""Adapter class for the VISA library, using PyVISA to communicate with instruments.

The workhorse of our library, used by most instruments.

Expand Down Expand Up @@ -72,7 +72,7 @@ class VISAAdapter(Adapter):
*implementing an instrument*.
"""

def __init__(self, resource_name, visa_library='', preprocess_reply=None, **kwargs):
def __init__(self, resource_name, visa_library="", preprocess_reply=None, **kwargs):
super().__init__(preprocess_reply=preprocess_reply)
if not VISAAdapter.has_supported_version():
raise NotImplementedError("Please upgrade PyVISA to version 1.8 or later.")
Expand All @@ -84,7 +84,9 @@ def __init__(self, resource_name, visa_library='', preprocess_reply=None, **kwar

# Clean up kwargs considering the interface type matching resource_name
if_type = self.manager.resource_info(self.resource_name).interface_type
for key in list(kwargs.keys()): # iterate over a copy of the keys as we modify kwargs

# iterate over a copy of the keys as we modify kwargs
for key in list(kwargs.keys()):
# Remove all interface-specific kwargs:
if key in pyvisa.constants.InterfaceType.__members__:
if getattr(pyvisa.constants.InterfaceType, key) is if_type:
Expand All @@ -95,54 +97,51 @@ def __init__(self, resource_name, visa_library='', preprocess_reply=None, **kwar
kwargs.setdefault(k, v)
del kwargs[key]

self.connection = self.manager.open_resource(
resource_name,
**kwargs
)
self.connection = self.manager.open_resource(resource_name, **kwargs)

@staticmethod
def has_supported_version():
""" Returns True if the PyVISA version is greater than 1.8 """
if hasattr(pyvisa, '__version__'):
return parse_version(pyvisa.__version__) >= parse_version('1.8')
"""Returns True if the PyVISA version is greater than 1.8"""
if hasattr(pyvisa, "__version__"):
return parse_version(pyvisa.__version__) >= parse_version("1.8")
else:
return False

def write(self, command):
""" Writes a command to the instrument
"""Writes a command to the instrument

:param command: SCPI command string to be sent to the instrument
"""
self.connection.write(command)

def read(self):
""" Reads until the buffer is empty and returns the resulting
"""Reads until the buffer is empty and returns the resulting
ASCII response

:returns: String ASCII response of the instrument.
"""
return self.connection.read()

def read_bytes(self, size):
""" Reads specified number of bytes from the buffer and returns
"""Reads specified number of bytes from the buffer and returns
the resulting ASCII response

:param size: Number of bytes to read from the buffer
:returns: String ASCII response of the instrument.
"""
return self.connection.read_bytes(size)

def ask(self, command):
""" Writes the command to the instrument and returns the resulting
def ask(self, command, **kwargs):
"""Writes the command to the instrument and returns the resulting
ASCII response

:param command: SCPI command string to be sent to the instrument
:returns: String ASCII response of the instrument
"""
return self.connection.query(command)
return self.connection.query(command, **kwargs)

def ask_values(self, command, **kwargs):
""" Writes a command to the instrument and returns a list of formatted
"""Writes a command to the instrument and returns a list of formatted
values from the result. This leverages the `query_ascii_values` method
in PyVISA.

Expand All @@ -153,7 +152,7 @@ def ask_values(self, command, **kwargs):
return self.connection.query_ascii_values(command, **kwargs)

def binary_values(self, command, header_bytes=0, dtype=np.float32):
""" Returns a numpy array from a query for binary data
"""Returns a numpy array from a query for binary data

:param command: SCPI command to be sent to the instrument
:param header_bytes: Integer number of bytes to ignore in header
Expand All @@ -167,7 +166,7 @@ def binary_values(self, command, header_bytes=0, dtype=np.float32):
return np.fromstring(data, dtype=dtype)

def write_binary_values(self, command, values, **kwargs):
""" Write binary data to the instrument, e.g. waveform for signal generators
"""Write binary data to the instrument, e.g. waveform for signal generators

:param command: SCPI command to be sent to the instrument
:param values: iterable representing the binary values
Expand All @@ -178,15 +177,15 @@ def write_binary_values(self, command, values, **kwargs):
return self.connection.write_binary_values(command, values, **kwargs)

def wait_for_srq(self, timeout=25, delay=0.1):
""" Blocks until a SRQ, and leaves the bit high
"""Blocks until a SRQ, and leaves the bit high

:param timeout: Timeout duration in seconds
:param delay: Time delay between checking SRQ in seconds
"""
self.connection.wait_for_srq(timeout * 1000)

def flush_read_buffer(self):
""" Flush and discard the input buffer
"""Flush and discard the input buffer

As detailed by pyvisa, discard the read buffer contents and if data was present
in the read buffer and no END-indicator was present, read from the device until
Expand Down
2 changes: 1 addition & 1 deletion pymeasure/instruments/ametek/ametek7270.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ def shutdown(self):
""" Ensures the instrument in a safe state """
self.voltage = 0.
self.isShutdown = True
log.info("Shutting down %s" % self.name)
log.info("Shutting down %s" % self.pymeasure_name)
2 changes: 1 addition & 1 deletion pymeasure/instruments/hp/hp8116a.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def check_errors(self):
return []
else:
for error in errors:
log.error(f'{self.name}: {error}')
log.error(f'{self.pymeasure_name}: {error}')
return errors

def _wait_for_commands_processed(self, timeout=1):
Expand Down
Loading