Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Configuring a Connector Pane Using VI Scripting

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

Requires: VI Scripting

You can use VI Scripting to interact with the connector pane of a VI programmatically to accomplish any of the following tasks:

  • Selecting a connector pane pattern for a subVI
  • Assigning a control to a terminal on a connector pane
  • Navigating across a connector pane
  • Defining whether a terminal of a subVI is required, optional, or recommended

This topic highlights the first two tasks. Refer to the Connector Pane methods for more information about interacting with a connector pane programmatically.

What to Use

This VI Scripting task requires the following objects:

VI:Connector Pane:Reference ConnectorPane:Pattern ConnectorPane:Assign Control To Terminal Connector Pane Pattern Reference Example

What to Do

Before you start: Open the Add Terminals to Connector Pane VI in the labview\examples\Application Control\VI Scripting\Connector Pane directory for an example that illustrates each step of the following procedure.

Expand the procedure for more information about this specific example.

  1. Obtain a reference to the VI whose connector pane you want to inspect or modify.

    Example Details

    In the example, the scripting VI uses the Open VI Reference function to obtain a reference to a specific VI.

  2. Use the VI:Connector Pane:Reference property to obtain a reference to the connector pane of the VI.
  3. Determine the connector pane pattern you want the VI to have.

    Connector pane patterns are denoted by a pattern index between 4800 and 4835. By default, connector panes use pattern 4815.

    You can use one of the following approaches to identify which pattern index to use.

    • Refer to the Connector Pane Pattern Reference VI located in the labview\examples\Application Control\VI Scripting\Connector Pane directory for a complete mapping of patterns to their indexes.
    • View the Context Help of a VI that has a connector pane pattern that you want to use for the VI that you are modifying. If you display additional VI scripting information in the Context Help window, the pattern index appears at the end of the path to the VI.
    • Use the ConnectorPane:Pattern property of another VI to programmatically obtain the pattern index of that VI.

    Example Details

    In the example, the scripting VI enables the user to select the connector pane pattern at run time. Therefore, the scripting VI uses a control to determine the connector pane pattern.

    Note Note  Because the Connector Pane Pattern control accepts any integer, this example should check the value of that control to ensure that it is within the 4800..4835 range of acceptable pattern indexes. For simplicity, the example omits this step.
  4. Use the Connector Pane:Pattern property to set the connector pane to your chosen pattern.
  5. Obtain references to the controls that you want to assign to connector pane terminals.

    Example Details

    In the example, the scripting VI uses the Panel:Controls[] property of the front panel of the target VI to obtain references to all front panel controls.

  6. Determine how you want to map these controls to the connector pane terminals.

    Refer to the LabVIEW Style Checklist for guidelines about assigning controls and indicators to connector panes that are visible to your users.

    Example Details

    In the example, the only goal of the scripting VI is to assign all controls to a terminal. Therefore, the scripting VI does not have criteria for how to map the controls to the terminals.

  7. Use the ConnectorPane:Assign Control To Terminal method to assign each control to the desired terminal of the connector pane.

    To identify the terminal index that corresponds to each terminal in your chosen pattern, refer to the Connector Pane Pattern Reference VI mentioned in step 3.

    Example Details

    In the example, the scripting VI iterates across the entire Panel:Controls[] array, assigning each control to the next terminal index of the connector pane. This approach does not require knowledge of specific terminal indexes because the scripting goal does not require the controls to be wired to the connector pane in a specific way.

    Note Note  Because it is possible in the example for the chosen connector pane pattern to have fewer terminals than there are controls on the front panel, it is also possible for the ConnectorPane:Assign Control To Terminal method to return an error. Refer to the Caveats and Recommendations section of this topic for information about avoiding this error.
  8. Use the Close Reference function to close each open object reference when you are finished using it.

    Example Details

    In the example, the scripting VI closes the reference to the front panel, the controls, the connector pane, and the target VI.

Caveats and Recommendations

  • Use caution when you change a connector pane pattern that has pre-existing control assignments—When you replace a connector pane pattern with a different pattern, LabVIEW reassigns the controls that were previously assigned to terminals on the old pattern to terminals on the new pattern. However, the new assignments do not preserve the terminal indexes or relative locations from the old pattern. Therefore, you can rely only on knowledge of terminal assignments that you obtain after the most recent pattern change.
  • Ensure that the pattern of a connector pane has enough terminals to accommodate the terminal indexes that you plan to use—The Connector Pane:Assign Control to Terminal method returns an error if the pattern of the referenced connector pane does not have enough terminals to accommodate the terminal index that you wire to the method. Use the ConnectorPane:Number of Connection Terminals property of the relevant connector pane to verify that the connector pane has enough terminals for the terminal index that you want to use.
  • Close all references that you open—An excessive number of open references negatively impacts the performance of a VI. Read about closing VI and VI object references for more performance details.

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit