using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Timers;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
bool meter_state = false;
double num2;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//serialPort1.Write("meas:freq:st 500 mhz\n");
//serialPort1.Write("*idn?\n");
//string data = serialPort1.ReadTo("\n");
//serialPort1.Write("meas:ocbw on\n");
//serialPort1.Write("meas:ocbw:chpw?\n");
//string data = serialPort1.ReadTo("\n");
//if ((data != null) && (data[0] !='<'))
//{
// num2 = Convert.ToDouble(data);
// textBox1.AppendText(Convert.ToString(num2));
//}
//serialPort1.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
//serialPort1.Open();
}
private void button3_Click(object sender, EventArgs e)
{
serialPort1.Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
serialPort1.Open();
serialPort1.Write("meas:ocbw on\n");
serialPort1.Write("meas:ocbw:chpw?\n");
string data = serialPort1.ReadTo("\n");
if ((data != null) && (data[0] !='<'))
{
num2 = Convert.ToDouble(data);
textBox1.AppendText(Convert.ToString(num2));
}
serialPort1.Close();
}
private void button4_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
textBox2.Clear();
textBox2.AppendText("clock dissabled");
}
private void button5_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
textBox2.Clear();
textBox2.AppendText("clock enabled");
}
}
}