NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent multiple sequence executions at a test station

Solved!
Go to solution

I'm trying to prevent multiple instances of a sequence from running in parallel on a test station (across both Sequence Editor and the Operator Interface Simple UI).  I've found a suggestion from other posts (Getting all Executions in Sequence Editor ) to access 'Executions' from Engine.GetInternalOption(InternalOption_ApplicationManager).  I'm able to insert the code below into a ProcessSetup callback to get the number of Executions within ApplicationManager, and then terminate if NumIncomplete > 1.  This seems to work to prevent multiple executions within Sequence Editor or the Operator Interface UI.  However, executions within TestStand Simple UI Operator Interface are counted separately from executions within TestStand Sequence Editor.  I believe this is because there are two separate TestStand Engine objects used by the Operator Interface and Sequence Editor.

mikep395_0-1761771095763.png

I'm considering writing ThisContext.RunState.Engine.UniqueEngineID to a StationGlobal, and preventing a new run from starting if StationGlobal.UniqueEngineID != (ThisContext.RunState.Engine.UniqueEngineID OR <empty string>).  I could set StationGlobal.UniqueEngineID back to an empty string within a ProcessCleanup callback however I see this leading to issues if/when a test sequence get Aborted and doesn't execute all cleanup steps to set StationGlobal.UniqueEngineID back to an empty string.

 

Are there any better suggestions on how to prevent multiple executions across ALL Engines?

0 Kudos
Message 1 of 4
(112 Views)
Solution
Accepted by mikep395

If we can assume, that the first execution is always the right one, you could use a lock step during Process Setup: if the second one finds the lock taken, it terminates...

 

 

Message 2 of 4
(104 Views)

Using a Lock works great, I just needed to also remember that if you name a lock with an * as the first character then it can be shared across engines.

Message 3 of 4
(65 Views)

Full disclosure: I tested Nigel, it came up with the idea of using locks.

Message 4 of 4
(12 Views)