LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Description to pass 'enum' to a call library function node

Hi,

I'm looking for some description/help regarding how to pass 'enum' to a call library function node.


The API documentation that I have states something like this:

enum ibApi_DEVICETYPE_e {
ibApi_DEVICETYPE_A = (1<<0),
ibApi_DEVICETYPE_B = (1<<1),
ibApi_DEVICETYPE_C = (1<<2),
ibApi_DEVICETYPE_D = (1<<3),
ibApi_DEVICETYPE_ANY = 0x3f /* used with filter */
};
typedef ibApi_UINT32 ibApi_DEVICETYPE;


The above is one of the input parameters to my call library function node. Hint to some documentation/example VI should be enough.
0 Kudos
Message 1 of 4
(3,600 Views)
Use an unsigned 32-bit integer, or U32 since the snippet indicates "ibApi_UINT32", which is probably just a renamed unsigned integer. Or, in your LabVIEW code you can create your own enum typdef (and set it U32) that matches these values, and then feed its value to the Call Library node input. The latter is self-documenting.

You can find an extensive example that ships with LabVIEW on using the Call Library function. Open up the Example Finder, and search for "DLL". The VI is called "Call DLL".

Message Edited by smercurio_fc on 05-23-2007 10:41 AM

0 Kudos
Message 2 of 4
(3,594 Views)

Hey, thanks for your input. Infact, I had checked the example before, and maybe I overlooked something, but I did not really find what I was looking for. What I'm doing is, I inserted an "enum" constant from the functions palette (for that matter I also did the same thing with a ring constant), added the devices (A, B, C,...) as items and their values in a sequence (0, 1, 3,...). I did not know how to create the hex values for DEVICETYPE_ANY though as the enum (and ring constant) allow only numeric values.I know there is a way to change representation to hex in the enum constant properties...dont know how to use it though. Maybe I could do with not using this value, but it would be better, that way I'm not restricted to any devicetype.

I then wired this enum constant to my call library function node. Am I atleast on the right track?

-Dude

0 Kudos
Message 3 of 4
(3,572 Views)
An enum requires sequential values, so you wouldn't be able to enter an arbitrary value for each of the enumeration items. You can still use an enum, but you would need a small "accessor" VI that converts the enum to a number. I do this often, as I prefer enums. You can, however, use a ring constant which allows you to enter your own values for each of the labels. With a ring constant you can enter the value based on a format you've selected. By default the format is "Automatic", which means you enter a decimal value. If you right-click on the ring constant and select "Format & Precision" you can change it "Hexadecimal". Then, in the "Edit Items" tab you can enter a hex value in the "Values" column. So, you would have a row that has "ANY" in the "Items" column and "3F" in the "Values" column. This is only if you prefer to see the values in hex.
 
Tip: You should make this into a typedef.
 
Note: The values for each of the constants are not 0, 1, 3, but rather 1, 2, 4, 8, etc...
0 Kudos
Message 4 of 4
(3,564 Views)