NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Obtain a Reference to the Sequence Context with a Lifetime of the Execution?

Is it possible to pass a SequenceContext (or Execution ref) to a LabVIEW VI that has a lifetime of the Execution and not just the step?  It seems the sequence context reference is closed automatically when the LabVIEW step VI goes idle.

 

I have a class that is created in the Setup section of the sequence and I bundle in the SequenceContext as part of the private data.  As soon as this step is completed, the SequenceContext reference becomes invalid.  I am trying to encapsulate everything related to the LabVIEW class inside of a TestStand variable.  I would like to pass only the LabVIEW class (instead of the LabVIEW class AND the SequenceContext) for each call.

CLA, CTA
Message 1 of 10
(4,508 Views)

Hi,

 

What do you mean by when the LabVIEW step VI goes idle? Does it not finish its execution? Are you getting an error that has to do with the SequenceContext reference becoming invalid? How are you currently encapsulating everything related to LabVIEW in TestStand?

Rohama K.
0 Kudos
Message 2 of 10
(4,488 Views)

What do you mean by when the LabVIEW step VI goes idle?  Does it not finish its execution?


The SequenceContext becomes invalid when the TestStand step is complete.  The VI properly finishes it's execution.  Sorry for the confusion.

 


 Are you getting an error that has to do with the SequenceContext reference becoming invalid?


I am essentialy storing the SequenceContext in a TestStand variable (LabVIEW class) and using it later in other steps.  The SequenceContext only seems to be valid for the step it was passed to the LabVIEW VI.  If I try to use the SequenceContext in a subsequent step, it comes back as invalid.

 


How are you currently encapsulating everything related to LabVIEW in TestStand?


I am not encapsulating everything related to LabVIEW.  I am launching a state machine that runs in parallel during one or more TestStand steps  I store the send queue, receive queue, and Sequence Context in a LabVIEW class located in a TestStand variable.
CLA, CTA
0 Kudos
Message 3 of 10
(4,480 Views)

Are you trying to use the Sequence Context for a subsequence or the Main Sequence? Posting an example of where you are running into problems will be helpful. The Sequence Context should be valid for the execution of the Sequence. 

Rohama K.
0 Kudos
Message 4 of 10
(4,462 Views)

Rohama,

 

Please see the attached zip.  There are two use cases in this example:

 

1. Launch a parallel VI from the class that uses the SequenceContext for the Termination Monitor

2. Execute a method that takes a while and uses the Termination Monitor

 

Please let me know if this issue could be better resolved via a support request.

CLA, CTA
0 Kudos
Message 5 of 10
(4,454 Views)

The first thing you need to have connect the sequence context to the Variant input of a Variant to Data VI and then bundle it when you create the class. Connect a Sequence Context Constant to theType input of Variant to Data. If you do that and try to run the the second case, you should not have any problems. 

 

snippet.png

 

As for trying to run a VI asynchronously, you should use the LabVIEW utility step "Run VI Asynchronously" in TestStand to run a VI asynchronously.

Rohama K.
Message 6 of 10
(4,420 Views)

Hi Rohama,

 

Thanks for the solution.

 

I was worried and wondering about this behaviour.

 

But I am curious to know the difference between the two. That means, with variant to data and without.

 

Best Regards,

Mirash

Coding is a combination of intelligent and creative work - someone
0 Kudos
Message 7 of 10
(4,383 Views)

This Developer Zone article will give you more insight on what is the difference between the two. The main reason is that the Sequence Context is an ActiveX reference. This KnowledgeBase will also be helpful in understanding why you have to use Variant to Data VI in LabVIEW when working with TestStand references.

Hope that helps!

Rohama K.
0 Kudos
Message 8 of 10
(4,358 Views)

Rohama,

 

Can you elaborate on why the Variant To Data function is required if the input terminal of the Create.vi is already a TS.SequenceContext reference?  It appears something is going on behind the scenes (garbage collection) to maintain the reference lifetime when the Variant To Data function is used.

 

Thanks for the information.

CLA, CTA
0 Kudos
Message 9 of 10
(4,354 Views)

There is come garbage collecting going on in the background. When you pass in a sequence context into a VI, it is a refnum and is lost when the VI exits. By using the Variant to Data VI, it doesn't get thrown away.

Hope that helps.

Rohama K.
Message 10 of 10
(4,318 Views)