05-08-2014 02:00 PM
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; }
Solved! Go to Solution.
05-09-2014 10:51 AM - edited 05-09-2014 10:57 AM
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
05-09-2014 11:42 AM
Excellent, thanks Doug. In my case I can indeed use copies of the elements.