NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
goel
Posts: 38
0 Kudos

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?

Member
goel
Posts: 38
0 Kudos

Re: Using Enumerated data type in NI Teststand.

Please reply urgently for this thread.
Member
herosphro
Posts: 171
0 Kudos

Re: Using Enumerated data type in NI Teststand.

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
Member
herosphro
Posts: 171

Re: Using Enumerated data type in NI Teststand.

[ Edited ]

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
Member
goel
Posts: 38
0 Kudos

Re: Using Enumerated data type in NI Teststand.

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.

Member
cs_BOT
Posts: 115
0 Kudos

Re: Using Enumerated data type in NI Teststand.

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;;;;;;;;_______.:/
.....),---.(_(____)/.....
....// (..) ),----/....
...//____//......
..//____//......
.//____//......
..-------
Member
goel
Posts: 38
0 Kudos

Re: Using Enumerated data type in NI Teststand.

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

Member
N Bouchelouh
Posts: 1
0 Kudos

Re: Using Enumerated data type in NI Teststand.

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.

Active Participant
dug9000
Posts: 1,506
0 Kudos

Re: Using Enumerated data type in NI Teststand.


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

Active Participant
dug9000
Posts: 1,506
0 Kudos

Re: Using Enumerated data type in NI Teststand.

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

 

-Doug

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page