NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TestStand Non blocking deported interface (C#)

Solved!
Go to solution

Hi,

I wish to have a graphic interface (C#) allowing to manage TestStand (Read/Write of the variables FileGlobals, Wait/Set Notifications, ...). This interface must be active during the TestStand activity (graphic indicators of the state of the tests, allows the activation of sub-sequences, etc.), and it has to allow to use the TestStand interface (Do a break, step by step debug, watch variables, state of threads, etc....).

I start from the NI TestStand exemple "\TestStand 4.2.1\Examples\Demo\DotNet" and do some modification :

 - call the constructor of the Dialog Windows with a SequeceCall New Thread

 - Add Notification managment (unsing TSSyncLib, change the Dialog constructor and send my FileGlobals.Notifier variable create during the Notification Create step).
 - Add a Button. When pressed, a FileGlobals variable Number is read, +1, then write, and display in a label. And another button Set a Notification.

 - Add a breackpoint in the step next to the SequanceCall of the Dialog Windows

 

My problem is, as long as I do not close the windows, TestStand remains " running " and do not stop on my breakpoint, and do not respond when doing "Break All", edit Watch Variables, ...

If i change this.mDialog.ShowDialog() by this.mDialog.Show(), TestStand responds but the Dialog Windows report error with FileGlobals Read/Write and Notification.

 

Is my need workable ?

 

In attachment, the .seq file (TS4.2) with the generated dll, and the DotNet project.

 

Thanks for help ;o)

0 Kudos
Message 1 of 4
(3,205 Views)
Solution
Accepted by topic author Eagle334

You need to use Thread.ExternallySuspended (see the API help for more details) while your dialog is running. Also you should consider using Execution.InitTerminationMonitor and Execution.GetTerminiationMonitorStatus.

 

That said, from the description of what you want to do, I thought you were going to start with one of the UI examples. If you really want to write a custom user interface, that might be a better way to go.

Hope this helps,

-Doug

0 Kudos
Message 2 of 4
(3,196 Views)

Great, it works !

I add "this.mSequenceContext.Thread.ExternallySuspended = true;" and I found the features of TestStand during the Dialog Windows.

 

 

That said, from the description of what you want to do, I thought you were going to start with one of the UI examples. If you really want to write a custom user interface, that might be a better way to go.

My need is to keep the full TestStand UI (list of variable, threads, Debug, ...) and to have an interface to interact on the execution of TestStand, but also manage other programs. When reading documentation, UI seems to be good for replacing the TestStand Interface by a custom interface, not for having two interfaces. And i don't want to spend time on coding (even if that seems no so difficult) something already existing and working well.

 

Thank you very much for your (very fast) help. 🐵 

0 Kudos
Message 3 of 4
(3,190 Views)

No problem. Glad I could help.

 

I just want to make sure you are aware that you should set this.mSequenceContext.Thread.ExternallySuspended back to false before your code module returns back to teststand otherwise it could leave the thread in a bad state which can lead to subtle problems.

 

So basically, inside your code module, you should probably have something similar to the following:

 

this.mSequenceContext.Thread.ExternallySuspended = true;

try

{

     // your code

}

finally

{

     this.mSequenceContext.Thread.ExternallySuspended = false;

}

 

-Doug

0 Kudos
Message 4 of 4
(3,176 Views)