<jupyter_start><jupyter_text>Qcodes example for National Instruments PXIe-2597 RF Switch<jupyter_code>from qcodes_contrib_drivers.drivers.NationalInstruments.PXIe_2597 import NI_PXIe_2597<jupyter_output><empty_output><jupyter_text>The PXIe-2597 has a multiplexer configuration. It connects the common `com` port to one of 6 ports. Default channel names are `"ch"`. We connect to the device using the VISA alias `RF_switch` assigned in NI MAX.<jupyter_code>dev = NI_PXIe_2597("Switch", resource="RF_switch")

print('All channels:', [ch.short_name for ch in dev.channels])
print('Initially connected to:',  dev.channel())<jupyter_output>Connected to: National Instruments PXI-2597 (serial:1DBFD38, firmware:Not Available) in 6.85s
All channels: ['ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6', 'com']
Initially connected to: ch3<jupyter_text>Connect different channels on the switchThe main way of connecting channels is the `channel` parameter.<jupyter_code>dev.channel("ch3")
print('Now connected to:', dev.channel())

# disconnect by setting to None
dev.channel(None)
print('Now connected to:', dev.channel())

dev.channel("ch1")
print('Now connected to:', dev.channel())

# or by using disconnect_all
dev.disconnect_all()
print('Now connected to:', dev.channel())<jupyter_output>Now connected to: ch3
Now connected to: None
Now connected to: ch1
Now connected to: None<jupyter_text>Channels may be also connected using their `connect_to` method, although it doesn't make much sense for the PXI-2597, which can have one connection at a time anyway.<jupyter_code>dev.channels.ch1.connect_to(dev.channels.com)
print("Connected to:", dev.channel())<jupyter_output>Connected to: ch1<jupyter_text>You can check which channels are connected to which using the `connections` parameter of a channel. Disconnected channels return an empty list.<jupyter_code>dev.channel("ch1")
print("ch1 is connected to", dev.channels.ch1.connections())
print("com is connected to", dev.channels.com.connections())
print("ch2 is connected to", dev.channels.ch2.connections())<jupyter_output>ch1 is connected to ['com']
com is connected to ['ch1']
ch2 is connected to []<jupyter_text>Aliasing channel names You may also provide a dict of aliases for more memorable channel names. This can be also set up in the station YAML file. Note that if you want to use the channel as a setpoint in a measurement, it should be a valid Python identifier (unlike in the example below). The `com` port cannot be aliased.<jupyter_code>name_mapping = {'ch1': 'Main channel',
                'ch3': 'Qubit channel'}

dev.close()

dev = NI_PXIe_2597("Switch", resource="RF_switch",
                   name_mapping=name_mapping)

dev.channel('Main channel')
print('Now connected to:', dev.channel())

dev.channel('Qubit channel')
print('Now connected to:', dev.channel())

# non-existent channel throws an error
try:
    dev.channel('Undefined channel')
except ValueError as e:
    print(e)<jupyter_output>Connected to: National Instruments PXI-2597 (serial:1DBFD38, firmware:Not Available) in 2.28s
Now connected to: Main channel
Now connected to: Qubit channel
("'Undefined channel' is not in {'ch5', 'ch2', 'ch4', 'Qubit channel', None, 'ch6', 'Main channel'}; Parameter: Switch.channel", 'setting Switch_channel to Undefined channel')<jupyter_text>Print a snapshot<jupyter_code>dev.print_readable_snapshot()
dev.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11254775198354393, 'fraction_numerical': 0.022333235380546577, 'mean_word_length': 6.166315789473685, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '542784', 'license': 'MIT', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1055, 'n_words': 358, 'path': 'docs/examples/NationalInstruments_PXIe_2597.ipynb', 'repo_name': 'simonzihlmann/Qcodes_contrib_drivers', 'size': '3403'}