Example Code

Creating a Sequence File with a LabVIEW Module Step Using the TestStand API

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW
  • Teststand

Code and Documents

Attachment

Description

Overview

This example demonstrates how to use the TestStand API to create a new sequence file, add an action step which calls a LabVIEW code module, and configure the parameters for the step.   

 

Description

This example Completes the following tasks using the TestStand API:

  1. Create an instance of the TestStand engine.
    • Create the engine object using the Automation Open node. 
    • Call Engine.LoadTypePaletteEx() to load any custom types.

      1.png
  2. Create a new sequence file using Engine.NewSequenceFile().
  3. Create two FileGlobal variables which will be used to store the output data from the VI.
    • Access the FileGlobals for the sequence files using SequenceFile.FileGlobalsDefaultValues().
    • Use the "SetVal" PropertyObject methods, such as PropertyObject.SetValString(), to create the fileGlobals.  The option of InsertIfMissing (1) is used to create the properties.
    • Call SequenceFile.IncrementChangeCount() to indicate that the file has been modified.

      2.png

  4. Create a new LabVIEW step.
    • Create the step using the Engine.NewStep() method.
    • Access the LabVIEW specific module properties by type casting the Module Object (Step.Module property) to the LabVIEWModule class, using the Variant to Data node.  
    • Set the LabVIEWModule.VIPath property to the desired VI.
    • Call LabVIEWModule.ReloadPrototype() to load the module parameters from the VI.
    • To set the parameters, access the LabVIEWModule.LabVIEWParameters collection, which contains an item for each parameter in the VI.
    • Set the ValueExpr property for each parameter to the desired property.  In this example, the FileGlobals are used here.

      3.png

  5. Add the step to the mainSequence of the new sequence file.
    • Access the MainSequence using the SequenceFile.GetSequenceByName() method.
    • Call Sequence.InsertStep() to add the new step to the sequence.
  6. Save the sequence file using SequenceFile.Save().
  7. Release the sequence file using Engine.ReleaseSequenceFileEx(), and close all references.  Note that this is called even if an error occurred.

 

Hardware and Software Requirements

Create Sequence File With LabVIEW Step Using API - TS2019.zip

TestStand 2019 or Compatible

LabVIEW 2020 or Compatible

 

Create Sequence File With LabVIEW Step Using API - TS2016.zip

TestStand 2016 or Compatible

LabVIEW 2016 or Compatible

 

Steps to Implement or Execute Code

  1. Extract the attached file, then open the Top Level - CreateSequenceFile.vi.
  2. Specify a path for the sequence file in the New Sequence File Path control.
  3. In the VI Path control, browse to the module.vi included in the example in the Test Module folder.
  4. Run the VI.
  5. In the sequence editor, browse to the path you specified in step 1.  Verify that a sequence file is present, and it contains a single action step.

Additional Information or References

The following TestStand shipping examples provide additional applications of the TestStand API.

Al B.
Staff Software Engineer - TestStand
CTA/CLD

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
anjalihari
Member
Member
on

Hello,
I have been using this example to create sequence file from labview by taking testcases from an excel sheet, but the thing is, as it says it contains a single action step, all my sequences are overwritten in a single step. How can I modify it include multiple steps?