NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Running a sequence in the background/asynchronously

Solved!
Go to solution

Hello,

 

I am working on a TestStand program that collects data from the DLL generated by a LabWindows/CVI workspace. Is there a way to run a sequence file in the background of the MainSequence running on TestStand? Essentially this sequence file would be monitoring a variable that is in the LabWindows/CVI based on a timer. It would check if that certain variable has been populated every 1 or 2 minutes. And if the variable is populated then the background thread should be able to log it in the test report that TestStand generates which the MainSequence uses to log results as well. Is that possible to do?

 

Thanks,

Shreya

0 Kudos
Message 1 of 8
(2,070 Views)

Yes, you can do a Sequence Call and configure it to run asynchronously (New thread or New execution)

santo_13_0-1660062424573.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 8
(2,066 Views)

Santosh,

 

Thank you for your response. One more question, the sequence that I am running as a new thread, has an output that I want to report in the test report. The test report is generated in the "MainSequence". Will the output from the new thread automatically be logged in the TestStand test report that the "MainSequence" also uses or are there additional steps I have add to have the thread do that?

 

Thanks,

Shreya

0 Kudos
Message 3 of 8
(2,020 Views)
Solution
Accepted by topic author shreyapatel

Hello Shreya,

 

generally results are only added to the ResultList and thereafter to the test report after completion of steps in the MainSequence. 

This means for normal sequence calls, that after the subsequence finished, the sequence call completes and adds an entry to the result list containing all report information from the subsequence.

 

However for asynchronous sequence calls, the sequence call step finishes immediately to allow for your MainSequence to continue while the asynchronous sequence is running. Therefore it cannot add any result information from the subsequence to the report.

 

You need to synchronize your MainSequence with the completion of the subsequence in order to add it's results to the test report.

The way to do that is to use a Wait (for Thread) step in the main sequence, which waits for completion of the subsequence. The results of the subsequence will appear as result information below the Wait step in your test report.

 

Hope that helps.

Stefan

0 Kudos
Message 4 of 8
(2,005 Views)

Hello,

 

So I added the Wait (for thread) step right before my software saves the test report and converts it to PDF, but I am still unable to see the result for that step logged into the PDF file. The thread with for the sequence executes properly. Is there another step I need to add after the Wait (for thread) call?

 

The sequence call for the new thread basically runs a Numeric Limit Test and I want to log the results whenever the limit fails. Is the fact that I'm only trying to log the failed limit causing some sort of issue? I will attach a screenshot of the way I have added the Wait (for thread) step in my MainSequence.

 

Capture.JPG

 

Thanks,

Shreya

0 Kudos
Message 5 of 8
(1,985 Views)
Normally the Wait (for Thread) step should be sufficient to add the results of the subsequence to the report. The only other blocking point I can think of is the result recording. Please make sure the result recording is enabled for both the subsequence and the Wait (for Thread) step. For debugging you can do the following: 1. Set a breakpoint at the end of your subsequence. There check your Locals.ResultList array. It should contain an entry for each step of your subsequence including your NumericLimitTest with result. 2. Set a breakpoint after your Wait (for Thread) step and check the Locals.ResultList array again. It will now contain an entry for each step of your calling sequence. The last element should be your Wait (for Thread) step. If you dig into that container, you should find ...TS.SequenceCall.ResultList. This should be the same ResultList array from step 1 including the NumericLimitTest with result. If you cannot see the expected results for one of the two steps, most likely something with your result recording configurations is wrong. Stefan
0 Kudos
Message 6 of 8
(1,960 Views)

I was able to get the Wait (For Thread) option to work. My async sequence call was running in a while loop until the condition was satisfied. The issue was that the exit condition was not able to update to end the while loop, so the thread was not able to end. Since, the thread wasn't ending the Wait (For Thread) step was failing and timing out. Once I resolved the ending of the while loop, the sequence was able to exit and the Wait (For Thread) step was able to capture the results. Thank you so much for your help!

 

Thanks,

Shreya

0 Kudos
Message 7 of 8
(1,951 Views)
Glad to help. Don't forget to mark solutions to pass on help for fellow forum users. Stefan
0 Kudos
Message 8 of 8
(1,938 Views)