2 using System.ComponentModel;
3 using System.Xml.Serialization;
6 namespace DirectOutput.Table
18 #region TableElementType
25 get {
return _TableElementType; }
28 if (_TableElementType != value)
30 _TableElementType = value;
38 private int _Number = 0;
44 get {
return _Number; }
59 private string _Name =
"";
72 if (NameChanged != null)
74 NameChanged(
this,
new EventArgs());
87 private int _Value =
int.MinValue;
95 get {
return _Value; }
101 StorePastValue(value);
103 if (ValueChanged != null)
112 const int PastValuesCount=100;
113 private int[] PastValues =
new int[PastValuesCount];
114 private DateTime[] PastValueTimestamp =
new DateTime[PastValuesCount];
115 private int PastValuesPosition = 0;
117 private void StorePastValue(
int Value)
119 PastValuesPosition++;
120 if (PastValuesPosition >= PastValuesCount) { PastValuesPosition = 0; }
122 PastValues[PastValuesPosition] = Value;
123 PastValueTimestamp[PastValuesPosition] = DateTime.Now;
133 public bool ValueHasBeen(
int Value,
int DuringLastMilliseconds)
135 DateTime EarliestTime = DateTime.Now.AddMilliseconds(-DuringLastMilliseconds);
137 int P = PastValuesPosition;
140 while (PastValueTimestamp[P] > EarliestTime && Cnt < PastValuesCount)
142 if (PastValues[P] == Value) {
return true; }
144 if (P < 0) { P = PastValuesCount - 1; }
155 public bool ValueHasChanged(
int DuringLastMilliseconds)
157 DateTime EarliestTime = DateTime.Now.AddMilliseconds(-DuringLastMilliseconds);
159 if (PastValueTimestamp[PastValuesPosition] >= EarliestTime)
return true;
168 public event EventHandler<TableElementValueChangedEventArgs>
ValueChanged;
174 AssignedEffects.Trigger(GetTableElementData());
187 get {
return _TableElementEffectList; }
190 _TableElementEffectList = value;
212 ValueChanged +=
new EventHandler<TableElementValueChangedEventArgs>(TableElement_ValueChanged);
225 this.TableElementType = TableElementType;
226 this.Number = Number;