Guest User

Untitled

a guest
Nov 19th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. private void ReceiveThread()
  2. {
  3. while (true)
  4. {
  5. runThread.WaitOne(Timeout.Infinite);
  6. while (true)
  7. {
  8. try
  9. {
  10. string msg = serialPort.ReadLine();
  11. this.Invoke(this.m_DelegateAddToList, new Object[] { msg });
  12. }
  13. catch
  14. {
  15. runThread.Reset();
  16. break;
  17. }
  18. }
  19. }
  20. }
  21.  
  22. private void AddToList(string msg)
  23. {
  24.  
  25. string[] words = msg.Split(' ');
  26. foreach (string word in words)
  27. {
  28.  
  29. txtid.Text = words[0];
  30.  
  31. if (txtid.Text == "NH1" && words.Length == 3)
  32. {
  33. txtInput.Text = words[1];
  34. txtSR.Text = words[2];
  35.  
  36. }
  37.  
  38. }
  39.  
  40. //draw grafick
  41. if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
  42. return;
  43. LineItem curve1 = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
  44. curve1.Line.Width = 1.25F;
  45. if (curve1 == null)
  46. return;
  47. // Get the PointPairList
  48. IPointListEdit list1 = curve1.Points as IPointListEdit;
  49. if (list1 == null)
  50. return;
  51. double d;
  52. double.TryParse(words[1], out d);
  53. list1.Add(timedt, d);
  54. zedGraphControl1.AxisChange();
  55. // Force a redraw
  56. zedGraphControl1.Invalidate();
  57. timedt++;
  58. }
  59.  
  60. if (serialPort.IsOpen == true)
  61. {
  62. //tutup koneksi ke database
  63. //cs.Close();
  64. runThread.Reset();
  65.  
  66. cmdBaudRate.Enabled = true;
  67. cmdSerial.Enabled = true;
  68. serialPort.Close();
  69.  
  70. }
Add Comment
Please, Sign In to add comment