예제 #1
0
        public void button3_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("还未完成");
            //return;
            try
            {
                string command = "FA0000";
                if (portData == null)
                {
                    MessageBox.Show("还没有打开串口,请先打开串口!");
                    return;
                }
                portData.SendCommand(command);
                //System.Threading.Thread.Sleep(10000);
                this.SerialString = new StringBuilder();
                getCollectorData get = new getCollectorData(this.SerialString);
                if (get.ShowDialog() == DialogResult.Cancel)
                    portData.port.DiscardInBuffer();

            }
            catch(Exception ex)
            {
                MessageBox.Show("获取数据失败" + Environment.NewLine + "错误信息:" + ex.Message);
            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: amedinarcr/fop
        private void 读取数据RToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                string command = "FA0000";
                if (portData == null)
                {
                    MessageBox.Show("串口还未打开,请先打开!");
                    return;
                }
                this.SerialString = new StringBuilder();
                portData.port.DiscardInBuffer();
                portData.SendCommand(command);
                //System.Threading.Thread.Sleep(10000);

                getCollectorData get = new getCollectorData(this.SerialString);
                DialogResult result = get.ShowDialog();
                if (result == DialogResult.Cancel)
                    portData.port.DiscardInBuffer();
                if (result == DialogResult.OK)
                {
                    Program.mainForm.ShowCharting(3, null);
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("获取数据失败" + Environment.NewLine + "错误信息:" + ex.Message);
            }
        }