Passing Structs to Code Modules - LabVIEW DLL

Purpose

This example demonstrates how to pass a TestStand container as a LabVIEW cluster to a LabVIEW VI. The container consists of several different data types. The VIs are compiled into a DLL and called as functions.

Note VIs always use a 1-byte packing scheme when passing clusters as parameters.

Example File Location

<TestStand Public>\Examples\Fundamentals\Passing Structs to Code Modules\LabVIEW DLL\Passing Structs to Code Modules.seq

Highlighted Features

  • LabVIEW Adapter
  • Local variables
  • Data types

Major API

None

Prerequisites

You do not need to have the LabVIEW development system installed to use this example, but you must have the LabVIEW development system installed if you want to review the source VIs.

How to Use This Example

The sequence specifies StructOut and StructIn container local variables, which you can review on the Variables pane. When the sequence runs, TestStand copies the values in the StructOut container to the individual local variables, and then copies the values again to the StructIn container. The LabVIEW DLL handles both operations. Before you run the sequence, the StructOut container contains values, the StructIn container contains default values, the individual local variables contains default values.

Complete the following steps to use this example.

  1. Select Execute»Test UUTs to run the sequence.
  2. Enter any serial number in the UUT Information dialog box and click OK. TestStand launches a Results for Unbundle dialog box that lists values loaded from the individual local variables, which specified default values before you executed the sequence.
  3. Click OK in the Results for Unbundle dialog box. TestStand launches another Results for Unbundle dialog box that lists values loaded from the StructIn container, which specified default values before you executed the sequence.
  4. Click OK when TestStand informs you that the sequence passed.
  5. Click Stop in the UUT Information dialog box to end the execution.

You can review the two Message Popup steps in the sequence to verify that the appropriate sources are providing values. You can open LV DLL 1.vi and LV DLL 2.vi, located in the <TestStand Public>\Examples\Fundamentals\Passing Structs to Code Modules\LabVIEW DLL directory, to see how the data is being copied. The LV DLL 1.vi uses an unbundle function to separate the values from the cluster, and the LV DLL 2.vi uses a bundle function to combine individual values into a single cluster. The sequence is using LVStructTest.dll, into which LV DLL 1.vi and LV DLL 2.vi were built.

To pass a TestStand container as a struct to a DLL, you must define the container as a custom data type, and you must specify that objects of the data type can be passed as structs.

Complete the following steps to use the Types window to review the data type definition for a container.

  1. In the Sequence File window, right-click the StructIn container on the Variables pane and select View»Type Definition from the context menu to launch the Types window.
  2. Right-click the DType1 data type and select Properties from the context menu to launch the Type Properties dialog box. Because the sequence is using a DLL, you must enable C struct passing for the data type.
  3. Click the C Struct Passing tab. Notice that the Allow Objects of This Type to be Passed as Structs option is enabled. The Packing ring control specifies the 8 Byte Boundary option, which is the packing scheme the DLL uses.
  4. Click OK to close the Type Properties dialog box.
  5. In the Types window, expand the DType1 data type. You can right-click each property and select Properties from the context menu to launch the Type Properties dialog box for each property of the data type. You can review each property to see how it is configured.