Jelajahi Sumber

整理命名空间

林豪 左 2 tahun lalu
induk
melakukan
c8deac4295
100 mengubah file dengan 638 tambahan dan 650 penghapusan
  1. 23 23
      PLC.Siemens/Communication/IsoSocket.cs
  2. 5 6
      PLC.Siemens/Core/Common/Argument.cs
  3. 3 4
      PLC.Siemens/Core/Common/Constants.cs
  4. 13 7
      PLC.Siemens/Core/Common/DefaultConvert.cs
  5. 16 6
      PLC.Siemens/Core/Common/DelegateFactory.cs
  6. 2 2
      PLC.Siemens/Core/Common/FlowControlUtil.cs
  7. 3 2
      PLC.Siemens/Core/Common/IControlAble.cs
  8. 2 6
      PLC.Siemens/Core/Common/IDisposableEx.cs
  9. 13 14
      PLC.Siemens/Core/Common/ModelHandler.cs
  10. 9 6
      PLC.Siemens/Core/Common/ObjectId.cs
  11. 4 5
      PLC.Siemens/Core/Common/Rand.cs
  12. 4 5
      PLC.Siemens/Core/Common/SingleBase.cs
  13. 2 4
      PLC.Siemens/Core/Common/SystemTime.cs
  14. 3 5
      PLC.Siemens/Core/Extension/ArrayExtension.cs
  15. 1 1
      PLC.Siemens/Core/Extension/BitExtension.cs
  16. 10 12
      PLC.Siemens/Core/Extension/ByteExtenstion.cs
  17. 12 15
      PLC.Siemens/Core/Extension/CollectionExtension.cs
  18. 4 4
      PLC.Siemens/Core/Extension/DateTimeExtension.cs
  19. 5 7
      PLC.Siemens/Core/Extension/EncodingHelper.cs
  20. 1 6
      PLC.Siemens/Core/Extension/EnumExtension.cs
  21. 2 5
      PLC.Siemens/Core/Extension/GuidExtension.cs
  22. 3 7
      PLC.Siemens/Core/Extension/IEnumerableExtensions.cs
  23. 5 8
      PLC.Siemens/Core/Extension/ObjectExtension.cs
  24. 5 5
      PLC.Siemens/Core/Extension/ReaderWriterLockSlimExtensions.cs
  25. 2 2
      PLC.Siemens/Core/Extension/StringBuilderExtension.cs
  26. 42 45
      PLC.Siemens/Core/Extension/StringHelper.cs
  27. 2 6
      PLC.Siemens/Core/Extension/TypeExtension.cs
  28. 14 15
      PLC.Siemens/O/ByteBuffer.cs
  29. 3 3
      PLC.Siemens/O/HelperFunction.cs
  30. 3 4
      PLC.Siemens/O/IBuildRequest.cs
  31. 2 4
      PLC.Siemens/O/IBuildResponse.cs
  32. 3 3
      PLC.Siemens/O/IIsoSender.cs
  33. 2 2
      PLC.Siemens/O/MessageEvent.cs
  34. 2 4
      PLC.Siemens/O/RequestHandle.cs
  35. 2 5
      PLC.Siemens/O/ResponseHandle.cs
  36. 43 48
      PLC.Siemens/O/SimenssPlc.cs
  37. 2 2
      PLC.Siemens/O/StaticConst.cs
  38. 0 0
      PLC.Siemens/PlcSiemens.csproj
  39. 7 2
      PLC.Siemens/Protocol/Common/AreaType.cs
  40. 3 2
      PLC.Siemens/Protocol/Common/CodeControl.cs
  41. 5 6
      PLC.Siemens/Protocol/Common/CodeError.cs
  42. 7 3
      PLC.Siemens/Protocol/Common/ConnectionType.cs
  43. 1 1
      PLC.Siemens/Protocol/Common/DataType.cs
  44. 3 3
      PLC.Siemens/Protocol/Common/ErrorType.cs
  45. 1 1
      PLC.Siemens/Protocol/Common/GrType.cs
  46. 5 3
      PLC.Siemens/Protocol/Common/PduFuncType.cs
  47. 2 2
      PLC.Siemens/Protocol/Common/PduKind.cs
  48. 9 5
      PLC.Siemens/Protocol/Common/PduType.cs
  49. 2 2
      PLC.Siemens/Protocol/Common/S7CpuStatus.cs
  50. 2 2
      PLC.Siemens/Protocol/Common/S7OpType.cs
  51. 2 2
      PLC.Siemens/Protocol/Common/TsType.cs
  52. 7 6
      PLC.Siemens/Protocol/Control/CompressParamsRequest.cs
  53. 6 7
      PLC.Siemens/Protocol/Control/CompressRequest.cs
  54. 6 6
      PLC.Siemens/Protocol/Control/CopyRamToRomParamsRequest.cs
  55. 7 8
      PLC.Siemens/Protocol/Control/CopyRamToRomRequest.cs
  56. 6 6
      PLC.Siemens/Protocol/Control/PlcColdStartParamsRequest.cs
  57. 6 7
      PLC.Siemens/Protocol/Control/PlcColdStartRequest.cs
  58. 8 6
      PLC.Siemens/Protocol/Control/PlcHotStartParamsRequest.cs
  59. 6 7
      PLC.Siemens/Protocol/Control/PlcHotStartRequest.cs
  60. 12 10
      PLC.Siemens/Protocol/Control/PlcStopParamsRequest.cs
  61. 6 7
      PLC.Siemens/Protocol/Control/PlcStopRequest.cs
  62. 5 5
      PLC.Siemens/Protocol/DateTime/ControlResponse.cs
  63. 11 7
      PLC.Siemens/Protocol/DateTime/DateTimeData.cs
  64. 4 4
      PLC.Siemens/Protocol/DateTime/FunCtrlResponse.cs
  65. 6 7
      PLC.Siemens/Protocol/DateTime/GetDateTimeRequest.cs
  66. 5 8
      PLC.Siemens/Protocol/DateTime/GetDateTimeResponse.cs
  67. 3 3
      PLC.Siemens/Protocol/DateTime/HandleRequest.cs
  68. 5 6
      PLC.Siemens/Protocol/DateTime/HandleResponse.cs
  69. 6 7
      PLC.Siemens/Protocol/DateTime/SetDateTimeRequest.cs
  70. 6 4
      PLC.Siemens/Protocol/Header/CotpDataHeader.cs
  71. 9 4
      PLC.Siemens/Protocol/Header/CotpHeader.cs
  72. 8 5
      PLC.Siemens/Protocol/Header/HeaderPacket.cs
  73. 4 4
      PLC.Siemens/Protocol/Header/HeaderPacketWithErrorCode.cs
  74. 6 3
      PLC.Siemens/Protocol/Header/TpktHeader.cs
  75. 4 4
      PLC.Siemens/Protocol/Iso/CoptParams.cs
  76. 16 10
      PLC.Siemens/Protocol/Iso/IsoControlPdu.cs
  77. 6 8
      PLC.Siemens/Protocol/Iso/IsoDataPdu.cs
  78. 4 4
      PLC.Siemens/Protocol/ListBlocks/BlockItem.cs
  79. 5 5
      PLC.Siemens/Protocol/ListBlocks/BlockItemListAll.cs
  80. 4 4
      PLC.Siemens/Protocol/ListBlocks/BotItem.cs
  81. 4 4
      PLC.Siemens/Protocol/ListBlocks/BotItemListAll.cs
  82. 6 5
      PLC.Siemens/Protocol/ListBlocks/DataBlockInfoDataRequest.cs
  83. 7 7
      PLC.Siemens/Protocol/ListBlocks/DataBlockInfoDataResponse.cs
  84. 7 8
      PLC.Siemens/Protocol/ListBlocks/DataBlockInfoRequest.cs
  85. 9 11
      PLC.Siemens/Protocol/ListBlocks/DataBlockInfoResponse.cs
  86. 6 5
      PLC.Siemens/Protocol/ListBlocks/DataBlockOfTypeDataRequest.cs
  87. 8 9
      PLC.Siemens/Protocol/ListBlocks/DataBlockOfTypeRequest.cs
  88. 6 7
      PLC.Siemens/Protocol/ListBlocks/DataBlockOfTypeResponse.cs
  89. 6 7
      PLC.Siemens/Protocol/ListBlocks/ListBlocksRequest.cs
  90. 9 10
      PLC.Siemens/Protocol/ListBlocks/ListBlocksResponse.cs
  91. 5 7
      PLC.Siemens/Protocol/Negotiate/NegotiateRequest.cs
  92. 5 6
      PLC.Siemens/Protocol/Negotiate/NegotiateRequestParams.cs
  93. 5 6
      PLC.Siemens/Protocol/Negotiate/NegotiateResponse.cs
  94. 4 4
      PLC.Siemens/Protocol/Negotiate/NegotiateResponseParams.cs
  95. 10 10
      PLC.Siemens/Protocol/ParamsRequest.cs
  96. 5 5
      PLC.Siemens/Protocol/ParamsResponse.cs
  97. 6 6
      PLC.Siemens/Protocol/ReadData/DataItem.cs
  98. 1 1
      PLC.Siemens/Protocol/ReadData/ReadItemRequest.cs
  99. 5 5
      PLC.Siemens/Protocol/ReadData/ReadItemResponse.cs
  100. 16 13
      PLC.Siemens/Protocol/ReadData/ReadParamsRequest.cs

+ 23 - 23
PLC.Siemens/Communication/IsoSocket.cs

@@ -1,20 +1,18 @@
-using System;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Iso;
 using System.Net;
 using System.Net.Sockets;
-using System.Threading;
-using PLC.Siemens.Protocol.Iso;
-using ByteBuffer = Core.Communication.Transport.ByteBuffer;
-using PLC.Siemens.O;
+using ByteBuffer = PlcSiemens.O.ByteBuffer;
 
-namespace PLC.Siemens.Communication
+namespace PlcSiemens.Communication
 {
     /// <summary>
     /// 采用同步通信机制
     /// </summary>
     public class IsoSocket : IIsoSender
-    { 
-
+    {
         private Socket _socket;
+
         public bool Connected
         {
             get
@@ -34,7 +32,6 @@ namespace PLC.Siemens.Communication
             }
         }
 
-
         private Action<MessageEvent> _messageAction;
 
         public void RegisterMessage(Action<MessageEvent> messageAction)
@@ -51,7 +48,8 @@ namespace PLC.Siemens.Communication
 
         private int _connecting;//连接中
 
-        bool conneted = false;
+        private bool conneted = false;
+
         public bool Connect(string ip, int port)
         {
             try
@@ -72,7 +70,7 @@ namespace PLC.Siemens.Communication
                 timeoutObject.Reset();
                 _socket.BeginConnect(server, new AsyncCallback(Callback), _socket);
                 if (!timeoutObject.WaitOne(1000))
-                { 
+                {
                     _socket.Close();
                     conneted = false;
                 }
@@ -88,8 +86,10 @@ namespace PLC.Siemens.Communication
                 Interlocked.CompareExchange(ref _connecting, 0, 1);
             }
         }
-        ManualResetEvent timeoutObject = new ManualResetEvent(false);
-        void Callback(IAsyncResult result)
+
+        private ManualResetEvent timeoutObject = new ManualResetEvent(false);
+
+        private void Callback(IAsyncResult result)
         {
             try
             {
@@ -100,7 +100,7 @@ namespace PLC.Siemens.Communication
                     conneted = true;
                 }
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
                 conneted = false;
             }
@@ -127,6 +127,7 @@ namespace PLC.Siemens.Communication
         }
 
         private int _sending;//发送中
+
         public byte[] SendRecive(byte[] sendBytes, int length)
         {
             try
@@ -166,14 +167,14 @@ namespace PLC.Siemens.Communication
                 Interlocked.CompareExchange(ref _sending, 0, 1);
             }
         }
-        
+
         private TResponse GetResponse<TResponse>(byte[] resBytes, bool isContainHeader = true)
             where TResponse : IBuildResponse, new()
         {
-            ByteBuffer buffer= ByteBuffer.Allocate();
+            ByteBuffer buffer = ByteBuffer.Allocate();
             buffer.Push(resBytes);
 
-            if(isContainHeader)
+            if (isContainHeader)
             {
                 IsoDataPdu pdu = new IsoDataPdu();
                 pdu.Build(buffer);
@@ -188,16 +189,16 @@ namespace PLC.Siemens.Communication
             return response;
         }
 
-        private ByteBuffer GetByteBuffer<TRequest>(TRequest request, bool isContainHeader=true)
+        private ByteBuffer GetByteBuffer<TRequest>(TRequest request, bool isContainHeader = true)
             where TRequest : IBuildRequest, new()
         {
-            if(request==null) throw  new ArgumentNullException("request");
+            if (request == null) throw new ArgumentNullException("request");
 
             request.Build();
             var bufferData = request.GetBuffer();
             ByteBuffer buffer = ByteBuffer.Allocate();
 
-            if(isContainHeader)
+            if (isContainHeader)
             {
                 //构建ISO头部
                 IsoDataPdu pdu = new IsoDataPdu { Length = (ushort)bufferData.WriteIndex };
@@ -224,7 +225,6 @@ namespace PLC.Siemens.Communication
 
             if (resByte == null || resByte.Length == 0) return default(TResponse);
 
-
             return GetResponse<TResponse>(resByte, false);
         }
 
@@ -238,9 +238,9 @@ namespace PLC.Siemens.Communication
         public TResponse IsoSend<TRequest, TResponse>(TRequest request) where TRequest : IBuildRequest, new() where TResponse : IBuildResponse, new()
         {
             var buffer = GetByteBuffer(request);
- 
+
             var resByte = SendRecive(buffer.Buffer, buffer.WriteIndex);
-         
+
             if (resByte == null)
                 return default(TResponse);
 

+ 5 - 6
PLC.Siemens/Core/Common/Argument.cs

@@ -1,15 +1,12 @@
-using System;
-using System.Collections.Generic;
-using Core.Util.Extension;
+using PlcSiemens.Core.Extension;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     /// <summary>
     /// 参数检查
     /// </summary>
     public static class Argument
     {
-        
         /// <summary>
         /// 非法Guid
         /// </summary>
@@ -267,6 +264,7 @@ namespace Core.Util.Common
                 throw new ArgumentOutOfRangeException(argumentName);
             }
         }
+
         /// <summary>
         /// 检查ICollection不为空
         /// </summary>
@@ -319,6 +317,7 @@ namespace Core.Util.Common
                     argumentName);
             }
         }
+
         /// <summary>
         /// 非法Web地址
         /// </summary>
@@ -336,4 +335,4 @@ namespace Core.Util.Common
             }
         }
     }
-}
+}

+ 3 - 4
PLC.Siemens/Core/Common/Constants.cs

@@ -1,13 +1,12 @@
-using System;
 using System.Globalization;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     //获取表示当前线程使用的区域性的 System.Globalization.CultureInfo。
     public static class Constants
     {
-        
         public static readonly DateTime ProductionDate = new DateTime(2008, 1, 11);
+
         //获取表示当前线程使用的区域性的 System.Globalization.CultureInfo。
         public static CultureInfo CurrentCulture
         {
@@ -17,4 +16,4 @@ namespace Core.Util.Common
             }
         }
     }
-}
+}

+ 13 - 7
PLC.Siemens/Core/Common/DefaultConvert.cs

@@ -1,8 +1,7 @@
-using System;
 using System.Globalization;
 using System.Text;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     /// <summary>
     /// 一些转换功能
@@ -41,10 +40,13 @@ namespace Core.Util.Common
                 {
                     case 1:
                         return buf[0];
+
                     case 2:
                         return BitConverter.ToInt16(buf, 0);
+
                     case 3:
-                        return BitConverter.ToInt32(new byte[] {buf[0], buf[1], buf[2], 0}, 0);
+                        return BitConverter.ToInt32(new byte[] { buf[0], buf[1], buf[2], 0 }, 0);
+
                     case 4:
                         return BitConverter.ToInt32(buf, 0);
                 }
@@ -92,12 +94,16 @@ namespace Core.Util.Common
                 {
                     case 1:
                         return buf[0];
+
                     case 2:
                         return BitConverter.ToInt16(buf, 0);
+
                     case 3:
-                        return BitConverter.ToInt32(new byte[] {buf[0], buf[1], buf[2], 0}, 0);
+                        return BitConverter.ToInt32(new byte[] { buf[0], buf[1], buf[2], 0 }, 0);
+
                     case 4:
                         return BitConverter.ToInt32(buf, 0);
+
                     default:
                         // 凑够8字节
                         if (buf.Length < 8)
@@ -206,9 +212,9 @@ namespace Core.Util.Common
             {
                 // 全角空格
                 if (ch[i] == 0x3000)
-                    ch[i] = (char) 0x20;
+                    ch[i] = (char)0x20;
                 else if (ch[i] > 0xFF00 && ch[i] < 0xFF5F)
-                    ch[i] = (char) (ch[i] - 0xFEE0);
+                    ch[i] = (char)(ch[i] - 0xFEE0);
             }
             return new string(ch);
         }
@@ -259,4 +265,4 @@ namespace Core.Util.Common
             return value.ToString(format);
         }
     }
-}
+}

+ 16 - 6
PLC.Siemens/Core/Common/DelegateFactory.cs

@@ -1,9 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
+using System.Reflection;
 using System.Reflection.Emit;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     /// <summary>A dynamic delegate factory.
     /// </summary>
@@ -54,7 +52,7 @@ namespace Core.Util.Common
             return dynamicMethod.CreateDelegate(typeof(D)) as D;
         }
 
-        class DynamicEmit
+        private class DynamicEmit
         {
             private ILGenerator _ilGenerator;
             private static readonly Dictionary<Type, OpCode> _converts = new Dictionary<Type, OpCode>();
@@ -74,10 +72,12 @@ namespace Core.Util.Common
                 _converts.Add(typeof(bool), OpCodes.Conv_I1);
                 _converts.Add(typeof(char), OpCodes.Conv_U2);
             }
+
             public DynamicEmit(DynamicMethod dynamicMethod)
             {
                 this._ilGenerator = dynamicMethod.GetILGenerator();
             }
+
             public DynamicEmit(ILGenerator ilGen)
             {
                 this._ilGenerator = ilGen;
@@ -90,15 +90,19 @@ namespace Core.Util.Common
                     case 0:
                         this._ilGenerator.Emit(OpCodes.Ldarg_0);
                         break;
+
                     case 1:
                         this._ilGenerator.Emit(OpCodes.Ldarg_1);
                         break;
+
                     case 2:
                         this._ilGenerator.Emit(OpCodes.Ldarg_2);
                         break;
+
                     case 3:
                         this._ilGenerator.Emit(OpCodes.Ldarg_3);
                         break;
+
                     default:
                         if (argumentIndex < 0x100)
                         {
@@ -111,6 +115,7 @@ namespace Core.Util.Common
                         break;
                 }
             }
+
             public void CastTo(Type fromType, Type toType)
             {
                 if (fromType != toType)
@@ -137,6 +142,7 @@ namespace Core.Util.Common
                     }
                 }
             }
+
             public void CastTo(Type toType)
             {
                 if (toType.IsValueType)
@@ -148,18 +154,22 @@ namespace Core.Util.Common
                     this._ilGenerator.Emit(OpCodes.Castclass, toType);
                 }
             }
+
             public void Pop()
             {
                 this._ilGenerator.Emit(OpCodes.Pop);
             }
+
             public void Convert(Type toType)
             {
                 this._ilGenerator.Emit(_converts[toType]);
             }
+
             public void Return()
             {
                 this._ilGenerator.Emit(OpCodes.Ret);
             }
+
             public void Call(MethodInfo method)
             {
                 if (method.IsFinal || !method.IsVirtual)
@@ -173,4 +183,4 @@ namespace Core.Util.Common
             }
         }
     }
-}
+}

+ 2 - 2
PLC.Siemens/Core/Common/FlowControlUtil.cs

@@ -1,4 +1,4 @@
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     public static class FlowControlUtil
     {
@@ -22,4 +22,4 @@
             return waitMilliseconds;
         }
     }
-}
+}

+ 3 - 2
PLC.Siemens/Core/Common/IControlAble.cs

@@ -1,4 +1,4 @@
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     public interface IControlAble
     {
@@ -6,9 +6,10 @@
         /// 启动控制
         /// </summary>
         void Start();
+
         /// <summary>
         /// 停止控制
         /// </summary>
         void Stop();
     }
-}
+}

+ 2 - 6
PLC.Siemens/Core/Common/IDisposableEx.cs

@@ -1,10 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Xml.Serialization;
+using System.Xml.Serialization;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     public interface IDisposableEx : IDisposable
     {

+ 13 - 14
PLC.Siemens/Core/Common/ModelHandler.cs

@@ -1,8 +1,7 @@
-using System.Collections.Generic;
-using System.Data;
+using System.Data;
 using System.Reflection;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     /// <summary>
     /// DataTable与实体类互相转换
@@ -29,9 +28,9 @@ namespace Core.Util.Common
             }
         }
 
-        /// <summary>  
+        /// <summary>
         /// 填充对象列表:用DataSet的第index个表填充实体类
-        /// </summary>  
+        /// </summary>
         public List<T> FillModel(DataSet ds, int index)
         {
             if (ds == null || ds.Tables.Count <= index || ds.Tables[index].Rows.Count == 0)
@@ -44,9 +43,9 @@ namespace Core.Util.Common
             }
         }
 
-        /// <summary>  
+        /// <summary>
         /// 填充对象列表:用DataTable填充实体类
-        /// </summary>  
+        /// </summary>
         public List<T> FillModel(DataTable dt)
         {
             if (dt == null || dt.Rows.Count == 0)
@@ -56,7 +55,7 @@ namespace Core.Util.Common
             List<T> modelList = new List<T>();
             foreach (DataRow dr in dt.Rows)
             {
-                //T model = (T)Activator.CreateInstance(typeof(T));  
+                //T model = (T)Activator.CreateInstance(typeof(T));
                 T model = new T();
                 foreach (PropertyInfo propertyInfo in typeof(T).GetProperties())
                 {
@@ -67,9 +66,9 @@ namespace Core.Util.Common
             return modelList;
         }
 
-        /// <summary>  
+        /// <summary>
         /// 填充对象:用DataRow填充实体类
-        /// </summary>  
+        /// </summary>
         public T FillModel(DataRow dr)
         {
             if (dr == null)
@@ -77,7 +76,7 @@ namespace Core.Util.Common
                 return default(T);
             }
 
-            //T model = (T)Activator.CreateInstance(typeof(T));  
+            //T model = (T)Activator.CreateInstance(typeof(T));
             T model = new T();
             foreach (PropertyInfo propertyInfo in typeof(T).GetProperties())
             {
@@ -86,7 +85,7 @@ namespace Core.Util.Common
             return model;
         }
 
-        #endregion
+        #endregion DataTable转换成实体类
 
         #region 实体类转换成DataTable
 
@@ -149,6 +148,6 @@ namespace Core.Util.Common
             return dataTable;
         }
 
-        #endregion
+        #endregion 实体类转换成DataTable
     }
-}
+}

+ 9 - 6
PLC.Siemens/Core/Common/ObjectId.cs

@@ -1,12 +1,9 @@
-using System;
-using System.Diagnostics;
-using System.Linq;
+using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Security.Cryptography;
 using System.Text;
-using System.Threading;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     /// <summary>Represents an ObjectId
     /// </summary>
@@ -15,12 +12,14 @@ namespace Core.Util.Common
     {
         // private static fields
         private static readonly DateTime __unixEpoch;
+
         private static readonly long __dateTimeMaxValueMillisecondsSinceEpoch;
         private static readonly long __dateTimeMinValueMillisecondsSinceEpoch;
         private static ObjectId __emptyInstance = default(ObjectId);
         private static int __staticMachine;
         private static short __staticPid;
         private static int __staticIncrement; // high byte will be masked out when generating new ObjectId
+
         private static uint[] _lookup32 = Enumerable.Range(0, 256).Select(i =>
         {
             string s = i.ToString("x2");
@@ -31,6 +30,7 @@ namespace Core.Util.Common
         // the extra two bytes are not visible to anyone outside of this class and they buy us considerable simplification
         // an additional advantage of this representation is that it will serialize to JSON without any 64 bit overflow problems
         private int _timestamp;
+
         private int _machine;
         private short _pid;
         private int _increment;
@@ -474,6 +474,7 @@ namespace Core.Util.Common
 
             return arr;
         }
+
         /// <summary>
         /// Converts a byte array to a hex string.
         /// </summary>
@@ -494,6 +495,7 @@ namespace Core.Util.Common
             }
             return new string(result);
         }
+
         /// <summary>
         /// Converts a DateTime to number of milliseconds since Unix epoch.
         /// </summary>
@@ -504,6 +506,7 @@ namespace Core.Util.Common
             var utcDateTime = ToUniversalTime(dateTime);
             return (utcDateTime - __unixEpoch).Ticks / 10000;
         }
+
         /// <summary>
         /// Converts a DateTime to UTC (with special handling for MinValue and MaxValue).
         /// </summary>
@@ -536,4 +539,4 @@ namespace Core.Util.Common
             return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
         }
     }
-}
+}

+ 4 - 5
PLC.Siemens/Core/Common/Rand.cs

@@ -1,8 +1,7 @@
-using System;
-using System.Security.Cryptography;
+using System.Security.Cryptography;
 using System.Text;
 
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     /// <summary>随机数</summary>
     public static class Rand
@@ -20,7 +19,7 @@ namespace Core.Util.Common
         public static int Next(int max = int.MaxValue)
         {
             if (max <= 0) throw new ArgumentOutOfRangeException("max");
-            
+
             return Next(0, max);
         }
 
@@ -67,4 +66,4 @@ namespace Core.Util.Common
             return sb.ToString();
         }
     }
-}
+}

+ 4 - 5
PLC.Siemens/Core/Common/SingleBase.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     /// <summary>
     /// 单例基类
@@ -17,7 +15,8 @@ namespace Core.Util.Common
         /// <summary>
         /// 获取单例句柄
         /// </summary>
-        public static T Instance { get { return _instance; } }
+        public static T Instance
+        { get { return _instance; } }
 
         static SingleBase()
         {
@@ -39,4 +38,4 @@ namespace Core.Util.Common
             }
         }
     }
-}
+}

+ 2 - 4
PLC.Siemens/Core/Common/SystemTime.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace Core.Util.Common
+namespace PlcSiemens.Core.Common
 {
     public static class SystemTime
     {
@@ -9,4 +7,4 @@ namespace Core.Util.Common
         /// </summary>
         public static Func<DateTime> Now = () => DateTime.UtcNow;
     }
-}
+}

+ 3 - 5
PLC.Siemens/Core/Extension/ArrayExtension.cs

@@ -1,7 +1,6 @@
-using System;
-using Core.Util.Common;
+using PlcSiemens.Core.Common;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     /// <summary>
     /// 数组集合扩展功能
@@ -21,7 +20,6 @@ namespace Core.Util.Extension
             return false;
         }
 
-
         /// <summary>
         /// 判断数组是否为空
         /// </summary>
@@ -48,4 +46,4 @@ namespace Core.Util.Extension
             return Array.FindAll(targer, predicate);
         }
     }
-}
+}

+ 1 - 1
PLC.Siemens/Core/Extension/BitExtension.cs

@@ -1,4 +1,4 @@
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     /// <summary>
     ///     λÔËËã²Ù×÷

+ 10 - 12
PLC.Siemens/Core/Extension/ByteExtenstion.cs

@@ -1,10 +1,8 @@
-using System;
-using System.Globalization;
-using System.Linq;
+using System.Globalization;
 using System.Text;
 using System.Text.RegularExpressions;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class ByteExtenstion
     {
@@ -18,7 +16,7 @@ namespace Core.Util.Extension
             return DetectInternal(data);
         }
 
-       public  static Encoding DetectInternal(this byte[] data)
+        public static Encoding DetectInternal(this byte[] data)
         {
             Encoding encoding = null;
             // 最笨的办法尝试
@@ -50,7 +48,7 @@ namespace Core.Util.Extension
 
             // 简单方法探测ASCII
             encoding = DetectASCII(data);
-           return encoding;
+            return encoding;
         }
 
         /// <summary>检测BOM字节序</summary>
@@ -82,7 +80,7 @@ namespace Core.Util.Extension
 
         /// <summary>检测是否ASCII</summary>
         // ReSharper disable once InconsistentNaming
-        static Encoding DetectASCII(byte[] data)
+        private static Encoding DetectASCII(byte[] data)
         {
             // 如果所有字节都小于128,则可以使用ASCII编码
             if (data.Any(t => t >= 128))
@@ -93,7 +91,7 @@ namespace Core.Util.Extension
             return Encoding.ASCII;
         }
 
-        static bool IsMatch(byte[] data, Encoding encoding)
+        private static bool IsMatch(byte[] data, Encoding encoding)
         {
             if (encoding == null) encoding = Encoding.Default;
 
@@ -116,7 +114,7 @@ namespace Core.Util.Extension
             }
             catch (Exception ex)
             {
-               // XTrace.WriteException(ex);
+                // XTrace.WriteException(ex);
                 // ignored
             }
 
@@ -124,7 +122,7 @@ namespace Core.Util.Extension
         }
 
         /// <summary>启发式探测Unicode编码</summary>
-        static Encoding DetectUnicode(byte[] data)
+        private static Encoding DetectUnicode(byte[] data)
         {
             var oddBinaryNullsInSample = 0;
             var evenBinaryNullsInSample = 0;
@@ -246,7 +244,7 @@ namespace Core.Util.Extension
         /// <param name="bt"></param>
         /// <returns></returns>
         // ReSharper disable once InconsistentNaming
-        static bool IsCommonASCII(byte bt)
+        private static bool IsCommonASCII(byte bt)
         {
             if (bt == 0x0A // 回车
                 || bt == 0x0D // 换行
@@ -319,4 +317,4 @@ namespace Core.Util.Extension
             return 0;
         }
     }
-}
+}

+ 12 - 15
PLC.Siemens/Core/Extension/CollectionExtension.cs

@@ -1,10 +1,7 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
+using System.Collections;
 using System.Text;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     /// <summary>集合扩展</summary>
     public static class CollectionExtension
@@ -23,16 +20,17 @@ namespace Core.Util.Extension
         {
             if (source == null)
             {
-                return ;
+                return;
             }
             var sourceArray = new List<T>(source);
             var itemIndex = sourceArray.FindIndex(m => m.GetType() == checkedItem);
-            if (itemIndex <= 0) return ;
+            if (itemIndex <= 0) return;
             var changeItem = sourceArray[itemIndex];
             sourceArray.RemoveAt(itemIndex);
             sourceArray.Insert(0, changeItem);
-            source= sourceArray;
+            source = sourceArray;
         }
+
         /// <summary>
         /// 确保某一类型的元素必须位于末尾位置
         /// </summary>
@@ -47,16 +45,17 @@ namespace Core.Util.Extension
         {
             if (source == null)
             {
-                return ;
+                return;
             }
             var sourceArray = new List<T>(source);
             var itemIndex = sourceArray.FindIndex(m => m.GetType() == checkedItem);
-            if (itemIndex == sourceArray.Count-1) return ;
+            if (itemIndex == sourceArray.Count - 1) return;
             var changeItem = sourceArray[itemIndex];
             sourceArray.RemoveAt(itemIndex);
-            sourceArray.Insert(sourceArray.Count-1, changeItem);
+            sourceArray.Insert(sourceArray.Count - 1, changeItem);
             source = sourceArray;
         }
+
         /// <summary>
         /// 集合转换
         /// </summary>
@@ -136,7 +135,6 @@ namespace Core.Util.Extension
         {
             return targer == null || targer.GetEnumerator().MoveNext() == false;
         }
-        
 
         /// <summary>
         ///     ICollection<T />转换成数组T[]
@@ -180,6 +178,7 @@ namespace Core.Util.Extension
             }
             return sb.ToString();
         }
+
         /// <summary>
         /// 在考虑依赖关系的情况下,使用托普法进行排序
         /// </summary>
@@ -189,7 +188,6 @@ namespace Core.Util.Extension
         /// <returns></returns>
         public static List<T> SortByDependencies<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> getDependencies)
         {
-
             var sorted = new List<T>();
             var visited = new Dictionary<T, bool>();
 
@@ -201,7 +199,6 @@ namespace Core.Util.Extension
             return sorted;
         }
 
-       
         private static void SortByDependenciesVisit<T>(T item, Func<T, IEnumerable<T>> getDependencies, List<T> sorted, Dictionary<T, bool> visited)
         {
             bool inProcess;
@@ -232,4 +229,4 @@ namespace Core.Util.Extension
             }
         }
     }
-}
+}

+ 4 - 4
PLC.Siemens/Core/Extension/DateTimeExtension.cs

@@ -1,7 +1,6 @@
-using System;
-using Core.Util.Common;
+using PlcSiemens.Core.Common;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     /// <summary>
     ///     时间帮助扩展类
@@ -20,6 +19,7 @@ namespace Core.Util.Extension
         {
             return (target >= MinDate) && (target <= MaxDate);
         }
+
         /// <summary>时间日期转为yyyy-MM-dd HH:mm:ss完整字符串,支持指定最小时间的字符串</summary>
         public static string ToFullString(this DateTime value, string emptyValue = null)
         {
@@ -32,4 +32,4 @@ namespace Core.Util.Extension
             return new DefaultConvert().ToString(value, format, emptyValue);
         }
     }
-}
+}

+ 5 - 7
PLC.Siemens/Core/Extension/EncodingHelper.cs

@@ -1,8 +1,6 @@
-using System;
-using System.IO;
-using System.Text;
+using System.Text;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class StreamExtension
     {
@@ -23,6 +21,7 @@ namespace Core.Util.Extension
     public static class EncodingHelper
     {
         #region 编码检测
+
         /// <summary>检测文件编码</summary>
         public static Encoding Detect(this string filename)
         {
@@ -72,7 +71,6 @@ namespace Core.Util.Extension
             return data.DetectInternal();
         }
 
-        
-        #endregion
+        #endregion 编码检测
     }
-}
+}

+ 1 - 6
PLC.Siemens/Core/Extension/EnumExtension.cs

@@ -1,8 +1,4 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Reflection;
-
-namespace System
+namespace PlcSiemens.Core.Extension
 {
     /// <summary>ö¾ÙÀàÐÍÖúÊÖÀà</summary>
     public static class EnumHelper
@@ -92,4 +88,3 @@ namespace System
         //}
     }
 }
-

+ 2 - 5
PLC.Siemens/Core/Extension/GuidExtension.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class GuidExtension
     {
@@ -16,7 +14,6 @@ namespace Core.Util.Extension
 
             var encoded = base64.Replace("/", "_").Replace("+", "-");
 
-
             return encoded.Substring(0, 22);
         }
 
@@ -30,4 +27,4 @@ namespace Core.Util.Extension
             return target == Guid.Empty;
         }
     }
-}
+}

+ 3 - 7
PLC.Siemens/Core/Extension/IEnumerableExtensions.cs

@@ -1,13 +1,9 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
+using System.Collections;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class IEnumerableExtensions
     {
-       
         public static IEnumerable<T> Safe<T>(this IEnumerable<T> collection)
         {
             return collection ?? Enumerable.Empty<T>();
@@ -33,4 +29,4 @@ namespace Core.Util.Extension
             return !IsEmpty(collection);
         }
     }
-}
+}

+ 5 - 8
PLC.Siemens/Core/Extension/ObjectExtension.cs

@@ -1,13 +1,12 @@
-using System;
-using Core.Util.Common;
+using PlcSiemens.Core.Common;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class ObjectExtension
     {
         #region 类型转换
 
-        public static DefaultConvert Convert= new DefaultConvert();
+        public static DefaultConvert Convert = new DefaultConvert();
 
         /// <summary>转为整数,转换失败时返回默认值。支持字符串、全角、字节数组(小端)</summary>
         public static int ToInt(this object value, int defaultValue = 0)
@@ -39,8 +38,6 @@ namespace Core.Util.Extension
             return Convert.ToDateTime(value, defaultValue);
         }
 
-       
-
-        #endregion
+        #endregion 类型转换
     }
-}
+}

+ 5 - 5
PLC.Siemens/Core/Extension/ReaderWriterLockSlimExtensions.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Threading;
-
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class ReaderWriterLockSlimExtensions
     {
@@ -32,6 +29,7 @@ namespace Core.Util.Extension
                 readerWriterLockSlim.ExitReadLock();
             }
         }
+
         /// <summary>An atom read func wrapper.
         /// </summary>
         /// <param name="readerWriterLockSlim"></param>
@@ -61,6 +59,7 @@ namespace Core.Util.Extension
                 readerWriterLockSlim.ExitReadLock();
             }
         }
+
         /// <summary>An atom write action wrapper.
         /// </summary>
         /// <param name="readerWriterLockSlim"></param>
@@ -88,6 +87,7 @@ namespace Core.Util.Extension
                 readerWriterLockSlim.ExitWriteLock();
             }
         }
+
         /// <summary>An atom write func wrapper.
         /// </summary>
         /// <param name="readerWriterLockSlim"></param>
@@ -118,4 +118,4 @@ namespace Core.Util.Extension
             }
         }
     }
-}
+}

+ 2 - 2
PLC.Siemens/Core/Extension/StringBuilderExtension.cs

@@ -1,6 +1,6 @@
 using System.Text;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class StringBuilderExtension
     {
@@ -14,4 +14,4 @@ namespace Core.Util.Extension
             return sb;
         }
     }
-}
+}

+ 42 - 45
PLC.Siemens/Core/Extension/StringHelper.cs

@@ -1,13 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
+using PlcSiemens.Core.Common;
 using System.Security.Cryptography;
 using System.Text;
 using System.Text.RegularExpressions;
-using System.Web;
-using Core.Util.Common;
 
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     public static class StringHelper
     {
@@ -31,7 +27,7 @@ namespace Core.Util.Extension
             '’', '“', '”', '»', '«'
         };
 
-        #endregion
+        #endregion 正则表达式
 
         #region 字符串判断
 
@@ -58,7 +54,7 @@ namespace Core.Util.Extension
             return !target.IsNullOrEmpty() && EmailExpression.IsMatch(target);
         }
 
-        #endregion
+        #endregion 字符串判断
 
         #region 格式转换
 
@@ -124,7 +120,7 @@ namespace Core.Util.Extension
             {
                 try
                 {
-                    convertedValue = (T) Enum.Parse(typeof (T), target.Trim(), true);
+                    convertedValue = (T)Enum.Parse(typeof(T), target.Trim(), true);
                 }
                 catch (ArgumentException)
                 {
@@ -192,7 +188,7 @@ namespace Core.Util.Extension
             return target;// HttpUtility.HtmlDecode(target);
         }
 
-        #endregion
+        #endregion 格式转换
 
         #region 截取扩展
 
@@ -280,7 +276,6 @@ namespace Core.Util.Extension
             if (target.IsNullOrEmpty()) return target;
             if (after.IsNullOrEmpty() && before.IsNullOrEmpty()) return target;
 
-
             var p = -1;
             if (!string.IsNullOrEmpty(after))
             {
@@ -402,7 +397,7 @@ namespace Core.Util.Extension
             return str;
         }
 
-        #endregion
+        #endregion 截取扩展
 
         #region 匹配查找
 
@@ -426,6 +421,7 @@ namespace Core.Util.Extension
             return !target.IsNullOrEmpty() &&
                    strs.Any(item => target.EndsWith(item, StringComparison.OrdinalIgnoreCase));
         }
+
         public static int GetHashcode2(this string s)
         {
             if (string.IsNullOrEmpty(s)) return 0;
@@ -444,7 +440,8 @@ namespace Core.Util.Extension
                 return hash;
             }
         }
-        #endregion
+
+        #endregion 匹配查找
 
         #region 分隔
 
@@ -453,7 +450,7 @@ namespace Core.Util.Extension
         {
             if (target.IsNullOrEmpty()) return new string[0];
             if (separators == null || separators.Length < 1 || separators.Length == 1 && separators[0].IsNullOrEmpty())
-                separators = new[] {",", ";"};
+                separators = new[] { ",", ";" };
 
             return target.Split(separators, StringSplitOptions.RemoveEmptyEntries);
         }
@@ -462,7 +459,7 @@ namespace Core.Util.Extension
         public static int[] SplitAsInt(this string target, params string[] separators)
         {
             if (target.IsNullOrEmpty()) return new int[0];
-            if (separators == null || separators.Length < 1) separators = new[] {",", ";"};
+            if (separators == null || separators.Length < 1) separators = new[] { ",", ";" };
 
             var ss = target.Split(separators, StringSplitOptions.RemoveEmptyEntries);
             var list = new List<int>();
@@ -485,7 +482,7 @@ namespace Core.Util.Extension
             if (target.IsNullOrWhiteSpace()) return dic;
 
             if (nameValueSeparator.IsNullOrEmpty()) nameValueSeparator = "=";
-            if (separators == null || separators.Length < 1) separators = new[] {",", ";"};
+            if (separators == null || separators.Length < 1) separators = new[] { ",", ";" };
 
             var ss = target.Split(separators, StringSplitOptions.RemoveEmptyEntries);
             if (ss.Length < 1) return null;
@@ -503,7 +500,7 @@ namespace Core.Util.Extension
             return dic;
         }
 
-        #endregion
+        #endregion 分隔
 
         #region 功能扩展
 
@@ -522,7 +519,7 @@ namespace Core.Util.Extension
             {
                 if (args[i] is DateTime)
                 {
-                    if (target.Contains("{" + i + "}")) args[i] = ((DateTime) args[i]).ToFullString();
+                    if (target.Contains("{" + i + "}")) args[i] = ((DateTime)args[i]).ToFullString();
                 }
             }
 
@@ -535,7 +532,7 @@ namespace Core.Util.Extension
             return target;
         }
 
-        #endregion
+        #endregion 功能扩展
 
         #region 语音播放
 
@@ -553,7 +550,7 @@ namespace Core.Util.Extension
             //Speecher.SpeakAsync(value);
         }
 
-        #endregion
+        #endregion 语音播放
 
         #region LD编辑距离算法
 
@@ -568,27 +565,27 @@ namespace Core.Util.Extension
         {
             if (IsNullOrWhiteSpace(key)) return new string[0];
 
-            var keys = key.Split(new[] {' ', ' '}, StringSplitOptions.RemoveEmptyEntries);
+            var keys = key.Split(new[] { ' ', ' ' }, StringSplitOptions.RemoveEmptyEntries);
 
             foreach (var item in keys)
             {
-                var maxDist = (item.Length - 1)/2;
+                var maxDist = (item.Length - 1) / 2;
 
                 var q = from str in words
-                    where item.Length <= str.Length
-                          && Enumerable.Range(0, maxDist + 1)
-                              .Any(dist =>
-                              {
-                                  return Enumerable.Range(0, Math.Max(str.Length - item.Length - dist + 1, 0))
-                                      .Any(
-                                          f =>
-                                          {
-                                              return LevenshteinDistance(item, str.Substring(f, item.Length + dist)) <=
-                                                     maxDist;
-                                          });
-                              })
-                    orderby str
-                    select str;
+                        where item.Length <= str.Length
+                              && Enumerable.Range(0, maxDist + 1)
+                                  .Any(dist =>
+                                  {
+                                      return Enumerable.Range(0, Math.Max(str.Length - item.Length - dist + 1, 0))
+                                          .Any(
+                                              f =>
+                                              {
+                                                  return LevenshteinDistance(item, str.Substring(f, item.Length + dist)) <=
+                                                         maxDist;
+                                              });
+                                  })
+                        orderby str
+                        select str;
                 words = q.ToArray();
             }
 
@@ -628,7 +625,7 @@ namespace Core.Util.Extension
             return C[n, m];
         }
 
-        #endregion
+        #endregion LD编辑距离算法
 
         #region LCS算法
 
@@ -644,16 +641,16 @@ namespace Core.Util.Extension
             if (IsNullOrWhiteSpace(key) || words == null || words.Length == 0) return new string[0];
 
             var keys = key
-                .Split(new[] {' ', '\u3000'}, StringSplitOptions.RemoveEmptyEntries)
+                .Split(new[] { ' ', '\u3000' }, StringSplitOptions.RemoveEmptyEntries)
                 .OrderBy(s => s.Length)
                 .ToArray();
 
             //var q = from sentence in items.AsParallel()
             var q = from word in words
-                let MLL = LCSDistance(word, keys)
-                where MLL >= 0
-                orderby (MLL + 0.5)/word.Length, word
-                select word;
+                    let MLL = LCSDistance(word, keys)
+                    where MLL >= 0
+                    orderby (MLL + 0.5) / word.Length, word
+                    select word;
 
             return q.ToArray();
         }
@@ -729,7 +726,7 @@ namespace Core.Util.Extension
             return result;
         }
 
-        #endregion
+        #endregion LCS算法
 
         #region 执行命令行
 
@@ -784,6 +781,6 @@ namespace Core.Util.Extension
         //    return p.ExitCode;
         //}
 
-        #endregion
+        #endregion 执行命令行
     }
-}
+}

+ 2 - 6
PLC.Siemens/Core/Extension/TypeExtension.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Linq;
-
-namespace Core.Util.Extension
+namespace PlcSiemens.Core.Extension
 {
     /// <summary>
     /// Type扩展类型
@@ -51,6 +48,5 @@ namespace Core.Util.Extension
                 parent = parent.GetGenericTypeDefinition();
             return parent;
         }
-
     }
-}
+}

+ 14 - 15
PLC.Siemens/O/ByteBuffer.cs

@@ -1,7 +1,4 @@
-using System;
-using System.IO;
-
-namespace Core.Communication.Transport
+namespace PlcSiemens.O
 {
     public static class ExtensionHelper
     {
@@ -32,25 +29,31 @@ namespace Core.Communication.Transport
             return 0;
         }
     }
+
     public class ByteBuffer
     {
         private readonly byte[] _bufferCache;
+
         /// <summary>
         /// 缓冲区
         /// </summary>
         public byte[] Buffer { get; private set; }
+
         /// <summary>
         /// 当前读取位置
         /// </summary>
         public int ReadIndex { get; private set; }
+
         /// <summary>
         /// 当前写入位置
         /// </summary>
         public int WriteIndex { get; private set; }
+
         /// <summary>
         /// 设置读取位置标记
         /// </summary>
         public int MarkReadIndex { get; private set; }
+
         /// <summary>
         /// 设置写入位置标记
         /// </summary>
@@ -125,6 +128,7 @@ namespace Core.Communication.Transport
         }
 
         #region 压入对象
+
         public void Push(byte[] bytes, int startIndex, int length)
         {
             lock (this)
@@ -150,7 +154,7 @@ namespace Core.Communication.Transport
         /// <param name="reversed"></param>
         public void Push(byte[] bytes, int length, bool reversed = false)
         {
-            if (reversed) bytes = bytes.Reverse(0,length);
+            if (reversed) bytes = bytes.Reverse(0, length);
             Push(bytes, 0, length);
         }
 
@@ -297,10 +301,11 @@ namespace Core.Communication.Transport
 
             Push(buf, reversed);
         }
-        #endregion
 
+        #endregion 压入对象
 
         #region pop出一个对象
+
         /// <summary>
         /// 读取一个<see cref="byte"/>
         /// </summary>
@@ -465,8 +470,8 @@ namespace Core.Communication.Transport
 
             return buf;
         }
-        #endregion
 
+        #endregion pop出一个对象
 
         /// <summary>
         /// 清除已读缓冲 后续队列前移
@@ -514,7 +519,6 @@ namespace Core.Communication.Transport
             ReadIndex = index;
         }
 
-
         /// <summary>
         /// 标记当前读取的索引位置
         /// </summary>
@@ -531,7 +535,6 @@ namespace Core.Communication.Transport
             MarkWirteIndex = WriteIndex;
         }
 
-
         /// <summary>
         /// 将读取的索引位置重置为标记的读取索引位置
         /// </summary>
@@ -548,7 +551,6 @@ namespace Core.Communication.Transport
             WriteIndex = MarkWirteIndex;
         }
 
-
         /// <summary>
         /// 剩余可读数量
         /// </summary>
@@ -558,7 +560,6 @@ namespace Core.Communication.Transport
             return WriteIndex - ReadIndex;
         }
 
-
         /// <summary>
         /// 剩余可读缓存转数组
         /// </summary>
@@ -572,7 +573,6 @@ namespace Core.Communication.Transport
 
         public int IndexOf(byte[] buf, int offset = 0, int length = -1)
         {
-
             if (length <= 0) length = buf.Length - offset;
 
             // 位置
@@ -620,7 +620,7 @@ namespace Core.Communication.Transport
             if (index == -1)
             {
                 //重建缓冲清除数据
-                //DiscardReadBytes(); 
+                //DiscardReadBytes();
                 //不能重建缓冲 有可能尾部有数据部分匹配而导致数据丢失
                 //重置ReaderIndex即可
                 SetReaderIndex(0);
@@ -635,6 +635,5 @@ namespace Core.Communication.Transport
 
             return true;
         }
-
     }
-}
+}

+ 3 - 3
PLC.Siemens/O/HelperFunction.cs

@@ -1,6 +1,6 @@
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public static class HelperFunction
     {
@@ -22,4 +22,4 @@ namespace PLC.Siemens.O
             }
         }
     }
-}
+}

+ 3 - 4
PLC.Siemens/O/IBuildRequest.cs

@@ -1,10 +1,9 @@
-using Core.Communication.Transport;
-
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public interface IBuildRequest
     {
         void Build();
+
         ByteBuffer GetBuffer();
     }
-}
+}

+ 2 - 4
PLC.Siemens/O/IBuildResponse.cs

@@ -1,9 +1,7 @@
-using Core.Communication.Transport;
-
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public interface IBuildResponse
     {
         void Build(ByteBuffer buffer);
     }
-}
+}

+ 3 - 3
PLC.Siemens/O/IIsoSender.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public interface IIsoSender
     {
@@ -12,6 +12,7 @@
         TResponse Send<TRequest, TResponse>(TRequest request)
             where TResponse : IBuildResponse, new()
             where TRequest : IBuildRequest, new();
+
         /// <summary>
         /// 包含ISO头的请求
         /// </summary>
@@ -22,6 +23,5 @@
         TResponse IsoSend<TRequest, TResponse>(TRequest request)
             where TResponse : IBuildResponse, new()
             where TRequest : IBuildRequest, new();
-
     }
-}
+}

+ 2 - 2
PLC.Siemens/O/MessageEvent.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public class MessageEvent
     {
@@ -11,4 +11,4 @@ namespace PLC.Siemens.O
             Message = message;
         }
     }
-}
+}

+ 2 - 4
PLC.Siemens/O/RequestHandle.cs

@@ -1,6 +1,4 @@
-using Core.Communication.Transport;
-
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public class RequestHandle<TRequest> where TRequest : IBuildRequest, new()
     {
@@ -21,4 +19,4 @@ namespace PLC.Siemens.O
             return Request.GetBuffer();
         }
     }
-}
+}

+ 2 - 5
PLC.Siemens/O/ResponseHandle.cs

@@ -1,6 +1,4 @@
-using Core.Communication.Transport;
-
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public class ResponseHandle<TResponse> where TResponse : IBuildResponse, new()
     {
@@ -14,5 +12,4 @@ namespace PLC.Siemens.O
             Response.Build(buffer);
         }
     }
-
-}
+}

+ 43 - 48
PLC.Siemens/O/SimenssPlc.cs

@@ -1,19 +1,12 @@
-using System;
-using System.Collections.Generic;
+using PlcSiemens.Communication;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.ReadData;
+using PlcSiemens.Protocol.Szl;
+using PlcSiemens.ProtocolHandle;
 using System.Text;
-using System.Threading;
-using PLC.Siemens.Communication;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Iso;
-using PLC.Siemens.Protocol.Negotiate;
-using PLC.Siemens.Protocol.ReadData;
-using PLC.Siemens.Protocol.Szl;
-using PLC.Siemens.ProtocolHandle;
-using PLC.Siemens.O;
-using System.Linq;
-
-namespace PLC.Siemens.O
-   
+
+namespace PlcSiemens.O
+
 {
     public class SimenssPlc
     {
@@ -26,6 +19,7 @@ namespace PLC.Siemens.O
         public int RecvTimeout { get; set; }
         public int RemotePort { get; set; }
         public int IsoPduSize { get; set; }
+
         // ReSharper disable once InconsistentNaming
         public string IP { get; private set; }
 
@@ -36,11 +30,10 @@ namespace PLC.Siemens.O
                 if (_socket == null)
                     return false;
                 return _socket.Connected;
-
             }
         }
 
-        private Action<PLC.Siemens.O.MessageEvent> _onMessageEvent;
+        private Action<PlcSiemens.O.MessageEvent> _onMessageEvent;
 
         private readonly IsoSocket _socket;
 
@@ -62,12 +55,13 @@ namespace PLC.Siemens.O
             DstRef = 0x0000;
             SrcTSap = 0x0100;
             DstTSap = 0x0000; // It's filled by connection functions
-            ConnectionType = ConnectionType.PG; 
+            ConnectionType = ConnectionType.PG;
         }
+
         public SimenssPlc(string ip, int rack, int slot)
         {
             _socket = new IsoSocket();
-            PduRequest = 480*2;
+            PduRequest = 480 * 2;
             IsoPduSize = 1024;
             RecvTimeout = 3000;
             RemotePort = 102;
@@ -85,10 +79,11 @@ namespace PLC.Siemens.O
             ConnectionType = ConnectionType.PG;
 
             var remoteTsap = (ushort)(((ushort)ConnectionType << 8) + (rack * 0x20) + slot);
-            SetConnectionParams(ip, SrcTSap, remoteTsap); 
+            SetConnectionParams(ip, SrcTSap, remoteTsap);
         }
 
         #region 连接
+
         public void RegisterMessageEvent(Action<MessageEvent> messageAction)
         {
             if (messageAction == null) throw new ArgumentNullException("messageAction");
@@ -97,7 +92,7 @@ namespace PLC.Siemens.O
 
         private void OnMessage(string method, string message)
         {
-            if(_onMessageEvent!=null)
+            if (_onMessageEvent != null)
                 _onMessageEvent.Invoke(new MessageEvent(method, message));
         }
 
@@ -122,8 +117,10 @@ namespace PLC.Siemens.O
 
         //暂时用系统SOCKET测试
         private int _connecting;//连接中
+
         private int _processing;//处理中
         private string _processMehtod;
+
         public bool Connect()
         {
             try
@@ -133,7 +130,7 @@ namespace PLC.Siemens.O
                 OnMessage("Connect", "正在连接");
                 if (!_socket.Connect(IP, 102))
                     return false;
-                 
+
                 IsoControlPduHandle pduHandle = new IsoControlPduHandle()
                 {
                     IsoPduSize = IsoPduSize,
@@ -172,8 +169,9 @@ namespace PLC.Siemens.O
             }
             return false;
         }
-        #endregion
-        
+
+        #endregion 连接
+
         public bool GetLock(string method)
         {
             if (Interlocked.CompareExchange(ref _processing, 1, 0) != 0)
@@ -199,7 +197,7 @@ namespace PLC.Siemens.O
             handle.Handle(_socket);
             return handle.SzlResponseFirst;
         }
-        
+
         public SzlResponse ReadSzl(SzlCmd szlcmd)
         {
             if (!GetLock("ReadSzl"))
@@ -273,7 +271,6 @@ namespace PLC.Siemens.O
                 cpuInfo.AsName = Encoding.UTF8.GetString(aaaa.Data.Data, 2, 24).TrimEnd('\0');
                 cpuInfo.Copyright = Encoding.UTF8.GetString(aaaa.Data.Data, 104, 26).TrimEnd('\0');
                 cpuInfo.ModuleName = Encoding.UTF8.GetString(aaaa.Data.Data, 36, 24).TrimEnd('\0');
-
             }
             catch (Exception ex)
             {
@@ -317,7 +314,8 @@ namespace PLC.Siemens.O
             }
             return info;
         }
-        #endregion
+
+        #endregion [System Info functions]
 
         private int DWordAt(byte[] buffer, int index, int length)
         {
@@ -331,6 +329,7 @@ namespace PLC.Siemens.O
         }
 
         #region [Date/Time functions]
+
         public DateTime GetS7DateTime()
         {
             if (!GetLock("GetS7DateTime"))
@@ -383,9 +382,11 @@ namespace PLC.Siemens.O
                 ReleaseLock();
             }
         }
-        #endregion
+
+        #endregion [Date/Time functions]
 
         #region [Control functions]
+
         public S7CpuStatus GetPlcStatus()
         {
             S7CpuStatus status = S7CpuStatus.Unknown;
@@ -515,7 +516,6 @@ namespace PLC.Siemens.O
 
         public bool Compress()
         {
-
             if (!GetLock("Compress"))
                 return false;
 
@@ -536,12 +536,12 @@ namespace PLC.Siemens.O
             {
                 ReleaseLock();
             }
-
         }
 
-        #endregion
+        #endregion [Control functions]
 
         #region [Security functions]
+
         public ProtectionInfo GetProtection()
         {
             ProtectionInfo info = new ProtectionInfo();
@@ -618,9 +618,11 @@ namespace PLC.Siemens.O
                 ReleaseLock();
             }
         }
-        #endregion
+
+        #endregion [Security functions]
 
         #region [Blocks]
+
         public ListBlocksHandle ListBlocks()
         {
             if (!GetLock("ListBlocks")) return null;
@@ -685,23 +687,22 @@ namespace PLC.Siemens.O
             {
                 ReleaseLock();
             }
-
         }
-        #endregion
 
-        object readlock = new object();
+        #endregion [Blocks]
+
+        private object readlock = new object();
+
         public DataItem ReadArea(AreaType area, ushort db, ushort start, ushort amount, DataType dataType)
         {
             lock (readlock)
             {
-
                 if (!GetLock("ReadArea"))
                 {
                     return null;
                 }
                 else
                 {
-
                 }
                 try
                 {
@@ -756,7 +757,6 @@ namespace PLC.Siemens.O
             }
             finally
 
-
             {
                 ReleaseLock();
             }
@@ -770,7 +770,6 @@ namespace PLC.Siemens.O
                 {
                     if (writeData.Max() == 0)
                     {
-
                     }
                 }
                 else if (start % 36 == 0)
@@ -779,12 +778,10 @@ namespace PLC.Siemens.O
                     {
                         if (writeData.Skip(16).Take(2).Max() == 0)
                         {
-
                         }
                     }
-                    else 
-                    { 
-                    
+                    else
+                    {
                     }
                 }
             }
@@ -808,7 +805,7 @@ namespace PLC.Siemens.O
                 };
                 OnMessage("WriteArea", handle.ResultCode.ToString());
                 handle.Handle(_socket);
-                return handle.ResultCode == ResultCode.OK|| handle.ResultCode == ResultCode.OKFF;
+                return handle.ResultCode == ResultCode.OK || handle.ResultCode == ResultCode.OKFF;
             }
             catch (Exception ex)
             {
@@ -844,7 +841,7 @@ namespace PLC.Siemens.O
                 ReleaseLock();
             }
         }
-        
+
         // ReSharper disable once InconsistentNaming
         public DataItem DBGet(ushort db)
         {
@@ -866,7 +863,6 @@ namespace PLC.Siemens.O
                 }
                 else
                     OnMessage("DBGet", "RequestBlock:{handle.ResultCode}");
-
             }
             catch (Exception ex)
             {
@@ -927,8 +923,7 @@ namespace PLC.Siemens.O
             handle1.UploadID = handle.Response.Params.UploadID;
             handle1.Handle(_socket);
 
-
             return false;
         }
     }
-}
+}

+ 2 - 2
PLC.Siemens/O/StaticConst.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.O
+namespace PlcSiemens.O
 {
     public static class StaticConst
     {
@@ -10,4 +10,4 @@
         public const int IsoPayloadSize = 4096;// Iso telegram Buffer size
         public const int NoError = 0;
     }
-}
+}

+ 0 - 0
PLC.Siemens/PLC.Siemens.csproj → PLC.Siemens/PlcSiemens.csproj


+ 7 - 2
PLC.Siemens/Protocol/Common/AreaType.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum AreaType
     {
@@ -6,25 +6,30 @@
         /// DigitalInputs
         /// </summary>
         PE = 0x81,
+
         /// <summary>
         /// Digital Outputs
         /// </summary>
         PA = 0x82,
+
         /// <summary>
         /// Merkers
         /// </summary>
         MK = 0x83,
+
         /// <summary>
         /// DB
         /// </summary>
         DB = 0x84,
+
         /// <summary>
         /// Counters
         /// </summary>
         CT = 0x1C,
+
         /// <summary>
         /// Times
         /// </summary>
         TM = 0x1D,
     }
-}
+}

+ 3 - 2
PLC.Siemens/Protocol/Common/CodeControl.cs

@@ -1,9 +1,10 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum CodeControl
     {
         // Control codes
         Unknown = 0,
+
         ColdStart = 1,      // Cold start
         WarmStart = 2,      // Warm start
         Stop = 3,      // Stop
@@ -11,4 +12,4 @@ namespace PLC.Siemens.Protocol.Common
         CpyRamRom = 5,     // Copy Ram to Rom
         InsDel = 6,      // Insert in working ram the block downloaded
     }
-}
+}

+ 5 - 6
PLC.Siemens/Protocol/Common/CodeError.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum ResultCode
     {
@@ -7,16 +7,17 @@ namespace PLC.Siemens.Protocol.Common
         /// </summary>
         OKFF = 0xFF,
 
-        OK=00,
+        OK = 00,
 
         /// <summary>
         /// PDUÈ·ÈÏʧ°Ü
         /// </summary>
         PduConfirmFault = 0x0999,
+
         CannotCopyRamToRom = 0x8001,
         ReadDataFalut = 0x9999,
         Unknown = 0xFFFF,
-        
+
         AddressOutOfRange = 0x0005,
         InvalidTransportSize = 0x0006,
         WriteDataSizeMismatch = 0x0007,
@@ -29,7 +30,5 @@ namespace PLC.Siemens.Protocol.Common
         NoPasswordToSet = 0xD605,
         FunNotAvailable = 0x8104,
         DataOverPdu = 0x8500,
-
-        
     }
-}
+}

+ 7 - 3
PLC.Siemens/Protocol/Common/ConnectionType.cs

@@ -1,11 +1,13 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum ConnectionType
     {
         // ReSharper disable once InconsistentNaming
         PG = 1,
+
         // ReSharper disable once InconsistentNaming
         OP = 2,
+
         // ReSharper disable once InconsistentNaming
         S7BASIC = 3,
     }
@@ -17,8 +19,10 @@
     public enum RWLevel
     {
         Unknown = 0x00,
+
         // ReSharper disable once InconsistentNaming
         RW = 0x01,
+
         R = 0x02,
     }
 
@@ -80,11 +84,11 @@
     {
         // Block languages
         AWL = 0x01,
+
         KOP = 0x02,
         FUP = 0x03,
         SCL = 0x04,
         DB = 0x05,
         GRAPH = 0x06,
-
     }
-}
+}

+ 1 - 1
PLC.Siemens/Protocol/Common/DataType.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public class CSTypeAttribute : Attribute
     {

+ 3 - 3
PLC.Siemens/Protocol/Common/ErrorType.cs

@@ -1,8 +1,8 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum ErrorType
     {
-        NoError=0,
+        NoError = 0,
         ErrIsoMask = 0x000F0000,
         ErrIsoBase = 0x0000FFFF,
 
@@ -22,4 +22,4 @@
         ErrIsoResvd3 = 0x000E0000, // Unassigned
         ErrIsoResvd4 = 0x000F0000, // Unassigned
     }
-}
+}

+ 1 - 1
PLC.Siemens/Protocol/Common/GrType.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum GrType
     {

+ 5 - 3
PLC.Siemens/Protocol/Common/PduFuncType.cs

@@ -1,9 +1,10 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum PduFuncType
     {
         // PDU Functions
         PduResponse = 0x02,   // Response (when error)
+
         PduFuncRead = 0x04,   // Read area
         PduFuncWrite = 0x05,   // Write area
         PduNegotiate = 0xF0,   // Negotiate PDU length
@@ -19,9 +20,10 @@
 
         // PDU SubFunctions
         SFunListAll = 0x01,   // List all blocks
+
         SFunListBoT = 0x02,   // List Blocks of type
         SFunBlkInfo = 0x03,   // Get Block info
-        SFunReadSzl = 0x01,   // Read SZL 
+        SFunReadSzl = 0x01,   // Read SZL
         SFunReadClock = 0x01,   // Read Clock (Date and Time)
         SFunSetClock = 0x02,   // Set Clock (Date and Time)
         SFunEnterPwd = 0x01,   // Enter password    for this session
@@ -29,4 +31,4 @@
         SFunInsert = 0x50,   // Insert block
         SFunDelete = 0x42,   // Delete block
     }
-}
+}

+ 2 - 2
PLC.Siemens/Protocol/Common/PduKind.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum PduKind
     {
@@ -9,4 +9,4 @@
         PkUnrecognizedType,
         PkValidData
     }
-}
+}

+ 9 - 5
PLC.Siemens/Protocol/Common/PduType.cs

@@ -1,23 +1,26 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum PduType
     {
         // PDU Type consts (Code + Credit)
         ConnRequest = 0xE0,  // Connection request
+
         ConnConfirm = 0xD0,  // Connection confirm
         DiscRequest = 0x80,  // Disconnect request
         DiscConfirm = 0xC0,  // Disconnect confirm
         DataTransfer = 0xF0,  // Data transfer
 
         EndTransfer = 0x80,  // End of Trasmission Packet (This packet is complete)
-        
+
         // PDU Type
         Request = 1,     // family request
+
         Response = 3,      // family response
         Userdata = 7,      // family user data
-        
+
         // PDU Functions
         PduResponse = 0x02,   // Response (when error)
+
         PduFuncRead = 0x04,   // Read area
         PduFuncWrite = 0x05,   // Write area
         PduNegotiate = 0xF0,   // Negotiate PDU length
@@ -33,9 +36,10 @@
 
         // PDU SubFunctions
         SFunListAll = 0x01,   // List all blocks
+
         SFunListBoT = 0x02,   // List Blocks of type
         SFunBlkInfo = 0x03,   // Get Block info
-        SFunReadSzl = 0x01,   // Read SZL 
+        SFunReadSzl = 0x01,   // Read SZL
         SFunReadClock = 0x01,   // Read Clock (Date and Time)
         SFunSetClock = 0x02,   // Set Clock (Date and Time)
         SFunEnterPwd = 0x01,   // Enter password    for this session
@@ -43,4 +47,4 @@
         SFunInsert = 0x50,   // Insert block
         SFunDelete = 0x42,   // Delete block
     }
-}
+}

+ 2 - 2
PLC.Siemens/Protocol/Common/S7CpuStatus.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum S7CpuStatus
     {
@@ -6,4 +6,4 @@
         Run = 0x08,
         Stop = 0x04,
     }
-}
+}

+ 2 - 2
PLC.Siemens/Protocol/Common/S7OpType.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum S7OpType
     {
@@ -32,4 +32,4 @@
         S7OpClearPassword = 27,
         S7OpDbFill = 28
     }
-}
+}

+ 2 - 2
PLC.Siemens/Protocol/Common/TsType.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.Common
+namespace PlcSiemens.Protocol.Common
 {
     public enum TsType
     {
@@ -8,4 +8,4 @@ namespace PLC.Siemens.Protocol.Common
         TsResReal = 0x07,
         TsResOctet = 0x09,
     }
-}
+}

+ 7 - 6
PLC.Siemens/Protocol/Control/CompressParamsRequest.cs

@@ -1,8 +1,8 @@
-using Core.Communication.Transport;
-using Core.Util.Extension;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.Core.Extension;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
     public class CompressParamsRequest
     {
@@ -11,7 +11,8 @@ namespace PLC.Siemens.Protocol.Control
         public ushort Len1;   // Length part 1 : 0x00
         public byte Len2;   // Length part 2 : 0x05
         public char[] Cmd;  // ascii '_GARB'
-        public ushort PacketLength   = 0x10;
+        public ushort PacketLength = 0x10;
+
         public void Build()
         {
             Fun = (byte)PduFuncType.PduControl;
@@ -30,4 +31,4 @@ namespace PLC.Siemens.Protocol.Control
             Cmd.ForEach(t => buffer.Push((byte)t));
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/Control/CompressRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
-    public class CompressRequest:IBuildRequest
+    public class CompressRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public CompressParamsRequest Params { get; set; }
@@ -30,4 +29,4 @@ namespace PLC.Siemens.Protocol.Control
             return buffer;
         }
     }
-}
+}

+ 6 - 6
PLC.Siemens/Protocol/Control/CopyRamToRomParamsRequest.cs

@@ -1,8 +1,8 @@
-using Core.Communication.Transport;
-using Core.Util.Extension;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.Core.Extension;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
     public class CopyRamToRomParamsRequest
     {
@@ -12,7 +12,7 @@ namespace PLC.Siemens.Protocol.Control
         public ushort SFun { get; set; }      // 'EP' 0x4550
         public byte Len2 { get; set; }     // Length part 2 : 0x05
         public char[] Cmd { get; set; }    // ascii '_MODU' 5
-        public ushort PacketLength   = 0x12;
+        public ushort PacketLength = 0x12;
 
         public void Build()
         {
@@ -34,4 +34,4 @@ namespace PLC.Siemens.Protocol.Control
             Cmd.ForEach(t => buffer.Push((byte)t));
         }
     }
-}
+}

+ 7 - 8
PLC.Siemens/Protocol/Control/CopyRamToRomRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
-    public class CopyRamToRomRequest:IBuildRequest
+    public class CopyRamToRomRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public CopyRamToRomParamsRequest Params { get; set; }
@@ -13,7 +12,7 @@ namespace PLC.Siemens.Protocol.Control
         public CopyRamToRomRequest()
         {
             Header = new HeaderPacket();
-            Params=new CopyRamToRomParamsRequest();
+            Params = new CopyRamToRomParamsRequest();
         }
 
         public void Build()
@@ -30,4 +29,4 @@ namespace PLC.Siemens.Protocol.Control
             return buffer;
         }
     }
-}
+}

+ 6 - 6
PLC.Siemens/Protocol/Control/PlcColdStartParamsRequest.cs

@@ -1,8 +1,8 @@
-using Core.Communication.Transport;
-using Core.Util.Extension;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.Core.Extension;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
     public class PlcColdStartParamsRequest
     {
@@ -12,7 +12,7 @@ namespace PLC.Siemens.Protocol.Control
         public ushort SFun;    // 'C ' 0x4320
         public byte Len2;   // Length part 2 : 0x09
         public char[] Cmd;  // ascii 'P_PROGRAM'
-        public ushort PacketLength   = 0x16;
+        public ushort PacketLength = 0x16;
 
         public void Build()
         {
@@ -34,4 +34,4 @@ namespace PLC.Siemens.Protocol.Control
             Cmd.ForEach(t => buffer.Push((byte)t));
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/Control/PlcColdStartRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
-    public class PlcColdStartRequest:IBuildRequest
+    public class PlcColdStartRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public PlcColdStartParamsRequest Params { get; set; }
@@ -30,4 +29,4 @@ namespace PLC.Siemens.Protocol.Control
             return buffer;
         }
     }
-}
+}

+ 8 - 6
PLC.Siemens/Protocol/Control/PlcHotStartParamsRequest.cs

@@ -1,18 +1,20 @@
-using Core.Communication.Transport;
-using Core.Util.Extension;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.Core.Extension;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
     public class PlcHotStartParamsRequest
     {
         public byte Fun;     // start 0x28
         public byte[] Uk7; // unknown 7
         public ushort Len1;   // Length part 1 : 0x0002
+
         //public ushort SFun;    // 'C ' 0x4320
         public byte Len2;   // Length part 2 : 0x09
+
         public char[] Cmd;  // ascii 'P_PROGRAM'
-        public ushort PacketLength   = 0x14;
+        public ushort PacketLength = 0x14;
 
         public void Build()
         {
@@ -34,4 +36,4 @@ namespace PLC.Siemens.Protocol.Control
             Cmd.ForEach(t => buffer.Push((byte)t));
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/Control/PlcHotStartRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
-    public class PlcHotStartRequest:IBuildRequest
+    public class PlcHotStartRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public PlcHotStartParamsRequest Params { get; set; }
@@ -30,4 +29,4 @@ namespace PLC.Siemens.Protocol.Control
             return buffer;
         }
     }
-}
+}

+ 12 - 10
PLC.Siemens/Protocol/Control/PlcStopParamsRequest.cs

@@ -1,8 +1,8 @@
-using Core.Communication.Transport;
-using Core.Util.Extension;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.Core.Extension;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
     public class PlcStopParamsRequest
     {
@@ -10,14 +10,16 @@ namespace PLC.Siemens.Protocol.Control
         public byte[] Uk5 { get; set; } // unknown 5 bytes 0x00
         public byte Len2 { get; set; }   // Length part 2 : 0x09
         public char[] Cmd { get; set; }  // ascii 'P_PROGRAM' 0x09
-        public ushort PacketLength { get{return 0x10;} } 
+
+        public ushort PacketLength
+        { get { return 0x10; } }
 
         public void Build()
         {
-            Fun = (byte) PduFuncType.PduStop;
-            Uk5 = new byte[] {0x00, 0x00, 0x00, 0x00, 0x00};
+            Fun = (byte)PduFuncType.PduStop;
+            Uk5 = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00 };
             Len2 = 0x09;
-            Cmd = new[] {'P', '_', 'P', 'R', 'O', 'G', 'R', 'A', 'M'};
+            Cmd = new[] { 'P', '_', 'P', 'R', 'O', 'G', 'R', 'A', 'M' };
         }
 
         public void GetByteBuffer(ByteBuffer buffer)
@@ -25,7 +27,7 @@ namespace PLC.Siemens.Protocol.Control
             buffer.Push(Fun);
             buffer.Push(Uk5);
             buffer.Push(Len2);
-            Cmd.ForEach(t=>buffer.Push((byte)t));
+            Cmd.ForEach(t => buffer.Push((byte)t));
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/Control/PlcStopRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Control
+namespace PlcSiemens.Protocol.Control
 {
-    public class PlcStopRequest:IBuildRequest
+    public class PlcStopRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public PlcStopParamsRequest Params { get; set; }
@@ -30,4 +29,4 @@ namespace PLC.Siemens.Protocol.Control
             return buffer;
         }
     }
-}
+}

+ 5 - 5
PLC.Siemens/Protocol/DateTime/ControlResponse.cs

@@ -1,8 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
     public class ControlResponse : IBuildResponse
     {
@@ -14,10 +13,11 @@ namespace PLC.Siemens.Protocol.DateTime
             Header = new HeaderPacketWithErrorCode();
             Params = new FunCtrlResponse();
         }
+
         public void Build(ByteBuffer buffer)
         {
             Header.Build(buffer);
             Params.Build(buffer);
         }
     }
-}
+}

+ 11 - 7
PLC.Siemens/Protocol/DateTime/DateTimeData.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
     public class DateTimeData
     {
@@ -11,7 +11,10 @@ namespace PLC.Siemens.Protocol.DateTime
         public byte Rsvd { get; set; }
         public byte HiYear { get; set; }
         public byte[] Time { get; set; }//³¤¶È8
-        public ushort PacketLength { get { return 0x0E; } }
+
+        public ushort PacketLength
+        { get { return 0x0E; } }
+
         public DateTimeData()
         {
             Time = new byte[8];
@@ -30,11 +33,11 @@ namespace PLC.Siemens.Protocol.DateTime
         public void Build(System.DateTime dt)
         {
             Ret = 0xFF;
-            Size = (byte) TsType.TsResOctet;
+            Size = (byte)TsType.TsResOctet;
             Length = 0x000A;
             Rsvd = 0x00;
             HiYear = 0x19; // *must* be 19 tough it's not the Hi part of the year...
-            
+
             Time[0] = WordToBcd((ushort)(dt.Year - 2000));
             Time[1] = WordToBcd((ushort)(dt.Month));
             Time[2] = WordToBcd((ushort)(dt.Day));
@@ -44,6 +47,7 @@ namespace PLC.Siemens.Protocol.DateTime
             Time[6] = 0x00;
             Time[7] = WordToBcd((ushort)(dt.DayOfWeek));
         }
+
         public void GetByteBuffer(ByteBuffer buffer)
         {
             buffer.Push(Ret);
@@ -59,4 +63,4 @@ namespace PLC.Siemens.Protocol.DateTime
             return (byte)(((value / 10) << 4) | (value % 10));
         }
     }
-}
+}

+ 4 - 4
PLC.Siemens/Protocol/DateTime/FunCtrlResponse.cs

@@ -1,6 +1,6 @@
-using Core.Communication.Transport;
+using PlcSiemens.O;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
     public class FunCtrlResponse
     {
@@ -9,8 +9,8 @@ namespace PLC.Siemens.Protocol.DateTime
 
         public void Build(ByteBuffer buffer)
         {
-            Fun= buffer.PopByte();
+            Fun = buffer.PopByte();
             Para = buffer.PopByte();
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/DateTime/GetDateTimeRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
-    public class GetDateTimeRequest:IBuildRequest
+    public class GetDateTimeRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public ParamsRequest Params { get; set; }
@@ -33,4 +32,4 @@ namespace PLC.Siemens.Protocol.DateTime
             return buffer;
         }
     }
-}
+}

+ 5 - 8
PLC.Siemens/Protocol/DateTime/GetDateTimeResponse.cs

@@ -1,10 +1,9 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
-    public class GetDateTimeResponse :IBuildResponse
+    public class GetDateTimeResponse : IBuildResponse
     {
         public HeaderPacket Header { get; set; }
         public ParamsResponse Params { get; set; }
@@ -17,7 +16,6 @@ namespace PLC.Siemens.Protocol.DateTime
             Data = new DateTimeData();
         }
 
-
         public void Build(ByteBuffer buffer)
         {
             Header.Build(buffer);
@@ -25,7 +23,6 @@ namespace PLC.Siemens.Protocol.DateTime
             Data.Build(buffer);
         }
 
-
         private int BcDtoByte(byte B)
         {
             return ((B >> 4) * 10) + (B & 0x0F);
@@ -47,4 +44,4 @@ namespace PLC.Siemens.Protocol.DateTime
             return dt;
         }
     }
-}
+}

+ 3 - 3
PLC.Siemens/Protocol/DateTime/HandleRequest.cs

@@ -1,10 +1,10 @@
-using PLC.Siemens.Protocol.Header;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
     public class HandleRequest
     {
         public HeaderPacket Header { get; set; }
         public ParamsResponse Params { get; set; }
     }
-}
+}

+ 5 - 6
PLC.Siemens/Protocol/DateTime/HandleResponse.cs

@@ -1,10 +1,9 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
-    public class HandleResponse<TResponseHeader>:IBuildResponse  where TResponseHeader : HeaderPacket, new()
+    public class HandleResponse<TResponseHeader> : IBuildResponse where TResponseHeader : HeaderPacket, new()
     {
         public TResponseHeader Header { get; set; }
         public ParamsResponse Params { get; set; }
@@ -23,4 +22,4 @@ namespace PLC.Siemens.Protocol.DateTime
             Data = buffer.PopBytes(Header.DataLen);
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/DateTime/SetDateTimeRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.DateTime
+namespace PlcSiemens.Protocol.DateTime
 {
-    public class SetDateTimeRequest:IBuildRequest
+    public class SetDateTimeRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public ParamsRequest Params { get; set; }
@@ -36,4 +35,4 @@ namespace PLC.Siemens.Protocol.DateTime
             return buffer;
         }
     }
-}
+}

+ 6 - 4
PLC.Siemens/Protocol/Header/CotpDataHeader.cs

@@ -1,6 +1,6 @@
-using Core.Communication.Transport;
+using PlcSiemens.O;
 
-namespace PLC.Siemens.Protocol.Header
+namespace PlcSiemens.Protocol.Header
 {
     public class CotpDataHeader
     {
@@ -10,7 +10,9 @@ namespace PLC.Siemens.Protocol.Header
                                            // EOT = 1 -> End of Trasmission Packet (This packet is complete)
                                            // PDU Number : Always 0
 
-        public ushort PacketLength { get{return 0x03;} } 
+        public ushort PacketLength
+        { get { return 0x03; } }
+
         public void GetByteBuffer(ByteBuffer buffer)
         {
             buffer.Push(Length);
@@ -18,4 +20,4 @@ namespace PLC.Siemens.Protocol.Header
             buffer.Push(EoTNum);
         }
     }
-}
+}

+ 9 - 4
PLC.Siemens/Protocol/Header/CotpHeader.cs

@@ -1,19 +1,23 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Iso;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Iso;
 
-namespace PLC.Siemens.Protocol.Header
+namespace PlcSiemens.Protocol.Header
 {
     public class CotpHeader
     {
         public byte Length { get; set; }     // Header length : initialized to 6 (length without params - 1)
+
         // descending classes that add values in params field must update it.
         public byte PduType { get; set; }    // 0xE0 Connection request
+
         // 0xD0 Connection confirm
         // 0x80 Disconnect request
         // 0xDC Disconnect confirm
         public ushort DstRef { get; set; }     // Destination reference : Always 0x0000
+
         public ushort SrcRef { get; set; }      // Source reference : Always 0x0000
         public byte CoR { get; set; }       // If the telegram is used for Connection request/Confirm,
+
         // the meaning of this field is CLASS+OPTION :
         //   Class (High 4 bits) + Option (Low 4 bits)
         //   Class : Always 4 (0100) but is ignored in input (RFC States this)
@@ -35,6 +39,7 @@ namespace PLC.Siemens.Protocol.Header
         // ISO 8073 define several type of parameters, but RFC 1006 recognizes only
         // TSAP related parameters and PDU size.  See RFC 0983 for more details.
         public CoptParams Params { get; set; }
+
         /* Other params not used here, list only for completeness
             ACK_TIME     	   = 0x85,  1000 0101 Acknowledge Time
             RES_ERROR    	   = 0x86,  1000 0110 Residual Error Rate
@@ -82,4 +87,4 @@ namespace PLC.Siemens.Protocol.Header
             Params.InitByBuffer(buffer);
         }
     }
-}
+}

+ 8 - 5
PLC.Siemens/Protocol/Header/HeaderPacket.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Header
+namespace PlcSiemens.Protocol.Header
 {
     public class HeaderPacket
     {
@@ -11,7 +11,9 @@ namespace PLC.Siemens.Protocol.Header
         public ushort Sequence { get; set; }// Message ID. This can be used to make sure a received answer
         public ushort ParLen { get; set; }   // Length of parameters which follow this header
         public ushort DataLen { get; set; }  // Length of data which follow the parameters
-        public ushort PacketLength { get{return 0x0A;} } 
+
+        public ushort PacketLength
+        { get { return 0x0A; } }
 
         public virtual void Build(ByteBuffer buffer)
         {
@@ -44,6 +46,7 @@ namespace PLC.Siemens.Protocol.Header
         }
 
         private static ushort _cntword = 1;
+
         protected static ushort GetNextWord()
         {
             if (_cntword == 0xFFFF)
@@ -51,4 +54,4 @@ namespace PLC.Siemens.Protocol.Header
             return _cntword++;
         }
     }
-}
+}

+ 4 - 4
PLC.Siemens/Protocol/Header/HeaderPacketWithErrorCode.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Header
+namespace PlcSiemens.Protocol.Header
 {
     public class HeaderPacketWithErrorCode : HeaderPacket
     {
@@ -18,4 +18,4 @@ namespace PLC.Siemens.Protocol.Header
             Error = (ResultCode)buffer.PopUshort();
         }
     }
-}
+}

+ 6 - 3
PLC.Siemens/Protocol/Header/TpktHeader.cs

@@ -1,6 +1,6 @@
-using Core.Communication.Transport;
+using PlcSiemens.O;
 
-namespace PLC.Siemens.Protocol.Header
+namespace PlcSiemens.Protocol.Header
 {
     // TPKT Header - ISO on TCP - RFC 1006 (4 bytes)
     // Packet length : min 7 max 65535
@@ -9,7 +9,10 @@ namespace PLC.Siemens.Protocol.Header
         public byte Version { get; set; }   // Always 3 for RFC 1006
         public byte Reserved { get; set; }  // 0
         public ushort Length { get; set; } //整个数据包的长度
-        public ushort PacketLength { get{return 0x04;} } 
+
+        public ushort PacketLength
+        { get { return 0x04; } }
+
         public void GetByteBuffer(ByteBuffer buffer)
         {
             buffer.Push(Version);

+ 4 - 4
PLC.Siemens/Protocol/Iso/CoptParams.cs

@@ -1,13 +1,13 @@
-using Core.Communication.Transport;
+using PlcSiemens.O;
 
-namespace PLC.Siemens.Protocol.Iso
+namespace PlcSiemens.Protocol.Iso
 {
     public class CoptParams
     {
         public byte PduSizeCode { get; set; }
         public byte PduSizeLen { get; set; }
         public byte PduSizeVal { get; set; }
-        public byte[] Tsap { get; set; } 
+        public byte[] Tsap { get; set; }
         public int TsapLenth { get; set; }
 
         public CoptParams()
@@ -34,4 +34,4 @@ namespace PLC.Siemens.Protocol.Iso
     }
 
     // COTP Header for DATA EXCHANGE
-}
+}

+ 16 - 10
PLC.Siemens/Protocol/Iso/IsoControlPdu.cs

@@ -1,21 +1,20 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Iso
+namespace PlcSiemens.Protocol.Iso
 {
-    public class IsoControlPdu :IBuildRequest,IBuildResponse
+    public class IsoControlPdu : IBuildRequest, IBuildResponse
     {
         public TpktHeader Tpkt { get; set; } // TPKT Header
         public CotpHeader Cotp { get; set; } // COPT Header for CONNECTION stuffs
 
-        
         public int IsoPduSize { get; set; }
         public ushort SrcRef { get; set; }
         public ushort DstRef { get; set; }
         public ushort SrcTSap { get; set; }
         public ushort DstTSap { get; set; }
+
         /// <summary>
         /// 该报发送长度和接受长度都应该为22
         /// </summary>
@@ -34,24 +33,31 @@ namespace PLC.Siemens.Protocol.Iso
                 case 128:
                     Cotp.Params.PduSizeVal = 0x07;
                     break;
+
                 case 256:
                     Cotp.Params.PduSizeVal = 0x08;
                     break;
+
                 case 512:
                     Cotp.Params.PduSizeVal = 0x09;
                     break;
+
                 case 1024:
                     Cotp.Params.PduSizeVal = 0x0A;
                     break;
+
                 case 2048:
                     Cotp.Params.PduSizeVal = 0x0B;
                     break;
+
                 case 4096:
                     Cotp.Params.PduSizeVal = 0x0C;
                     break;
+
                 case 8192:
                     Cotp.Params.PduSizeVal = 0x0D;
                     break;
+
                 default:
                     Cotp.Params.PduSizeVal = 0x0B;  // Our Default
                     break;
@@ -92,7 +98,7 @@ namespace PLC.Siemens.Protocol.Iso
 
         public void Build(byte[] resBytes)
         {
-            ByteBuffer buffer=ByteBuffer.Allocate();
+            ByteBuffer buffer = ByteBuffer.Allocate();
             buffer.Push(resBytes);
             Tpkt.InitByBuffer(buffer);
             Cotp.InitByBuffer(buffer);
@@ -100,7 +106,7 @@ namespace PLC.Siemens.Protocol.Iso
 
         public ByteBuffer GetBuffer()
         {
-            ByteBuffer buffer=ByteBuffer.Allocate();
+            ByteBuffer buffer = ByteBuffer.Allocate();
             Tpkt.GetByteBuffer(buffer);
             Cotp.GetByteBuffer(buffer);
             return buffer;
@@ -112,4 +118,4 @@ namespace PLC.Siemens.Protocol.Iso
             Cotp.InitByBuffer(buffer);
         }
     }
-}
+}

+ 6 - 8
PLC.Siemens/Protocol/Iso/IsoDataPdu.cs

@@ -1,9 +1,8 @@
-using Core.Communication.Transport;
-using PLC.Siemens.O;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Iso
+namespace PlcSiemens.Protocol.Iso
 {
     public class IsoDataPdu
     {
@@ -27,7 +26,7 @@ namespace PLC.Siemens.Protocol.Iso
         {
             Tpkt.Version = StaticConst.IsoTcpVersion;
             Tpkt.Reserved = 0;
-            Tpkt.Length = (ushort)(Length+0x07);
+            Tpkt.Length = (ushort)(Length + 0x07);
 
             Cotp.Length = (byte)(Cotp.PacketLength - 1);//去掉长度占用的一个字节
             Cotp.PduType = (byte)PduType.DataTransfer;
@@ -44,7 +43,6 @@ namespace PLC.Siemens.Protocol.Iso
             Cotp.Length = buffer.PopByte();
             Cotp.PduType = buffer.PopByte();
             Cotp.EoTNum = buffer.PopByte();
-
         }
     }
-}
+}

+ 4 - 4
PLC.Siemens/Protocol/ListBlocks/BlockItem.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class BlockItem
     {
@@ -16,4 +16,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             Count = buffer.PopUshort();
         }
     }
-}
+}

+ 5 - 5
PLC.Siemens/Protocol/ListBlocks/BlockItemListAll.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class BlockItemListAll
     {
@@ -12,7 +12,7 @@ namespace PLC.Siemens.Protocol.ListBlocks
 
         public void Build(ByteBuffer buffer)
         {
-            Ret = (ResultCode) buffer.PopByte();
+            Ret = (ResultCode)buffer.PopByte();
             Size = buffer.PopByte();
             Length = buffer.PopUshort();
             Items = new BlockItem[Length / 4];
@@ -25,4 +25,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             }
         }
     }
-}
+}

+ 4 - 4
PLC.Siemens/Protocol/ListBlocks/BotItem.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class BotItem
     {
@@ -16,4 +16,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             BlockLang = (BlockLangType)buffer.PopByte();
         }
     }
-}
+}

+ 4 - 4
PLC.Siemens/Protocol/ListBlocks/BotItemListAll.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class BotItemListAll
     {
@@ -25,4 +25,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             }
         }
     }
-}
+}

+ 6 - 5
PLC.Siemens/Protocol/ListBlocks/DataBlockInfoDataRequest.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class DataBlockInfoDataRequest
     {
@@ -13,7 +13,8 @@ namespace PLC.Siemens.Protocol.ListBlocks
         public byte[] AsciiBlk { get; set; } // BlockNum in ascii
         public byte A { get; set; }
 
-        public ushort PacketLength { get { return (ushort)(7 + AsciiBlk.Length); } }
+        public ushort PacketLength
+        { get { return (ushort)(7 + AsciiBlk.Length); } }
 
         public void Build(BlockType blockType, ushort db)
         {
@@ -47,4 +48,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             buffer.Push(A);
         }
     }
-}
+}

+ 7 - 7
PLC.Siemens/Protocol/ListBlocks/DataBlockInfoDataResponse.cs

@@ -1,9 +1,8 @@
-using System;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 using System.Text;
-using PLC.Siemens.Protocol.Common;
-using ByteBuffer = Core.Communication.Transport.ByteBuffer;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class DataBlockInfoDataResponse
     {
@@ -22,11 +21,13 @@ namespace PLC.Siemens.Protocol.ListBlocks
         public ushort BlkNumber { get; set; }
         public uint LenLoadMem { get; set; }
         public byte[] BlkSec { get; set; }//[4]
+
         //public uint CodeTimeMs { get; set; }
         //public ushort CodeTimeDy { get; set; }
         //public uint IntfTimeMs { get; set; }
         //public ushort IntfTimeDy { get; set; }
         public System.DateTime CodeDateTime { get; set; }
+
         public System.DateTime IntfDateTime { get; set; }
         public ushort SbbLen { get; set; }
         public ushort AddLen { get; set; }
@@ -75,7 +76,7 @@ namespace PLC.Siemens.Protocol.ListBlocks
             BlkNumber = buffer.PopUshort();
             LenLoadMem = buffer.PopUint();
             BlkSec = buffer.PopBytes(4);// { get; set; }//[4]
-            var codeTimeMs = buffer.PopUint();//毫秒时间 
+            var codeTimeMs = buffer.PopUint();//毫秒时间
             var codeTimeDy = buffer.PopUshort();//天数 开始时间1984/1/1
             var intfTimeMs = buffer.PopUint();//毫秒时间
             var intfTimeDy = buffer.PopUshort();//天数 开始时间1984/1/1
@@ -94,7 +95,6 @@ namespace PLC.Siemens.Protocol.ListBlocks
             Family = Encoding.UTF8.GetString(family).TrimEnd('\0');
             Header = Encoding.UTF8.GetString(header).TrimEnd('\0');
 
-
             Version = buffer.PopByte();
             Unknown2 = buffer.PopByte();
             BlkChksum = buffer.PopUshort();
@@ -123,4 +123,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
         //           $"Header       : {Header}";
         //}
     }
-}
+}

+ 7 - 8
PLC.Siemens/Protocol/ListBlocks/DataBlockInfoRequest.cs

@@ -1,18 +1,17 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
-    public class DataBlockInfoRequest:IBuildRequest
+    public class DataBlockInfoRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public ParamsRequest Params { get; set; }
         public DataBlockInfoDataRequest Data { get; set; }
 
         public BlockType BlockType { get; set; }
-        public  ushort DB { get; set; }
+        public ushort DB { get; set; }
 
         public DataBlockInfoRequest()
         {
@@ -39,4 +38,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             return buffer;
         }
     }
-}
+}

+ 9 - 11
PLC.Siemens/Protocol/ListBlocks/DataBlockInfoResponse.cs

@@ -1,10 +1,9 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
-    public class DataBlockInfoResponse:IBuildResponse
+    public class DataBlockInfoResponse : IBuildResponse
     {
         public HeaderPacket Header { get; set; }
         public ParamsResponse Params { get; set; }
@@ -12,17 +11,16 @@ namespace PLC.Siemens.Protocol.ListBlocks
 
         public DataBlockInfoResponse()
         {
-            Header=new HeaderPacket();
-            Params=new ParamsResponse();
-            Data=new DataBlockInfoDataResponse();
+            Header = new HeaderPacket();
+            Params = new ParamsResponse();
+            Data = new DataBlockInfoDataResponse();
         }
-        
+
         public void Build(ByteBuffer buffer)
         {
-
             Header.Build(buffer);
             Params.Build(buffer);
             Data.Build(buffer);
         }
     }
-}
+}

+ 6 - 5
PLC.Siemens/Protocol/ListBlocks/DataBlockOfTypeDataRequest.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class DataBlockOfTypeDataRequest
     {
@@ -12,7 +12,8 @@ namespace PLC.Siemens.Protocol.ListBlocks
         public BlockType BlockType { get; set; }
         public bool First { get; private set; }
 
-        public ushort PacketLength { get { return First ? (ushort)0x06 : (ushort)0x04; } }
+        public ushort PacketLength
+        { get { return First ? (ushort)0x06 : (ushort)0x04; } }
 
         public void Build(bool first, BlockType blockType)
         {
@@ -47,4 +48,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             buffer.Push((byte)BlockType);
         }
     }
-}
+}

+ 8 - 9
PLC.Siemens/Protocol/ListBlocks/DataBlockOfTypeRequest.cs

@@ -1,10 +1,9 @@
-using Core.Communication.Transport;
-using Core.Util.Extension;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.Core.Extension;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
     public class DataBlockOfTypeRequest : IBuildRequest
     {
@@ -14,9 +13,9 @@ namespace PLC.Siemens.Protocol.ListBlocks
 
         public byte[] PadData { get; set; }
 
-        public bool First   = true;
+        public bool First = true;
         public BlockType BlockType { get; set; }
-        public byte Seq   = 0x00;
+        public byte Seq = 0x00;
 
         public DataBlockOfTypeRequest()
         {
@@ -51,4 +50,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             return buffer;
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/ListBlocks/DataBlockOfTypeResponse.cs

@@ -1,10 +1,9 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
-    public class DataBlockOfTypeResponse:IBuildResponse
+    public class DataBlockOfTypeResponse : IBuildResponse
     {
         public HeaderPacket Header { get; set; }
         public ParamsResponse Params { get; set; }
@@ -14,7 +13,7 @@ namespace PLC.Siemens.Protocol.ListBlocks
         {
             Header = new HeaderPacket();
             Params = new ParamsResponse();
-            Data=new BotItemListAll();
+            Data = new BotItemListAll();
         }
 
         public void Build(ByteBuffer buffer)
@@ -24,4 +23,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             Data.Build(buffer);
         }
     }
-}
+}

+ 6 - 7
PLC.Siemens/Protocol/ListBlocks/ListBlocksRequest.cs

@@ -1,11 +1,10 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
-    public class ListBlocksRequest:IBuildRequest
+    public class ListBlocksRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public ParamsRequest Params { get; set; }
@@ -33,4 +32,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             return buffer;
         }
     }
-}
+}

+ 9 - 10
PLC.Siemens/Protocol/ListBlocks/ListBlocksResponse.cs

@@ -1,20 +1,19 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.ListBlocks
+namespace PlcSiemens.Protocol.ListBlocks
 {
-    public class ListBlocksResponse:IBuildResponse
+    public class ListBlocksResponse : IBuildResponse
     {
         public HeaderPacket Header { get; set; }
         public ParamsResponse Params { get; set; }
         public BlockItemListAll Data { get; set; }
 
-        public ListBlocksResponse()  
+        public ListBlocksResponse()
         {
-            Header=new HeaderPacket();
-            Params=new ParamsResponse();
-            Data=new BlockItemListAll();
+            Header = new HeaderPacket();
+            Params = new ParamsResponse();
+            Data = new BlockItemListAll();
         }
 
         public void Build(ByteBuffer buffer)
@@ -24,4 +23,4 @@ namespace PLC.Siemens.Protocol.ListBlocks
             Data.Build(buffer);
         }
     }
-}
+}

+ 5 - 7
PLC.Siemens/Protocol/Negotiate/NegotiateRequest.cs

@@ -1,16 +1,14 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Negotiate
+namespace PlcSiemens.Protocol.Negotiate
 {
     public class NegotiateRequest : IBuildRequest
     {
         public HeaderPacket Header { get; set; }
         public NegotiateRequestParams Params { get; set; }
 
-
         public ushort PduRequestLength { get; set; }
 
         public void Build()
@@ -30,4 +28,4 @@ namespace PLC.Siemens.Protocol.Negotiate
             return buffer;
         }
     }
-}
+}

+ 5 - 6
PLC.Siemens/Protocol/Negotiate/NegotiateRequestParams.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.Negotiate
+namespace PlcSiemens.Protocol.Negotiate
 {
     public class NegotiateRequestParams
     {
@@ -11,7 +11,7 @@ namespace PLC.Siemens.Protocol.Negotiate
         public ushort ParallelJobs2 { get; set; }
         public ushort PduLength { get; set; }
 
-        public ushort PacketLength  = 0x08;
+        public ushort PacketLength = 0x08;
 
         public void GetByteBuffer(ByteBuffer buffer)
         {
@@ -31,5 +31,4 @@ namespace PLC.Siemens.Protocol.Negotiate
             PduLength = pduRequest;
         }
     }
-
-}
+}

+ 5 - 6
PLC.Siemens/Protocol/Negotiate/NegotiateResponse.cs

@@ -1,10 +1,9 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Header;
-using PLC.Siemens.O;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Header;
 
-namespace PLC.Siemens.Protocol.Negotiate
+namespace PlcSiemens.Protocol.Negotiate
 {
-    public class NegotiateResponse:IBuildResponse
+    public class NegotiateResponse : IBuildResponse
     {
         public HeaderPacketWithErrorCode Header { get; set; }
         public NegotiateResponseParams Params { get; set; }
@@ -21,4 +20,4 @@ namespace PLC.Siemens.Protocol.Negotiate
             Params.Build(buffer);
         }
     }
-}
+}

+ 4 - 4
PLC.Siemens/Protocol/Negotiate/NegotiateResponseParams.cs

@@ -1,6 +1,6 @@
-using Core.Communication.Transport;
+using PlcSiemens.O;
 
-namespace PLC.Siemens.Protocol.Negotiate
+namespace PlcSiemens.Protocol.Negotiate
 {
     public class NegotiateResponseParams
     {
@@ -10,7 +10,7 @@ namespace PLC.Siemens.Protocol.Negotiate
         public ushort ParallelJobs2 { get; set; }
         public ushort PduLength { get; set; }
 
-        public void  Build(ByteBuffer buffer)
+        public void Build(ByteBuffer buffer)
         {
             FunNegotiate = buffer.PopByte();
             Unknown = buffer.PopByte();
@@ -19,4 +19,4 @@ namespace PLC.Siemens.Protocol.Negotiate
             PduLength = buffer.PopUshort();
         }
     }
-}
+}

+ 10 - 10
PLC.Siemens/Protocol/ParamsRequest.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol
+namespace PlcSiemens.Protocol
 {
     /// <summary>
     /// 请求数据包参数
@@ -17,7 +17,7 @@ namespace PLC.Siemens.Protocol
         public ushort Rsvd { get; set; }//Next所需的参数
         public ushort ErrNo { get; set; }//Next所需的参数
 
-        public bool First   = true;
+        public bool First = true;
 
         public ushort PacketLength
         {
@@ -37,8 +37,8 @@ namespace PLC.Siemens.Protocol
             buffer.Push(Tg);
             buffer.Push(SubFun);
             buffer.Push(Seq);
-            if(First) return;
-            
+            if (First) return;
+
             buffer.Push(Rsvd);
             buffer.Push(ErrNo);
         }
@@ -46,15 +46,15 @@ namespace PLC.Siemens.Protocol
         public void Build(bool first, byte seq, GrType grType, PduFuncType pduFuncType)
         {
             First = first;
-            Head = new byte[] {0x00, 0x01, 0x12};
+            Head = new byte[] { 0x00, 0x01, 0x12 };
             PLen = first ? (byte)0x04 : (byte)0x08;
             Uk = 0x11;//用处未知 有时会有0x11
-            Tg = (byte) grType;
-            SubFun = (byte) pduFuncType;
+            Tg = (byte)grType;
+            SubFun = (byte)pduFuncType;
             Seq = seq;
             if (first) return;
             Rsvd = 0x0000;
             ErrNo = 0x0000;
         }
     }
-}
+}

+ 5 - 5
PLC.Siemens/Protocol/ParamsResponse.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol
+namespace PlcSiemens.Protocol
 {
     /// <summary>
     /// ·µ»ØÊý¾Ý°ü²ÎÊý
@@ -17,7 +17,7 @@ namespace PLC.Siemens.Protocol
         public ushort Rsvd { get; set; } // Reserved 0x0000
         public ResultCode Err { get; set; }   // Error Code
 
-        public ushort PacketLength  = 0x0C;
+        public ushort PacketLength = 0x0C;
 
         public ParamsResponse()
         {
@@ -36,4 +36,4 @@ namespace PLC.Siemens.Protocol
             Err = (ResultCode)buffer.PopUshort();
         }
     }
-}
+}

+ 6 - 6
PLC.Siemens/Protocol/ReadData/DataItem.cs

@@ -1,7 +1,7 @@
-using PLC.Siemens.O;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ReadData
+namespace PlcSiemens.Protocol.ReadData
 {
     public class DataItem
     {
@@ -13,7 +13,7 @@ namespace PLC.Siemens.Protocol.ReadData
         public ResultCode Err { get; set; }
         public byte[] Data { get; set; }
         public int DataOffset { get; set; }
-        public byte SizeByte { get { return HelperFunction.DataSizeByte(DataType); } }
-
+        public byte SizeByte
+        { get { return HelperFunction.DataSizeByte(DataType); } }
     }
-}
+}

+ 1 - 1
PLC.Siemens/Protocol/ReadData/ReadItemRequest.cs

@@ -1,4 +1,4 @@
-namespace PLC.Siemens.Protocol.ReadData
+namespace PlcSiemens.Protocol.ReadData
 {
     public class ReadItemRequest
     {

+ 5 - 5
PLC.Siemens/Protocol/ReadData/ReadItemResponse.cs

@@ -1,7 +1,7 @@
-using Core.Communication.Transport;
-using PLC.Siemens.Protocol.Common;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ReadData
+namespace PlcSiemens.Protocol.ReadData
 {
     public class ReadItemResponse
     {
@@ -21,8 +21,8 @@ namespace PLC.Siemens.Protocol.ReadData
 
             Data = buffer.PopBytes(DataLength);
             //如果读取数量为奇数则取出一条填充字节
-            if (Data.Length%2 != 0)
+            if (Data.Length % 2 != 0)
                 buffer.PopByte();
         }
     }
-}
+}

+ 16 - 13
PLC.Siemens/Protocol/ReadData/ReadParamsRequest.cs

@@ -1,24 +1,29 @@
-using System.Collections.Generic;
-using Core.Communication.Transport;
-using Core.Util.Extension;
-using PLC.Siemens.Protocol.Common;
+using PLC.Siemens.Protocol.ReadData;
+using PlcSiemens.Core.Extension;
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
 
-namespace PLC.Siemens.Protocol.ReadData
+namespace PlcSiemens.Protocol.ReadData
 {
     public class ReadParamsRequest
     {
         public byte FunRead { get; set; }
         public byte ItemsCount { get; set; }
-        public ReadItemRequest[] Items{ get; set; }//最大长度20
-        public byte PacketLength {get{
-            return (byte)(0x0C * Items.Length + 2); 
-        }} 
+        public ReadItemRequest[] Items { get; set; }//最大长度20
+
+        public byte PacketLength
+        {
+            get
+            {
+                return (byte)(0x0C * Items.Length + 2);
+            }
+        }
 
         public void Build(List<DataItem> dataItems)
         {
             //Header
             FunRead = (byte)PduFuncType.PduFuncRead;
-            ItemsCount = (byte) dataItems.Count;
+            ItemsCount = (byte)dataItems.Count;
             //项处理
             Items = new ReadItemRequest[ItemsCount];
 
@@ -54,7 +59,6 @@ namespace PLC.Siemens.Protocol.ReadData
             }
         }
 
-
         public void GetByteBuffer(ByteBuffer buffer)
         {
             buffer.Push(FunRead);
@@ -69,7 +73,6 @@ namespace PLC.Siemens.Protocol.ReadData
                 buffer.Push(t.Area);
                 buffer.Push(t.Address);
             });
-           
         }
     }
-}
+}

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini