Specifications

Chapter 4 Programming Demos RIGOL
M300 Programming Guide 4-29
strReturn = Encoding.ASCII.GetString(temp);
if (strReturn.IndexOf('\n') != -1)
{
strReturn = strReturn.Substring(0, strReturn.IndexOf('\n'));
}
else
{ }
return strReturn;
}
6. Add the Click event of the button controls.
1) Connect the instrument.
//Define the Global Variables of visa
byte[] g_bpRsrcName; //Resource name byte array
Int32 g_i32RsrcManager; //Resource manager identifier
Int32 g_i32VisaIO; //Dialogue channel
string g_strCurrentDevice; //Current device VISA Address
public string[] DevResource = new string[10]; //Used to store Device resources
public string DevInfoReturn = ""; //The returned device information
private void btnConnect_Click(object sender, EventArgs e)
{
string[] CMD_SYST_INFO ={"SYST:CTYP? 100", "SYST:CTYP? 200", "SYST:CTYP? 300",
"SYST:CTYP? 400", "SYST:CTYP? 500" };
string[] strCMDReturn = new string[6];
Int32 intFuncReturn = 0;
string strSlotTemp = "";
string strTemp = "";
string CurrentDeviceM300 = "";
g_bpRsrcName = new byte[200];
Int32 fList = 0;
Int32 DeviceNum = 0;
Int32 retCount = 0;
// Find Device
viOpenDefaultRM(ref g_i32RsrcManager);
retCount = viFindRsrc(g_i32RsrcManager, "?*", ref fList, ref DeviceNum,
g_bpRsrcName);
if (DeviceNum > 0)
{
for (int i = 0; i < DeviceNum; i++)
{
strTemp = Encoding.ASCII.GetString(g_bpRsrcName);
g_strCurrentDevice = strTemp.Substring(0, strTemp.IndexOf('\0'));
DevResource[i] = g_strCurrentDevice;
retCount = viFindNext(fList, g_bpRsrcName);
if (retCount >= 0)
{
i++;
strTemp = Encoding.ASCII.GetString(g_bpRsrcName);
g_strCurrentDevice = strTemp.Substring(0, strTemp.IndexOf('\0'));
DevResource[i] = g_strCurrentDevice;
}
}
}
else
{