Click or drag to resize

Adding a Method

Before adding a method to a driver design, it is useful to consider if the capability might better be exposed from the driver as a property. The topic Properties vs. Methods provides a few guidelines on choosing between exposing driver capabilities as methods versus exposing them as properties.

To add an IVI-COM method to a driver

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

  2. The Driver Designer opens as a tabbed document window. Select the IVI-COM tab.

  3. From the tree view expand the type library node for the instrument-specific hierarchy. This node is named "<driverName>Lib".

  4. Right-click on the desired location within the hierarchy and choose Add Method.

  5. A new method is added with a default name and the tree node enters edit mode. By default the method return type is Void, meaning that the method has no return type. However, the underlying COM return type is still a standard HRESULT. The return type specified is for client languages, such as Visual Basic and C#, that recognize COM return values.

  6. With the method node still in edit mode, type the desired name of the method followed by a colon (:) followed by the name of the return type, and hit the Enter key. The colon and return type can be excluded if the method has no return type (e.g. the Void return type is implied).

    Any of the following data types may be entered as a return type:

    • Void

    • Boolean

    • String

    • Byte

    • Int16

    • Int32

    • Int64

    • Single

    • Double

    • Any enum defined in the type library.

    • An array of any of the above -- designated by appending opening and closing square brackets ([]) to the type name.

      Example: Enter double[] for an array of double-precision floating-pointer numbers.

    Tip Tip

    When typing an enum as the return type, a shortened form of the enum name can be used. The project name prefix and the Enum suffix can be excluded. For example, if the desired return type is Acme4321TriggerSourceEnum, then type only TriggerSource and the full enum name will be expanded when the Enter key is pressed.

    When choosing a method name, the following naming rules apply:

    • The name must be unique within its parent interface. It need not be unique across the entire driver.

    • The name must contain only alphanumeric characters.

    • Spaces are not allowed.

    • The name must begin with a capital letter.

  7. After the method is added, the IVI-COM Method General Editor appears in the right portion of the IVI-COM Designer. See the help topic for that Item Editor for details on defining the method further.

  8. Once a method has been added, parameters can be added to the method. See the topic Adding a Parameter for details on adding parameters.

  9. If IVI-C wrapper generation is enabled on the IVI-C Page of the Driver Settings Editor, then an IVI-C function is automatically created at this time and linked to the IVI-COM method.

    To view the linked IVI-C function, right-click the IVI-COM method, and choose Go to IVI-C Function.

    To remove the linked IVI-C function, thereby creating an IVI-COM-only method, right-click the IVI-COM method, and choose Delete IVI-C Function.

    For a detailed discussion of the associations between IVI-COM methods and IVI-C functions, see the topics Managing IVI-C Driver Functionality and Linking IVI-COM and IVI-C Methods and Properties.

See Also

Download a complete CHM version of this documentation here.