Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use IVI-COM diver in Lab Windows /CVI

Thank you for your advice.
Below is  N5530S Measuring Receiver Software
http://www.home.agilent.com/cgi-bin/pub/agilent/editorial/cp_MiscEditorial.jsp?NAV_ID=-536890808.536...
I followed the article you have mentioned,and created ActiveX controller,then generated an AgilentMr.fp.
But I don't know how to invoke the function in special  steps.
I will try your advice.
Thanks a lot.
0 Kudos
Message 11 of 15
(1,923 Views)

I installed the N5530S software and am seeing the type-lib information through VB6.  Now I could not find any driver help and, I have also found that it is *NOT* an IVI-COM driver but just a custom-made automation library exclusively designed for N5530S system. Of course the COM-access approach is almost the same as if IVI-COM though...

According to the object hierarchy of the N5530S Measuring Receiver library DLL (by seeing it through the VB6 Object Browser), the IAgilentMrTunedRFLevel interface must be queried through:

Application->Measurement->TunedRFLevel

Actually, you must:
(1)QueryInterface the IAgilentMrMeasurement interface through Application's get_Measurement() method's return
(2)QueryInterface the IAgilentMrTunedRFLevel interface through Measurement's get_TunedRFLevel() method's return
(3)then you can access any method of IAgilentMrTunedRFLevel interface.

You can't directly QueryInterface the IAgilentMrTunedRFLevel interface from Application.

Hope this helps.
Makoto

 

0 Kudos
Message 12 of 15
(1,919 Views)

For example, I check the QueryInterface relationship by VB6's SET statement, which invoked QueryInterface() behind the scene. The code of your problem is equivalent to the last SET statement in the following example.  Sorry for writing VB6 equivalent code here instead of LabWindows/CVI code.

    Dim app As New AgilentMrApplication
    Dim m As IAgilentMrMeasurement
    Dim t As IAgilentMrTunedRFLevel
   
    ' Succeeds for QueryInterface operation
    Set m = app.Measurement
    Set t = m.TunedRFLevel
   
    ' Generates Type-mismatch error (due to E_NOINTERFACE)
    Set t = app

このメッセージは 11-08-2005 05:41 PMに Makoto が編集しています。

0 Kudos
Message 13 of 15
(1,919 Views)
How about the example below?  This is written in CVI, and succeeds to acquire objectHandleTunedRFLevel.
 
#include "AgilentAgilentMr.h"
int main()
{
 HRESULT hr;
 CAObjHandle objectHandle = 0;
 CAObjHandle objectHandleMeasurement = 0;
 CAObjHandle objectHandleTunedRFLevel = 0;
 
 hr = AgilentAgilentMr_NewIAgilentMrApplication (NULL, 1, LOCALE_NEUTRAL, 0, &objectHandle);
 hr = AgilentAgilentMr_IAgilentMrApplicationGetMeasurement (objectHandle, NULL, &objectHandleMeasurement);
 hr = AgilentAgilentMr_IAgilentMrMeasurementGetTunedRFLevel (objectHandleMeasurement, NULL, &objectHandleTunedRFLevel);
 

 return 0;
}
0 Kudos
Message 14 of 15
(1,912 Views)
Makoto:
Thank you for your help . I  solved the problem  yesterday,You are right,the objectHanld point to wrong COM interface.so I corrected the program like this :
     
#include "AgilentAgilentMr.h"
#include <utility.h>
#include <cvirte.h>  
#include <userint.h>
#include "test.h"

 
static int panelHandle;
static CAObjHandle  objectHandle,AgilentMrFreqencyCounter, AgilentMrMeasurement, AgilentMrTunedRFLevel;
static CAObjHandle   AgilentMrTunedRFLevel;
static HRESULT hr;
double Level;

int main (int argc, char *argv[])
{
 if (InitCVIRTE (0, argv, 0) == 0)
  return -1; /* out of memory */
 if ((panelHandle = LoadPanel (0, "test.uir", PANEL)) < 0)
  return -1;
 DisplayPanel (panelHandle);
 RunUserInterface ();
 DiscardPanel (panelHandle);
 return 0;
}
int CVICALLBACK Cal (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
  {
  case EVENT_COMMIT:
  
    
   
     hr = AgilentAgilentMr_NewIAgilentMrApplication (NULL, 1, LOCALE_NEUTRAL, 0, &objectHandle);  
     AgilentAgilentMr_IAgilentMrApplicationGetMeasurement (objectHandle, NULL, &AgilentMrMeasurement);
  
      
     AgilentAgilentMr_IAgilentMrMeasurementGetFrequencyCounter (AgilentMrMeasurement, NULL,&AgilentMrFreqencyCounter);
     AgilentAgilentMr_IAgilentMrFrequencyCounterInitialize (AgilentMrFreqencyCounter, NULL);
      
     AgilentAgilentMr_IAgilentMrFrequencyCounterRead (AgilentMrFreqencyCounter, NULL, &Level);
 
    
   break;
  }
 return 0;
}
 
Now my program can be complied  successfully, Thank you very much !
 
I think it could be a good  example of invoking the IVI-COM in Lab Windows/CVI,  ha-ha!,
 
Hope it can hlep other people who face the same problem!
 
 
Adam
0 Kudos
Message 15 of 15
(1,894 Views)