Skip to content
Merged
Changes from all commits
Commits
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
59 changes: 59 additions & 0 deletions src/pythonequipmentdrivers/oscilloscope/_tektronix_dpo4xxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,62 @@ def clear_annotation(self):
Clear the current annotation
"""
self.write_resource("MESSAGE:CLEAR; STATE 0")

def load_setup_file(
self, setup_path: Union[str, Path], timeout_seconds: float = 5
) -> None:
"""
Load a scope setup from a file and wait for the scope to complete the
reconfiguration

Args:
setup_path (Union[str, Path]): path the the text file containing the setup
timeout_seconds (float, optional): Maximum time to wait for setup to
complete. Defaults to 5s.
"""
prev_timeout = self.timeout
self.timeout = timeout_seconds * 1000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice that the timeout setter in VisaResource uses milliseconds. That seems inconsistent since the init method uses seconds to define it.

I'll update the baseclass timeout setter, this line, and the one in recall_setup in a subsequent commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok makes sense to me.

with open(Path(setup_path), "r") as f:
self.write_resource(f.read())
self.query_resource("*OPC?")
self.timeout = prev_timeout

def save_setup_file(self, setup_path: Union[str, Path]) -> None:
"""
Save a scope setup to a file

Args:
setup_path (Union[str, Path]): path to the setup file
"""
with open(Path(setup_path), "w") as f:
setup_string = self.query_resource("SET?")
f.write(setup_string)

def store_setup(self, setup_index: int) -> None:
"""
Store the current setup to one of the setup memory locations

Args:
setup_index (int): setup memory location (1 to 10)
"""
if setup_index not in range(1, 10 + 1):
ValueError(f"{setup_index=} is not valid")
self.write_resource(f"*SAV {setup_index}")

def recall_setup(self, setup_index: int, timeout_seconds: float = 5) -> None:
"""
Load a scope setup from a file and wait for the scope to complete the
reconfiguration

Args:
setup_index (int): setup memory location (1 to 10)
timeout_seconds (float, optional): Maximum time to wait for setup to
complete. Defaults to 5s.
"""
if setup_index not in range(1, 10 + 1):
ValueError(f"{setup_index=} is not valid")
prev_timeout = self.timeout
self.timeout = timeout_seconds * 1000
self.write_resource(f"*RCL {setup_index}")
self.query_resource("*OPC?")
self.timeout = prev_timeout