Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void timer_Tick(object sender, EventArgs e)
- {
- timer.Stop();
- for (int i = 0; i < TOTAL_SENSORS; i++)
- {
- DateTime d = DateTime.Now;
- devices[i].Value = float.Parse(serialPort.ReadLine());
- if (chart1.Series[i].Points.Count > MAX_POINTS)
- {
- //see the most recent points
- }
- chart1.Series[i].Points.AddXY(d, devices[i].Value);
- }
- timer.Start();
- }
- Dictionary<DateTime, float> points = new Dictionary<DateTime, float>();
- points.Add(d, devices[i].Value);
- points.Remove(points.Keys[0]);
- IEnumerable<KeyValuePair<DateTime, float>> mostRecent = points.Skip(points.Count - 10).Take(10);
- float value = points[DateTime.Now.AddMinutes(-1)];
- foreach(KeyValuePair<DateTime, float> point in points)
- {
- DateTime time = point.Key;
- float value = point.Value;
- }
Add Comment
Please, Sign In to add comment