Click or drag to resize

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.

To add an enum to a driver

  1. From Solution Explorer, double-click the Driver Designer node under the Nimbus node.

  2. The IVI-C Driver Designer tree view opens.

  3. Right-click on the Enums node and select Add Enum.

  4. A new enum is added with a default name and the tree node enters edit mode.

  5. With the enum node still in edit mode, type the desired name of the enum and hit the Enter key.

    Note Note

    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.

  6. After the enum is added, the Enum General Editor appears in the right portion of the IVI-C Driver Designer.

Tip Tip

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.

To add an enum member to an enum

  1. Locate the enum to be modified under the Enums node in the IVI-C Driver Designer

  2. Right click on the enum name and select Add Enum Member.

  3. A new enum member is added with a default name and the tree node enters edit mode.

  4. 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.

    Tip Tip

    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.

  5. After the enum member is added, the Enum Member Editor appears in the right portion of the IVI-C Driver Designer.

Shorthand notation for defining enums

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.