04-14-2008 06:31 AM
04-14-2008 09:28 AM
04-14-2008 09:39 AM
Hello Nathan. Thank you
I want to make a software that was able to communicate with any DMM that use LXI.
Im usin Visual C++ .NET and the IVI COm driver are by Agilent.
I think that the problem is that i would know the ProgID.
For Example the next code give me an error that says that the CLASS ID its not registred, how can i discover the PRog ID??
#include
"stdafx.h"#import
"IviDriverTypeLib.dll" no_namespace named_guids#import
"IviDmmTypeLib.dll" no_namespace named_guids#import
"GlobMgr.dll" no_namespace named_guids#import
"IviSessionFactory.dll" no_namespace named_guids#import
"IviConfigServer.dll" no_namespace named_guids//using namespace IVICONFIGSERVERLib;
int
main(int argc, char* argv[]){
HRESULT hr;
char
nombre[56];
hr = CoInitialize(NULL);
if
(FAILED(hr))exit(1);
printf("introduzca el nombre del nuevo hardware: \n");
scanf("%s",nombre);
getchar();
{
IIviConfigStorePtr cs(
__uuidof(IviConfigStore));//cs.Detach;
try
{// Deserialize the master configuration store.
cs->Deserialize(cs->MasterLocation);
try
{// Create an empty Hardware Asset
IIviHardwareAssetPtr ha(
__uuidof(IviHardwareAsset));//Set its properties
ha->Name = _bstr_t(nombre);
ha->Description = _bstr_t("Multimeter connected to the switch");
ha->IOResourceDescriptor = _bstr_t("GPIB::22::INSTR");
// Add it to the global hardware asset collection
printf("hasta aqui");
IIviSoftwareModulePtr sm(
__uuidof(IviSoftwareModule));sm->Name =_bstr_t(nombre);
sm->ProgID=bstr_t("Jolin");
cs->SoftwareModules->Add(sm);
cs->HardwareAssets->Add(ha);
}
catch (_com_error e) {printf("Add HardwareAsset failed.\n");
printf("Error description is: %s\n",(
char*)e.Description());//printf("%s");
getchar();
}
try
{// Create an empty DriverSession
IIviDriverSessionPtr ds(
__uuidof(IviDriverSession));// Set its properties
ds->Name = _bstr_t(nombre);
ds->Description = _bstr_t("DriverSession for the system multimeter");
ds->Cache =
true;ds->InterchangeCheck =
false;ds->QueryInstrStatus =
false;ds->RangeCheck =
true;ds->RecordCoercions =
false;ds->Simulate =
false;ds->DriverSetup = _bstr_t("");
// Add the HardwareAsset reference to the Session
ds->HardwareAsset = cs->HardwareAssets->Item[nombre];
// Add the SoftwareModule reference to the Session.
printf("hasta aqui");
ds->SoftwareModule = cs->SoftwareModules->Item[nombre];
// Add it to the global driver session collection
printf("hasta aqui");
cs->DriverSessions->Add(ds);
}
catch (_com_error e) {printf("Add DriverSession failed.\n");
printf("Error description is: %s\n",(
char*)e.Description());getchar();
}
try
{// Create the Logical Name
IIviLogicalNamePtr ln(
__uuidof(IviLogicalName));// Set its properties
ln->Name = _bstr_t(nombre);
ln->Description = _bstr_t("The name used in the test program");
ln->Session = cs->Sessions->Item[nombre];
// Add it to the global logical name collection
cs->LogicalNames->Add(ln);
}
catch (_com_error e) {printf("Add LogicalName failed.\n");
printf("Error description is: %s\n",(
char*)e.Description());getchar();
}
// Overwrite the master with the modified configuration store
try
{cs->Serialize(cs->MasterLocation);
IIviSessionFactoryPtr spSF(
__uuidof(IviSessionFactory));IIviDmmPtr spDmm = spSF->CreateSession(nombre);
}
catch (_com_error e) {printf("Serialize failed.\n");
printf("Error description is: %s\n",(
char*)e.Description());getchar();
}
}
catch (_com_error e) {printf("Deserialize failed.\n");
printf("Error description is: %s\n",(
char*)e.Description());getchar();
}
}
//getchar();
CoUninitialize();
return
0;}
And other question: its possible make a software that can discover what class of intrument have you linked at network??
Excuse me by my english, and thank you for your help
04-14-2008 09:49 AM
04-14-2008 10:31 AM
04-15-2008 10:09 AM
04-15-2008 10:26 AM
Hi Nathan.
I have a source code which try to start communication with a instrument that i connect at network. I don't wnat to know what is the specific instrument. I use IVI-COM.
My code use IviConfigurationServer to configurate the ConfigurationServer. I configure the Hardware Asset (IOResourceDescriptor), Driver Session and SoftwareModule. And i add a logical name. I use the logical name to create a session:
IIviSessionFactoryPtr spSF(
__uuidof(IviSessionFactory));IIviDmmPtr spDmm = spSF->CreateSession(nombre);
The problem is the Software Module. With IVI-COM i have to configurate a ProgID that the application will use to identifies what is the "driver" to use.
I don't know if it ProgID is somthing that the vendor have to pass to me or if there is a Prog ID by class instruments.
i have used an invented ProgID and the results its a exception:
Error description is: IIviSessionFactory: Session CLSID (NI_IDEA) not registered
04-16-2008 08:13 AM
04-16-2008 08:51 AM