NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Create Run VI Asynchronously Step using the API

Solved!
Go to solution

I am looking to create a "Run VI Asynchronously Step" using the TestStand API in LabVIEW.

 

Upon browsing the step details and object properties, it seems this is a "special" step type that is actually a SequenceCall.  However, I do not see how to access the data contained within this step type.  I have attached my current VI used to "browse" the associated data for reference.

 

Please advise on how to create this step.

 

Thanks

CLA, CTA
0 Kudos
Message 1 of 11
(4,606 Views)

Hi LVB,

 

The more robust and recomended way to run a code module asynchronously is through creating a new sequence that contains that code module and then use a sequence call step and select to run it in a new thread.  This should have less restrictions than the "special" step type.  Let us know if you run into issues implementing this programmatically.

 

Ryan T
National Instruments
Applications Engineer
0 Kudos
Message 2 of 11
(4,572 Views)

Ryan,

 

Thanks for the reply.  During the creation of this step type, I ran into a slightly off-topic issue.  It seems that the API does not throw an error when a duplicate SubSequence is created.  Please see the attached VI.  This VI will create two SubSequences with the same name (which should not be possible).  If I attempt to do this within the TestStand Sequence Editor, I get an error.

 

I realize that it would be best to check for an existing SubSequence via the SequenceNameExists method of the SequenceFile object.  However, it seems there should be an error thrown from the API. Is there a way to obtain an error when a duplicate sequence is created using the API?

 

Thanks

Message Edited by LVB on 05-27-2010 12:52 PM
CLA, CTA
0 Kudos
Message 3 of 11
(4,554 Views)

Yeah, look what happens when the Sequence File is loaded into the SeqEditor

 

The second DupSequence has no Groups.

 

DupSequence.PNG

 

 

 

Bit of a mess.

 

Regards

Ray

Regards
Ray Farmer
0 Kudos
Message 4 of 11
(4,547 Views)

Ryan T wrote:

Hi LVB,

 

The more robust and recomended way to run a code module asynchronously is through creating a new sequence that contains that code module and then use a sequence call step and select to run it in a new thread.  This should have less restrictions than the "special" step type.  Let us know if you run into issues implementing this programmatically.

 


 

Ryan,

 

I have run into an issue creating the SubSequence call.  What is the proper method for adding a SubSequence Call with the "Use Prototype of Sequence" enabled?

 

No parameters are created if I use the Module.LoadPrototype method.

Parameters are created if I use the SequenceCallModule.PrototypeFromSequence, but this returns an error when I do not disable UseSequenceParameterPrototype:

 

 

Error -17300 occurred at SequenceCallModule.LoadParametersFromSequence cannot load parameters from a sequence. Please set SequenceCallModule.UseSequenceParameterPrototype equal to False first. in Load SequenceCall Prototype.vi->Create TS Sequence File (Single Async Step).vi

This error code is undefined. No one has provided a description for this code, or you might have wired a number that is not an error code to the error code input.

 

 

 

Message Edited by LVB on 05-28-2010 01:52 PM
CLA, CTA
0 Kudos
Message 5 of 11
(4,523 Views)

Hi LVB,

 

You will want to either set the UseSequenceParameterPrototype to true or use the LoadPrototypeFromSequence, but not both.  In fact it will not allow you to use both:

 

LoadPrototypeFromSequence Method

Syntax

SequenceCallModule.LoadPrototypeFromSequence ( sequence, options)

Return Value

Boolean

Returns whether the step was modified.

Purpose

Sets the prototype of the module to the prototype specified by a sequence.

Remarks

Use this method to set the parameters of the SequenceCallModule when the UseSequenceParameterPrototype property is False or if the SpecifyByExpression property is True.

Parameters

sequence As Sequence

[In] Specifies the sequence with the prototype to use.

options As Long

[In] Pass one or more LoadPrototypeOptions constants. Use the bitwise-OR operator to specify multiple flags.

 

 

If you look in the TestStand Sequence Editor we can explore the difference between the two methods.  Place a SequenceCall Step into a sequence.  In the Module tab for this step you will see a check box for "Use Prototype of Sequence". If it is checked (True) then you can not use the button with an arrow directly to the right (this is the LoadPrototypeFromSequence method).  If the box is not checked, you can select the button with an arrow on it.  I would try both of these options out in the TestStand Sequence Editor to see the functionality of each in order to see which one you want to use. 

Message Edited by Ryan T on 06-01-2010 05:06 PM
Ryan T
National Instruments
Applications Engineer
0 Kudos
Message 6 of 11
(4,456 Views)

Ryan,

 

Thank you for the response.  I am aware the LoadPrototypeFromSequence Method will not allow UseSequenceParameterPrototype to be true.

 

What is the proper method for adding a SubSequence Call with the "Use Prototype of Sequence" enabled?  No parameters are created if I use the Module.LoadPrototype method.

 

Error -17500 occurred at Operation Failed. in SequenceCall Load Prototype.vi->Create TS Sequence File (Single Ramp Step).vi

This error code is undefined. No one has provided a description for this code, or you might have wired a number that is not an error code to the error code input.

 

 

 

CLA, CTA
0 Kudos
Message 7 of 11
(4,435 Views)

Hi LVB,

 

Using the LoadPrototypeFromSequence method was the correct method to use.  Are you still using this method or are you now using the Module.LoadPrototype?  Also, what are you using as the sequence reference that you are passing into the LoadPrototypeFromSequence method? Is it located in the same sequence file?

 

Ryan T
National Instruments
Applications Engineer
0 Kudos
Message 8 of 11
(4,404 Views)

Ryan,

 

My use case is to wrap a LabVIEW VI in a New Thread SubSequence as originally stated.  Thus, I create a SubSequence with parameters that map to the LabVIEW VI.  I need to be able to create this through the TestStand API and I would like to create the SubSequence Call with the "Use Prototype of Sequence" enabled/checked.

 

 

LoadPrototypeFromSequence method
Using the LoadPrototypeFromSequence method, I can create and load parameters a SubSequence call with no errors.  However, the SubSequence call does not have the "Use Prototype of Sequence" checkbox enabled.  From the documentation and our previous discussions, this method should not be used when SequenceCallModule.UseSequenceParameterPrototype is True.

 

 

Module.LoadPrototype

Looking at the API documentation, it seems the Module.LoadPrototype should be used when SequenceCallModule.UseSequenceParameterPrototype is True.

Purpose
This property affects the behavior of the Module.LoadPrototype method. When this property is True, Module.LoadPrototype loads the module's parameters from the sequence specified by the SequenceCallModule.UseCurrentFile, SequenceCallModule.SequenceFilePath, and SequenceCallModule.SequenceName properties

  • I cannot load parameters from a SubSequence call using this method.

 




Ryan T wrote: 

Using the LoadPrototypeFromSequence method was the correct method to use.


  • Are you sure the LoadPrototypeFromSequence method is correct to use with SequenceCallModule.UseSequenceParameterPrototype = True?  This conflicts with our conversation to date.

 

 

 


Ryan T wrote: 

Are you still using this method or are you now using the Module.LoadPrototype?


I started to explore Module.LoadPrototype because it seemed like the proper method when SequenceCallModule.UseSequenceParameterPrototype = True.  I can load parameters from a SubSequence using the LoadPrototypeFromSequence method, but the  SequenceCallModule.UseSequenceParameterPrototype must be False.  I would like to create a SubSequence Call with the "Use Prototype of Sequence" enabled when I open the sequence file in TestStand.

  • What method is called in the TestStand Sequence editor when "Use Prototype of Sequence" is checked (and Load Prototype is greyed)?

 




Ryan T wrote: 

Also, what are you using as the sequence reference that you are passing into the LoadPrototypeFromSequence method? Is it located in the same sequence file?


The sequence reference is created from the IEngine.NewSequence method.  I also insert into the current SequenceFile.

 

 

 


Ryan T wrote: 

 

If you look in the TestStand Sequence Editor we can explore the difference between the two methods.  Place a SequenceCall Step into a sequence.  In the Module tab for this step you will see a check box for "Use Prototype of Sequence". If it is checked (True) then you can not use the button with an arrow directly to the right (this is the LoadPrototypeFromSequence method).  If the box is not checked, you can select the button with an arrow on it.  I would try both of these options out in the TestStand Sequence Editor to see the functionality of each in order to see which one you want to use.


I would like to use the same method that the TestStand editor is when the "Use Prototype of Sequence" box is checked.  I have not identified what method this is (my assumption is the Module.LoadPrototype).

 

  • What is the proper method for adding a SubSequence Call with the "Use Prototype of Sequence" enabled?
    No parameters are created if I use the Module.LoadPrototype method and SequenceCallModule.UseSequenceParameterPrototype must be False when calling the LoadPrototypeFromSequence method.

 

  • If you give me your e-mail, I will send my current VIs used.


Thanks for the assistance
 

CLA, CTA
0 Kudos
Message 9 of 11
(4,384 Views)
Solution
Accepted by LVB

Hi LVB,

 

I appologize, I did not realize that you still wanted to use the "Use Prototype of Sequence" checkbox option.  In that case the attached code should demonstrate how this can be accomplished.

 

Thanks

 

 

 

Ryan T
National Instruments
Applications Engineer
Download All
0 Kudos
Message 10 of 11
(4,310 Views)