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: 

Using Enumerated data type in NI Teststand.

Hello,

 

I am using using a C# dll in which there is some functions use enumerated data type define in same dll. I need to test that function for all enumerated values. For this, I want to create local variable array of enum type which has all the values of the enumerated data type and then using for loop and enum type variable I can iterate through that array for whole enum range.

I can do this by using int variable also but then I will not be able to retrieve the string value of the enum or it may be the case that enum integer value are not in serial order.

So can you help me how can I use enum?

0 Kudos
Message 1 of 10
(13,047 Views)
Please reply urgently for this thread.
0 Kudos
Message 2 of 10
(13,029 Views)

goel,

 

I think that you are handling the enums correctly and in the best method available via TestStand.  Since enums are not a native TestStand type we cannot directly import this information into TestStand.  The best way to handle them is to use the integer indices to pass the information back and forth (which is what you seem to be doing).  The only other thing we could do to better represent the enum within TestStand is to build an array of strings (our enum values) and then map the indices of that array to the integer values of our enum.  This would create holes if you didn't have a serial order, but it could help to manipulate the data from within TestStand.

John B.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 10
(13,001 Views)

goel,

 

I overlooked a second way we can create an enum in TestStand.  We can create a container of numbers, and then each numeric element in the container will hold the integer value of our enum element.  Thus we can use non-serial enums since we can name the elements consecutively (as show below) but the values stored are nonconsecutive integers to represent the actual enum indices we are working with.

 

.

 

Now we can access each element of our container (Locals.Enum.FirstElement) and retrieve the corresponding enum index.

Message Edited by herosphro on 09-10-2008 01:42 PM
John B.
Applications Engineer
National Instruments
Message 4 of 10
(12,996 Views)

This way I can use the enumerated data type but how can I get the return value of the fiunction returning Enums. I tried to pass integer for storing the return value of the function but it gives error. Which data type can be used to store returned enum types?

Please reply urgently.

0 Kudos
Message 5 of 10
(12,805 Views)

hi,

 

like in the post above you have to refer or call each element for the assignment, not the whole container. the error might be because of that...

 

hope tat solves ur issue.

 

vaibhav

.......^___________________^
....../ '---_BOT ____________ ]
...../_==O;;;;;;;;_______.:/
.....),---.(_(____)/.....
....// (..) ),----/....
...//____//......
..//____//......
.//____//......
..-------
0 Kudos
Message 6 of 10
(12,772 Views)

I am using the C# dll having function which returns enumerated array? How can I handle that in Teststand?

In case of returning single enum I can get value using either string or integer but in case of enum array both string array and integer array didn't work. I am getting error in both cases?

Please reply urgently.

 

Thanks,

Saurabh

0 Kudos
Message 7 of 10
(12,730 Views)

I know this is an old issue, but I am giving this response in case some one get to this thread.

Using the Container as proposed by John.B, you can use the TestStand PropertyObject to get the Nth Property Name.

0 Kudos
Message 8 of 10
(11,274 Views)

@goel wrote:

I am using the C# dll having function which returns enumerated array? How can I handle that in Teststand?

In case of returning single enum I can get value using either string or integer but in case of enum array both string array and integer array didn't work. I am getting error in both cases?

Please reply urgently.

 

Thanks,

Saurabh


What version of TestStand are you using? There were major improvements made to the .NET adapter in TestStand 2010. I verified that an array of string and an array of numbers both work fine in recent versions of TestStand. If you are using the .NET adapter a lot? If so I highly recommend you upgrade to TestStand 2010 or higher (2012 was just released recently).

 

-Doug

Message 9 of 10
(11,259 Views)

I just realized I replied to a very old post, but oh well, hopefully that info will be useful to someone.

 

-Doug

Message 10 of 10
(11,257 Views)