From e228b78fb99ce65b03f9e199a8a409c3ecb1befd Mon Sep 17 00:00:00 2001 From: amccann-Tek Date: Thu, 17 Apr 2025 15:06:21 -0700 Subject: [PATCH 1/8] force_sequence example added --- docs/basic_usage.md | 11 +++++++++++ examples/force_sequence.py | 17 +++++++++++++++++ src/tekhsi/tek_hsi_connect.py | 20 +++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 examples/force_sequence.py diff --git a/docs/basic_usage.md b/docs/basic_usage.md index 4833996..b7bf52b 100644 --- a/docs/basic_usage.md +++ b/docs/basic_usage.md @@ -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 a 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 diff --git a/examples/force_sequence.py b/examples/force_sequence.py new file mode 100644 index 0000000..7b19b24 --- /dev/null +++ b/examples/force_sequence.py @@ -0,0 +1,17 @@ +"""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) diff --git a/src/tekhsi/tek_hsi_connect.py b/src/tekhsi/tek_hsi_connect.py index ca54b29..2af8007 100644 --- a/src/tekhsi/tek_hsi_connect.py +++ b/src/tekhsi/tek_hsi_connect.py @@ -489,11 +489,25 @@ 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. - - to the current acquisition data. This is useful when connecting to a stopped instrument to + """force_sequence asks the instrument to please give us access to the already acquired data. + 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") + + # Save the waveform to a file + write_file(f"{wfm.source_name}.csv", wfm) + """ _logger.debug("force_sequence") request = ConnectRequest(name=self.clientname) From 01a9eb28847d265fafa602cf52b39559190fd918 Mon Sep 17 00:00:00 2001 From: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> Date: Fri, 18 Apr 2025 08:35:20 -0700 Subject: [PATCH 2/8] Update docs/basic_usage.md Co-authored-by: Nicholas Felt Signed-off-by: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> --- docs/basic_usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic_usage.md b/docs/basic_usage.md index b7bf52b..9d991c7 100644 --- a/docs/basic_usage.md +++ b/docs/basic_usage.md @@ -109,7 +109,7 @@ synchronization using start and `*OPC?`. ## 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 a the [`force_sequence()`][tekhsi.TekHSIConnect.force_sequence] method. +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. From c5a5bd1c9bb95bf8f1d58b00b5f2f1fb24c3e43c Mon Sep 17 00:00:00 2001 From: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> Date: Fri, 18 Apr 2025 08:35:27 -0700 Subject: [PATCH 3/8] Update examples/force_sequence.py Co-authored-by: Nicholas Felt Signed-off-by: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> --- examples/force_sequence.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/force_sequence.py b/examples/force_sequence.py index 7b19b24..a07e3a3 100644 --- a/examples/force_sequence.py +++ b/examples/force_sequence.py @@ -1,6 +1,5 @@ """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 From b5a9e2ed0a9fe5c56d77c720bd578acc3dc5b579 Mon Sep 17 00:00:00 2001 From: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> Date: Fri, 18 Apr 2025 08:35:40 -0700 Subject: [PATCH 4/8] Update src/tekhsi/tek_hsi_connect.py Co-authored-by: Nicholas Felt Signed-off-by: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> --- src/tekhsi/tek_hsi_connect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tekhsi/tek_hsi_connect.py b/src/tekhsi/tek_hsi_connect.py index 2af8007..eea7326 100644 --- a/src/tekhsi/tek_hsi_connect.py +++ b/src/tekhsi/tek_hsi_connect.py @@ -489,7 +489,7 @@ 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 to the already acquired data. + """Ask the instrument to give us access to the already acquired data. 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. From a6df992b702598928afd6be72fba6e7e6281fe32 Mon Sep 17 00:00:00 2001 From: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> Date: Fri, 18 Apr 2025 08:35:51 -0700 Subject: [PATCH 5/8] Update src/tekhsi/tek_hsi_connect.py Co-authored-by: Nicholas Felt Signed-off-by: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> --- src/tekhsi/tek_hsi_connect.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tekhsi/tek_hsi_connect.py b/src/tekhsi/tek_hsi_connect.py index eea7326..57cb7a4 100644 --- a/src/tekhsi/tek_hsi_connect.py +++ b/src/tekhsi/tek_hsi_connect.py @@ -490,6 +490,7 @@ def done_with_data(self) -> None: def force_sequence(self) -> None: """Ask the instrument to give us access to the already acquired data. + 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. From 67f669d28bb5d5b9ea7fffdf557a36c37cd9a681 Mon Sep 17 00:00:00 2001 From: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> Date: Fri, 18 Apr 2025 08:36:18 -0700 Subject: [PATCH 6/8] Update src/tekhsi/tek_hsi_connect.py Co-authored-by: Nicholas Felt Signed-off-by: Andrew McCann <53876256+amccann-Tek@users.noreply.github.com> --- src/tekhsi/tek_hsi_connect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tekhsi/tek_hsi_connect.py b/src/tekhsi/tek_hsi_connect.py index 57cb7a4..2fad60b 100644 --- a/src/tekhsi/tek_hsi_connect.py +++ b/src/tekhsi/tek_hsi_connect.py @@ -496,7 +496,7 @@ def force_sequence(self) -> None: acquisition. Examples: - from tm_data_types import AnalogWaveform, write_file + >>> 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 From 4c8de2bf81cf65bafb20c73bc542623d3b386574 Mon Sep 17 00:00:00 2001 From: amccann-Tek Date: Fri, 18 Apr 2025 09:12:13 -0700 Subject: [PATCH 7/8] update formatting for PR comments --- examples/force_sequence.py | 10 +++++----- src/tekhsi/tek_hsi_connect.py | 20 +++++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/examples/force_sequence.py b/examples/force_sequence.py index a07e3a3..deb0d08 100644 --- a/examples/force_sequence.py +++ b/examples/force_sequence.py @@ -8,9 +8,9 @@ # 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") + 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) + # Save the waveform to a file + write_file(f"{wfm.source_name}.csv", wfm) diff --git a/src/tekhsi/tek_hsi_connect.py b/src/tekhsi/tek_hsi_connect.py index 2fad60b..81695d9 100644 --- a/src/tekhsi/tek_hsi_connect.py +++ b/src/tekhsi/tek_hsi_connect.py @@ -497,17 +497,15 @@ def force_sequence(self) -> None: 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") - - # Save the waveform to a file - write_file(f"{wfm.source_name}.csv", wfm) + >>> 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") From ac237add74b7974c9dc0953c5694a9d3df54111c Mon Sep 17 00:00:00 2001 From: Nicholas Felt Date: Fri, 18 Apr 2025 09:19:34 -0700 Subject: [PATCH 8/8] Update examples/force_sequence.py Signed-off-by: Nicholas Felt --- examples/force_sequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/force_sequence.py b/examples/force_sequence.py index deb0d08..e1ecae4 100644 --- a/examples/force_sequence.py +++ b/examples/force_sequence.py @@ -1,4 +1,4 @@ -"""A script demonstrating a way to use force_sequence to save a wfm locally""" +"""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