Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using ZedGraph;
  11.  
  12.  
  13. namespace ecg_display_elg
  14. {
  15.  
  16. public partial class Form1 : Form
  17. {
  18. int counter;
  19. List<int> listim = new List<int>();
  20.  
  21. public Form1()
  22. {
  23. InitializeComponent();
  24.  
  25. }
  26.  
  27. private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  28. {
  29. egserialPort.Close();
  30. }
  31.  
  32. string rxString;
  33. int numVal = -1;
  34. int[] myData;
  35.  
  36. private void egserialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
  37. {
  38. rxString = egserialPort.ReadExisting();
  39. this.Invoke(new EventHandler(displayText));
  40. this.Invoke(new EventHandler(Form1_Load));
  41. bool result = Int32.TryParse(rxString, out numVal);
  42. listim.Add(numVal);
  43. }
  44.  
  45. private void displayText(object o, EventArgs e)
  46. {
  47. thRx.AppendText(rxString);
  48. }
  49.  
  50. private void thRx_TextChanged(object sender, EventArgs e)
  51. {
  52.  
  53. }
  54.  
  55.  
  56. private void button1_Click(object sender, EventArgs e)
  57. {
  58. if (!egserialPort.IsOpen)
  59. {
  60. egserialPort.Open();
  61. thRx.Text = "serialPort is Open :-)";
  62. }
  63. else
  64. thRx.Text = "serialPort is Busy -:( ";
  65.  
  66. }
  67.  
  68. private void button2_Click(object sender, EventArgs e)
  69. {
  70. this.Close();
  71. }
  72.  
  73. private void Form1_Load( object sender, EventArgs e )
  74. {
  75.  
  76. int i;
  77.  
  78.  
  79. GraphPane pane = zedGraphControl1.GraphPane;
  80. pane.CurveList.Clear();
  81. RollingPointPairList list = new RollingPointPairList(1200);
  82.  
  83. for (i = 0; i < listim.Count; i++) // Loop through List with for
  84. {
  85. Console.WriteLine(listim[i]);
  86. list.Add(i, listim[i]);
  87. }
  88.  
  89.  
  90.  
  91. LineItem myCurve = pane.AddCurve("Voltage", list, Color.Blue, SymbolType.Circle);
  92. myCurve.Line.IsVisible = true;
  93. myCurve.Symbol.Fill.Color = Color.Blue;
  94. myCurve.Symbol.Fill.Type = FillType.Solid;
  95. myCurve.Symbol.Size = 10;
  96.  
  97. pane.XAxis.Scale.Min = 0;
  98. pane.XAxis.Scale.Max = 30;
  99.  
  100.  
  101. zedGraphControl1.AxisChange();
  102.  
  103. Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;
  104. if (i > xScale.Max - xScale.MajorStep)
  105. {
  106. xScale.Max = i + xScale.MajorStep;
  107. xScale.Min = xScale.Max - 30.0;
  108. }
  109.  
  110.  
  111. zedGraphControl1.Invalidate();
  112.  
  113.  
  114.  
  115.  
  116. }
  117.  
  118. private void zedGraphControl1_Load(object sender, EventArgs e)
  119. {
  120.  
  121. }
  122.  
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement