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.
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?
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.
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.
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.
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.
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.
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.
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!
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.
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.