Skip to content

Commit

Permalink
MSO5k, DPO5k, and DPO7k full driver support (tektronix#125)
Browse files Browse the repository at this point in the history
* feat: Added full support for MSO5K, DPO5K, and DPO7K devices.

Co-authored-by: Shashank P <[email protected]>

* feat: Added a read-only implementation of a cached property.

---------

Co-authored-by: Shashank P <[email protected]>
  • Loading branch information
2 people authored and qthompso committed Feb 16, 2024
1 parent b9f8f65 commit a9273c9
Show file tree
Hide file tree
Showing 333 changed files with 64,639 additions and 4,914 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ repos:
rev: 1.16.0
hooks:
- id: blacken-docs
files: \.(rst|md|markdown|tex)$
- repo: https://github.com/lyz-code/yamlfix/
rev: 1.16.0
hooks:
Expand Down Expand Up @@ -122,7 +123,7 @@ repos:
always_run: true
args: [., --min=10]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
rev: v0.1.11
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Things to be included in the next release go here.
### Added

- Added a step during a device reboot that will reset all the cached properties in the event that one of them changed.
- Added command API support for MSO5K, DPO5K, and DPO7K models.
- Added a custom, read-only implementation of the [`cached_property`](https://docs.python.org/3/library/functools.html#functools.cached_property) decorator.

### Changed

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ requires = ["poetry-core>=1.0.0"]

[tool]

[tool.coverage.coverage_conditional_plugin.rules]
py-gte-39 = "sys_version_info >= (3, 9)"
py-lt-39 = "sys_version_info < (3, 9)"

[tool.coverage.report]
exclude_lines = [
"if TYPE_CHECKING:",
Expand All @@ -20,6 +24,7 @@ skip_empty = true
[tool.coverage.run]
branch = true
cover_pylib = false
plugins = ["coverage_conditional_plugin"]
source = ["tm_devices"]

[tool.docformatter]
Expand Down Expand Up @@ -89,6 +94,7 @@ zeroconf = ">=0.54.0"
# Development dependencies
[tool.poetry.group.dev.dependencies]
coverage = {extras = ["toml"], version = ">=7.2.2"}
coverage-conditional-plugin = ">=0.9.0"
docformatter = {extras = ["tomli"], version = ">=1.6.5,<1.7.1"} # upper bound is due to https://github.com/PyCQA/docformatter/issues/174
flask = ">=2.2.2"
graphviz = ">=0.20.1"
Expand Down
56 changes: 42 additions & 14 deletions src/tm_devices/commands/_60xy3r_smu/smu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,9 @@ def func(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".func"
return self._device.query(f"print({self._cmd_syntax}.func)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.func)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -1043,7 +1045,9 @@ def func(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".func", value
)
else:
self._device.write(f"{self._cmd_syntax}.func = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.func = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -2782,7 +2786,9 @@ def fail(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".fail"
return self._device.query(f"print({self._cmd_syntax}.fail)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.fail)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.fail`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -2822,7 +2828,9 @@ def clear(self) -> None:
tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
"""
try:
self._device.write(f"{self._cmd_syntax}.clear()") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.clear()"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.clear()`` function." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3001,7 +3009,9 @@ def type(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".type"
return self._device.query(f"print({self._cmd_syntax}.type)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.type)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.type`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3035,7 +3045,9 @@ def type(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".type", value
)
else:
self._device.write(f"{self._cmd_syntax}.type = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.type = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.type`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3435,7 +3447,9 @@ def once(self) -> None:
tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
"""
try:
self._device.write(f"{self._cmd_syntax}.once()") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.once()"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.once()`` function." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3973,7 +3987,9 @@ def func(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".func"
return self._device.query(f"print({self._cmd_syntax}.func)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.func)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4005,7 +4021,9 @@ def func(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".func", value
)
else:
self._device.write(f"{self._cmd_syntax}.func = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.func = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4062,7 +4080,9 @@ def nplc(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".nplc"
return self._device.query(f"print({self._cmd_syntax}.nplc)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.nplc)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.nplc`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4095,7 +4115,9 @@ def nplc(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".nplc", value
)
else:
self._device.write(f"{self._cmd_syntax}.nplc = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.nplc = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.nplc`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4333,7 +4355,9 @@ def unit(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".unit"
return self._device.query(f"print({self._cmd_syntax}.unit)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.unit)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.unit`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4366,7 +4390,9 @@ def unit(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".unit", value
)
else:
self._device.write(f"{self._cmd_syntax}.unit = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.unit = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.unit`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -5113,7 +5139,9 @@ def reset(self) -> None:
tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
"""
try:
self._device.write(f"{self._cmd_syntax}.reset()") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.reset()"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.reset()`` function." # noqa: E501
raise NoDeviceProvidedError(msg) from error
4 changes: 3 additions & 1 deletion src/tm_devices/commands/_60xy3r_smu/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def unit(self) -> None:
tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
"""
try:
self._device.write(f"{self._cmd_syntax}.unit()") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.unit()"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.unit()`` function." # noqa: E501
raise NoDeviceProvidedError(msg) from error
56 changes: 42 additions & 14 deletions src/tm_devices/commands/_6srh1x_smu/smu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,9 @@ def func(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".func"
return self._device.query(f"print({self._cmd_syntax}.func)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.func)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -1043,7 +1045,9 @@ def func(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".func", value
)
else:
self._device.write(f"{self._cmd_syntax}.func = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.func = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -2782,7 +2786,9 @@ def fail(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".fail"
return self._device.query(f"print({self._cmd_syntax}.fail)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.fail)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.fail`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -2822,7 +2828,9 @@ def clear(self) -> None:
tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
"""
try:
self._device.write(f"{self._cmd_syntax}.clear()") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.clear()"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.clear()`` function." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3001,7 +3009,9 @@ def type(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".type"
return self._device.query(f"print({self._cmd_syntax}.type)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.type)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.type`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3035,7 +3045,9 @@ def type(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".type", value
)
else:
self._device.write(f"{self._cmd_syntax}.type = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.type = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.type`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3435,7 +3447,9 @@ def once(self) -> None:
tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
"""
try:
self._device.write(f"{self._cmd_syntax}.once()") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.once()"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.once()`` function." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -3973,7 +3987,9 @@ def func(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".func"
return self._device.query(f"print({self._cmd_syntax}.func)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.func)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4005,7 +4021,9 @@ def func(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".func", value
)
else:
self._device.write(f"{self._cmd_syntax}.func = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.func = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.func`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4062,7 +4080,9 @@ def nplc(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".nplc"
return self._device.query(f"print({self._cmd_syntax}.nplc)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.nplc)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.nplc`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4095,7 +4115,9 @@ def nplc(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".nplc", value
)
else:
self._device.write(f"{self._cmd_syntax}.nplc = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.nplc = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.nplc`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4333,7 +4355,9 @@ def unit(self) -> str:
try:
if self._device.command_syntax_enabled: # type: ignore[union-attr]
return self._cmd_syntax + ".unit"
return self._device.query(f"print({self._cmd_syntax}.unit)") # type: ignore[union-attr]
return self._device.query( # type: ignore[union-attr]
f"print({self._cmd_syntax}.unit)"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.unit`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -4366,7 +4390,9 @@ def unit(self, value: Union[str, float]) -> None:
self._cmd_syntax + ".unit", value
)
else:
self._device.write(f"{self._cmd_syntax}.unit = {value}") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.unit = {value}"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.unit`` attribute." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Expand Down Expand Up @@ -5113,7 +5139,9 @@ def reset(self) -> None:
tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
"""
try:
self._device.write(f"{self._cmd_syntax}.reset()") # type: ignore[union-attr]
self._device.write( # type: ignore[union-attr]
f"{self._cmd_syntax}.reset()"
)
except AttributeError as error:
msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.reset()`` function." # noqa: E501
raise NoDeviceProvidedError(msg) from error
Loading

0 comments on commit a9273c9

Please sign in to comment.