01-10-2011 12:09 AM
Hi, I'm trying to automate the this Agilent6700 PS,
I have the following code, which I can't access the instrument specific options.
#import "IviDriverTypeLib.dll" no_namespace
#import "IviDCPwrTypeLib.dll" no_namespace
#import "IviSessionFactory.dll" no_namespace
#import "GlobMgr.dll" no_namespace
void main()
{
HRESULT hr;
hr = CoInitialize(NULL);
if (FAILED(hr)) exit(1);
IIviDCPwrPtr DCptr("Agilent6700");
DCptr->Initialize("GPIB::23",false,true,"Simulate=true");
....
}
After initiazing it, I can't access any specific option of the instrument.
When I type DCptr-> intellisense only offers only basic options the are common to all instruments.
Regards,
Hagai.
01-11-2011 07:59 AM
Hello Hagai,
Have you looked into the manual for your device for the proper commands to send to your device? That should tell you how to bring up the advanced options for the device.
Best Regards,
Adam G
01-13-2011 02:48 AM
Hi,
I finally managed to find those commands, but I keep getting runtime error while trying to initialize it.
Note I do not have the deivce connected yet, and only use the Simulation mode.
Here's what Im trying to do:
#import "IviDriverTypeLib.dll" no_namespace
#import "IviDCPwrTypeLib.dll" no_namespace
#import "GlobMgr.dll" no_namespace
#import "AgN67xx.dll" no_namespace
int main(int argc, char* argv[])
{
HRESULT hr;
IAgilentN67xx4Ptr driverPtr=NULL;
hr = CoInitialize(NULL);
if (FAILED(hr))
exit(1);
// create a safe pointer for interface access
hr = driverPtr.CreateInstance(__uuidof(AgilentN67xx));
if (FAILED(hr))
exit(1);
// open the instrument for communication
hr = driverPtr->Initialize(
L"GPIB0::20::INSTR", //Visa address,(not applicable if simulation=true)
VARIANT_TRUE, // ID query
VARIANT_TRUE, // Reset
LPCTSTR("Cache=true, InterchangeCheck=false, QueryInstrStatus=true, Simulate=true, DriverSetup= Trace=true, TraceName=MyTrace"));
if (FAILED(hr))
exit(1);
...
}
After calling to driverPtr->Initialize I get runtime error in 'ividrivertypelib.tli' :
inline HRESULT IIviDriver::Initialize ( _bstr_t ResourceName, VARIANT_BOOL IdQuery, VARIANT_BOOL Reset, _bstr_t OptionString ) {
HRESULT _hr = raw_Initialize(ResourceName, IdQuery, Reset, OptionString);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr;
}
The value in _hr is 0x80047060.
Please help,
Hagai.
01-13-2011 01:34 PM
Have you tried using our IVI-C driver instead of IVI-COM driver from Agilent?
01-13-2011 01:54 PM
No, I need this for a Visual C++ code, so sticking with IVI-COM.
01-13-2011 08:45 PM
You aren't using any NI software. Why are you asking about COM drivers here instead of Agilent? I would expect they are going to be much more familiar with how their code should be used.