Can someone explain how IVI drivers allow for interchangeability; I'm specifically confused because in the IVI Getting Started Guide on page 104 it says
One aspect of the IVI standard is instrument interchangeability, which allows you to write and compile your program for an instrument from one manufacturer and then swap it out for the same type of instrument from another manufacturer. After making changes to a configuration file on your computer to identify the new instrument (and driver) and the hardware address (if that changes), you can run your program without modifying or recompiling it.
which in theory makes sense but then for the C# example on page 34, the code is
Agilent34401Class dmm = new Agilent34401Class(); dmm.Initialize("GPIB::23", false, true, "simulate=true");
It would seem to me that the fact that you're declaring the "Agilent34401Class" digital multimeter makes this code not interchangeable; if I were to swap it with another dmm from another manufacturer, would I not need to rewrite that line and then recompile?
Am I missing something in the example?
While I'm here, I might as well ask the other question I'm trying to find the answer to. Is there an easy way to use C# with an IVI-C library or some way to change IVI-C library to IVI-COM?
Any help with either question would be greatly appreciated!
Answer by Kirk Fertitta · Jan 10 at 10:20 PM
You are correct in that the above code does not represent an interchangeability example. In order to swap drivers without rebuilding or relinking your code, you must use the IVI Session Factory to create the driver, like so:
IIviSessionFactory factory = new IviSessionFactory(); var dmm = (IIviDmm)factory.CreateDriver("MyLogicalName");
In the above, the "MyLogicalName" references a Logical Name (or Driver Session) that you create in the IVI Configuration Store using a tool like NI-MAX. You associate that Logical Name (or Driver Session) with the specific driver (Agilent34401) that you're interested in. NI-MAX makes it easy to establish this association. Finally, you associate a Hardware Asset with the Logical Name (or Driver Session). The only really interesting bit of the Hardware Asset is the VISA resource descriptor used to connect to the device. So, for instance, the Hardware Asset would be something like "TCPIP::192.168.1.120" or "GPIB0::6".
With this arrangement, your code has no direct references to a specific driver and you can change the driver and/or hardware address using just NI-MAX and making no code changes.
Hope this helps.