Guest User

Untitled

a guest
Jul 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. private void timer_Tick(object sender, EventArgs e)
  2. {
  3. timer.Stop();
  4. for (int i = 0; i < TOTAL_SENSORS; i++)
  5. {
  6. DateTime d = DateTime.Now;
  7. devices[i].Value = float.Parse(serialPort.ReadLine());
  8. if (chart1.Series[i].Points.Count > MAX_POINTS)
  9. {
  10. //see the most recent points
  11. }
  12. chart1.Series[i].Points.AddXY(d, devices[i].Value);
  13. }
  14. timer.Start();
  15. }
  16.  
  17. Dictionary<DateTime, float> points = new Dictionary<DateTime, float>();
  18.  
  19. points.Add(d, devices[i].Value);
  20.  
  21. points.Remove(points.Keys[0]);
  22.  
  23. IEnumerable<KeyValuePair<DateTime, float>> mostRecent = points.Skip(points.Count - 10).Take(10);
  24.  
  25. float value = points[DateTime.Now.AddMinutes(-1)];
  26.  
  27. foreach(KeyValuePair<DateTime, float> point in points)
  28. {
  29. DateTime time = point.Key;
  30. float value = point.Value;
  31. }
Add Comment
Please, Sign In to add comment