Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void ReceiveThread()
- {
- while (true)
- {
- runThread.WaitOne(Timeout.Infinite);
- while (true)
- {
- try
- {
- string msg = serialPort.ReadLine();
- this.Invoke(this.m_DelegateAddToList, new Object[] { msg });
- }
- catch
- {
- runThread.Reset();
- break;
- }
- }
- }
- }
- private void AddToList(string msg)
- {
- string[] words = msg.Split(' ');
- foreach (string word in words)
- {
- txtid.Text = words[0];
- if (txtid.Text == "NH1" && words.Length == 3)
- {
- txtInput.Text = words[1];
- txtSR.Text = words[2];
- }
- }
- //draw grafick
- if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
- return;
- LineItem curve1 = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
- curve1.Line.Width = 1.25F;
- if (curve1 == null)
- return;
- // Get the PointPairList
- IPointListEdit list1 = curve1.Points as IPointListEdit;
- if (list1 == null)
- return;
- double d;
- double.TryParse(words[1], out d);
- list1.Add(timedt, d);
- zedGraphControl1.AxisChange();
- // Force a redraw
- zedGraphControl1.Invalidate();
- timedt++;
- }
- if (serialPort.IsOpen == true)
- {
- //tutup koneksi ke database
- //cs.Close();
- runThread.Reset();
- cmdBaudRate.Enabled = true;
- cmdSerial.Enabled = true;
- serialPort.Close();
- }
Add Comment
Please, Sign In to add comment