03-21-2023 10:33 AM
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.
Thanks you very much !
Solved! Go to Solution.
03-22-2023 02:41 AM
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
03-22-2023 03:27 AM
All right, I thought there would be another way to do this 😞 .
Thank you for your explanation !
03-22-2023 07:00 AM
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
2. Add NI controls in the COM component on the left toolbar, and then select the desired controls to place on the form
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}");
03-22-2023 08:17 AM
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 🙂
03-22-2023 12:52 PM
Hello,
The second method appears most relevant for my program.
To really simplify, I tried this :
The thing is, I have a problem on my third line, the set of SequenceFile.
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 ?
03-22-2023 11:31 PM
oh,Let me give you a simple example of how this works, this is what I call method 2.
03-23-2023 04:51 AM
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 ?
03-23-2023 05:46 AM - edited 03-23-2023 05:47 AM
Thank you VERY MUCH for your help, I managed to make things work 🙂 !