04-12-2012 03:28 PM
I have a .Net DLL that returns an enum status code.
Here is the defintion:
public enum eStatus { OK = 0, Except = 1, IOError = 2, }
How can I import the enum into Test Stand so that I don't have to recreate it in TestStand?
Solved! Go to Solution.
04-13-2012 03:05 PM
mef526,
This forum thread might help you get on the right track with using the enum data type in TestStand (not a native TestStand type).
Thanks,
04-13-2012 04:29 PM
I looked at the thread you reccomended and it implies that there is no way to import an enum from .Net into TestStand.
The only solution is to recreate the enum as a container value in TestStand.
I am already doing that by using explicit integer values in the TestStand code.
I was hoping to avoid managing 2 sets of code with the same enum in each.
04-14-2012 09:56 PM
You can also specify an enum value by string which is a little less error prone since you don't have to ensure that you keep values up to date. The string will be converted into whatever the current value for the type is at runtime.
-Doug
04-15-2012 02:56 AM
Right now I am using the interger values instead of the enum's names. If I use the names in TestStand then somehow the name's integer values are associated with them.
If I don't have to maintain the name / value association by duplicating the enum in TestStand then TestStand must be getting those integer values from the .Net code. If not, then how does TestStand use the enum's names?
What is the best way to accomplish this method (using the .Net enum names) in TestStand without having to recreate the enum in TestStand?
04-16-2012 10:13 AM - edited 04-16-2012 10:16 AM
TestStand gets the enum values via reflection at load time. They are not hardcoded anywhere. Thus if the values change in the assembly and you specify enum values by name, teststand will pick this up automatically when it reloads the assembly.
Regarding your question:
mef526 wrote:What is the best way to accomplish this method (using the .Net enum names) in TestStand without having to recreate the enum in TestStand?
It depends on what you are wanting to do. Please explain in more detail as I'm not sure what you are trying to do.
-Doug
04-16-2012 03:55 PM
Thank you for your time in considering this issue.
In the .Net code:
public enum eStatus { OK = 0, Except = 1, IOError = 2, } public eStatus GetErrorsAndClearQueue() { try { _SysErrs = GetErrorsAndClearQueue(_formattedIO488); return Instrument.eStatus.OK; } catch (Exception e) { _lastException = e; return Instrument.eStatus.Except; } }
I changed the TestStand step Settings for the function "GetErrorsAndClearQueue" to return a string, not an int and I got the proper value value back. As an int I get 0, as a string I get "OK". So it works as you said it would.
04-17-2012 09:19 AM
Sounds good. Did you have any further questions reguarding this? Does this feature meet your requirements?
-Doug