Skip to content

force_sequence example added #75

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions docs/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ synchronization using start and `*OPC?`.
# fmt: off
--8<-- "src/tekhsi/tek_hsi_connect.py:any_horizontal_change"
```
## Transmitting an acquisition made before connecting
There are cases in which you might want to connect and transfer waveforms that you have already acquired on the scope.

To do this, we provide the [`force_sequence()`][tekhsi.TekHSIConnect.force_sequence] method.

It is important to note that this is provided for the specific case when you establish the HSI connection AFTER acquiring the data.

```python
# fmt: off
--8<-- "examples/force_sequence.py"
```

## Mixing TekHSI and PyVISA

Expand Down
16 changes: 16 additions & 0 deletions examples/force_sequence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""A script demonstrating a way to use force_sequence to save a wfm locally."""

from tm_data_types import AnalogWaveform, write_file
from tekhsi import TekHSIConnect

addr = "192.168.0.1" # Replace with the IP address of your instrument

# Connect to instrument
with TekHSIConnect(f"{addr}:5000") as connect:
# Save a single acquisition that was made prior to connecting
connect.force_sequence()
with connect.access_data():
wfm: AnalogWaveform = connect.get_data("ch1")

# Save the waveform to a file
write_file(f"{wfm.source_name}.csv", wfm)
17 changes: 15 additions & 2 deletions src/tekhsi/tek_hsi_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,24 @@ def done_with_data(self) -> None:
self._done_with_data_release_lock()

def force_sequence(self) -> None:
"""force_sequence asks the instrument to please give us access.
"""Ask the instrument to give us access to the already acquired data.

to the current acquisition data. This is useful when connecting to a stopped instrument to
This is useful when connecting to a stopped instrument to
get access to the currently available data. Otherwise, the API will wait until the next
acquisition.

Examples:
>>> from tm_data_types import AnalogWaveform, write_file
>>> from tekhsi import TekHSIConnect

>>> addr = "192.168.0.1" # Replace with the IP address of your instrument
>>> with TekHSIConnect(f"{addr}:5000") as connect:
... # Save a single acquisition that was made prior to connecting
... connect.force_sequence()
... with connect.access_data():
... wfm: AnalogWaveform = connect.get_data("ch1")
... write_file(f"{wfm.source_name}.csv", wfm)

"""
_logger.debug("force_sequence")
request = ConnectRequest(name=self.clientname)
Expand Down
Loading