NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

C# .Net application - Run MainSequence using api

Solved!
Go to solution

Sequences.JPG

Hello,

 

I'm in charge of developping a software in C# .Net using TestStand API, like this example program : C:\Users\Public\Documents\National Instruments\<TestStand version>\Examples\TestStand API\Executing Sequences Using API\DotNet \.

When I call one sequence, it works.

Now, I need to execute a sequence file .seq, as it is done in the example program C:\Users\Public\Documents\National Instruments\<TestStand version>\Examples\Modifying User Interfaces\Creating a Basic User Interface\DotNet.

I need to create a button like the one called in the example (see the image above, the button is yellow-colored).

In this NI C# code, this is not the same logic as in Executing Sequences Using API.

 

  • My question is, could you explain to me how to get the same result as in Creating a Basic User Interface, but the same way Executing Sequences Using API is written ?

 

Thanks you very much !

0 Kudos
Message 1 of 9
(1,364 Views)

The button you are referring to is meant to execute the active sequence without a process model.

This is why the command connections differ from the ones when using prodess models

 

Oli_Wachno_0-1679470897829.png

 

Message 2 of 9
(1,339 Views)

All right, I thought there would be another way to do this 😞 .

Thank you for your explanation !

0 Kudos
Message 3 of 9
(1,328 Views)

Hi, brother, I've read your question.

 

       You can use three methods to complete this task:

 

       Method 1:

             Like the image and path in your example, that example actually uses the ActiveX control provided by NI to implement it. What you need to do:

                  1. Reference the required dll in C #, as shown in the following figure

1.png

                  2. Add NI controls in the COM component on the left toolbar, and then select the desired controls to place on the form

2.png

                  3. Add the corresponding event response to the control.

                 The code is similar to:

axSequenceFileViewMgr.ConnectCommand(axRunSelectedButton, CommandKinds.CommandKind_RunCurrentSequence, 0, CommandConnectionOptions.CommandConnection_NoOptions);

                 So, actually, Oli_Wachno's reply on the second floor was right, but he didn't explain it in more detail (I guess he probably thought you should have more experience)

 

      Method 2:

            Reference the basic axApplicationMgr control, and then use C# native controls for other controls. You add a button, and the code should look like this:

if (axSequenceFileViewMgr.SequenceFile != null)
{
    axSequenceFileViewMgr.GetCommand(CommandKinds.CommandKind_ExecutionEntryPoints_Set, 0).Execute(true);
}
else
{
    MessageBox.Show("You must open a sequence file before you can execute.");
}

           If you need more details, please refer to: <NI Public Folder> \ Examples \ Modifying User Interfaces \ Building a TestStand UI with Native Controls

 

        Method 3:

              Instead of using NI controls, directly instantiate the NI engine to load the sequence file and run it. At this point, your code should look similar to:

string strEntryPoint = "Test UUTs";              //"Single Pass"; //"Run MainSequence";
Sequence sequence = seqFileModel.GetSequenceByName(strEntryPoint);
Execution execution = engine.NewExecution(sequenceFile, strEntryPoint, seqFileModel, false, 0, null, null, null); 
bool Execution_Result = execution.WaitForEndEx(-1, true, null, null);
MessageBox.Show($"Execution Result: {Execution_Result}");

 

Message 4 of 9
(1,313 Views)

Hi,

 

Thank you very much ! I have not been working on TestStand software for long, so the details are very helpful indeed !

I'm working on it today, hopefully I will get it work 🙂

0 Kudos
Message 5 of 9
(1,299 Views)

Hello,

 

The second method appears most relevant for my program.

To really simplify, I tried this :

 

IsMu_0-1679507375753.png

The thing is, I have a problem on my third line, the set of SequenceFile.

IsMu_1-1679507413327.png

I tried only to create my AxSequenceFileViewMgr in the C# button click method, in order not to touch to the rest of the program, but perhaps I should have initialized it in the form as in the NI example program Building a TestStand UI with Native Controls ?

0 Kudos
Message 6 of 9
(1,285 Views)
Solution
Accepted by IsMu

oh,Let me give you a simple example of how this works, this is what I call method 2.

Message 7 of 9
(1,261 Views)

Thanks, this is great !

Starting from your program "method 2", how would you "hide" the path to the file ? I need it to be hidden from the user...is is possible to give the path in the C# code, directly ?

0 Kudos
Message 8 of 9
(1,246 Views)

Thank you VERY MUCH for your help, I managed to make things work 🙂 !

0 Kudos
Message 9 of 9
(1,240 Views)