NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

exchange data between C# application and Test Stand by using Test Stand API

Solved!
Go to solution

Hello,

 

from C# application, I have to use test stand API to:

1- load File sequence created with the test stand editor

2- execute sequence by passing parameters

3- get sequence results data

 

I found how

-  loading a sequenceFile with Engine.GetSequenceFileEx() methode

-  how executing the sequence with Engine.NewExecution() methode but I don't know how passing parameters to the sequence with Engine.NewExecution() methode?

- how to get back locals and parameter variables of the sequence but it seems that variables are re-initialized at the end of the sequence ?

 

could you help me please.

 

0 Kudos
Message 1 of 9
(7,606 Views)

Hi,

 

 You have to pass the arguments to the sequence through sequenceArgsParam which is one of the arguments to the method Engine.NewExecution . You will have to create a property object that will contain the sequences parameters and pass it to sequenceArgsParam.

 

To get back the locals and fileglobals in the sequence you will have to access the sequence file through the execution reference and not through the engine. Because only the execution contains the modified objects of the locals & fileglobals. My guess is Execution.ClientFile should contain the modified values.

 

Thanks 

0 Kudos
Message 2 of 9
(7,594 Views)
Solution
Accepted by topic author seblp

Make sure sure argument list is in the same order as that defined in your Sequence.

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 3 of 9
(7,592 Views)

Hi

 

first of all, thank you for you quick response. I am gonna try this solution, indeed my problem was that I didn't use Execution object to get parameters so I could not see variables changed. In other hand I could see that exexution was still running..

 

Moreover, I would like to know how create an interactive sequence with the client C# application. Is it mandatory to use UI messages to communicate between the sequence process and the C# client application ?

 

1- if yes, when i create my sequence with the TS editor, how I can send message to the application and what is th way to synchronize sequence process and client application ?

2- if not, which are the other possibilities ?

 

for exemple: below there is a scenario of what I need to do.

 

sequence:

1- action step: call C-function of a dll. (I know to do that)=> result: 2 returns parameters, one array of unsigend char and and char.

2- action step: signal the C# application Client that theses 2 parameters are ready to be read.

3- break step: until the the C# client has read these data

transition: the C# application Client read theses parameters

4- sequence has be signaled that client has read data and continue to execute next steps....

 

thank a lot.

 

best regards.

 

sebastien

0 Kudos
Message 4 of 9
(7,575 Views)

Hi,

 

Take a look to this Thread:

http://forums.ni.com/ni/board/message?board.id=330&message.id=17663&query.id=281482#M17663

It shows a small Dialog Example

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 5 of 9
(7,566 Views)

Hi,

 

Moreover, I would be interested to know how dynamically transfer data from sequence file to the C# client application during sequence execution?

Is UImessage class is the response to my query ?

 

regards

 

sebastien

0 Kudos
Message 6 of 9
(7,541 Views)

Hi,

 

Ui Messages are designed to communicate between the OperatorInterface and TS Executions,

So if your client C# is a OperatorInterface Ui Messages are the recommend way.

 

If not you might get some trouble

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 7 of 9
(7,526 Views)

As Juergen stated, UIMessages are the preferred way if you are writing a UI. Another way is using the TestStand synchronization step types and API (See Engine.GetSyncManager() in the API help for the API for accessing TestStand synchronization primitives). Both the TestStand synchronization step types and the sync manager API use the same underlying code so they can be used together (basically the step types use the sync manager API). Queues and Notifications can both be used for passing data (i.e. messages) synchronously between threads.

 

Hope this helps,

-Doug

0 Kudos
Message 8 of 9
(7,521 Views)

Sebastien,

 

I'd also like to point out that TestStand has an architecture for result collection that is likely something you should be using rather than trying to do something similar from scratch. After each step in TestStand executes, it's results are added to a special local variable called ResultList.  Once the execution is done running you can get the results from the Execution.ResultObject property using the TestStand PropertyObject API. See the API help for more information. If you want the results after each step rather than all at once at the end you can add a SequenceFilePostResultListEntry callback to your sequence files instead and inside of that sequence pass the result back to your UI using UImessages or you can even just call whatever code you want to call to do the processing directly.

 

Also if what you are really trying to do is just show the status of the execution while it's running you should be using the Trace UIMessage instead. The Trace UIMessage is sent to the UI between the execution of each step, while the UI is handling the message (i.e. before the UI calls Acknowledge on the message) the execution is in a suspected state so you can use the TestStand API to examine whatever data you wish to display.

 

Hope this helps,

-Doug

0 Kudos
Message 9 of 9
(7,518 Views)