NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Get and set Local variables from C#

Solved!
Go to solution

Hi,

 

I am instantiating a .net assembly (C# 2005) from Teststand.

I want to get all Locals from Teststand in my C# application and also to be able to set Teststand locals from C#.

Does anyone have a solution for this?

 

Thanks in advance.

0 Kudos
Message 1 of 6
(6,456 Views)

Hi,

 

here is a link from Juergen that may help

 

http://forums.ni.com/ni/board/message?board.id=330&message.id=23514&query.id=840666#M23514

 

In fact you may come up with other useful snippets by searching for Juergen's responses

 

Regards

Ray Farmer

Regards
Ray Farmer
Message 2 of 6
(6,452 Views)

The example above is for a UIMessage case for a user-interface (getting the locals from within a user interface application). If you just want to pass them into and access them from a code module called from a sequence,  you just need to pass in the local variables or sequence context into the method you are calling in your assembly and use the PropertyObject API to access the variables. You can make the data type of your parameter that you are passing the local variables or sequence context a PropertyObject (add an assembly reference to the teststand interop assemblies if you haven't already, they are in the GAC).

 

Hope this helps,

-Doug

Message Edited by dug9000 on 06-16-2009 10:08 AM
Message 3 of 6
(6,445 Views)

Thanks Doug,

 

You are pointing me in the right direction.

Do you have a code snippet how to iterate through a PropertyObject to read all the variables?

 

PropertyObject PropertyObject = ProObj.GetPropertyObject("Locals", 0);

 

PCCDS

0 Kudos
Message 4 of 6
(6,433 Views)

I'm not sure if there is a dotnet example that comes with teststand, but there is a CVI one. You can probably figure out the APIs to use and write something equivalent in dotnet depending on your needs.

 

The CVI one is located in <TestStand>\API\CVI\tsutil.c look for TS_TraverseProperties.

 

You should also take a look at the online help for the following API functions:

 

PropertyObject.Name

PropertyObject.GetType() (or the newer PropertyObject.Type API, depends on the version of TestStand and your preference)

PropertyObject.GetNumSubProperties()

PropertyObject.GetNthSubProperty()

PropertyObject.GetDimensions()

PropertyObject.GetPropertyObjectByOffset()

PropertyObject.GetValNumber()

PropertyObject.GetValNumberByOffset()

PropertyObject.GetValString()

PropertyObject.GetValStringByOffset()

etc.

 

Those are the main ones you'll need. There's more than one way to do it (either with building lookup strings or using indices/offsets) so there's more than one set of functions you could use, but they are all part of the PropertyObject interface.

 

Hope this helps,

-Doug

 

Message 5 of 6
(6,421 Views)
Solution
Accepted by topic author ccds

Hi,

 

here is a CVI example that maybe you can use as a guide.

 

http://sine.ni.com/devzone/cda/epd/p/id/3086

 

regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 6 of 6
(6,412 Views)