device_manager

Device manager module.

AFGAlias module-attribute

AFGAlias = TypeVar('AFGAlias', bound=AFG, default=AFG)

An alias to a specific Arbitrary Function Generator Python driver.

AWGAlias module-attribute

AWGAlias = TypeVar('AWGAlias', bound=AWG, default=AWG)

An alias to a specific Arbitrary Waveform Generator Python driver.

DataAcquisitionSystemAlias module-attribute

DataAcquisitionSystemAlias = TypeVar(
    "DataAcquisitionSystemAlias", bound=DataAcquisitionSystem, default=DataAcquisitionSystem
)

An alias to a specific Data Acquisition System Python driver.

DigitalMultimeterAlias module-attribute

DigitalMultimeterAlias = TypeVar(
    "DigitalMultimeterAlias", bound=DigitalMultimeter, default=DigitalMultimeter
)

An alias to a specific Digital Multimeter Python driver.

MainframeAlias module-attribute

MainframeAlias = TypeVar('MainframeAlias', bound=Mainframe, default=Mainframe)

An alias to a specific Mainframe driver.

MarginTesterAlias module-attribute

MarginTesterAlias = TypeVar('MarginTesterAlias', bound=MarginTester, default=MarginTester)

An alias to a specific Margin Tester Python driver.

PowerSupplyUnitAlias module-attribute

PowerSupplyUnitAlias = TypeVar(
    "PowerSupplyUnitAlias", bound=PowerSupplyUnit, default=PowerSupplyUnit
)

An alias to a specific Power Supply Unit Python driver.

ScopeAlias module-attribute

ScopeAlias = TypeVar('ScopeAlias', bound=Scope, default=Scope)

An alias to a specific Scope driver.

SourceMeasureUnitAlias module-attribute

SourceMeasureUnitAlias = TypeVar(
    "SourceMeasureUnitAlias", bound=SourceMeasureUnit, default=SourceMeasureUnit
)

An alias to a specific Source Measure Unit Python driver.

SystemsSwitchAlias module-attribute

SystemsSwitchAlias = TypeVar('SystemsSwitchAlias', bound=SystemsSwitch, default=SystemsSwitch)

An alias to a specific Systems Switch Python driver.

UnsupportedDeviceAlias module-attribute

UnsupportedDeviceAlias = TypeVar('UnsupportedDeviceAlias', bound=Device, default=Device)

An alias to a custom device driver for an unsupported device type.

DeviceManager

DeviceManager(
    verbose: bool = True,
    config_options: DMConfigOptions | None = None,
    external_device_drivers: Mapping[str, type[Device]] | None = None,
)

The manager for all devices.

Once instantiated, this class creates and manages connections to all devices.

This class is a singleton, meaning only one instance can ever be created. Any subsequent instantiation attempts will return a pointer to the original instance.

Parameters:
  • verbose (bool, default: True ) –

    A boolean indicating if verbose output should be printed. This flag cascades down to all connected devices. Setting it to False will not remove all printouts to stdout. To remove all console output, use configure_logging() before instantiating the DeviceManager.

  • config_options (DMConfigOptions | None, default: None ) –

    An optional set of configuration options to use (updates the current configuration options).

  • external_device_drivers (Mapping[str, type[Device]] | None, default: None ) –

    An optional dict for passing in additional device drivers.

default_visa_timeout property writable

default_visa_timeout: int

Return the default VISA timeout value.

devices property

devices: Mapping[str, Device]

Return the dictionary of devices.

disable_command_verification property writable

disable_command_verification: bool

Indicate if command verification is disabled for all devices.

is_open property

is_open: bool

Indicate if the DeviceManager has closed all device connections.

setup_cleanup_enabled property writable

setup_cleanup_enabled: bool

Indicate if cleanup at setup is enabled for devices.

teardown_cleanup_enabled property writable

teardown_cleanup_enabled: bool

Indicate if cleanup at teardown is enabled for devices.

verbose property writable

verbose: bool

Return the verbosity setting of the DeviceManager.

verbose_visa property writable

verbose_visa: bool

Return the VISA verbosity setting of the DeviceManager.

visa_library property writable

visa_library: str

Return the currently selected VISA library.

add_afg

add_afg(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    serial_config: SerialConfig | None = None,
    gpib_board_number: int | None = None
) -> AFGAlias

Add an Arbitrary Function Generator to the DeviceManager.

Parameters:
  • address (str) –

    The address of the AFG, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the AFG. If no alias is provided, the device type and number can be used to access the AFG instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • serial_config (SerialConfig | None, default: None ) –

    Serial connection settings, only needed when connection_type=”SERIAL”.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:
  • AFGAlias

    The Arbitrary Function Generator device driver.

add_awg

add_awg(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    serial_config: SerialConfig | None = None,
    gpib_board_number: int | None = None
) -> AWGAlias

Add an Arbitrary Waveform Generator to the DeviceManager.

Parameters:
  • address (str) –

    The address of the AWG, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the AWG. If no alias is provided, the device type and number can be used to access the AWG instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • serial_config (SerialConfig | None, default: None ) –

    Serial connection settings, only needed when connection_type=”SERIAL”.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:
  • AWGAlias

    The Arbitrary Waveform Generator device driver.

add_daq

add_daq(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    serial_config: SerialConfig | None = None,
    gpib_board_number: int | None = None
) -> DataAcquisitionSystemAlias

Add a Data Acquisition System to the DeviceManager.

Parameters:
  • address (str) –

    The address of the DAQ, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the DAQ. If no alias is provided, the device type and number can be used to access the DAQ instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • serial_config (SerialConfig | None, default: None ) –

    Serial connection settings, only needed when connection_type=”SERIAL”.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:

add_dmm

add_dmm(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    serial_config: SerialConfig | None = None,
    gpib_board_number: int | None = None
) -> DigitalMultimeterAlias

Add a Digital Multimeter to the DeviceManager.

Parameters:
  • address (str) –

    The address of the DMM, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the DMM. If no alias is provided, the device type and number can be used to access the AWG instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • serial_config (SerialConfig | None, default: None ) –

    Serial connection settings, only needed when connection_type=”SERIAL”.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:

add_mf

add_mf(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None
) -> MainframeAlias

Add a Mainframe to the DeviceManager.

Parameters:
  • address (str) –

    The address of the device, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the Mainframe. If no alias is provided, the device type and number can be used to access the Mainframe instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

Returns:

add_mt

add_mt(
    address: str, device_driver: str, *, alias: str | None = None, port: int | None = None
) -> MarginTesterAlias

Add a Margin Tester to the DeviceManager.

Parameters:
  • address (str) –

    The address of the Margin Tester, either an IP address or hostname.

  • device_driver (str) –

    A string indicating the specific Python device driver to use.

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the Margin Tester. If no alias is provided, the device type and number can be used to access the Margin Tester instead.

  • port (int | None, default: None ) –

    The port to use when creating the connection.

Returns:

add_psu

add_psu(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    serial_config: SerialConfig | None = None,
    gpib_board_number: int | None = None
) -> PowerSupplyUnitAlias

Add a Power Supply Unit to the DeviceManager.

Parameters:
  • address (str) –

    The address of the PSU, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the PSU. If no alias is provided, the device type and number can be used to access the PSU instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • serial_config (SerialConfig | None, default: None ) –

    Serial connection settings, only needed when connection_type=”SERIAL”.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:

add_scope

add_scope(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    serial_config: SerialConfig | None = None,
    gpib_board_number: int | None = None
) -> ScopeAlias

Add a scope to the DeviceManager.

Parameters:
  • address (str) –

    The address of the scope, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the scope. If no alias is provided, the device type and number can be used to access the scope instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • serial_config (SerialConfig | None, default: None ) –

    Serial connection settings, only needed when connection_type=”SERIAL”.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:

add_smu

add_smu(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    serial_config: SerialConfig | None = None,
    gpib_board_number: int | None = None
) -> SourceMeasureUnitAlias

Add a Source Measure Unit to the DeviceManager.

Parameters:
  • address (str) –

    The address of the device, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the SMU. If no alias is provided, the device type and number can be used to access the SMU instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • serial_config (SerialConfig | None, default: None ) –

    Serial connection settings, only needed when connection_type=”SERIAL”.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:

add_ss

add_ss(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    gpib_board_number: int | None = None
) -> SystemsSwitchAlias

Add a Systems Switch to the DeviceManager.

Parameters:
  • address (str) –

    The address of the device, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the Systems Switch. If no alias is provided, the device type and number can be used to access the Systems Switch instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:

add_unsupported_device

add_unsupported_device(
    address: str,
    *,
    alias: str | None = None,
    connection_type: str | None = None,
    port: int | None = None,
    lan_device_endpoint: str | None = None,
    gpib_board_number: int | None = None
) -> UnsupportedDeviceAlias

Add a custom device to the DeviceManager that is not an officially supported device type.

Warning

This should not be used unless absolutely necessary.

Parameters:
  • address (str) –

    The address of the device, either an IP address or hostname. If the connection type is "USB" then the address must be specified as "<model>-<serial>".

  • alias (str | None, default: None ) –

    An optional alias to use to refer to the device. If no alias is provided, the device type and number can be used to access the device instead.

  • connection_type (str | None, default: None ) –

    The type of connection to use for VISA, defaults to TCPIP, not needed when the address is a visa resource expression since the connection type is parsed from the address string.

  • port (int | None, default: None ) –

    The port to use when creating a socket connection.

  • lan_device_endpoint (str | None, default: None ) –

    The LAN device endpoint to connect on, used for TCPIP connections. The default (when needed) is ‘inst0’.

  • gpib_board_number (int | None, default: None ) –

    The GPIB board number (also referred to as a controller) to be used when making a GPIB connection (defaults to 0).

Returns:

cleanup_all_devices

cleanup_all_devices() -> None

Cleanup and reset all devices.

close

close(*, suppress_logging: bool = False) -> None

Close the DeviceManager.

disable_device_command_checking

disable_device_command_checking() -> None

Set the .enable_verification attribute of each device to False.

This can have the effect of speeding up automation scripts by no longer checking each command after it is sent via the .set_and_check() method.

get_afg

get_afg(number_or_alias: int | str) -> AFGAlias

Get the Arbitrary Function Generator Python driver for the given AFG number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the AFG to get.

Returns:
  • AFGAlias

    The Arbitrary Function Generator device driver.

get_available_devices

get_available_devices(
    search: str = "", configured: bool = True, local: bool = True
) -> dict[str, tuple[str, ...]]

Get tuples of local and configured devices, optionally narrowed by a search.

Parameters:
  • search (str, default: '' ) –

    Simple case-insensitive search criteria for available devices.

  • configured (bool, default: True ) –

    Whether to include configured devices.

  • local (bool, default: True ) –

    Whether to include local devices.

Returns:
Raises:
  • AssertionError

    Local resources can’t be queried with the VISA ResourceManager. May need to configure the VISA backend.

get_awg

get_awg(number_or_alias: int | str) -> AWGAlias

Get the Arbitrary Waveform Generator Python driver for the given AWG number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the AWG to get.

Returns:
  • AWGAlias

    The Arbitrary Waveform Generator device driver.

get_current_configuration_as_environment_variable_strings

get_current_configuration_as_environment_variable_strings() -> str

Return the current configuration represented as environment variables.

get_daq

get_daq(number_or_alias: int | str) -> DataAcquisitionSystemAlias

Get the Data Acquisition System Python driver for the given DAQ number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the DAQ to get.

Returns:

get_device

get_device(
    *,
    device_type: str | None = None,
    device_number: int | str | None = None,
    alias: str | None = None
) -> Device

Get the driver for the given device.

Either device_type and device_number or alias must be provided when using this method.

Parameters:
  • device_type (str | None, default: None ) –

    The type of the device to get.

  • device_number (int | str | None, default: None ) –

    The number of the device to get.

  • alias (str | None, default: None ) –

    The alias of the device to get.

Returns:
  • Device

    The device driver.

Raises:
  • LookupError

    The device was not found in the device driver dictionary.

  • ValueError

    Indicates that both the type/number and alias parameter were left empty.

  • TypeError

    Indicates that the fetched device type does not match the specified type.

get_dmm

get_dmm(number_or_alias: int | str) -> DigitalMultimeterAlias

Get the Digital Multimeter Python driver for the given DMM number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the DMM to get.

Returns:

get_mf

get_mf(number_or_alias: int | str) -> MainframeAlias

Get the Mainframe driver for the given device number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the Mainframe to get.

Returns:

get_mt

get_mt(number_or_alias: int | str) -> MarginTesterAlias

Get the Margin Tester Python driver for the given Margin Tester number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the Margin Tester to get.

Returns:

get_psu

get_psu(number_or_alias: int | str) -> PowerSupplyUnitAlias

Get the Power Supply Unit Python driver for the given PSU number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the PSU to get.

Returns:

get_scope

get_scope(number_or_alias: int | str) -> ScopeAlias

Get the scope driver for the given scope number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the scope to get.

Returns:

get_smu

get_smu(number_or_alias: int | str) -> SourceMeasureUnitAlias

Get the Source Measure Unit Python driver for the given SMU number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the SMU to get.

Returns:

get_ss

get_ss(number_or_alias: int | str) -> SystemsSwitchAlias

Get the Systems Switch Python driver for the given Systems Switch number or alias.

Integers are treated as a device number, strings are treated as an alias.

Parameters:
  • number_or_alias (int | str) –

    The number or alias of the Systems Switch to get.

Returns:

load_config_file

load_config_file(config_file_path: str | PathLike[str]) -> None

Load in the config file located at the given path.

This method will update the current configuration options with any newly defined options and add any newly defined devices.

Parameters:
  • config_file_path (str | PathLike[str]) –

    The path to the config file to load.

open

open() -> bool

Reopen all devices if the DeviceManager has been previously closed.

Returns:
  • bool

    A boolean indicating if the DeviceManager was opened.

remove_all_devices

remove_all_devices() -> None

Remove all devices from the DeviceManager.

remove_device

remove_device(
    *,
    device_type: str | None = None,
    device_number: int | str | None = None,
    alias: str | None = None
) -> None

Remove a device from the DeviceManager.

Either device_type and device_number or alias must be provided when using this method.

Parameters:
  • device_type (str | None, default: None ) –

    The type of the device to remove, e.g. ‘SCOPE’.

  • device_number (int | str | None, default: None ) –

    The number of the device to remove, e.g. ‘1’.

  • alias (str | None, default: None ) –

    A device alias.

write_current_configuration_to_config_file

write_current_configuration_to_config_file(
    config_file_path: str | PathLike[str] | None = None,
) -> None

Write a config file located at the current working directory (or custom path).

This method will overwrite any existing config file with the current devices and options. This method also respects the TM_DEVICES_CONFIG environment variable.

Parameters:
  • config_file_path (str | PathLike[str] | None, default: None ) –

    The path to the config file. If ends in “.toml” will create toml file.

print_available_visa_devices

print_available_visa_devices() -> None

Print all available VISA devices to the console.