|
|
@@ -1,29 +1,21 @@
|
|
|
-using System;
|
|
|
-using System.Collections;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.ComponentModel.DataAnnotations;
|
|
|
-using System.Linq;
|
|
|
-using System.Net.Sockets;
|
|
|
+using System.ComponentModel.DataAnnotations;
|
|
|
using System.Reflection;
|
|
|
using System.Runtime.InteropServices;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Channels;
|
|
|
-using System.Threading.Tasks;
|
|
|
|
|
|
namespace WCS.Core
|
|
|
{
|
|
|
public abstract class ProtocolProxyBase : IProtocolProxy
|
|
|
{
|
|
|
- string Id = Guid.NewGuid().ToString();
|
|
|
+ private string Id = Guid.NewGuid().ToString();
|
|
|
public ProtocolInfo Info { get; private set; }
|
|
|
public ushort BytesCount { get; private set; }
|
|
|
- Dictionary<string, PlcItem> Items = new Dictionary<string, PlcItem>();
|
|
|
- Type ProtocolType, ProtocolDataType;
|
|
|
+ private Dictionary<string, PlcItem> Items = new Dictionary<string, PlcItem>();
|
|
|
+ private Type ProtocolType, ProtocolDataType;
|
|
|
public Device Device { get; private set; }
|
|
|
|
|
|
- DataBlock Db;
|
|
|
+ private DataBlock Db;
|
|
|
|
|
|
- public ProtocolProxyBase(Device dev, ProtocolInfo info,Type protocolType)
|
|
|
+ public ProtocolProxyBase(Device dev, ProtocolInfo info, Type protocolType)
|
|
|
{
|
|
|
this.Device = dev;
|
|
|
this.Info = info;
|
|
|
@@ -31,7 +23,6 @@ namespace WCS.Core
|
|
|
Db.DbChanged += Db_DbChanged;
|
|
|
ProtocolType = protocolType;
|
|
|
|
|
|
-
|
|
|
var bitStart = info.Position * 8;//偏移量,按位算
|
|
|
|
|
|
//this.Start = start;
|
|
|
@@ -71,7 +62,7 @@ namespace WCS.Core
|
|
|
bitStart += modeNum - mod;
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+ #endregion 计算偏移量
|
|
|
|
|
|
byte arrlen = 0;
|
|
|
byte strLen = 0;
|
|
|
@@ -97,7 +88,8 @@ namespace WCS.Core
|
|
|
ProtocolDataType = ProtocolType.Assembly.GetTypes().Where(v => v.IsClass).Where(v => v.GetInterface(ProtocolType.Name) != null && v != this.GetType()).First();
|
|
|
}
|
|
|
|
|
|
- byte[] Data = new byte[0];
|
|
|
+ private byte[] Data = new byte[0];
|
|
|
+
|
|
|
private void Db_DbChanged(byte[] data)
|
|
|
{
|
|
|
var pos = Info.Position - Db.Start;
|
|
|
@@ -112,10 +104,12 @@ namespace WCS.Core
|
|
|
protected abstract void DataChanged();
|
|
|
|
|
|
#region
|
|
|
+
|
|
|
public void AddEvent(string eventName, Delegate delgate)
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
+
|
|
|
public void RemoveEvent(string eventName, Delegate delgate)
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
@@ -131,13 +125,12 @@ namespace WCS.Core
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public T Get<T>(string propertyName)
|
|
|
{
|
|
|
var item = Items[propertyName] as PlcItem<T>;
|
|
|
var res = item.Value;
|
|
|
var channel = Ltc.GetChannel();
|
|
|
- Device.World.OnInternalLog(channel, $"{propertyName}:{res}");
|
|
|
+ Device.World.OnInternalLog(channel, $"{Device.Code}:{propertyName}:{res}");
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@@ -146,8 +139,9 @@ namespace WCS.Core
|
|
|
var item = Items[propertyName] as PlcItem<T>;
|
|
|
item.Value = value;
|
|
|
var channel = Ltc.GetChannel();
|
|
|
- Device.World.OnInternalLog(channel, $"{propertyName}={value}");
|
|
|
+ Device.World.OnInternalLog(channel, $"{Device.Code}:{propertyName}={value}");
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|