Skip to content

Commit

Permalink
Merge pull request #699 from pyvisa/vicp
Browse files Browse the repository at this point in the history
Adding support for VICP resources
  • Loading branch information
MatthieuDartiailh committed Dec 14, 2022
2 parents abc2fb1 + fbf4fca commit 37c774d
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 10 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exclude =
build,
dist,
pyvisa/thirdparty/*,
visa.py,
ignore = E203, E266, E501, W503, E731
# line length is intentionally set to 80 here because pyvisa uses Bugbear
# See https://github.com/psf/black/blob/master/README.md#line-length for more details
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ on:
- .github/workflows/ci.yml
- "pyvisa/**"
- pyproject.toml
- setup.cfg
- setup.py

jobs:
Expand Down Expand Up @@ -72,7 +71,7 @@ jobs:
- name: Test with pytest
run: |
pip install pytest-cov
python -X dev -m pytest --pyargs pyvisa --cov pyvisa --cov-report xml -v
python -X dev -m pytest --pyargs pyvisa --cov --cov-report xml -v
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
6 changes: 5 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
PyVISA Changelog
================

1.12.1 (11-10-2022)
1.13.0 (unreleased)
-------------------

- add support for VICP resource names PR #699
NOTE: the interface type enum value for VICP is unknown. No documentation was
found and tests using the VICP passport were not conclusive. If somebody figures
out the right value it would be great
- numerous bug fixes related to VISA attributes PR #697
This included fixing several typos, uncommenting the
AttrVI_ATTR_INTF_PARENT_NUM class, and adding in the
Expand Down
7 changes: 1 addition & 6 deletions pyvisa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
"""
import logging
import sys

if sys.version_info >= (3, 8):
from importlib.metadata import PackageNotFoundError, version
else:
from importlib_metadata import PackageNotFoundError, version # type: ignore
from importlib.metadata import PackageNotFoundError, version

# Defined here since it is imported in other pyvisa modules
logger = logging.getLogger("pyvisa")
Expand Down
3 changes: 3 additions & 0 deletions pyvisa/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ class InterfaceType(enum.IntEnum):
#: Rohde and Schwarz Device via Passport
rsnrp = 33024

#: Lecroy VICP via passport
vicp = 36000 # FIXME


@enum.unique
class LineState(enum.IntEnum):
Expand Down
12 changes: 12 additions & 0 deletions pyvisa/resources/tcpip.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ class TCPIPInstrument(ControlRenMixin, MessageBasedResource):
pass


@Resource.register(constants.InterfaceType.vicp, "INSTR")
class VICPInstrument(ControlRenMixin, MessageBasedResource):
"""Communicates with to devices of type VICP::host address[::INSTR]
Do not instantiate directly, use
:meth:`pyvisa.highlevel.ResourceManager.open_resource`.
"""

pass


@Resource.register(constants.InterfaceType.tcpip, "SOCKET")
class TCPIPSocket(MessageBasedResource):
"""Communicates with to devices of type TCPIP::host address::port::SOCKET
Expand Down
21 changes: 21 additions & 0 deletions pyvisa/rname.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,27 @@ class TCPIPInstr(ResourceName):
is_rc_optional: ClassVar[bool] = True


@register_subclass
@dataclass
class VICPInstr(ResourceName):
"""VICP INSTR
The syntax is:
VICP[board]::host address[::INSTR]
"""

#: Board to use.
board: str = "0"

#: Host address of the device (IPv4 or host name)
host_address: str = ""

interface_type: ClassVar[str] = "VICP"
resource_class: ClassVar[str] = "INSTR"
is_rc_optional: ClassVar[bool] = True


@register_subclass
@dataclass
class TCPIPSocket(ResourceName):
Expand Down
38 changes: 38 additions & 0 deletions pyvisa/testsuite/test_rname.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,44 @@ def test_tcpip_intr(self):
canonical_resource_name="TCPIP3::1.2.3.4::inst3::INSTR",
)

def test_vicp_intr(self):

self._parse_test(
"VICP::192.168.134.102",
interface_type="VICP",
resource_class="INSTR",
host_address="192.168.134.102",
board="0",
canonical_resource_name="VICP0::192.168.134.102::INSTR",
)

self._parse_test(
"VICP::dev.company.com::INSTR",
interface_type="VICP",
resource_class="INSTR",
host_address="dev.company.com",
board="0",
canonical_resource_name="VICP0::dev.company.com::INSTR",
)

self._parse_test(
"VICP3::dev.company.com::INSTR",
interface_type="VICP",
resource_class="INSTR",
host_address="dev.company.com",
board="3",
canonical_resource_name="VICP3::dev.company.com::INSTR",
)

self._parse_test(
"VICP3::1.2.3.4::INSTR",
interface_type="VICP",
resource_class="INSTR",
host_address="1.2.3.4",
board="3",
canonical_resource_name="VICP3::1.2.3.4::INSTR",
)

def test_tcpip_socket(self):
self._parse_test(
"TCPIP::1.2.3.4::999::SOCKET",
Expand Down

0 comments on commit 37c774d

Please sign in to comment.