NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to programmatically know if the sequence is terminating?

Solved!
Go to solution

I can determine if a sequence has failed (RunState.SequenceFailed), Errored (RunState.SequenceError.Occurred), and it is set to go to Cleanup (RunState.GotoCleanup), but I'm not sure how to determine if the sequence is terminating. Is there a boolean or another way to determine this?

 

Purpose: I believe the MainSequence Cleanup still runs even if a sequence is terminating. I'd like to have a step in the cleanup that operates only during a termination (must be within "MainSequence"). Can this be done?


Thanks!

0 Kudos
Message 1 of 5
(4,789 Views)

Look into Execution.GetStates().


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 5
(4,784 Views)
Solution
Accepted by topic author Raydur

I may have been able to get Execution.GetStates() to work, however after looking at the Exection methods I found an alternative. I was looking to use this as a precondition, so I'm not sure how to use GetStates() within the precondition (since it returns the state to another variable) without calling this in another statement prior to the one I'm interested in. I'm gussing there is a way (maybe I'm overthinking that), but the following worked for me:

 

Solution:

RunState.Execution.GetTerminationMonitorStatus(Locals.TerminationMonitor)

 

where Locals.TerminationMonitor is an Object Reference variable initialized to RunState.Execution.InitTerminationMonitor() earlier in the test (I did this in the MainSequence Setup steps).

 

Thanks again!

0 Kudos
Message 3 of 5
(4,766 Views)

The result of a compound expression is the value of the last expression so the following should work:

 

RunState.Execution.GetStates(Locals.runState, Locals.termState), (Locals.termState == ExecTermState_Terminating || Locals.termState == ExecTermState_TerminatingInteractive)

Message 5 of 5
(4,756 Views)