NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting (.net) type information from TestStand Object Reference

Solved!
Go to solution

Hi there,

 

here I am again with a very strange question:

 

I have a local variable of Type Object Reference. During Runtime, the Variables Pane shows the type of .net reference stored in this variable:

Oli_Wachno_0-1703083784754.png

 

How can I access this information using the TestStand API? I have tried to use the PropertyObject API but failed so far with TestStand telling me more or less the same

 

Oli_Wachno_1-1703083926461.png

Can anyone nudge me in the right direction please?

 

Cheers

Oli

 

0 Kudos
Message 1 of 7
(1,665 Views)

A .NET class object can be anything, so TestStand has no way to process it.  The best you can do is hold a reference to it and pass it to another .NET class.

TestStand can only pass, standard data types:  Number, String, and Boolean and References to objects

 

Or create TestStand type container and mark that Type to be allowed to pass C# struct and pass a reference to the C# class.  Then populate the fields of the struct, then the data will show up in TestStand.

 

eejallen_0-1703108936414.png

 

0 Kudos
Message 2 of 7
(1,644 Views)

Understood!

 

In my use case, I need to check if a Object Reference Type variable holds a certain .net class type (DateTime in this case). Since the Variables Pane of the Sequence Editor seems to be able to determine this, I suppose there must some way to achieve this progamatically in TestStand

 

 

0 Kudos
Message 3 of 7
(1,637 Views)
Solution
Accepted by topic author Oli_Wachno

After talking to a colleague who's very much into .net my interpretation is that the Variables Pane Control uses some .net functionality

 

For future reference: 

Oli_Wachno_0-1703156778474.png

 

Throws error on NULL references, but also seems to work with COM references (like ActiveX objects)

0 Kudos
Message 4 of 7
(1,619 Views)

Oli_Wachno_0-1703083784754.png

 

How can I access this information using the TestStand API?


Your original question was how to access an arbitary object via "TestStand API", so I approached the answer only in that context. (Answer is: you cannot.  TestStand PropertObject API can only access TestStand objects).  And as I replied before and you found out, access of .NET object is possible only using additional .NET assemblies until you get to a return value of basic data types (String, Number, Boolean), which at that point TestStand can consume the value into a variable.

 

This holds true for any Class Object architecture (C, C++, C#, etc).

Message 5 of 7
(1,587 Views)

Sorry, for the wording, no intention to upset you

0 Kudos
Message 6 of 7
(1,574 Views)

@Oli_Wachno wrote:

Understood!

 

In my use case, I need to check if a Object Reference Type variable holds a certain .net class type (DateTime in this case). Since the Variables Pane of the Sequence Editor seems to be able to determine this, I suppose there must some way to achieve this progamatically in TestStand

 

 


Many years ago I created a suggestion that never materialized. Still amazed that more people don't run into problems with this.

 

https://forums.ni.com/t5/NI-TestStand-Idea-Exchange/Add-a-native-DateTime-data-type-to-the-TestStand...

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 7 of 7
(1,527 Views)