Initialization

NI Switches

Initialization

For any application you write, call the niSwitch Initialize With Topology VI or the niSwitch_InitWithTopology function to establish communication with the switch.

Use the niSwitch Initialize With Topology VI or the niSwitch_InitWithTopology function to establish a session with the switch and send initialization commands that set the instrument to the state necessary for NI-SWITCH operation. The niSwitch Initialize With Topology VI or the niSwitch_InitWithTopology function also verifies that NI-SWITCH supports the switch, resets the switch to a known state, returns a ViSession handle used to identify the instrument in all subsequent NI-SWITCH calls, and allows you to set the topology of the switch, including simulation.

The niSwitch Initialize With Topology VI and the niSwitch_InitWithTopology function override the topology for the switch module you set in Measurement & Automation Explorer (MAX). Refer to the NI Switches Getting Started Guide for information on configuring your switch module in MAX.

Resource Names

To establish a session with the correct switch module, you must pass a resource name to the niSwitch Initialize With Topology VI or the niSwitch_InitWithTopology function. The syntax of the resource name depends on where in MAX you configured your switch module—under NI-DAQmx Devices, Traditional NI-DAQ (Legacy) Devices, or PXI System.

Note  Existing NI-SWITCH applications may use additional suffixes in the resource name (such as ::SCANNER, ::INDEP, or ::MATRIX). While these suffixes are still supported, they are unnecessary with NI-SWITCH 2.0. Refer to Legacy Programming for more information.

MAX Configuration Under NI-DAQmx Devices

If you configured the switch module under NI-DAQmx Devices in MAX, the resource name is the string in quotes. For example, the resource name of the first NI SCXI-1129 in the following figure would be SC1Mod2. Pass this string to the niSwitch Initialize With Topology VI or the niSwitch_InitWithTopology function. You can rename the resource name for switch modules configured as DAQmx devices simply by clicking on the device in MAX and entering a new name.

MAX Configuration Under Traditional NI-DAQ (Legacy) Devices

If you configured the switch module in MAX under the Traditional NI-DAQ (Legacy) Devices category in the Configuration pane, the resource name syntax is:

SCXI[chassis ID]::[slot number]

For example, the resource name of the first NI SCXI-1129 for the following configuration would be SCXI1::2. "1" denotes the chassis ID and "2" the slot number. Pass this string to niSwitch Init With Topology.

MAX Configuration Under PXI System

If the switch module appears in MAX under the PXI System category in the Configuration pane, the resource name syntax is:

PXI[bus number]::[device number]

Note  The NI PXI-2566 and NI PXI-2593 appear under the PXI System folder, but can only be configured under NI-DAQmx Devices.

For example, the resource name of the NI PXI-2591 for the following configuration would be PXI2::12. "2" denotes the bus number and "1" denotes the device number. Pass this string to the niSwitch Initialize With Topology VI or the niSwitch_InitWithTopology function.

Alternative Initialization Methods

You can also open a session to the switch module by calling the niSwitch Initialize VI or the niSwitch_init function, or by calling the niSwitch Initialize With Options VI or the niSwitch_InitWithOptions function. The niSwitch Initialize VI or the niSwitch_init function performs all the functionality of the niSwitch Initialize With Topology VI or the niSwitch_InitWithTopology function except that it does not set the topology of the switch. Instead, the driver uses the topology you set in MAX for the switch module. The niSwitch Initialize VI or the niSwitch_init function is available for those interested in maintaining IVI-compliance. For more information about IVI, refer to ivifoundation.org.

In addition to performing all the functionality of the niSwitch Initialize VI or the niSwitch_init function, the niSwitch Initialize With Options VI or the niSwitch_InitWithOptions function optionally sets the initial state of the switch. With the niSwitch Initialize With Options VI or the niSwitch_InitWithOptions function, you can configure the topology, range checking, caching, coercion recording, simulation, and status reporting. Refer to the option string (optionString) parameter of niSwitch Initialize With Options VI or the niSwitch_InitWithOptions function.

Once you have initialized the switch, you must configure it.