|
Top Previous Next |
Instruments often contain multiple instances of the same kind of functionality or capability. For instance, modern oscilloscopes may have multiple channels, each with independent settings for such things as vertical scale and input attenuation. IVI refers to funtionality that is duplicated in an instrument as a repeated capability. Instances of repeated capabilities are identified by name. These names are passed as parameters to standard repeated capability accessor functions in order to change settings and execute methods on a driver's repeated capabilities. There are two types of repeated capability names -- physical names and virtual names. Physical repeated capability names are those that the driver writer specifies during driver development. These are the names that the driver natively understands and, as such, they cannot be modified by an end user. They can only be read by an end user. Virtual repeated capability names are explained below. The physical repeated capability names (or simply physical names) understood by a particular driver can be discovered interactively or programmatically. Each IVI driver is required to register the set of physical names it understands with the IVI Configuration Store. This means an end user can use whatever IVI Configuration Store browser they have to look up the physical names supported by the driver. Physical names can also be discovered programmatically using standard repeated capability functions. Example code for doing this is given below in the section on Parameter-Style Repeated Capabilities.
|
C++ |
|
ViSession vi; |
In the code above, the second parameter is the repeated capability name. The repeated capability name almost always appears as the second parameter to a function that applies to a repeated capability. The example is setting the operation mode to burst for only the output channel identified by "Output1". The name "Output1" could be a physical name or a virtual name.
Drivers that expose a parameter-style repeated capability always expose a couple of additional functions and attributes that allow you to programmatically determine the number of repeated capabilities instances (e.g. "channels") and the physical names supported (e.g. channel names). The names of these support functions are also standardized, so that they can easily be identified when the name of the capability is know. IVI-COM drivers and IVI-C drivers differ slightly in the repeated capability support functions they expose for parameter-style repeated capabilities.
For IVI-COM drivers, the following are required to be present:
•<Capability>Count attribute (Ex: "ChannelCount")
•<Capability>Name attribute (Ex: "ChannelName")
For IVI-C drivers, the following are required to be present:
•<Capability>Count attribute (Ex: "ChannelCount")
•Get<Capability>Name attribute (Ex: "GetChannelName")
With either IVI-COM or IVI-C, the use model for these attributes is virtually identical. Specifically, the client code simply reads the value of the Count attribute and then uses this value to iterate through the repeated capability instances. The Name attribute (for IVI-COM) and the GetName function (for IVI-C) both accept a one-based index parameter to identify which repeated capability instance name is desired. The code below shows how to iterate through all of the physical names supported by an IVI-C FGen driver that exposes a "Channel" repeated capability.
C++ |
|
ViSession vi; |
Selector-style repeated capabilities use a special selector function to set the "active" repeated capability. Subsequent function calls that apply to a repeated capability are understood to apply to the active instance. The active instance remains active until the client code sets the active instance to another repeated capability name.
Selector-style repeated capabilities can be used in both IVI-COM and IVI-C drivers, and, though less common than the parameter style and collection style (discussed shortly), selector-style repeated capabilities have the advantage of not requiring a repeated capability name to be passed to every function that applies to the repeated capability.
As with parameter-style repeated capabilities, drivers that expose a selector-style repeated capability always expose additional functions for managing the repeated capability instances. Indeed, the selector-style repeated capability uses the same functions and attributes as the parameter style, with the addition of one attribute and one function for setting and getting the active instance.
For IVI-COM drivers, the following are required to be present:
•<Capability>Count attribute (Ex: "ChannelCount")
•<Capability>Name attribute (Ex: "ChannelName")
•Active<Capability> attribute (Ex: "ActiveChannel")
•SetActive<Capability> function (Ex: "SetActiveChannel")
For IVI-C drivers, the following are required to be present:
•<Capability>Count attribute (Ex: "ChannelCount")
•Get<Capability>Name attribute (Ex: "GetChannelName")
•Active<Capability> attribute (Ex: "ActiveChannel")
•SetActive<Capability> function (Ex: "SetActiveChannel")
Since the selector-style repeated capability uses the same Count attribute and GetName function as the parameter style, the code required to iterate through the instance names for a selector-style repeated capability is identical to that shown above for the parameter style.
By far, the most common type of repeated capability for IVI-COM drivers is the collection-style repeated capability. Collection-style repeated capabilities are not supported for IVI-C drivers.
As with the parameter and collection style, collection-style repeated capabilities always expose a Count and Name attribute for iterating through the list of available repeated capability names. Unique to collection-style repeated capabilities is the Item property, which provides access to individual repeated capability instances. The Item property accepts a repeated capability name (physical name or virtual name) and returns an interface pointer to the desired repeated capability instance. All method and property calls on the returned interface pointer implicitly apply to the repeated capability instance chosen with the Item property.
The C# code below demonstrates how to use the Item property to access a channel called "CH1" and enable it.
C# |
|
IIviScope scope = new AcmeScopeClass(); |
Note that in C#, the Item property is invoked using the get_Item accessor method. This is required for C# because that language does not support parameterized properties. Thus, any property that accepts one or more parameters must be accessed as if it were a method. The standard way in which such properties appear in C# is with a "get_" prefix (for reads) and a "set_" prefix (for writes).
Note also that declaring the intermediate variable for the IIviScopeChannel interface returned by get_Item is not necessary. Depending upon the client application, it may be more convenient to write the code as follows:
C# |
|
IIviScope scope = new AcmeScopeClass(); |
Many instruments have a fixed number of repeated capabilities. For instance, a function generator typically has a fixed number of output channels. However, some instruments can have a variable number of repeated capabilities, depending upon end-user configuration. For instance, a switching mainframe might have any of a number of combinations of multiplexer cards installed on a particular end-user system. Thus, the number of channels is not fixed and can only be determined at runtime. Such instruments possess what are termed dynamic repeated capabilities. Conversely, instruments that always have a fixed number of repeated capabilities use the term static repeated capabilities.
A driver that exposes dynamic repeated capabilities cannot register the supported repeated capability names during driver installation. Instead, during the driver Initialize call, the driver typically queries the instrument to determine its exact configuration. The mechanism by which a driver determines the name and number of the supported repeated capabilities is always instrument specific, but the net result is that the end user must use the Count and Name attributes to programmatically determine what repeated capability instances are available. An IVI Configuration Store browser is useless in determining what dynamic repeated capabilities a driver supports. It relies only upon static information in the IVI Configuration Store, so it can only report details on static repeated capabilities.
Finally, it is worth noting that a driver can contain both static and dynamic repeated capabilities.