Creating and Using the Resource Manager
Overview
The IVI VISA Shared components (installed with the Keysight IO Libraries Suite) include a Global Resource Manager (GRM), which can instantiate (create) any VISA COM resource installed on the system. The GRM can find and use Vendor-Specific Resource Managers (SRMs) to find and create sessions to all the resources on a system. The GRM and the SRMs export the IResourceManager interface, which you will use to find and instantiate resources.
(Some early versions of the Keysight IO Libraries did not include the Global Resource Manager, but only the Keysight specific resource manager (SRM). If your program was written to use the Keysight SRM, modify it to use the GRM, by modifying the resource manager instantiation code (see below) and recompiling it to use the GlobalRM.dll type library file rather than the visacom.tlb type library file. If you do not make these changes, your program will still run, but will be less flexible and less portable. Whereas the GRM is able to locate resources that are supported by any implementation of VISA installed on your PC, the Keysight SRM communicates only with Keysight VISA. So if you need to use non-Keysight resources – for example, if you need to communicate with National Instruments PXI devices using VISA – then you need to use the GRM.)
Instantiating the Global Resource Manager
Visual Basic
-
Include the "VISA COM 5.2 Type Library" (located in the GlobMgr.dll file) in Project >References (as shown in Figure 1 below).
-
Create an object reference variable with the line
Dim rm As VisaComLib.ResourceManager
-
To instantiate the GRM object, use the line
Set rm = New VisaComLib.ResourceManager
Figure 1: The Visual Basic Project References Dialog Box
Visual C++
-
Use the statement
#import "c:\program files\IVI Foundation\visa\visacom64\GlobMgr.dll" no_namespace
or
#import "c:\program files (x86)\IVI Foundation\visa\visacom\GlobMgr.dll" no_namespace
to import the VISA COM type library.
-
Create a variable of type IResourceManagerPtr with a statement such as
IResourceManagerPtr rmPtr;
-
To instantiate the GRM, use the line
rmPtr.CreateInstance(__uuidof(ResourceManager));
The IResourceManagerPtr type is a specialization of the _com_ptr_t template class defined in comdef.h. See MSDN help on #import
for more information.
Using the Global Resource Manager
Both GRMs and SRMs use the same interface, IResourceManager, to create resources. This interface provides resource creation and location services. The two methods you will find most useful will be the Open and FindRsrc methods. Use Open to create resources and use FindResourceAddress to retrieve valid resource strings based on a search string. Below is sample code for Open:
Visual Basic
|
Visual C++
|
See VISA Resource Strings for more information on the ResourceString parameter of Open and The Option String for more information on the OptionString parameter of Open.
See Also
Supported VISA COM I/O Resource Classes