06-16-2009 08:38 AM
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.
Solved! Go to Solution.
06-16-2009 09:04 AM
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
06-16-2009 10:03 AM - edited 06-16-2009 10:08 AM
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
06-16-2009 12:58 PM
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
06-16-2009 06:39 PM
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
06-17-2009 12:46 AM
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