From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Python - obj - get multiple fields from class

Solved!
Go to solution

What is the best way to get many (100) fields from a python obj into teststand.

 

We're comming from C#, where it's possible to generate a data-type in TestStand based on the data-type in C# (at least on C# structs).

 

That means if we have a C# struct with hundred of fields, TestStand can create a similar custom data type with the correct field names, by a right click.

 

How do I access field values in a Python object passed back into Teststand ?

 

we are using TestStand 2014.

Is it an advantage to use TestStand 2019 in this respect ?

0 Kudos
Message 1 of 3
(2,601 Views)
Solution

In Python, if you have an object (assume a python class instance) stored in a variable of type object reference, you can use python adapter to call function or get/set attributes (equivalent of properties in C#) in the class instance.

 

Similar to how a C# struct is mapped to a container in TestStand, tuple in Python is mapped to container. So, you can return a tuple and you can store its data in a container. Python adapter does not have the ability to detect the contents of the parameter or return value at edit time. Hence, in Python adapter, you do not get a single click option to create custom data type. You need to create the container along with its subproperties and then use it in the return value to store the contents of tuple.

 

-Shashidhar

Message 2 of 3
(2,536 Views)

Hi  NikolajEgeskovOstergaard,

If  Shashidhar 's answer has helped please remember to mark it as a solution.

 

Kind Regards,
 
Danielle
Technical Support Engineer
Platforms & Systems
National Instruments
 
0 Kudos
Message 3 of 3
(2,499 Views)