Adding an Enumeration
IVI-C drivers do not explicitly support the enum data type, as do IVI-COM and IVI.NET drivers. Enumerated types are not allowed in IVI-C driver APIs. However, IVI-C drivers support sets of defined values which can very accurately be though of as enums. These defined numeric values are simply #define macros exported in the IVI-C driver's header file. They share the characteristics of enums in that they represent a set of related values, any one of which is a valid attribute or parameter value. This means that each defined value must be unique within its related set of defined values. Additionally, enumerated values can be very conveniently mapped to instrument command strings when working with message-based devices. For these reasons, Nimbus models these sets of related defined values as enums when working within the Nimbus user interface.
From Solution Explorer, double-click the Driver Designer node under the Nimbus node.
The IVI-C Driver Designer tree view opens.
Right-click on the Enums node and select Add Enum.
A new enum is added with a default name and the tree node enters edit mode.
With the enum node still in edit mode, type the desired name of the enum and hit the Enter key.
Since there are no enum data types in IVI-C drivers, no code is actually added to the driver as a result of adding an enum. Only when enum members are added will Nimbus generate #define macros for the enum member values.
After the enum is added, the Enum General Editor appears in the right portion of the IVI-C Driver Designer.
Use the Info Panel in the lower portion of the IVI-C Driver Designer to view and navigate to functions and attribute that use the enum.
Locate the enum to be modified under the Enums node in the IVI-C Driver Designer
Right click on the enum name and select Add Enum Member.
A new enum member is added with a default name and the tree node enters edit mode.
With the enum member node still in edit mode, type the desired name of the enum member and hit the Enter key.
When choosing an enum member name, the following naming rules apply:
The member name must be unique within the enum being modified.
The name must contain only alphanumeric characters, and must start with an alphabetic character.
Spaces are not allowed.
The enum member value can be entered in either hexadecimal or decimal format. It will be converted to the format configured for that enum. Right-click on the parent enum to see a context menu which enables or disables hexadecimal display mode.
After the enum member is added, the Enum Member Editor appears in the right portion of the IVI-C Driver Designer.
Nimbus supports a convenient shorthand notation for defining enums. The enum and its members can be defined all at once when the enum is initially added.
After executing the Add Enum command, and while still in edit mode, the following text can be used to define a TriggerSource enum with members Internal, External, and Software.
TriggerSource; Internal, External, Software
In the above, the enum name TriggerSource is specified first, followed by a semicolon to delineate it from the enum member specifications. Enum members follow and are separated by commas.
This shorthand notation can also be used to define the enum member values, as in the following:
TriggerSource; Internal = 2, External = 0x15, Software = 47
Note that when assigning enum member values, either hex format or decimal format may be used.
Once an enum is defined, additional enum members can be added using this same shorthand notation, except that the enum name is excluded. After executing the Add Enum Member command, and while still in edit mode, the following text can be used to add a series of TTL trigger source lines to the existing TriggerSource enum from the above example:
TTL0, TTL1 = 5, TTL2 = 6, TTL3, TTL4, TTL5 = 0x14, TTL6, TTL7
Download a complete CHM version of this documentation here.