From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Enable Polling VI In New Thread While Main Sequence Runs

In the "setup group" of my main sequence I'd like to call a subsequence in a new thread which continuously polls for communication to the Unit Under Test (UUT) every 5 seconds.  In parallel, I'd like to have the main sequence to continue running steps in the "main group."

 

Test sequence handling:

1. If the new thread subsequence detects a communication error, I'd like the subsequence to tell the main sequence to stop immediately and then run the main sequence's "cleanup group."   

2. If the main sequence comes upon a step where the UUT needs to be communicated with, I'd like the main sequence to tell the new thread subsequence to stop, then have the main sequence step communicate with it, and then tell the subsequence to begin polling again.

 

What is the most efficient way to do this?  Thanks so much for everyone's help!

0 Kudos
Message 1 of 7
(3,537 Views)

I have  done this before this way

 

so you launch the subsequence on a new thread. You will communicate between threads with at notifier

 

on the new thread running parallel Do a While loop to poll data from whatever you want to validate.. if it fails you send a notifier to the main sequence and then set a flag to exit the loop 

CLAD, CTD
Message 2 of 7
(3,517 Views)

Buton,

 

Thanks for the reply.  That makes sense in creating a notification and then waiting for the notification to get set to exit.

 

What I want to do is:

1. Create a New Communcation Poll Thread

2. Continue Running Main Sequence Thread at the same time

3. If the Communcation Poll Thread Fails, I want it to notify the main sequence immediately to shutdown.  What is the best way to do this?

 

Thanks for your help.

0 Kudos
Message 3 of 7
(3,489 Views)

Are you going to be looping on the main sequene all the time?  or it will execute and exit ?

CLAD, CTD
Message 4 of 7
(3,486 Views)

Had an idea

 

what if you place a SequenceFilePostStep Callback and there you check the notification and in case it activates you jump to cleanup or RunState.Execution.Terminate() to terminate and it will force teststand to run cleanup step.

 

that way after each step is executed it will check for that flag

CLAD, CTD
Message 5 of 7
(3,483 Views)

I will not be looping in the main sequence.  Within the main sequence, I plan on starting the new thread with the polling and shutting it down in the main sequence in the cleanup section (after all the main sequence steps finish).  

 

The PostStep Call Back would be great but this polling is only specific for certain DUTs and not all DUTs to be tested.

0 Kudos
Message 6 of 7
(3,471 Views)

Hello,

 

I found this rather interesting, I've included some documentation below. Based on my research I would suggest to as mentioned, use sequence call to call a subsequence or other sequence file to run in a new thread or execution. Depending on how you would like your thread to operate, is whether to select a new thread of execution. I have included some documentation on setting this up, selecting the execution type and also on the wait settings:

 

1. http://digital.ni.com/public.nsf/allkb/FFD781C44C146B8B862574A6004E0B04

 

2. http://www.ni.com/white-paper/4823/en/

 

3. http://zone.ni.com/reference/en-XX/help/370052N-01/tsref/infotopics/db_thread_settings/

 

4. https://forums.ni.com/t5/NI-TestStand/How-to-Stop-Thread-Within-TestStand/td-p/1137385

 

The next step is how to efficiently communicate between the two, as mentioned in the thread above you can pass a parameter by reference to use in pre-expressions or use notification. I would recommend a parameter by reference, you could pass two, one is the HaltMain boolean and another is HaltThread boolean.

 

The Main will set HaltThread which the new thread can check in pre-expressions for steps and potentially move to a subsequence which will the run the synchronization step to wait on a notification from the Main sequence to return. I have included some documentation which refers to an example on the wait on notification step:

 

http://zone.ni.com/reference/en-XX/help/370052N-01/tsexamples/infotopics/sync_notif_wait/

 

Best regards,

 

Ed

Message 7 of 7
(3,353 Views)