using WCS.Core; using WCS.Entity.Protocol.DataStructure; using WCS.WorkEngineering.Worlds; namespace WCS.WorkEngineering; public class ProtocolProxy : ProtocolProxyBase { public ProtocolProxy(Device dev, ProtocolInfo info, Type protocolType, World world) : base(dev, info, protocolType,world) { } public static DeviceDataPack DataPack { get; set; } = new(); protected override void DataChanged() { MainWorld.DataQueue.Enqueue(this); } private Type GetProtocolType(Type source) { var t = source.GetInterfaces().FirstOrDefault(v => v.GetInterfaces().Any(d => d.Name == "IProtocol")); return t; } public object DictionaryToEntity(Type type, Dictionary items) { var a = Activator.CreateInstance(type); foreach (var ty in type.GetProperties()) foreach (var item in items.Where(item => ty.Name == item.Key)) { ty.SetValue(a, item.Value.Value); break; } return a; } public string GetString(string value) { return value.Replace("INSERT INTO ", "") .Replace(",N'", ",'") .Replace("\0", "") .Replace("wcs_", "") .Replace("(N'", "('") + "\r"; } }