HP (Hewlett-Packard) Drive Network Card User Manual


 
110
Chapter 11
a reference to the instance of the driver. This line of code then casts the
reference returned to type IIviDriver, from which all of IVI’s inherent capabilities
can be referenced.
IIviDriver driver =
(IIviDriver)factory.CreateDriver(logicalName);
6 Initialize is required, because the Session Factory does not take care of that
function.
driver.Initialize(logicalName, true, true);
7 Identity is a property of IIviDriver that references the IIviDriverIdentity interface.
Identifier is a property of IIviDriverIdentity interface that returns a string that
identifies the driver.
string identifier = driver.Identity.Identifier;
8 Print the string.
Console.WriteLine("Identifier: {0}", identifier);
IIviDmm
If we want the code to use multiple drivers that all support the DMM class and use
the IVI DMM class interfaces, we must modify it as shown below. Note that only IVI-
COM drivers that implement the IVI DMM class will work with this program.
1 Create a string variable for logical name.
string logicalName = "LineVoltage";
2 Create an instance of the Session Factory.
IIviSessionFactory factory = new IviSessionFactoryClass();
3 Set the type to match the referenced IVI Instrument Class for class
interchangeability. This code for IIviDmm uses the factory to create a driver
based on the logical name "LineVoltage."
4 In the Configuration Store, logical name "LineVoltage" points to a driver
session. The driver session points to a software module, which can be any IVI-
COM driver. The Session Factory creates an instance of the driver and returns
a reference to the instance of the driver. This line of code then casts the
reference returned to type IIviDmm, from which all of IVI DMM’s class-
compliant features can be referenced.
IIviDmm dmm = (IIviDmm)factory.CreateDriver(logicalName);
5 Initialize is required, because the session factory does not take care of that
function.
dmm.Initialize(logicalName, false, false, “simulate=true”);