-
Notifications
You must be signed in to change notification settings - Fork 935
/
EventBuffer.cs
70 lines (60 loc) · 1.59 KB
/
EventBuffer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//------------------------------------------------------------------------------
// <copyright>
// Copyright (c) Microsoft Corporation. All Rights Reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceSimulator
{
public class DataPoint
{
public DataPoint(double val, int eventDeltaMs)
{
this.Value = val;
this.EventDeltaMillisec = eventDeltaMs;
}
public double Value
{
get;
private set;
}
public int EventDeltaMillisec
{
get;
private set;
}
}
public class EventBuffer
{
private List<DataPoint> dataPoints = new List<DataPoint>();
public int Count
{
get
{
return this.dataPoints.Count;
}
}
public void InsertAtStart(DataPoint item)
{
this.dataPoints.Insert(0, item);
}
public void InsertRangeAtStart(IEnumerable<DataPoint> items)
{
this.dataPoints.InsertRange(0, items);
}
public DataPoint Next()
{
var dataPoint = this.dataPoints[0];
this.dataPoints.RemoveAt(0);
return dataPoint;
}
public void Clear()
{
this.dataPoints.Clear();
}
}
}