Skip to content

Commit

Permalink
docs: Add a code example of passing in config options in a dataclass …
Browse files Browse the repository at this point in the history
…via a keyword argument when initializing the `DeviceManager`.
  • Loading branch information
nfelt14 committed Dec 4, 2023
1 parent a710ec3 commit deea74b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions examples/miscellaneous/adding_devices.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
"""An example of adding devices via Python code."""
from tm_devices import DeviceManager
from tm_devices.helpers import PYVISA_PY_BACKEND, SerialConfig, SYSTEM_DEFAULT_VISA_BACKEND
from tm_devices.helpers import (
DMConfigOptions,
PYVISA_PY_BACKEND,
SerialConfig,
SYSTEM_DEFAULT_VISA_BACKEND,
)

with DeviceManager(verbose=True) as device_manager:
# Specific config options can optionally be passed in when creating
# the DeviceManager via a dataclass, they are used to update any existing
# configuration options from a config file.
CONFIG_OPTIONS = DMConfigOptions(
setup_cleanup=True, # update the value for this option, all other options will remain untouched
)


# Create the DeviceManager, turning on verbosity and passing in some specific configuration values.
with DeviceManager(
verbose=True, # optional argument
config_options=CONFIG_OPTIONS, # optional argument
) as device_manager:
# Explicitly specify to use the system VISA backend, this is the default,
# **this code is not required** to use the system default.
device_manager.visa_library = SYSTEM_DEFAULT_VISA_BACKEND
Expand Down

0 comments on commit deea74b

Please sign in to comment.