using System; using System.Collections.Generic; namespace EGFramework{ public class EGProtocolSchedule : IEGFramework,IModule { public Dictionary ProtocolTools = new Dictionary(); public void Init() { } public void CheckedProcess() { foreach (IProtocolReceived tool in ProtocolTools.Values) { if (tool.GetReceivedMsg().Count > 0) { bool isDequeue = tool.GetReceivedMsg().TryDequeue(out ResponseMsg msg); if (isDequeue) { this.GetModule().OnDataReceived.Invoke(msg); } } } } public void EnabledAllTools(){ this.EnabledTool(); this.EnabledTool(); this.EnabledTool(); this.EnabledTool(); this.EnabledTool(); } public void EnabledTool() where TProtocolReceived : class, IModule,IProtocolReceived,new(){ if(!ProtocolTools.ContainsKey(typeof(TProtocolReceived))){ ProtocolTools.Add(typeof(TProtocolReceived),this.GetModule()); } } public void DisabledAllTools(){ ProtocolTools.Clear(); } public void DisabledTool() where TProtocolReceived : class, IModule,IProtocolReceived,new(){ if(ProtocolTools.ContainsKey(typeof(TProtocolReceived))){ ProtocolTools.Remove(typeof(TProtocolReceived)); } } public IArchitecture GetArchitecture() { return EGArchitectureImplement.Interface; } } }