using System; using System.Collections; using System.Collections.Generic; namespace CommonLib.LOG { public class RingList : List { private int first; private int last; //private int index; private int validSize; // private T current; public int MaxSize { get { return Capacity; } set { Capacity = value; } } public new void Add(T item) { if(Count< Capacity) { base.Add(item); } else { this[this.last] = item; //this.Clear(); } this.last = (this.last + 1) % Capacity; if (first == last) { first = (first + 1) % Capacity; return; } validSize++; } public T Get(int Index) { int Ptr = (Index + last) % Count; return this[Ptr]; } public void Remove() { if (this.first == this.last) { throw new InvalidOperationException(); } this[first] = default(T); first = (this.first + 1) % Capacity; validSize--; } public new void Clear() { if (this.validSize > 0) { base.Clear(); this.validSize = 0; } } } public enum LogLevel { Error=0, Warning, Trace , DIO, Network, Ports, PLC, MOTOR_Error, Error1, Error2, } }