NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Property of PropertyObject[]

Solved!
Go to solution

I am attempting to create a .NET interface which exposes an array of TestStand parameters of Named Types (named container type in my case).  I can expose this property either as an array of property objects or a property object that is itself an array of the named types.

 

In neither case am I able to from within TestStand get this property object and set it to an array property.  The array property has the correct type of course but it seems that TestStand sees these properties as Object References which are not directly compatible with a TestStand property

 

How can I set the 'Definitions' property (see below) in TestStand using one of these .NET properties?

 

Thanks.

 

public PropertyObject[] Definitions { get; }

or

 

public PropertyObject Definitions { get; }


TestStand Container Array.png

0 Kudos
Message 1 of 3
(4,692 Views)
Solution
Accepted by TerrenceJ

1) What version of TestStand are you using?

 

2) Do you care if the elements are copies or do you need to put those actual objects themselves directly into the array?

 


If you don't care about the elements being copies then the following will work:

 

Use the prototype "public PropertyObject Definitions { get; }" and store the output in an Object Reference variable. Then in a post expression or statement step do the following:

 

Locals.myArray = *Locals.objectRefContainingArray

 

The '*' means to de-reference the object reference to directly treat it as a teststand variable and the assignment will make copies of all of the elements. You do need a relatively recent version of TestStand for this to work.

 

 

If you want the elements to be the actual returned objects then the following will work:

 

Use the prototype "public PropertyObject[] Definitions { get; }" and store the output in an Array of Object References variable.

 

Then in steps after that step you will need to make sure your destination array is empty to start with (i.e. SetNumElements(Locals.objArray, 0)). Then in a loop (either step looping options or for loop steps) do something like the following:

 

Locals.objArray.SetPropertyObjectByOffset(Locals.LoopIndex, PropOption_InsertIfMissing, Locals.refArray[Locals.LoopIndex])

 

 

Also, I submitted a request to make this work more directly, by just specifying the object array, in a future version since I agree that it's odd that this doesn't work in a more straightforward way.

 

Hope this helps,

-Doug

Message 2 of 3
(4,662 Views)

Excellent, thanks Doug.  In my case I can indeed use copies of the elements.

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