Instructions

Chapter 4 Programming Demos RIGOL
DSG800 Programming Guide 4-19
ViPFindList findList = new unsigned long;
ViPUInt32 retcnt = new unsigned long;
ViChar instrDesc[1000];
CString strSrc = "";
CString strInstr = "";
unsigned long i = 0;
bool bFindDSG = false;
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS)
{
//Error Initializing VISA...exiting
MessageBox("No VISA instrument was opened ! ");
return ;
}
memset(instrDesc,0,1000);
//Find resource
status = viFindRsrc(defaultRM,expr,findList, retcnt, instrDesc);
for (i = 0;i < (*retcnt);i++)
{
//Get instrument name
strSrc.Format("%s",instrDesc);
InstrWrite(strSrc,"*IDN?");
::Sleep(200);
InstrRead(strSrc,&strInstr);
//If the instrument(resource) belongs to the DSG series then jump out from the loop
strInstr.MakeUpper();
if (strInstr.Find("DSG") >= 0)
{
bFindDSG = true;
m_strInstrAddr = strSrc;
break;
}
//Find next instrument
status = viFindNext(*findList,instrDesc);
}
if (bFindDSG == false)
{
MessageBox("Didn't find any DSG!");
}
UpdateData(false);
}
2) Write operation
void CDSG800_DEMO_VCDlg::OnSend()
{
//TODO: Add your control notification handler code here
UpdateData(true);
if (m_strInstrAddr.IsEmpty())
{
MessageBox("Please connect to the instrument first!");
}