tek_hsi_connect
¶
Module for connecting to Tektronix instruments and retrieving waveform data using gRPC.
AcqWaitOn
¶
Bases: Enum
This enumeration is used to select how to wait to access data.
NewData
class-attribute
instance-attribute
¶
NewData = 4
Wait for new data.
Using the NewData criterion for data acceptance will continue when the current data from the
stored acquisition has not been read by
get_data(). This is
import since the underlying data is buffered because it’s stored as data on the instrument is
available. If you have seen the underlying data since the last
get_data() call,
it will return the buffered data. If you
haven’t seen the data, it will block until the next new piece of data arrives.
Examples:
>>> from tekhsi import AcqWaitOn, TekHSIConnect
>>> with TekHSIConnect("192.168.0.1:5000") as connection:
... with connection.access_data(AcqWaitOn.NewData):
... ...
NextAcq
class-attribute
instance-attribute
¶
NextAcq = 1
Wait for the next acquisition.
Using the NextAcq criterion for data acceptance will force the data access call to wait until
the next new acquisition is available.
Examples:
>>> from tekhsi import AcqWaitOn, TekHSIConnect
>>> with TekHSIConnect("192.168.0.1:5000") as connection:
... with connection.access_data(AcqWaitOn.NextAcq):
... ...
Time
class-attribute
instance-attribute
¶
Time = 2
Wait for a specific time.
Using the Time criterion for data acceptance will force a time delay before accepting the next
acquisition. The typical usage of this is if you are using multiple instruments and PyVISA. If
you are turning on an AFG you need some time for the instrument to be set up and the data to
arrive. This process is approximately the same as sleeping for half a second then calling
access_data(AcqWaitOn.NextAcq).
Examples:
>>> from tekhsi import AcqWaitOn, TekHSIConnect
>>> with TekHSIConnect("192.168.0.1:5000") as connection:
... with connection.access_data(AcqWaitOn.Time, after=0.5):
... ...
TekHSIConnect
¶
TekHSIConnect(
url: str,
activesymbols: list[str] | None = None,
callback: Callable | None = None,
data_filter: Callable | None = None,
)
Support for Tektronix High-Speed Interface data API.
- This API is intended to aid in retrieving data from instruments as fast as possible.
| Parameters: |
|
|---|
available_symbols
property
¶
Returns the list of available symbols on the instrument.
“Available” means the channel is on. What data type is returned will depend upon the probe attached or action requested by the user. This property will only return the currently available channel list. If channels are off or modes are disabled, the corresponding symbols will not be present.
Examples:
>>> from tekhsi import TekHSIConnect
>>> with TekHSIConnect("192.168.0.1:5000") as connection:
... print(connection.available_symbols)
['ch1', 'ch1_iq', 'ch3', 'ch4_DAll']
In the above example, 'ch1' is an analog channel, 'ch1_iq' is the spectrum view channel
associated with 'ch1' (when enabled). 'ch3' is another analog channel, and 'ch4_DAll'
is a digital probe on 'ch4'. Types are generally determined by the name of the symbol.
| Returns: |
|---|
current_time
property
¶
current_time: float
This property returns time relative to the connection to the gRPC client.
| Returns: |
|
|---|
instrumentation_enabled
property
writable
¶
instrumentation_enabled: bool
Indicates if instrumentation is enabled.
| Returns: |
|
|---|
source_names
property
¶
verbose
property
writable
¶
verbose: bool
Indicates if verbose mode is enabled.
| Returns: |
|
|---|
access_data
¶
Grants access to data.
Must be used as a context manager to grant access for
get_data() method calls.
The access_data() context manager is used to get access to the available data. It holds
access to the current acquisition (as a blocking method) for the duration of the current
context. This is how you ensure that all data you get is from the same acquisition.
It does not matter if the scope is running continuously or using single sequence, all the
data is from the same acquisition when inside the access_data() context manager code
block.
This also means you are potentially holding off scope acquisitions when inside the
access_data() code block. So, it’s recommended you only get the data in the context
manager, and then do any processing outside the context manager block.
Examples:
>>> from tm_data_types import AnalogWaveform
>>> from tekhsi import TekHSIConnect
>>> with TekHSIConnect("192.168.0.1:5000") as connection:
... # Request access to data
... with connection.access_data():
... # Access granted
... ch1: AnalogWaveform = connection.get_data("ch1")
... ch3: AnalogWaveform = connection.get_data("ch3")
| Parameters: |
|---|
active_symbols
¶
any_acq
staticmethod
¶
any_horizontal_change
staticmethod
¶
any_horizontal_change(
previous_header: dict[str, WaveformHeader], current_header: dict[str, WaveformHeader]
) -> bool
Acq acceptance filter that accepts only acqs with changes to horizontal settings.
| Parameters: |
|---|
| Returns: |
|
|---|
any_vertical_change
staticmethod
¶
any_vertical_change(
previous_header: dict[str, WaveformHeader], current_header: dict[str, WaveformHeader]
) -> bool
Prebuilt acq acceptance filter that accepts only acqs with changes to vertical settings.
| Parameters: |
|---|
| Returns: |
|
|---|
data_arrival
staticmethod
¶
data_arrival(waveforms: list[AnyWaveform]) -> None
Available to be overridden if user wants to create a derived class.
This method will be called on every accepted acq.
| Parameters: |
|
|---|
done_with_data
¶
done_with_data() -> None
Releases the acquisition after accessing the required data.
force_sequence
¶
force_sequence() -> 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 get access to the currently available data. Otherwise, the API will wait until the next acquisition.
get_data
¶
get_data(name: str) -> AnyWaveform | None
Gets the saved data of the previous acquisition with the data item of the requested name.
The provided name parameter must correspond to the names returned from the
available_symbols property,
however, the names are case-insensitive.
| Parameters: |
|
|---|
| Returns: |
|
|---|
set_acq_filter
¶
set_acq_filter(acq_filter: Callable) -> None
Sets rules for acquisitions that are accepted and forwarded.
This is to allow only import data changes to be passed to the callback or saved to backing store.
| Parameters: |
|
|---|