tsp_control
¶
Base Test Script Processing (TSP) control class module.
TSPControl
¶
TSPControl(
config_entry: DeviceConfigEntry,
verbose: bool,
visa_resource: MessageBasedResource,
default_visa_timeout: int,
)
Base Test Script Processing (TSP) control class.
Important
Any class that inherits this control mixin must also inherit a descendant of the
Device class in order to have access to the
attributes required by this class.
| Parameters: |
|
|---|
default_visa_timeout
property
¶
default_visa_timeout: int
Return the default VISA timeout value in milliseconds.
device_type
abstractmethod
cached
property
¶
device_type: str
Return a string representing the device type.
idn_string
cached
property
¶
idn_string: str
Return the string returned from the *IDN? query when the device was created.
ieee_cmds
property
¶
ieee_cmds: TSPIEEE4882Commands
Return an internal class containing methods for the standard IEEE 488.2 command set.
name_and_alias
abstractmethod
cached
property
¶
name_and_alias: str
A string containing the device name and alias.
series
cached
property
¶
series: str
Return the series of the device.
| Returns: |
|
|---|
visa_resource
property
¶
visa_resource: MessageBasedResource
Return the VISA resource object.
This gives access to all the attributes and methods that PyVISA provides.
visa_timeout
property
writable
¶
visa_timeout: float
Return the current VISA timeout of the device in milliseconds.
add_method
classmethod
¶
add_method(method: Callable[Concatenate[Self, _P], _T]) -> None
Add a method to the class.
This class method is best used as a decorator on functions in order to add them to a class.
Examples:
>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_method
... def print_hello(self: Device, var: str):
... print("Hello World!")
... print(f"I am a {self.__class__.__name__}!")
... print(f"My var is {var}")
| Parameters: |
|
|---|
add_property
classmethod
¶
add_property(method: Callable[Concatenate[_EM, _P], _T]) -> None
add_property(
method: None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[Concatenate[_EM, _P], _T]], None]
add_property(
method: Callable[[Self], _T] | None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[[Self], _T]], None] | None
Add a property to the class.
This class method is best used as a decorator on functions in order to add them to a class.
Examples:
>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_property
... def foo(self: Device):
... return "bar"
>>>
>>> @Device.add_property(is_cached=True)
... def foo(self: Device):
... return self.name + self.address
| Parameters: |
|---|
check_visa_connection
¶
check_visa_connection() -> bool
Check if a VISA connection can be made to the device.
Wrapper function for check_visa_connection.
expect_esr
¶
expect_esr(
esr: int, error_messages: tuple[str, ...] = (), *, use_regex_match: bool = False
) -> bool
Checks for the expected esr value and queued error messages.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
export_buffers
¶
Export one or more of the device’s buffers to the given filepath.
| Parameters: |
|---|
factory_reset
¶
factory_reset() -> None
Send the FACTORY command followed by an *OPC? query.
This command is equivalent to pressing the DEFAULT SETUP button located on the instrument front panel or selected Default Setup from the File menu.
It recalls the instrument to factory default settings.
In addition to what *RST does, this command also performs the following operations:
- Clears any pending OPC operations
- Resets the following IEEE488.2 registers:
*ESR0 (Event Status Enable Register)*SRE0 (Service Request Enable Register)- DESE 255 (Device Event Status Enable Register)
*PSC1 (Power-on Status Clear Flag)- Deletes all defined aliases.
- Enables command headers (:HEADer 1).
FACTORY only resets the programmable interface settings, it does not change the
user interface settings.
get_buffers
¶
load_script
¶
load_script(
script_name: str,
*,
script_body: str = "",
file_path: str | PathLike[str] | None = None,
run_script: bool = False,
to_nv_memory: bool = False
) -> None
Upload a TSP script to the instrument.
| Parameters: |
|
|---|
poll_query
¶
poll_query(
number_of_polls: int,
query: str,
wanted_val: float | str,
sleep_time: float = 0.4,
tolerance: float = 0,
percentage: bool = False,
invert_range: bool = False,
invalid_values: list[float | str] | None = None,
) -> None
Poll the query until the wanted value appears.
| Parameters: |
|
|---|
| Raises: |
|
|---|
print_buffers
¶
print_buffers(*args: str) -> None
Print one of more of the device’s buffers to the console.
| Parameters: |
|
|---|
query
¶
query(
query: str, *, verbose: bool = True, remove_quotes: bool = False, allow_empty: bool = False
) -> str
Send a query to the device and return the result.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
query_binary
¶
query_binary(
query: str,
verbose: bool = True,
datatype: BINARY_DATATYPES = "f",
is_big_endian: bool = False,
container: type[T] | Callable[[Iterable[Any]], T] = list,
delay: float | None = None,
header_fmt: BINARY_HEADERS = "ieee",
expect_termination: bool = True,
data_points: int = 0,
chunk_size: int | None = None,
) -> T
Send a query to the device and return the binary values.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
query_expect_timeout
¶
Send a query expecting it to time out and fail.
| Parameters: |
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
query_less_than
¶
query_less_than(
query: str,
value: float | str,
tolerance: float = 0,
percentage: bool = False,
allow_equal: bool = False,
) -> bool
Send the given query and verify the result is less than the expected response.
| Parameters: |
|
|---|
| Returns: |
|
|---|
query_raw_binary
¶
Send a command to the device and then read and return the raw binary values.
| Parameters: |
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
query_response
¶
query_response(
query: str,
value: str | float,
tolerance: float = 0,
percentage: bool = False,
remove_quotes: bool = False,
custom_message_prefix: str = "",
allow_empty: bool = False,
) -> tuple[bool, str]
Query the device and verify the result.
| Parameters: |
|
|---|
| Returns: |
|---|
query_response_not
¶
query_response_not(
query: str, value: str, remove_quotes: bool = False, custom_message_prefix: str = ""
) -> tuple[bool, str]
Query the device and verify the result is not the given value.
| Parameters: |
|
|---|
| Returns: |
|---|
read_raw
¶
reset
¶
reset() -> None
Send the *RST command followed by an *OPC? query.
*RST only resets the programmable interface settings, it does not change the user
interface settings.
run_script
¶
run_script(script_name: str) -> None
Run a TSP script on the instrument.
| Parameters: |
|
|---|
set_and_check
¶
set_and_check(
command: str,
value: str | float,
tolerance: float = 0,
percentage: bool = False,
remove_quotes: bool = False,
custom_message_prefix: str = "",
*,
expected_value: str | float | None = None,
opc: bool = False
) -> str
Send the given command with the given value and then verify the results.
| Parameters: |
|
|---|
| Returns: |
|
|---|
set_if_needed
¶
set_if_needed(
command: str,
value: str | float,
tolerance: float = 0,
percentage: bool = False,
remove_quotes: bool = False,
custom_message_prefix: str = "",
*,
expected_value: str | float | None = None,
opc: bool = False,
allow_empty: bool = False,
verify_value: bool = False
) -> tuple[bool, str]
Query the command’s field and update it if the value does not match the input.
| Parameters: |
|
|---|
| Returns: |
|---|
temporary_visa_timeout
¶
Set a temporary VISA timeout value for the duration of the context.
This will reset the VISA timeout to the previous value when the context exits.
| Parameters: |
|
|---|
wait_for_srq_event
¶
wait_for_srq_event(timeout: int) -> WaitResponse
Wait for the service request event to happen, up to the given timeout.
| Parameters: |
|
|---|
| Returns: |
|
|---|
wait_for_visa_connection
¶
wait_for_visa_connection(
wait_time: float, sleep_seconds: int = 5, accept_immediate_connection: bool = False
) -> bool
Wait for a VISA connection to be made to the device.
| Parameters: |
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
write
¶
Write a command to the device.
| Parameters: |
|---|
| Raises: |
|
|---|