private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string c = serialPort1.ReadLine(); System.Diagnostics.Debug.WriteLine("RECEIVE " + c);//可以在调试里看到串口收到的数据 if (c.Length < 2) { return; } ReceiveMessage(new MESSAGE(c)); if (page) { No.Text = index.ToString(); show_index = index; mydata[index++] = new MYDATA(NAME.Text, Concentration.Text, BAC.Text, Temperature.Text, Humidity.Text, year.Text, month.Text, day.Text, minute.Text, second.Text); if (index > 99) { index = 0; } page = false; Form1_Load(sender, e); } float BAC1, Num1, BAC2, Num2, data1, data2; if (show_index > 1) { data1 = float.Parse(mydata[show_index - 1].BASData); // data1 = TestData[index-1]; BAC1 = 220 - data1 * 200; Num1 = show_index * 10; data2 = float.Parse(mydata[show_index].BASData); // data2 = TestData[index]; BAC2 = 220 - data2 * 200; Num2 = (show_index + 1) * 10; wava.points.Add(new RectangleF(Num1, BAC1, Num2, BAC2)); // InitializeComponent(); // wava1.wava_DrawPoint(BAC1, Num1, BAC2, Num2);. this.Refresh(); } }
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string c = serialPort1.ReadLine(); System.Diagnostics.Debug.WriteLine("RECEIVE " + c);//可以在调试里看到串口收到的数据 if (c.Length < 2) { return; } ReceiveMessage(new MESSAGE(c)); if (page) { show_index = index; mydata[index++] = new MYDATA(NO.Text, Concentration.Text, BAC.Text, Temperature.Text, Humidity.Text); if (index > 99) { index = 0; } page = false; Form1_Load(sender, e); } }