NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

C# TestStand API - "MainSequence" execution finishes immediately when using a process model

Solved!
Go to solution

I am running the example sequence Computer Motherboard Test Sequence that comes with TestStand in a C# application using the TestStand API. I am trying to get a report out of it. If I run the MainSequence with no process model, everything seems to run okay. If I add in a process model, WaitForEndEx() returns right away and I don't see any popup from the sequence itself. I added a 5 second wait and a few message popups to the sequence and none of these appear to run. The ExecutionRunStates value shows that execution has stopped as well. My code is as follows:

 

Engine eng = new Engine();

User admin = eng.GetUser("administrator");
eng.CurrentUser = admin;

StationOptions stationOptions = eng.StationOptions;
stationOptions.DisableResults = false;
stationOptions.AllowOtherModels = true;

SequenceFile seqFile = eng.GetSequenceFileEx(seqName);
SequenceFile modFile = eng.GetSequenceFileEx("C:\\Program Files\\National Instruments\\TestStand 2017\\Components\\Models\\TestStandModels\\SequentialModel.seq");

Execution exec = eng.NewExecution(seqFile, "MainSequence", modFile, false, 0);
exec.WaitForEndEx(-1);

exec.GetStates(out ExecutionRunStates runState, out ExecutionTerminationStates termState); MessageBox.Show(runState.ToString()); MessageBox.Show(termState.ToString());
exec.Report.Save("report.xml", false, 0);
eng.ReleaseSequenceFileEx(seqFile); eng.ReleaseSequenceFileEx(modFile);

In the NewExecution() call, if I replace modFile with null, it runs as expected. If I change "MainSequence" to "Test UUTs" or "Single Pass", the code ends up stuck in WaitForEndEx(). I plan to focus on this more after I get "MainSequence" working correctly with a process model, but I figured I might as well bring it up in case anyone knows the solution to that.

0 Kudos
Message 1 of 7
(2,821 Views)

I may be wrong but it feels like you need to pass "Test UUTs" or "Single Pass" as your sequenceNameParam if you are using a model.  This is from the TestStand help:

sequenceNameParam As String

[In] Specifies the name of the sequence or Process Model entry point to execute.

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 7
(2,800 Views)

I was under the impression that I could do all three for the sequenceNameParam. If I use "Test UUTs" or "Single Pass" though, the application is forever in the WaitForEndEx(-1) call, so I must be missing something for those sequenceNameParam values as well.

0 Kudos
Message 3 of 7
(2,794 Views)

to be honest I've never really called a sequence file like this without a user interface or from an existing execution.  By user interface, I mean an executable that has an application manager. 

 

Not sure if you know this but you can pass parameters to the shipping UIs and have it run silently.  https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9lvSAC

 

Generally I do this if I need to run a sequence file dynamically.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 4 of 7
(2,786 Views)

Thanks for pointing me to that. That may be the route I need to go if I can get it working that way. Currently I'm trying to figure out how to get around the login screen and have it run silently.

0 Kudos
Message 5 of 7
(2,778 Views)

The way around the login dialog is to use a front end callback that simply sets the user to an administrator or operator. 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 6 of 7
(2,764 Views)
Solution
Accepted by topic author cjohnson963

I got it figured out. I should be using the "Single Pass" entry point and I had some non-standard results processing options set from going through the NI training on TestStand. I am now able to get the report and can use a process model.

0 Kudos
Message 7 of 7
(2,758 Views)