From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

TestStand User Interface using C#

I am trying to modify the C# simple user interface which came with TestStand 2014.  I want to run a sub-sequence and retrieve the results from the parameters.  I can load parameters into the sequence prior to running it and I can run it, but I cannot figure out how to retrieve the parameter data after the sequence is run.

 

Here is my code:

this.axSequenceFileViewMgr.Sequence = this.axSequenceFileViewMgr.SequenceFile.GetSequenceByName("zzTestSeq");

this.axSequenceFileViewMgr.Sequence.AsPropertyObject().SetValNumber("Parameters.SetPoint", 0, 149.0);

Execution ex = this.axSequenceFileViewMgr.Run();

val = this.axSequenceFileViewMgr.Sequence.Parameters.GetValNumber("SetPoint", 0);

The TestStand sub-sequence zzTestSeq takes the SetPoint value and calculates a new value 321 which it returns in the same SetPoint variable.

The last line above, after the run command, only returns the original SetPoint value, 149, not the modified one.

How do I access the parameters, in this case the SetPoint AFTER the sequence runs with the updated values?


Thanks,

Robert

 

0 Kudos
Message 1 of 10
(4,949 Views)

Hey RobertSalo,

 

I believe that the main issue is is that there might be a breakdown in how we are passing data back.

 

I think moving forward our best bet is to set up some breakpoints in our sequence file and check the parameters pre, during, and post execution. I have a hunch that the parameters might be going back to a default value after execution. You could do this by just running the seqence file in the sequence editior and setting breakpoints.

 

What might you might want to do if you need to get data during execution is to use UI messages.

 

Getting Data from the User Interface During Sequence Execution - http://www.ni.com/example/27606/en/

 

Using TestStand User Interface Messages (UI Messages) - http://www.ni.com/tutorial/4532/en/

 

Hope that helps!

 

JY
Application Engineer, RF and Communications
National Instruments
0 Kudos
Message 2 of 10
(4,897 Views)

It seems that programmatically we can only get the 'initial' values of ANY variable.  I had hoped that I could pass data into and out of a sequence using the StationGlobals, but again, I only get the value set prior to execution.  There should be a way to get access to the variables at the end of execution?

I tried getting results data from the execution object but could not.

Execution ex = this.axSequenceFileViewMgr.Run();

PropertyObject exPO = ex.AsPropertyObject();

exPO when viewed from the DisplayBrowsePropertyObjectDialog shows 66 entries in the Result.ResultList which matchs the number of items in the sequence file.

When I try to access any of these ResultList entries, the number goes to 0 (empty)

PropertyObject result = exPO.GetPropertyObject("Result.ResultList", 0);  is null

I 'should' be able to get data from a sequence through the results variables shouldn't I?  How can I do that?

Thanks,

Robert

0 Kudos
Message 3 of 10
(4,890 Views)

Hello RobertSalo,

 

What were the results of trying to send data back through a UI Message?

 

Moving forward if that isn't excatly what you are looking for we could also try leveraging event callbacks.

 

I think this would be helpful since I know they specifically happen during runtime. How you would implment them is by overiding the callback function that suits your application best (probably a callback that happens after your calculation of the setpoint but before ending the execution of the sequence).

 

In the overriding call you can get event data in one of the arguments of the callback.

 

For more information check out this walkthrough of the simple user interface below.

 

Working with the TestStand Simple User Interface - C#.NET - http://www.ni.com/product-documentation/52369/en/

JY
Application Engineer, RF and Communications
National Instruments
0 Kudos
Message 4 of 10
(4,872 Views)

Yes, using UIMessages works, but that requires me to modify the sequence files.  I am thinking of sub-sequences as functions, where you pass parameters into and outof.  I can pass parameters into the function, call the function, but I can not get the return parameters when the function exits.  This obviously works within TestStand when sequences call each other. 

One thing I was able to do was programmatically place a 'break point' at the end of the sequence and trap the OnBreak event.  Using this I was able to get to the FileGlobals, but again, cannot get to the parameter list.  I think I am missing some combination of variables which would return the Parameters object from which I can extract the parameters I am interested in.  The strange thing is there is a command

PropertyObject exParaPO = this.axExecutionViewMgr.SequenceContext.Parameters;

which you would think would be exactly what I am looking for, but everytime I call this, it throws an error stating "the execution must be paused".  It throws this same error when I am sitting at the break point I described above.  Any idea of what it is looking for?  How do I 'pause' execution any more than a break point?

 

0 Kudos
Message 5 of 10
(4,855 Views)

Hello RobertSalo,

 

I'm glad to hear that UIMessages do work. Moving forward there is going to be a difference when running the passing data from TestStand memory to UI memory rather than passing data from TestStand memory to TestStand Memory as you mentioned.

 

In order to better understand possible solutions, could you help me understand why modifying the sequence file and posting the data through a UIMessage isn't what you need for you application?

 

The UIMessage implementation is the recommended way to accomplish passing data from the sequence to the UI so I'm wondering what specific functionality is necessary for your application.

JY
Application Engineer, RF and Communications
National Instruments
0 Kudos
Message 6 of 10
(4,848 Views)

My efforts are 2 fold.  First I am creating a 'debug' tab in the simple user interface from which I can run specific sub-sequences for debugging / troubleshooting issues with the unit and/or station.  Second I am thinking of how best to be able to run 'unit' tests on sub-sequences.  I know there are tools for LabVIEW VIs but I have not found nor heard of anything that could be used for sequences in TestStand.  My idea is that I don't want to modify the sequences that run the automated tests in order to either run in debug mode or to run unit test on them.  For example we don't have to 'modify' LabVIEW VIs in order to run unit tests on them, they have defined input / output variables.  Why can we not do the same with sequences in TestStand?  Any modification to support debug / unit testing is a source of potential error.

0 Kudos
Message 7 of 10
(4,839 Views)

Hello Robert,

 

Thanks for letting me know some background information on your application. From that I talked to some colleagues and looked further into some options.

 

Firstly, possible to save some time in implementing debug features, have you looked at the full-featured operator interfaces in the TestStand Public directory? This might be useful because it has some of these debugging features in it already.

 

"C:\Users\Public\Documents\National Instruments\TestStand 2016 (32-bit)\UserInterfaces\Full-Featured\VB.Net"

 

As for the unit test functionality, there isn't anything purposed built like we have in LabVIEW. Although this is the case you can still pursue that independently as you already are doing.

 

As for your original question about trying to load different parameters and read from them after execution, you may have a few options depending on what kind of variable "setpoint" is. Could you let me know if it is a limit? Are you using a property file?

JY
Application Engineer, RF and Communications
National Instruments
0 Kudos
Message 8 of 10
(4,821 Views)

I took a look at the 'full' UI and it did give me an idea.  There is the 'ExecutionVariables' which shows all the 'active' varialble.  The 'SetPoint' variable I am interested in is the one/only number parameter.  I added the ExecutionVariablesView to my UI and ran the sequence with a break point at the last line of the sequence.  Now I can SEE the parameter SetPoint, with the correct value, but I cannot get that parameter value back into my code.  Can you help describe how I might be able to read a variable, Parameter.SetPoint from the ExecutionVariables object? 

0 Kudos
Message 9 of 10
(4,810 Views)

Hey  Robert,

 

I'm glad that looking at the full featured UI helped you out! As for the Setpoint I was wondering  more along the lines of if it was a result, limit, etc.

 

The reason why I keep asking for use case is because there are different methods I would suggest depending on your use case.

 

For example, when I think of the unit testing use case, we don't require to modify things on the fly. We just need to be able to change the inputs and see the outputs after executions. As for changing the inputs I would highly suggest implementing something like a property loader step. I know that does mean you have to modify the sequence file but I would also keep this modification in by in your debug and your test mode. The suggestion is then to use a user-selectable flag to enable/disable debug mode, then use a property loader step to set the parameter values based on which mode was selected. You could make it part of the UI or Model or Sequence File depending on their needs.

 

As for collecting the results, I would make take advantage of the results list and logging options in TestStand by adding your results to additional results. There is a good discussion about how to do this in the fourm post below.

 

Adding additional result programmatically  - http://forums.ni.com/t5/NI-TestStand/Adding-additional-result-programmatically/td-p/3180834

 

To address what you are seeing in the fully featured operator interface the reason why you can see the variables correctly during runtime but not after is due to all parameters being replaced by their defaults after finishing runtime. So in order to save them we have to something during the run time. Technically you are doing that by adding a breakpoint, but if we want to get to something during runtime otherwise we will have to edit something like a the sequence itself or do something with the process model by overwriting a sequence callback or something similar to that nature.

 

Lastly, I know that this was mentioned in the discussion above, but for making tools there are already ways to do this through test stand instead of in another ADE. You could check out more about that functionality in this example below.

 

Creating a Sequence File Iteration Tool - Replacing Absolute Module Paths with Relative Paths - http://www.ni.com/example/25087/en/

JY
Application Engineer, RF and Communications
National Instruments
0 Kudos
Message 10 of 10
(4,796 Views)