User manual

RIGOL Chapter 4 Programming Examples
4-8 DP700 Programming Guide
{
MessageBox.Show("No Available Serial Port Found!") ;
}
}
4. Click "Open Power" to add the following program.
/// <summary>
/// Turn on the power output
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_Click(object sender, EventArgs e)
{
//Turn on/off the output
if (bOpen)
{
bOpen = false;
serialPort.Write(":OUTPut:STATe CH1,OFF\n");
button.Text = "Open Power";
}
else
{
bOpen = true;
serialPort.Write(":OUTPut:STATe CH1,ON\n");
button.Text = "Close Power";
}
}
5. Double-click the window to enter the programming environment and add the following codes.
/// <summary>
/// Open the serial port
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
if (serialPort.IsOpen)
{
serialPort.Close();
}
try
{
serialPort.PortName = comBox.Text.Trim(); //Serial Port
serialPort.BaudRate = int.Parse(baudBox.Text); //Baud Rate
serialPort.DataBits = int.Parse(dataBox.Text); //Data Bits
}
catch (Exception)
{
MessageBox.Show("Error!");
}
//Initialize the stop bits
float fstopValue = Convert.ToSingle(stopBox.Text.Trim());
if (fstopValue == 0)
{
serialPort.StopBits = StopBits.None;
}
else if (fstopValue == 1)
{