using System; using Aitex.Core.RT.Event; using Aitex.Core.Util; using Aitex.Core.RT.Log; namespace Aitex.Triton160.UI { public class UiEvent { public event Action OnEvent; FixSizeQueue _queue = new FixSizeQueue(300); PeriodicJob _fireJob; public UiEvent() { } public void Start() { if (_fireJob != null) return; _fireJob = new PeriodicJob(1000, this.FireEvent, "UIEvent", true); } public void Stop() { _fireJob.Stop(); } bool FireEvent() { if (OnEvent != null) { EventItem ev; while (_queue.TryDequeue(out ev)) { OnEvent(ev); } } return true; } public void Event(EventItem ev) { LOG.Info(ev.Description); _queue.Enqueue(ev); } public void Event(string message, EventLevel level=EventLevel.Information) { LOG.Info(message); _queue.Enqueue(new EventItem() { OccuringTime = DateTime.Now, Description = message, Id = 0, Level = level, Type = EventType.EventUI_Notify, }); } } }