02-07-2006 09:19 AM
02-08-2006 09:42 PM
Unfortunately I have never seen good example codes for IVI-COM IviDmm class interfaces.
To keep interoperability between different DMM models using IVI-COM DMM class interfaces, first you must forget about IAgilent34410 interface, which always requires the specific Agilent model at runtime. Instead, your application must only use IVI-defined IIviDmm interfaces. Also, a special appoach that uses IVI Session Factory is required to create a virtualized driver session, bacause IviDmmTypeLib.DLL only provides class interfaces and not provide driver loader engine.
Here is an example I wrote:
/////////////
// STDAFX.H
#import "c:/progra~1/Ivi/bin/IviDriverTypeLib.DLL" no_namespace named_guids
#import "c:/progra~1/Ivi/bin/IviDmmTypeLib.DLL" no_namespace named_guids
#import "c:/progra~1/Ivi/bin/IviSessionFactory.DLL" no_namespace named_guids
////////////////////////////////
// You app code:
try
{
IIviSessionFactoryPtr spSF(__uuidof(IIviSessionFactory));
IIviDmmPtr spDmm = spSF->CreateSession( "AGILENT_DMM");
spDmm->Initialize( "AGILENT_DMM", VARIANT_FALSE, VARIANT_FALSE, "");
IIviDmmMeasurementPtr spMeas = spDmm->Measurement;
double dReading = spMeas->Read( 3000);
spDmm->Close();
}
catch( _com_error e) {
}
////////////////////////////////
To map your Logical Name ("AGILENT_DMM" in above example), it must be properly configured in NI-MAX, so that it can be associated to Agilent34410 driver including its VISA address. Then make sure to assign Agilent34410 IVI-COM driver for its Software Module.
To create a DMM driver instance, use CreateSession() method of IIviSessionFactory. You can just typecast (actually QueryInterface) the returned IUnknown pointer to IIviDmm. (The driver module loaded by the IVI Session Factory will be an Agilent34410 object, therefore QueryInterface to IIviDmm must succeed.) After that, you can use any DMM class interfaces without having any dependency to specific Agilent DMM models in your code. To change your DMM hardware to other model, just change NI-MAX configuration.
Hope this helps,
Makoto
02-09-2006 10:18 AM
02-09-2006 10:59 AM
This Initialize() call is actually invoking the Initialize() method that is embedded in the Agilent34410 driver DLL. Although the Initialize() method takes the logical name "AGILENT_DMM", the method does not reference to Software Module configuration of "AGILENT_DMM" in the IVI Configuration Store. It just picks up the VISA Address (Hardware Asset) and default IVI settings such as Cache, QueryInstrStatus, etc..., but Software Module (driver DLL) configuration is ignored.
Therefore, even if the "AGILENT_DMM" Logical Name was configured to use any other Software Module such as Fluke45 or Advantest6552 IviDmm IVI-COM driver (assuming they exist), the software module configuration will not be referenced by Initialize() method, therefore Agilent34410 Initialize() function will be finally executed.
The only DLL module, which dynamically selects a driver DLL by referencing IVI Configuration Store, is the IVI Session Factory in the IVI-COM world. In contrast, IVI-C class drivers have this kind of loader mechanism in them, therefore no need to use IVI Session Factory.
02-09-2006 01:11 PM
02-09-2006 08:16 PM