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: 

How to change values ​​in teststand station globals using C#?

Solved!
Go to solution

Hi

I want to use C# to change some  values ​​in station globals, how can I do this?

Thanks!

 

0 Kudos
Message 1 of 3
(901 Views)
Solution
Accepted by topic author charleserr

Hi charleserr,

 

First, add NationalInstruments.TestStand.Interop.API to your project (right-click References >> Add Reference >> Assemblies >> Extensions >> NationalInstruments.TestStand.Interop.API).

Then add using NationalInstruments.TestStand.Interop.API to your source file.

After that; you need to add the TestStand sequence context as an argument to your method. From there, you can access all of the TestStand variables from the sequence context and modify them using the set methods. There are several different set methods available depending on the datatype of the variable you want to modify. Since this is already at the intended variable scope, the lookup string argument will just be the name of the variable. Here, I'm setting a StationGlobal named "test" that is a numeric datatype:

DJColeslaw_0-1661365612852.png

Then, from TestStand, pass "ThisContext" into the sequence context argument:

DJColeslaw_1-1661365739800.png

 

 

 

Regards,
Message 2 of 3
(868 Views)

Thank you very much for your reply, under your guidance, this problem has been solved!

 

I also tried to modify the file type of "StationGlobals.ini" to XML, and directly edit this XML file to achieve the effect I need.

捕获.PNG

0 Kudos
Message 3 of 3
(807 Views)