08-28-2018 07:29 AM
I have attached an example where there are one subsequence that runs in a new thread in parallel with 3 other sequences that runs sequentially.
Is it possible to stop Seq1 and still log the results that it has sofar if seq2 or seq3 fails?
Solved! Go to Solution.
12-13-2018 04:24 PM
Hi PR_Kim,
There are a couple ways you can go about this:
1) You can create a boolean ("StopSequence") in Sequence1 and a corresponding "StopSequence1" boolean local variable in your main. This will then expose a boolean input to the sequence call in the sequence call module tab
Since this boolean is passed by reference, you can set it in the Main and have the value affect your local variable in Sequence1.
Then, you make a post-expression for Sequence2 and 3. Something like:
Step.Result.Status == "Failed"?Locals.StopSequence1 = True: Nothing
This works well if your Sequence1 is a loop because you can make this boolean the run condition for the loop. If you have a sequential sequence like the one you sent, you can make that boolean a precondition of every step so if it gets set, those steps won't execute or you could use a pre-expression that checks that boolean and uses GOTO to jump to the end of the sequence if it's set.
2) If you call this sequence in another execution instead of another thread, you get termination control (You can see here in the TestStand API poster that threads don't have this method - this poster is the best, by the way if you're not familiar). When you call the sequence, you can use the Sequence Call Advanced Settings (button has a wrench crossing a hammer on it and is at the right of the module tab when you have the sequence call selected) to store back a reference to the execution object (you just create a local variable of type object instance and input that here). Then, you can call Terminate on the object to stop it. So, this would change the expression above to:
Step.Result.Status == "Failed"?ExecutionObject.Terminate(): Nothing
The one caveat here is I'm not sure what affect this will have on result collection - I think you would need to have on-the-fly reporting enabled to get everything up to the termination and/or you may need to jump to the cleanup section of Sequence1 and have a wait call in there to synchronize with the controlling thread to enable the result collection.
Unfortunately, I can't test this at the moment, so there may be gotchas I'm overlooking.
04-24-2020 04:38 AM
Thanks DJ
I forgot to give you Kudos
04-07-2021 06:43 AM
I have updated to your mention it,but I think that have some wrong with this code somewhere if I configure mistake,please highlight it,thanks!!