NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

C# Return Container to TestStand

Hello,

 

I'm trying to figure out how to return a Container object to TestStand that is populated with one or more values (of mixed types... strings, numbers, etc) from a C# DLL method call.

 

Is this possible?

 

Thanks!

0 Kudos
Message 1 of 4
(4,161 Views)

You will need to create a custom data type in TestStand that matches the struct.  You will then need to specify how to map the struct to the data type through the .NET Struct Passing dialog.

http://zone.ni.com/reference/en-XX/help/370052J-01/tsref/infotopics/db_datatypeprop_netstruct_tab/

 

You can do this automatically if you have an Assembly with the struct defined through the .NET Pane.

 

http://zone.ni.com/reference/en-XX/help/370052J-01/tsref/infotopics/pane_module_net/

 

See the section: Create Type from Struct


Message 2 of 4
(4,157 Views)

Thanks for the reply. I understand now how to work with structs that are defined ahead of time, but the DLL we have deals with dynamic data and the structure of the returned data is unknown until runtime. I don't see any way to handle that in the references you posted. Did I overlook something?

 

-Aaron

0 Kudos
Message 3 of 4
(4,139 Views)

Keep using propertyobjects and a container as the return value like you probably are doing. Return the container into an Object Reference variable (not a container variable). Then, if you really want to make it a local variable directly, rather than a object reference, so you can directly access it with expressions, do something like the following:

 

If you are sharing the container with other things:

 

Locals.SetPropertyObject("MyNewLocal", PropOption_InsertIfMissing | PropOption_NotOwning | PropOption_ReferToAlias, Locals.MyreturnValStoredinAnObjectReferenceVariable)

 

If the returned container is now owned and referenced only by the sequence:

 

Locals.SetPropertyObject("MyNewLocal", PropOption_InsertIfMissing, Locals.MyreturnValStoredinAnObjectReferenceVariable)

 

If you want to make a copy of the container that was returned:

 

Locals.SetPropertyObject("MyNewLocal", PropOption_InsertIfMissing, Locals.MyreturnValStoredinAnObjectReferenceVariable.Clone("", PropOption_DoNotShareProperties | PropOption_CopyAllFlags)

 

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 4
(4,136 Views)