From fe78ade0acf1c83986fe0b5ffa92fd2ead09555c Mon Sep 17 00:00:00 2001
From: vincent <1341870251@qq.com>
Date: 星期四, 04 六月 2020 16:04:12 +0800
Subject: [PATCH] #gateway-core

---
 src/main/java/com/zy/gateway/core/domain/FunctionOperateExOne.java    |    8 
 src/main/java/com/zy/gateway/core/domain/ActionOperate.java           |   15 
 src/main/java/com/zy/gateway/core/domain/ActionOperateExThree.java    |   20 
 src/main/java/com/zy/gateway/core/base/SoftBasic.java                 |  383 +++
 src/main/java/com/zy/gateway/core/domain/FunctionOperate.java         |    8 
 src/main/java/com/zy/gateway/core/transfer/DataFormat.java            |   23 
 src/main/java/com/zy/gateway/core/base/SoftZipped.java                |   49 
 src/main/java/com/zy/gateway/core/domain/OperateResultExFour.java     |  100 
 src/main/java/com/zy/gateway/core/StringResources.java                |   48 
 src/main/java/com/zy/gateway/pipeline/PipelineProperties.java         |   96 
 src/main/java/com/zy/gateway/core/net/HslProtocol.java                |  229 +
 src/main/java/com/zy/gateway/Test.java                                |   90 
 src/main/java/com/zy/gateway/core/language/DefaultLanguage.java       |  282 ++
 src/main/java/com/zy/gateway/core/base/HslSecurity.java               |   29 
 src/main/java/com/zy/gateway/core/transfer/ByteTransformBase.java     |  545 ++++
 src/main/java/com/zy/gateway/core/domain/siemens/S7Message.java       |   74 
 src/main/java/com/zy/gateway/core/transfer/IByteTransform.java        |  264 ++
 src/main/java/com/zy/gateway/core/IReadWriteNet.java                  |  227 +
 src/main/java/com/zy/gateway/core/domain/OperateResultExThree.java    |   94 
 src/main/java/com/zy/gateway/core/net/IReadWriteNet.java              |  227 +
 src/main/java/com/zy/gateway/pipeline/PipelineBootstrap.java          |   81 
 src/main/java/com/zy/gateway/core/domain/ActionOperateExTwo.java      |   19 
 src/main/java/com/zy/gateway/core/net/NetworkDeviceBase.java          |  443 +++
 src/main/java/com/zy/gateway/core/utils/Utilities.java                |  379 +++
 src/main/java/com/zy/gateway/core/net/NetworkBase.java                |  317 ++
 src/main/java/com/zy/gateway/pipeline/Test.java                       |   21 
 src/main/java/com/zy/gateway/core/transfer/ByteTransformHelper.java   |  175 +
 src/main/java/com/zy/gateway/pipeline/Bootstrap.java                  |   12 
 src/main/java/com/zy/gateway/core/domain/ActionOperateExOne.java      |   17 
 src/main/java/com/zy/gateway/core/net/session/AlienSession.java       |   74 
 src/main/java/com/zy/gateway/core/language/English.java               |  463 +++
 src/main/java/com/zy/gateway/core/domain/OperateResult.java           |   91 
 src/main/java/com/zy/gateway/core/domain/OperateResultExOne.java      |   67 
 src/main/java/com/zy/gateway/core/log/ILogNet.java                    |  146 +
 src/main/java/com/zy/gateway/pipeline/HandlerInitializer.java         |   51 
 src/main/java/com/zy/gateway/core/log/HslMessageDegree.java           |   31 
 src/main/java/com/zy/gateway/core/net/session/AppSession.java         |  228 +
 src/main/java/com/zy/gateway/core/net/siemens/SiemensS7Net.java       |  808 ++++++
 src/main/java/com/zy/gateway/core/domain/siemens/INetMessage.java     |   75 
 src/main/java/com/zy/gateway/core/domain/OperateResultExTwo.java      |   79 
 src/main/java/com/zy/gateway/core/domain/siemens/SiemensPLCS.java     |   27 
 src/main/java/com/zy/gateway/core/net/NetworkDoubleBase.java          |  621 +++++
 src/main/java/com/zy/gateway/core/transfer/ReverseBytesTransform.java |  212 +
 src/main/java/com/zy/gateway/core/domain/HslTimeOut.java              |   41 
 src/main/java/com/zy/gateway/core/domain/IDataTransfer.java           |   26 
 45 files changed, 7,315 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/zy/gateway/Test.java b/src/main/java/com/zy/gateway/Test.java
new file mode 100644
index 0000000..1ba856c
--- /dev/null
+++ b/src/main/java/com/zy/gateway/Test.java
@@ -0,0 +1,90 @@
+package com.zy.gateway;
+
+import com.zy.gateway.core.domain.OperateResult;
+import com.zy.gateway.core.domain.OperateResultExOne;
+import com.zy.gateway.core.domain.siemens.SiemensPLCS;
+import com.zy.gateway.core.net.siemens.SiemensS7Net;
+
+/**
+ * Created by vincent on 2020-06-04
+ */
+public class Test {
+
+    public static void main(String[] args) throws InterruptedException {
+        SiemesTest();
+        try {
+
+            SiemensS7Net siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200,"192.168.1.102");
+            OperateResult write = siemensS7Net.Write("M200",(short)200);
+
+            if(!write.IsSuccess){
+                System.out.println("Write failed:"+write.Message);
+            }
+
+            OperateResultExOne<Short> read = siemensS7Net.ReadInt16("M200");
+            if(read.IsSuccess){
+                System.out.println("Value:"+read.Content.toString());
+            }
+            else {
+                System.out.println("Read failed:"+read.Message);
+            }
+        }
+        catch (Exception ex){
+            System.out.println(ex.getMessage());
+        }
+        Thread.sleep(1000);
+    }
+
+    private static void SiemesTest(){
+        SiemensS7Net siemens_net = new SiemensS7Net(SiemensPLCS.S1200,"192.168.1.102");
+        OperateResult connect = siemens_net.ConnectServer();
+        if(connect.IsSuccess){
+            System.out.println("connect success!");
+        }
+        else {
+            System.out.println("failed:"+connect.Message);
+        }
+        siemens_net.ConnectClose();
+
+        // 涓婇潰鏄垵濮嬪寲
+        System.out.println(siemens_net.ReadByte("M100").Content);
+
+        byte m100_byte = siemens_net.ReadByte("M100").Content;
+        short m100_short = siemens_net.ReadInt16("M100").Content;
+        int m100_int = siemens_net.ReadInt32("M100").Content;
+        long m100_long = siemens_net.ReadInt64("M100").Content;
+        float m100_float = siemens_net.ReadFloat("M100").Content;
+        double m100_double = siemens_net.ReadDouble("M100").Content;
+        String m100_string = siemens_net.ReadString("M100",(short) 10).Content;
+
+        siemens_net.Write("M100",(byte) 123);
+        siemens_net.Write("M100",(short) 123);
+        siemens_net.Write("M100",(int) 123);
+        siemens_net.Write("M100",(long) 123);
+        siemens_net.Write("M100", 123.456f);
+        siemens_net.Write("M100", 123.456d);
+        siemens_net.Write("M100","1234567890");
+
+        OperateResultExOne<byte[]> read = siemens_net.Read( "M100", (short) 10 );
+        {
+            if(read.IsSuccess)
+            {
+                byte m100 = read.Content[0];
+                byte m101 = read.Content[1];
+                byte m102 = read.Content[2];
+                byte m103 = read.Content[3];
+                byte m104 = read.Content[4];
+                byte m105 = read.Content[5];
+                byte m106 = read.Content[6];
+                byte m107 = read.Content[7];
+                byte m108 = read.Content[8];
+                byte m109 = read.Content[9];
+            }
+            else
+            {
+                // 鍙戠敓浜嗗紓甯�
+            }
+        }
+
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/IReadWriteNet.java b/src/main/java/com/zy/gateway/core/IReadWriteNet.java
new file mode 100644
index 0000000..8c809b2
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/IReadWriteNet.java
@@ -0,0 +1,227 @@
+package com.zy.gateway.core;
+
+import com.zy.gateway.core.domain.IDataTransfer;
+import com.zy.gateway.core.domain.OperateResult;
+import com.zy.gateway.core.domain.OperateResultExOne;
+
+/**
+ * 鎵�鏈夎澶囦氦浜掔被鐨勭粺涓�鐨勮鍐欐帴鍙�
+ */
+public interface IReadWriteNet {
+
+    /**
+     * 鎵归噺璇诲彇搴曞眰鐨勬暟鎹俊鎭紝闇�瑕佹寚瀹氬湴鍧�鍜岄暱搴︼紝鍏蜂綋鐨勭粨鏋滃彇鍐充簬瀹炵幇
+     * @param address 鍦板潃淇℃伅
+     * @param length 鏁版嵁闀垮害
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刡yte[]鏁扮粍
+     */
+    OperateResultExOne<byte[]> Read(String address, short length);
+
+    /**
+     * 璇诲彇16浣嶇殑鏈夌鍙锋暣鍨�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨剆hort鏁版嵁
+     */
+    OperateResultExOne<Short> ReadInt16(String address);
+
+    /**
+     * 璇诲彇16浣嶇殑鏈夌鍙锋暣鍨嬫暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨剆hort鏁扮粍
+     */
+    OperateResultExOne<short []> ReadInt16(String address, short length);
+
+    /**
+     * 璇诲彇32浣嶇殑鏈夌鍙锋暣鍨�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刬nt鏁版嵁
+     */
+    OperateResultExOne<Integer> ReadInt32(String address);
+
+    /**
+     * 璇诲彇32浣嶆湁绗﹀彿鏁村瀷鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<int[]> ReadInt32(String address, short length);
+
+    /**
+     * 璇诲彇64浣嶇殑鏈夌鍙锋暣鍨�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刲ong鏁版嵁
+     */
+    OperateResultExOne<Long> ReadInt64(String address);
+
+    /**
+     * 璇诲彇64浣嶇殑鏈夌鍙锋暣鍨嬫暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<long[]> ReadInt64(String address, short length);
+
+    /**
+     * 璇诲彇鍗曟诞鐐圭簿搴︾殑鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刦loat鏁版嵁
+     */
+    OperateResultExOne<Float> ReadFloat(String address);
+
+    /**
+     * 璇诲彇鍗曟诞鐐圭簿搴︾殑鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<float[]> ReadFloat(String address, short length);
+
+    /**
+     * 璇诲彇鍙屾诞鐐圭簿搴︾殑鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刣ouble鏁版嵁
+     */
+    OperateResultExOne<Double> ReadDouble(String address);
+
+
+    /**
+     * 璇诲彇鍙屾诞鐐圭簿搴︾殑鏁版嵁鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<double[]> ReadDouble(String address, short length);
+
+    /**
+     * 璇诲彇瀛楃涓叉暟鎹�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁版嵁闀垮害
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨剆tring鏁版嵁
+     */
+    OperateResultExOne<String> ReadString(String address, short length);
+
+
+    /**
+     * 璇诲彇鑷畾涔夌殑鏁版嵁绫诲瀷锛岄渶瑕佺户鎵胯嚜IDataTransfer鎺ュ彛
+     * @param address 璧峰鍦板潃
+     * @param <T> 鑷畾涔夌殑绫诲瀷
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勮嚜瀹氫箟绫诲瀷鏁版嵁
+     */
+    <T extends IDataTransfer> OperateResultExOne<T> ReadCustomer(String address, Class<T> tClass);
+
+
+
+
+
+
+
+
+    /**
+     * 鍐欏叆short鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, short value);
+
+    /**
+     * 鍐欏叆short鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, short[] values);
+
+    /**
+     * 鍐欏叆int鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, int value);
+
+    /**
+     * 鍐欏叆int[]鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, int[] values);
+
+    /**
+     * 鍐欏叆long鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, long value);
+
+    /**
+     * 鍐欏叆long鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, long[] values);
+
+    /**
+     * 鍐欏叆float鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, float value);
+
+    /**
+     * 鍐欏叆float鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, float[] values);
+
+    /**
+     * 鍐欏叆double鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, double value);
+
+    /**
+     * 鍐欏叆double鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, double[] values);
+
+    /**
+     * 鍐欏叆瀛楃涓蹭俊鎭紝缂栫爜涓篈SCII
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, String value);
+
+
+    /**
+     * 鍐欏叆瀛楃涓蹭俊鎭紝缂栫爜涓篈SCII
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @param length 鍐欏叆鐨勫瓧绗︿覆鐨勯暱搴�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, String value, int length);
+
+    /**
+     * 鍐欏叆鑷畾涔夌被鍨嬬殑鏁版嵁锛岃绫诲瀷蹇呴』缁ф壙鑷狪DataTransfer鎺ュ彛
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @param <T> 绫诲瀷瀵硅薄
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    <T extends IDataTransfer> OperateResult WriteCustomer(String address, T value);
+
+}
diff --git a/src/main/java/com/zy/gateway/core/StringResources.java b/src/main/java/com/zy/gateway/core/StringResources.java
new file mode 100644
index 0000000..c625816
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/StringResources.java
@@ -0,0 +1,48 @@
+package com.zy.gateway.core;
+
+import com.zy.gateway.core.language.DefaultLanguage;
+import com.zy.gateway.core.language.English;
+
+import java.util.Locale;
+
+public class StringResources {
+
+    static
+    {
+        Locale locale = Locale.getDefault();
+        if (locale.getLanguage().startsWith( "zh" ))
+        {
+            SetLanguageChinese( );
+        }
+        else
+        {
+            SeteLanguageEnglish( );
+        }
+    }
+
+    /**
+     * 鑾峰彇鎴栬缃郴缁熺殑璇█閫夐」 ->
+     * Gets or sets the language options for the system
+     */
+    public static DefaultLanguage Language = new DefaultLanguage( );
+
+    /**
+     * 灏嗚瑷�璁剧疆涓轰腑鏂� ->
+     * Set the language to Chinese
+     */
+    public static void SetLanguageChinese( )
+    {
+        Language = new DefaultLanguage( );
+    }
+
+
+    /**
+     * 灏嗚瑷�璁剧疆涓鸿嫳鏂� ->
+     * Set the language to English
+     */
+    public static void SeteLanguageEnglish( )
+    {
+        Language = new English( );
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/base/HslSecurity.java b/src/main/java/com/zy/gateway/core/base/HslSecurity.java
new file mode 100644
index 0000000..f0a441e
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/base/HslSecurity.java
@@ -0,0 +1,29 @@
+package com.zy.gateway.core.base;
+
+public class HslSecurity {
+
+    /// <summary>
+    /// 鍔犲瘑鏂规硶锛屽彧瀵瑰綋鍓嶇殑绋嬪簭闆嗗紑鏀�
+    /// </summary>
+    /// <param name="enBytes">绛夊緟鍔犲瘑鐨勬暟鎹�</param>
+    /// <returns>鍔犲瘑鍚庣殑鏁版嵁</returns>
+    public static byte[] ByteEncrypt(byte[] enBytes) {
+        if (enBytes == null) return null;
+        byte[] result = new byte[enBytes.length];
+        for (int i = 0; i < enBytes.length; i++) {
+            result[i] = (byte) (enBytes[i] ^ 0xB5);
+        }
+        return result;
+    }
+
+
+    /// <summary>
+    /// 瑙e瘑鏂规硶锛屽彧瀵瑰綋鍓嶇殑绋嬪簭闆嗗紑鏀�
+    /// </summary>
+    /// <param name="deBytes">绛夊緟瑙e瘑鐨勬暟鎹�</param>
+    /// <returns>瑙e瘑鍚庣殑鏁版嵁</returns>
+    public static byte[] ByteDecrypt(byte[] deBytes) {
+        return ByteEncrypt(deBytes);
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/base/SoftBasic.java b/src/main/java/com/zy/gateway/core/base/SoftBasic.java
new file mode 100644
index 0000000..29686f5
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/base/SoftBasic.java
@@ -0,0 +1,383 @@
+package com.zy.gateway.core.base;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+
+
+public class SoftBasic {
+
+
+    /**
+     * 鏍规嵁澶у皬鑾峰彇鏂囨湰鎻忚堪淇℃伅
+     * @param size 鏁版嵁澶у皬
+     * @return 瀛楃涓叉枃鏈�
+     */
+    public static String GetSizeDescription(long size) {
+        if (size < 1000) {
+            return size + " B";
+        } else if (size < 1000 * 1000) {
+            float data = (float) size / 1024;
+            return String.format("%.2f", data) + " Kb";
+        } else if (size < 1000 * 1000 * 1000) {
+            float data = (float) size / 1024 / 1024;
+            return String.format("%.2f", data) + " Mb";
+        } else {
+            float data = (float) size / 1024 / 1024 / 1024;
+            return String.format("%.2f", data) + " Gb";
+        }
+    }
+
+
+    /**
+     * 鍒ゆ柇涓や釜瀛楄妭鏁扮粍鏄惁鏄竴鑷寸殑锛屽彲浠ユ寚瀹氫腑闂寸殑鏌愪釜鍖哄煙
+     * @param b1 绗竴涓瓧鑺傛暟缁�
+     * @param start1 璧峰瀛楄妭
+     * @param b2 绗簩涓瓧鑺傛暟缁�
+     * @param start2 璧峰瀛楄妭
+     * @param length 瀵规瘮鏁版嵁鐨勯暱搴�
+     * @return 鏄惁涓�鑷�
+     */
+    public static boolean IsTwoBytesEquel(byte[] b1, int start1, byte[] b2, int start2, int length)
+    {
+        if (b1 == null || b2 == null) return false;
+        for (int i = 0; i < length; i++)
+        {
+            if (b1[i + start1] != b2[i + start2])
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
+    /**
+     * 灏哹yte鏁扮粍鐨勯暱搴︽墿鍏呭埌鎸囧畾闀垮害
+     * @param data 鍘熷厛鐨勬暟鎹暱搴�
+     * @param length 鎵╁厖鎴栨槸缂╃煭鍚庣殑闀垮害
+     * @return 鏂扮殑鎵╁厖鍚庣殑鏁版嵁瀵硅薄
+     */
+    public static byte[] ArrayExpandToLength(byte[] data,int length){
+        if (data == null) return new byte[0];
+        byte[] buffer =  new byte[length];
+        System.arraycopy( data,0, buffer,0, Math.min( data.length, buffer.length ) );
+        return buffer;
+    }
+
+    /**
+     * 灏哹yte鏁扮粍鐨勯暱搴︽墿鍏呭埌鍋舵暟闀垮害
+     * @param data 鍘熷厛鐨勬暟鎹暱搴�
+     * @return 鏂扮殑鎵╁厖鍚庣殑鏁版嵁瀵硅薄
+     */
+    public static byte[] ArrayExpandToLengthEven( byte[] data )
+    {
+        if (data == null) data = new byte[0];
+        if (data.length % 2 == 1)
+        {
+            return ArrayExpandToLength(data, data.length + 1 );
+        }
+        else
+        {
+            return data;
+        }
+    }
+
+
+
+    /**
+     * 灏嗕竴涓暟缁勮繘琛屾墿鍏呭埌鍋舵暟闀垮害
+     * @param data 鍘熷厛鏁版嵁鐨勬暟鎹�
+     * @param <T> 鏁扮粍鐨勭被鍨�
+     * @return 鏂版暟缁勯暱搴︿俊鎭�
+     */
+    public static <T> T[] ArrayExpandToLengthEven(Class<T> tClass,  T[] data )
+    {
+        if (data == null) data = (T[]) new Object[0];
+
+        if (data.length % 2 == 1)
+        {
+            return ArrayExpandToLength(tClass, data, data.length + 1 );
+        }
+        else
+        {
+            return data;
+        }
+    }
+
+    /**
+     * 灏嗕竴涓暟缁勮繘琛屾墿鍏呭埌鎸囧畾闀垮害锛屾垨鏄缉鐭埌鎸囧畾闀垮害
+     * @param data 鍘熷厛鏁版嵁鐨勬暟鎹�
+     * @param length 鏂版暟缁勭殑闀垮害
+     * @param <T> 鏁扮粍鐨勭被鍨�
+     * @return 鏂版暟缁勯暱搴︿俊鎭�
+     */
+    public static <T> T[] ArrayExpandToLength(Class<T> tClass, T[] data, int length )
+    {
+        if (data == null) return (T[]) Array.newInstance(tClass,0);
+
+        if (data.length == length) return data;
+
+        T[] buffer = (T[]) Array.newInstance(tClass,length);
+
+        System.arraycopy( data,0, buffer,0, Math.min( data.length, buffer.length ) );
+
+        return buffer;
+    }
+
+
+
+    /**
+     * 鑾峰彇涓�涓插敮涓�鐨勯殢鏈哄瓧绗︿覆锛岄暱搴︿负20锛岀敱Guid鐮佸拰4浣嶆暟鐨勯殢鏈烘暟缁勬垚锛屼繚璇佸瓧绗︿覆鐨勫敮涓�鎬�
+     * @return 闅忔満瀛楃涓叉暟鎹�
+     */
+    public static String GetUniqueStringByGuidAndRandom()
+    {
+        Random random = new Random();
+        return UUID.randomUUID().toString() + (random.nextInt(9000)+1000);
+    }
+
+
+
+
+    /**
+     * 瀛楄妭鏁版嵁杞寲鎴�16杩涘埗琛ㄧず鐨勫瓧绗︿覆
+     * @param InBytes 瀛楄妭鏁扮粍
+     * @return 杩斿洖鐨勫瓧绗︿覆
+     */
+    public static String ByteToHexString(byte[] InBytes)
+    {
+        return ByteToHexString(InBytes, (char)0);
+    }
+
+
+    /**
+     * 瀛楄妭鏁版嵁杞寲鎴�16杩涘埗琛ㄧず鐨勫瓧绗︿覆
+     * @param InBytes 瀛楄妭鏁扮粍
+     * @param segment 鍒嗗壊绗�
+     * @return 杩斿洖鐨勫瓧绗︿覆
+     */
+    public static String ByteToHexString(byte[] InBytes, char segment)
+    {
+
+        StringBuilder stringBuilder = new StringBuilder("");
+        if (InBytes == null || InBytes.length <= 0) {
+            return null;
+        }
+        for (int i = 0; i < InBytes.length; i++) {
+            int v = InBytes[i] & 0xFF;
+            String hv = Integer.toHexString(v);
+            if (hv.length() < 2) {
+                stringBuilder.append(0);
+            }
+            stringBuilder.append(hv);
+            stringBuilder.append(segment);
+        }
+        return stringBuilder.toString();
+    }
+
+
+    /**
+     *灏哹ool鏁扮粍杞崲鍒癰yte鏁扮粍
+     * @param array bool鏁扮粍
+     * @return 瀛楄妭鏁扮粍
+     */
+    public static byte[] BoolArrayToByte(boolean[] array)
+    {
+        if (array == null) return null;
+
+        int length = array.length % 8 == 0 ? array.length / 8 : array.length / 8 + 1;
+        byte[] buffer = new byte[length];
+
+        for (int i = 0; i < array.length; i++)
+        {
+            int index = i / 8;
+            int offect = i % 8;
+
+            byte temp = 0;
+            switch (offect)
+            {
+                case 0: temp = 0x01; break;
+                case 1: temp = 0x02; break;
+                case 2: temp = 0x04; break;
+                case 3: temp = 0x08; break;
+                case 4: temp = 0x10; break;
+                case 5: temp = 0x20; break;
+                case 6: temp = 0x40; break;
+                case 7: temp = (byte) 0x80; break;
+                default: break;
+            }
+
+            if (array[i]) buffer[index] += temp;
+        }
+
+        return buffer;
+
+    }
+
+
+    /**
+     * 浠嶣yte鏁扮粍涓彁鍙栦綅鏁扮粍
+     * @param InBytes 鍘熷厛鐨勫瓧鑺傛暟缁�
+     * @param length 鎯宠杞崲鐨勯暱搴︼紝濡傛灉瓒呭嚭鑷姩浼氱缉灏忓埌鏁扮粍鏈�澶ч暱搴�
+     * @return 缁撴灉瀵硅薄
+     */
+    public static boolean[] ByteToBoolArray(byte[] InBytes, int length)
+    {
+        if (InBytes == null) return null;
+
+        if (length > InBytes.length * 8) length = InBytes.length * 8;
+        boolean[] buffer = new boolean[length];
+
+        for (int i = 0; i < length; i++)
+        {
+            int index = i / 8;
+            int offect = i % 8;
+
+            byte temp = 0;
+            switch (offect)
+            {
+                case 0: temp = 0x01; break;
+                case 1: temp = 0x02; break;
+                case 2: temp = 0x04; break;
+                case 3: temp = 0x08; break;
+                case 4: temp = 0x10; break;
+                case 5: temp = 0x20; break;
+                case 6: temp = 0x40; break;
+                case 7: temp = (byte) 0x80; break;
+                default: break;
+            }
+
+            if ((InBytes[index] & temp) == temp)
+            {
+                buffer[i] = true;
+            }
+        }
+
+        return buffer;
+    }
+
+
+    /**
+     * 瀛楃涓叉暟鎹浆鍖栨垚16杩涘埗琛ㄧず鐨勫瓧绗︿覆
+     * @param InString 杈撳叆鐨勫瓧绗︿覆鏁版嵁
+     * @return 杩斿洖鐨勫瓧绗︿覆
+     * @throws UnsupportedEncodingException
+     */
+    public static String ByteToHexString(String InString) throws UnsupportedEncodingException
+    {
+        return ByteToHexString(InString.getBytes("unicode"));
+    }
+
+
+    /**
+     * 瀹為檯鐨勫瓧绗︿覆鍒楄〃
+     */
+    private static List<Character> hexCharList = Arrays.asList('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
+
+
+
+    /**
+     * 灏�16杩涘埗鐨勫瓧绗︿覆杞寲鎴怋yte鏁版嵁锛屽皢妫�娴嬫瘡2涓瓧绗﹁浆鍖栵紝涔熷氨鏄锛屼腑闂村彲浠ユ槸浠绘剰瀛楃
+     * @param hex 16杩涘埗琛ㄧず鐨勫瓧绗︿覆鏁版嵁
+     * @return 瀛楄妭鏁扮粍
+     */
+    public static byte[] HexStringToBytes(String hex)
+    {
+        hex = hex.toUpperCase();
+
+        ByteArrayOutputStream ms = new ByteArrayOutputStream ();
+
+        for (int i = 0; i < hex.length(); i++)
+        {
+            if ((i + 1) < hex.length())
+            {
+                if (hexCharList.contains(hex.charAt(i)) && hexCharList.contains(hex.charAt(i+1)))
+                {
+                    // 杩欐槸涓�涓悎鏍肩殑瀛楄妭鏁版嵁
+                    ms.write((byte)(hexCharList.indexOf(hex.charAt(i)) * 16 +hexCharList.indexOf(hex.charAt(i+1))));
+                    i++;
+                }
+            }
+        }
+
+        byte[] result = ms.toByteArray();
+        try {
+            ms.close();
+        }
+        catch (IOException ex)
+        {
+
+        }
+        return result;
+    }
+
+
+    /**
+     * 鎷兼帴2涓瓧鑺傛暟缁勭殑鏁版嵁
+     * @param bytes1 鏁扮粍涓�
+     * @param bytes2 鏁扮粍浜�
+     * @return 鎷兼帴鍚庣殑鏁扮粍
+     */
+    public static byte[] SpliceTwoByteArray( byte[] bytes1, byte[] bytes2 )
+    {
+        if (bytes1 == null && bytes2 == null) return null;
+        if (bytes1 == null) return bytes2;
+        if (bytes2 == null) return bytes1;
+
+        byte[] buffer = new byte[bytes1.length + bytes2.length];
+        System.arraycopy(bytes1,0,buffer,0,bytes1.length);
+        System.arraycopy(bytes2,0,buffer,bytes1.length,bytes2.length);
+        return buffer;
+    }
+
+    /**
+     * 灏嗕竴涓猙yte鏁扮粍鐨勫墠闈㈡寚瀹氫綅鏁扮Щ闄わ紝杩斿洖鏂扮殑涓�涓暟缁�
+     * @param value 瀛楄妭鏁扮粍
+     * @param length 绛夊緟绉婚櫎鐨勯暱搴�
+     * @return 鏂扮殑鏁版嵁
+     */
+    public static byte[] BytesArrayRemoveBegin( byte[] value, int length )
+    {
+        return BytesArrayRemoveDouble( value, length, 0 );
+    }
+
+
+    /**
+     * 灏嗕竴涓猙yte鏁扮粍鐨勫悗闈㈡寚瀹氫綅鏁扮Щ闄わ紝杩斿洖鏂扮殑涓�涓暟缁�
+     * @param value 瀛楄妭鏁扮粍
+     * @param length 绛夊緟绉婚櫎鐨勯暱搴�
+     * @return 鏂扮殑鏁版嵁
+     */
+    public static byte[] BytesArrayRemoveLast( byte[] value, int length )
+    {
+        return BytesArrayRemoveDouble( value, 0, length );
+    }
+
+    /**
+     * 灏嗕竴涓猙yte鏁扮粍鐨勫墠鍚庣Щ闄ゆ寚瀹氫綅鏁帮紝杩斿洖鏂扮殑涓�涓暟缁�
+     * @param value 瀛楄妭鏁扮粍
+     * @param leftLength 鍓嶉潰鐨勪綅鏁�
+     * @param rightLength 鍚庨潰鐨勪綅鏁�
+     * @return 鏂扮殑鏁版嵁
+     */
+    public static byte[] BytesArrayRemoveDouble( byte[] value, int leftLength, int rightLength )
+    {
+        if (value == null) return null;
+        if (value.length <= (leftLength + rightLength)) return new byte[0];
+
+        byte[] buffer = new byte[value.length - leftLength - rightLength];
+        System.arraycopy( value, leftLength, buffer, 0, buffer.length );
+
+        return buffer;
+    }
+
+}
+
diff --git a/src/main/java/com/zy/gateway/core/base/SoftZipped.java b/src/main/java/com/zy/gateway/core/base/SoftZipped.java
new file mode 100644
index 0000000..af8adee
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/base/SoftZipped.java
@@ -0,0 +1,49 @@
+package com.zy.gateway.core.base;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+public class SoftZipped {
+
+    public static byte[] CompressBytes(byte[] data) {
+        byte[] b = null;
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            GZIPOutputStream gzip = new GZIPOutputStream(bos);
+            gzip.write(data);
+            gzip.finish();
+            gzip.close();
+            b = bos.toByteArray();
+            bos.close();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return b;
+    }
+
+
+
+    public static byte[] Decompress(byte[] data) {
+        byte[] b = null;
+        try {
+            ByteArrayInputStream bis = new ByteArrayInputStream(data);
+            GZIPInputStream gzip = new GZIPInputStream(bis);
+            byte[] buf = new byte[1024];
+            int num = -1;
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            while ((num = gzip.read(buf, 0, buf.length)) != -1) {
+                baos.write(buf, 0, num);
+            }
+            b = baos.toByteArray();
+            baos.flush();
+            baos.close();
+            gzip.close();
+            bis.close();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return b;
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/ActionOperate.java b/src/main/java/com/zy/gateway/core/domain/ActionOperate.java
new file mode 100644
index 0000000..f13c3ad
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/ActionOperate.java
@@ -0,0 +1,15 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 绌烘搷浣滅殑绫�
+ */
+public class ActionOperate
+{
+    /**
+     * 绌烘搷浣�
+     */
+    public void Action(){
+
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/ActionOperateExOne.java b/src/main/java/com/zy/gateway/core/domain/ActionOperateExOne.java
new file mode 100644
index 0000000..7cfb22d
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/ActionOperateExOne.java
@@ -0,0 +1,17 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 甯︿竴涓弬鏁板璞$殑鎿嶄綔绫�
+ * @param <T>
+ */
+public class ActionOperateExOne<T>
+{
+    /**
+     * 甯︿竴涓弬鏁板璞$殑绌烘搷浣�
+     * @param content 绫诲瀷瀵硅薄
+     */
+    public void Action(T content)
+    {
+
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/ActionOperateExThree.java b/src/main/java/com/zy/gateway/core/domain/ActionOperateExThree.java
new file mode 100644
index 0000000..0f70560
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/ActionOperateExThree.java
@@ -0,0 +1,20 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 甯︿笁涓弬鏁扮殑绫诲瀷瀵硅薄
+ * @param <T1> 绫诲瀷涓�
+ * @param <T2> 绫诲瀷浜�
+ * @param <T3> 绫诲瀷涓�
+ */
+public class ActionOperateExThree<T1,T2,T3>
+{
+    /**
+     * 瀹為檯鐨勬搷浣滄柟娉曪紝闇�瑕佺户鎵块噸鍐�
+     * @param content1 绫诲瀷涓�瀵硅薄
+     * @param content2 绫诲瀷浜屽璞�
+     * @param content3 绫诲瀷涓夊璞�
+     */
+    public void Action(T1 content1,T2 content2,T3 content3){
+
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/ActionOperateExTwo.java b/src/main/java/com/zy/gateway/core/domain/ActionOperateExTwo.java
new file mode 100644
index 0000000..b7c905e
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/ActionOperateExTwo.java
@@ -0,0 +1,19 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 甯︿簩涓弬鏁板璞$殑鎿嶄綔绫�
+ * @param <T1> 绫诲瀷涓�
+ * @param <T2> 绫诲瀷浜�
+ */
+public class ActionOperateExTwo <T1,T2>
+{
+    /**
+     * 瀹為檯鐨勬搷浣滄柟娉曪紝搴旇閲嶅啓
+     * @param content1 绫诲瀷涓�瀵硅薄
+     * @param content2 绫诲瀷浜屽璞�
+     */
+    public void Action(T1 content1,T2 content2)
+    {
+
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/FunctionOperate.java b/src/main/java/com/zy/gateway/core/domain/FunctionOperate.java
new file mode 100644
index 0000000..05d030d
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/FunctionOperate.java
@@ -0,0 +1,8 @@
+package com.zy.gateway.core.domain;
+
+public class FunctionOperate<R>
+{
+    public R Action(){
+        return null;
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/FunctionOperateExOne.java b/src/main/java/com/zy/gateway/core/domain/FunctionOperateExOne.java
new file mode 100644
index 0000000..4c89313
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/FunctionOperateExOne.java
@@ -0,0 +1,8 @@
+package com.zy.gateway.core.domain;
+
+public class FunctionOperateExOne<T,R>
+{
+    public R Action(T content){
+        return null;
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/HslTimeOut.java b/src/main/java/com/zy/gateway/core/domain/HslTimeOut.java
new file mode 100644
index 0000000..9a00afb
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/HslTimeOut.java
@@ -0,0 +1,41 @@
+package com.zy.gateway.core.domain;
+import java.net.Socket;
+import java.util.Date;
+
+public class HslTimeOut {
+
+
+    /**
+     * 榛樿鐨勬棤鍙傛瀯閫犲嚱鏁�
+     */
+    public HslTimeOut()
+    {
+        StartTime = new Date();
+        IsSuccessful = false;
+    }
+
+
+    /**
+     * 鎿嶄綔鐨勫紑濮嬫椂闂�
+     */
+    public Date StartTime = null;
+
+
+    /**
+     * 鎿嶄綔鏄惁鎴愬姛
+     */
+    public boolean IsSuccessful = false;
+
+
+    /**
+     * 寤舵椂鐨勬椂闂达紝鍗曚綅锛氭绉�
+     */
+    public int DelayTime = 5000;
+
+
+    /**
+     * 褰撳墠鐨勭綉缁滈�氳鐨勬牳蹇�
+     */
+    public Socket WorkSocket = null;
+
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/IDataTransfer.java b/src/main/java/com/zy/gateway/core/domain/IDataTransfer.java
new file mode 100644
index 0000000..80e2eaa
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/IDataTransfer.java
@@ -0,0 +1,26 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 鐢ㄤ簬PLC閫氳鍙奙odbus鑷畾涔夋暟鎹被鍨嬬殑璇诲啓鎿嶄綔
+ */
+public interface IDataTransfer {
+
+    /**
+     * 璇诲彇鐨勬暟鎹暱搴︼紝瀵逛簬瑗块棬瀛愶紝绛夊悓浜庡瓧鑺傛暟锛屽浜庝笁鑿卞拰Modbus涓哄瓧鑺傛暟鐨勪竴鍗�
+     * @return
+     */
+    short getReadCount();
+
+
+    /**
+     * 浠庡瓧鑺傛暟缁勮繘琛岃В鏋愬疄闄呯殑瀵硅薄
+     * @param Content 瀹為檯鐨勫唴瀹�
+     */
+    void ParseSource(byte[] Content);
+
+    /**
+     * 灏嗗璞$敓鎴愬瓧绗︽簮锛屽啓鍏LC涓�
+     * @return 鍐欏叆PLC涓�
+     */
+    byte[] ToSource();
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/OperateResult.java b/src/main/java/com/zy/gateway/core/domain/OperateResult.java
new file mode 100644
index 0000000..3d247b3
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/OperateResult.java
@@ -0,0 +1,91 @@
+package com.zy.gateway.core.domain;
+
+import com.zy.gateway.core.StringResources;
+
+/**
+ * 涓�涓粨鏋滄搷浣滅被鐨勫熀绫�
+ */
+public class OperateResult {
+
+
+    /**
+     * 榛樿鐨勬棤鍙傛瀯閫犳柟娉�
+     */
+    public OperateResult(){
+
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勬秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param msg 閿欒鐨勬秷鎭�
+     */
+    public OperateResult(String msg){
+        this.Message = msg;
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勯敊璇彿鍜屾秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param err 閿欒鐮�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResult(int err, String msg){
+        this.ErrorCode = err;
+        this.Message = msg;
+    }
+
+
+    /**
+     * 鎸囩ず鏈璁块棶鏄惁鎴愬姛
+     */
+    public boolean IsSuccess = false;
+
+
+    /**
+     * 鍏蜂綋鐨勯敊璇弿杩�
+     */
+    public String Message = StringResources.Language.UnknownError();
+
+
+    /**
+     * 鍏蜂綋鐨勯敊璇唬鐮�
+     */
+    public int ErrorCode = 10000;
+
+
+    /**
+     * @return 鑾峰彇閿欒浠e彿鍙婃枃鏈弿杩�
+     */
+    public String ToMessageShowString() {
+        return "閿欒浠g爜锛�" + ErrorCode + "\r\n閿欒淇℃伅锛�" + Message;
+    }
+
+
+    /**
+     * 浠庡彟涓�涓粨鏋滅被涓嫹璐濋敊璇俊鎭�
+     *
+     * @param result 鏀寔缁撴灉绫诲強娲剧敓绫�
+     */
+    public void CopyErrorFromOther(OperateResult result) {
+        if (result != null) {
+            ErrorCode = result.ErrorCode;
+            Message = result.Message;
+        }
+
+    }
+
+
+    /**
+     * 鍒涘缓涓�涓垚鍔熺殑缁撴灉绫诲璞�
+     *
+     * @return 缁撴灉绫诲璞�
+     */
+    public static OperateResult CreateSuccessResult() {
+        OperateResult result = new OperateResult();
+        result.IsSuccess = true;
+        result.Message = "success";
+        return result;
+    }
+
+
+}
+
diff --git a/src/main/java/com/zy/gateway/core/domain/OperateResultExFour.java b/src/main/java/com/zy/gateway/core/domain/OperateResultExFour.java
new file mode 100644
index 0000000..c3f5761
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/OperateResultExFour.java
@@ -0,0 +1,100 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 甯︿笁涓弬鏁扮殑娉涘瀷绫诲璞�
+ * @param <T1> 鍙傛暟涓�
+ * @param <T2> 鍙傛暟浜�
+ * @param <T3> 鍙傛暟涓�
+ * @param <T4> 鍙傛暟鍥�
+ */
+public class OperateResultExFour<T1,T2,T3,T4> extends OperateResult
+{
+    /**
+     * 榛樿鐨勬棤鍙傛瀯閫犳柟娉�
+     */
+    public OperateResultExFour(){
+        super();
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勬秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExFour(String msg){
+        super(msg);
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勯敊璇彿鍜屾秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param err 閿欒鐮�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExFour(int err,String msg){
+        super(err,msg);
+    }
+
+
+
+    /**
+     * 娉涘瀷瀵硅薄1
+     */
+    public T1 Content1 = null;
+
+
+    /**
+     * 娉涘瀷瀵硅薄浜�
+     */
+    public T2 Content2 = null;
+
+
+    /**
+     * 娉涘瀷瀵硅薄涓�
+     */
+    public T3 Content3 = null;
+
+    /**
+     * 娉涘瀷瀵硅薄鍥�
+     */
+    public T4 Content4 = null;
+
+
+    /**
+     * 鍒涘缓涓�涓垚鍔熺殑娉涘瀷绫荤粨鏋滃璞�
+     * @param content1 鍐呭涓�
+     * @param content2 鍐呭浜�
+     * @param content3 鍐呭涓�
+     * @param content4 鍐呭鍥�
+     * @param <T1> 绫诲瀷涓�
+     * @param <T2> 绫诲瀷浜�
+     * @param <T3> 绫诲瀷涓�
+     * @param <T4> 绫诲瀷鍥�
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T1,T2,T3,T4> OperateResultExFour<T1,T2,T3,T4> CreateSuccessResult(T1 content1,T2 content2,T3 content3,T4 content4){
+        OperateResultExFour<T1,T2,T3,T4> result = new OperateResultExFour<>();
+        result.IsSuccess = true;
+        result.Content1 = content1;
+        result.Content2 = content2;
+        result.Content3 = content3;
+        result.Content4 = content4;
+        result.Message = "success";
+        return result;
+    }
+
+
+    /**
+     * 鍒涘缓涓�涓け璐ョ殑娉涘瀷绫荤粨鏋滃璞�
+     * @param result 澶嶅埗鐨勭粨鏋滃璞�
+     * @param <T1> 绫诲瀷涓�
+     * @param <T2> 绫诲瀷浜�
+     * @param <T3> 绫诲瀷涓�
+     * @param <T4> 绫诲瀷鍥�
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T1,T2,T3,T4> OperateResultExFour<T1,T2,T3,T4> CreateFailedResult(OperateResult result){
+        OperateResultExFour resultExFour = new OperateResultExFour();
+        resultExFour.CopyErrorFromOther(result);
+        return resultExFour;
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/OperateResultExOne.java b/src/main/java/com/zy/gateway/core/domain/OperateResultExOne.java
new file mode 100644
index 0000000..ba374ac
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/OperateResultExOne.java
@@ -0,0 +1,67 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 甯︿竴涓弬鏁扮殑缁撴灉绫诲璞�
+ * @param <T>
+ */
+public class OperateResultExOne<T> extends  OperateResult {
+
+    /**
+     * 榛樿鐨勬棤鍙傛瀯閫犳柟娉�
+     */
+    public OperateResultExOne(){
+        super();
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勬秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExOne(String msg){
+        super(msg);
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勯敊璇彿鍜屾秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param err 閿欒鐮�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExOne(int err, String msg){
+        super(err,msg);
+    }
+
+
+    /**
+     * 娉涘瀷鍙傛暟瀵硅薄
+     */
+    public T Content = null;
+
+
+    /**
+     * 鍒涘缓涓�涓け璐ョ殑瀵硅薄
+     * @param result 澶辫触鐨勭粨鏋�
+     * @param <T> 绫诲瀷鍙傛暟
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T> OperateResultExOne<T> CreateFailedResult(OperateResult result){
+        OperateResultExOne<T> resultExOne = new OperateResultExOne<T>();
+        resultExOne.CopyErrorFromOther(result);
+        return resultExOne;
+    }
+
+
+    /**
+     * 鍒涘缓涓�涓垚鍔熺殑娉涘瀷绫荤粨鏋滃璞�
+     * @param content 鍐呭
+     * @param <T> 绫诲瀷
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T> OperateResultExOne<T> CreateSuccessResult(T content){
+        OperateResultExOne<T> result = new OperateResultExOne<T>();
+        result.IsSuccess = true;
+        result.Content = content;
+        result.Message = "success";
+        return result;
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/OperateResultExThree.java b/src/main/java/com/zy/gateway/core/domain/OperateResultExThree.java
new file mode 100644
index 0000000..4bc6640
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/OperateResultExThree.java
@@ -0,0 +1,94 @@
+package com.zy.gateway.core.domain;
+
+
+/**
+ * 甯︿笁涓弬鏁扮殑娉涘瀷绫诲璞�
+ * @param <T1> 鍙傛暟涓�
+ * @param <T2> 鍙傛暟浜�
+ * @param <T3> 鍙傛暟涓�
+ */
+public class OperateResultExThree<T1,T2,T3> extends OperateResult
+{
+
+
+    /**
+     * 榛樿鐨勬棤鍙傛瀯閫犳柟娉�
+     */
+    public OperateResultExThree(){
+        super();
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勬秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExThree(String msg){
+        super(msg);
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勯敊璇彿鍜屾秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param err 閿欒鐮�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExThree(int err,String msg){
+        super(err,msg);
+    }
+
+
+
+    /**
+     * 娉涘瀷瀵硅薄1
+     */
+    public T1 Content1 = null;
+
+
+    /**
+     * 娉涘瀷瀵硅薄浜�
+     */
+    public T2 Content2 = null;
+
+
+    /**
+     * 娉涘瀷瀵硅薄涓�
+     */
+    public T3 Content3 = null;
+
+
+
+    /**
+     * 鍒涘缓涓�涓垚鍔熺殑娉涘瀷绫荤粨鏋滃璞�
+     * @param content1 鍐呭涓�
+     * @param content2 鍐呭浜�
+     * @param content3 鍐呭涓�
+     * @param <T1> 绫诲瀷涓�
+     * @param <T2> 绫诲瀷浜�
+     * @param <T3> 绫诲瀷涓�
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T1,T2,T3> OperateResultExThree<T1,T2,T3> CreateSuccessResult(T1 content1,T2 content2,T3 content3){
+        OperateResultExThree<T1,T2,T3> result = new OperateResultExThree<>();
+        result.IsSuccess = true;
+        result.Content1 = content1;
+        result.Content2 = content2;
+        result.Content3 = content3;
+        result.Message = "success";
+        return result;
+    }
+
+
+
+    /**
+     * 鍒涘缓涓�涓け璐ョ殑娉涘瀷绫荤粨鏋滃璞�
+     * @param result 澶嶅埗鐨勭粨鏋滃璞�
+     * @param <T1> 绫诲瀷涓�
+     * @param <T2> 绫诲瀷浜�
+     * @param <T3> 绫诲瀷涓�
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T1,T2,T3> OperateResultExThree<T1,T2,T3> CreateFailedResult(OperateResult result){
+        OperateResultExThree resultExThree = new OperateResultExThree();
+        resultExThree.CopyErrorFromOther(result);
+        return resultExThree;
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/OperateResultExTwo.java b/src/main/java/com/zy/gateway/core/domain/OperateResultExTwo.java
new file mode 100644
index 0000000..9425077
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/OperateResultExTwo.java
@@ -0,0 +1,79 @@
+package com.zy.gateway.core.domain;
+
+/**
+ * 甯�2涓弬鏁扮殑缁撴灉绫�
+ * @param <T1> 绗竴涓弬鏁扮被鍨�
+ * @param <T2> 绗簩涓弬鏁扮被鍨�
+ */
+public class OperateResultExTwo<T1,T2> extends OperateResult
+{
+
+    /**
+     * 榛樿鐨勬棤鍙傛瀯閫犳柟娉�
+     */
+    public OperateResultExTwo(){
+        super();
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勬秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExTwo(String msg){
+        super(msg);
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勯敊璇彿鍜屾秷鎭疄渚嬪寲榛樿鐨勫璞�
+     * @param err 閿欒鐮�
+     * @param msg 閿欒娑堟伅
+     */
+    public OperateResultExTwo(int err,String msg){
+        super(err,msg);
+    }
+
+
+
+
+    /**
+     * 娉涘瀷瀵硅薄1
+     */
+    public T1 Content1 = null;
+
+
+    /**
+     * 娉涘瀷瀵硅薄浜�
+     */
+    public T2 Content2 = null;
+
+    /**
+     * 鍒涘缓涓�涓垚鍔熺殑娉涘瀷绫荤粨鏋滃璞�
+     * @param content1 鍐呭涓�
+     * @param content2 鍐呭浜�
+     * @param <T1> 绫诲瀷涓�
+     * @param <T2> 绫诲瀷浜�
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T1,T2> OperateResultExTwo<T1,T2> CreateSuccessResult(T1 content1,T2 content2){
+        OperateResultExTwo<T1,T2> result = new OperateResultExTwo<T1,T2>();
+        result.IsSuccess = true;
+        result.Content1 = content1;
+        result.Content2 = content2;
+        result.Message = "success";
+        return result;
+    }
+
+    /**
+     * 鍒涘缓涓�涓け璐ョ殑娉涘瀷绫荤粨鏋滃璞�
+     * @param result 澶嶅埗鐨勭粨鏋滃璞�
+     * @param <T1> 绫诲瀷涓�
+     * @param <T2> 绫诲瀷浜�
+     * @return 缁撴灉绫诲璞�
+     */
+    public static <T1,T2> OperateResultExTwo<T1,T2> CreateFailedResult(OperateResult result){
+        OperateResultExTwo resultExTwo = new OperateResultExTwo();
+        resultExTwo.CopyErrorFromOther(result);
+        return resultExTwo;
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/siemens/INetMessage.java b/src/main/java/com/zy/gateway/core/domain/siemens/INetMessage.java
new file mode 100644
index 0000000..38f6c10
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/siemens/INetMessage.java
@@ -0,0 +1,75 @@
+package com.zy.gateway.core.domain.siemens;
+
+/**
+ * 鏈郴缁熺殑娑堟伅绫伙紝鍖呭惈浜嗗悇绉嶈В鏋愯鍒欙紝鏁版嵁淇℃伅鎻愬彇瑙勫垯
+ */
+public interface INetMessage {
+
+    /**
+     * 娑堟伅澶寸殑鎸囦护闀垮害
+     */
+    int ProtocolHeadBytesLength();
+
+
+    /**
+     * 浠庡綋鍓嶇殑澶村瓙鑺傛枃浠朵腑鎻愬彇鍑烘帴涓嬫潵闇�瑕佹帴鏀剁殑鏁版嵁闀垮害
+     * @return 杩斿洖鎺ヤ笅鏉ョ殑鏁版嵁鍐呭闀垮害
+     */
+    int GetContentLengthByHeadBytes();
+
+
+    /**
+     * 妫�鏌ュご瀛愯妭鐨勫悎娉曟��
+     * @param token 鐗规畩鐨勪护鐗岋紝鏈変簺鐗规畩娑堟伅鐨勯獙璇�
+     * @return 鏄惁鍚堟硶鐨勯獙璇�
+     */
+    boolean CheckHeadBytesLegal(byte[] token);
+
+
+    /**
+     * 鑾峰彇澶村瓙鑺傞噷鐨勬秷鎭爣璇�
+     * @return
+     */
+    int GetHeadBytesIdentity();
+
+
+    /**
+     * 璁剧疆娑堟伅澶村瓙鑺�
+     * @param headBytes 瀛楄妭鏁版嵁
+     */
+    void setHeadBytes(byte[] headBytes);
+
+    /**
+     * 鑾峰彇娑堟伅澶村瓧鑺�
+     * @return
+     */
+    byte[] getHeadBytes();
+
+
+
+    /**
+     * 鑾峰彇娑堟伅鍐呭瀛楄妭
+     * @return
+     */
+    byte[] getContentBytes();
+
+    /**
+     * 璁剧疆娑堟伅鍐呭瀛楄妭
+     * @param contentBytes 鍐呭瀛楄妭
+     */
+    void setContentBytes(byte[] contentBytes);
+
+
+    /**
+     * 鑾峰彇鍙戦�佺殑娑堟伅
+     * @return
+     */
+    byte[] getSendBytes();
+
+    /**
+     * 璁剧疆鍙戦�佺殑瀛楄妭淇℃伅
+     * @param sendBytes 鍙戦�佺殑瀛楄妭淇℃伅
+     */
+    void setSendBytes(byte[] sendBytes);
+
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/siemens/S7Message.java b/src/main/java/com/zy/gateway/core/domain/siemens/S7Message.java
new file mode 100644
index 0000000..8ebd657
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/siemens/S7Message.java
@@ -0,0 +1,74 @@
+package com.zy.gateway.core.domain.siemens;
+
+public class S7Message implements INetMessage {
+
+    // 澶村瓧鑺�
+    private byte[] HeadBytes = null;
+
+    // 娑堟伅鍐呭瀛楄妭
+    private byte[] ContentBytes = null;
+
+    // 鍙戦�佺殑娑堟伅
+    private byte[] SendBytes = null;
+
+    /**
+     * 娑堟伅澶寸殑鎸囦护闀垮害
+     */
+    public int ProtocolHeadBytesLength(){
+        return 4;
+    }
+
+    /**
+     * 浠庡綋鍓嶇殑澶村瓙鑺傛枃浠朵腑鎻愬彇鍑烘帴涓嬫潵闇�瑕佹帴鏀剁殑鏁版嵁闀垮害
+     * @return 杩斿洖鎺ヤ笅鏉ョ殑鏁版嵁鍐呭闀垮害
+     */
+    public int GetContentLengthByHeadBytes(){
+        if(HeadBytes == null) return 0;
+        return (HeadBytes[2] & 0xff) * 256 + (HeadBytes[3] & 0xff) - 4;
+    }
+
+    /**
+     * 妫�鏌ュご瀛愯妭鐨勫悎娉曟��
+     * @param token 鐗规畩鐨勪护鐗岋紝鏈変簺鐗规畩娑堟伅鐨勯獙璇�
+     * @return 鏄惁鍚堟硶鐨勯獙璇�
+     */
+    public boolean CheckHeadBytesLegal(byte[] token) {
+        if(HeadBytes == null) return false;
+        return HeadBytes[0] == 0x03 && HeadBytes[1] == 0x00;
+    }
+
+    /**
+     * 鑾峰彇澶村瓙鑺傞噷鐨勬秷鎭爣璇�
+     */
+    public int GetHeadBytesIdentity(){
+        return 0;
+    }
+
+    @Override
+    public byte[] getHeadBytes() {
+        return HeadBytes;
+    }
+
+    @Override
+    public byte[] getContentBytes() {
+        return ContentBytes;
+    }
+
+    @Override
+    public byte[] getSendBytes() {
+        return SendBytes;
+    }
+
+    public void setHeadBytes(byte[] headBytes){
+        HeadBytes = headBytes;
+    }
+
+    public void setContentBytes(byte[] contentBytes){
+        ContentBytes = contentBytes;
+    }
+
+    public void setSendBytes(byte[] sendBytes){
+        SendBytes = sendBytes;
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/domain/siemens/SiemensPLCS.java b/src/main/java/com/zy/gateway/core/domain/siemens/SiemensPLCS.java
new file mode 100644
index 0000000..6d8a759
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/domain/siemens/SiemensPLCS.java
@@ -0,0 +1,27 @@
+package com.zy.gateway.core.domain.siemens;
+
+/**
+ * 瑗块棬瀛愮殑PLC绫诲瀷锛岀洰鍓嶆敮鎸佺殑璁块棶绫诲瀷
+ */
+public enum SiemensPLCS {
+
+    /**
+     * 1200绯诲垪
+     */
+    S1200,
+
+    /**
+     * 300绯诲垪
+     */
+    S300,
+
+    /**
+     * 1500绯诲垪
+     */
+    S1500,
+
+    /**
+     * S200Smart绯诲垪
+     */
+    S200Smart,
+}
diff --git a/src/main/java/com/zy/gateway/core/language/DefaultLanguage.java b/src/main/java/com/zy/gateway/core/language/DefaultLanguage.java
new file mode 100644
index 0000000..4f9a410
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/language/DefaultLanguage.java
@@ -0,0 +1,282 @@
+package com.zy.gateway.core.language;
+
+/**
+ * 绯荤粺鐨勮瑷�鍩虹被锛岄粯璁や篃鍗虫槸涓枃鐗堟湰
+ */
+public class DefaultLanguage
+{
+    /***********************************************************************************
+     *
+     *    涓�鑸殑閿欒淇℃伅
+     *
+     ************************************************************************************/
+
+    public String ConnectedFailed (){ return "杩炴帴澶辫触锛�"; }
+    public String UnknownError (){ return "鏈煡閿欒"; }
+    public String ErrorCode (){ return "閿欒浠e彿"; }
+    public String TextDescription (){ return "鏂囨湰鎻忚堪"; }
+    public String ExceptionMessage (){ return "閿欒淇℃伅锛�"; }
+    public String ExceptionSourse (){ return "閿欒婧愶細"; }
+    public String ExceptionType (){ return "閿欒绫诲瀷锛�"; }
+    public String ExceptionStackTrace (){ return "閿欒鍫嗘爤锛�"; }
+    public String ExceptopnTargetSite (){ return "閿欒鏂规硶锛�"; }
+    public String ExceprionCustomer (){ return "鐢ㄦ埛鑷畾涔夋柟娉曞嚭閿欙細"; }
+    public String SuccessText (){ return "鎴愬姛"; }
+    public String TwoParametersLengthIsNotSame (){ return "涓や釜鍙傛暟鐨勪釜鏁颁笉涓�鑷�"; }
+    public String NotSupportedDataType (){ return "杈撳叆鐨勭被鍨嬩笉鏀寔锛岃閲嶆柊杈撳叆"; }
+    public String DataLengthIsNotEnough (){ return "鎺ユ敹鐨勬暟鎹暱搴︿笉瓒筹紝搴旇鍊�:{0},瀹為檯鍊�:{1}"; }
+    public String ReceiveDataTimeout (){ return "鎺ユ敹鏁版嵁瓒呮椂锛�"; }
+    public String ReceiveDataLengthTooShort (){ return "鎺ユ敹鐨勬暟鎹暱搴﹀お鐭細"; }
+    public String MessageTip (){ return "娑堟伅鎻愮ず锛�"; }
+    public String Close (){ return "鍏抽棴"; }
+    public String Time (){ return "鏃堕棿锛�"; }
+    public String SoftWare (){ return "杞欢锛�"; }
+    public String BugSubmit (){ return "Bug鎻愪氦"; }
+    public String MailServerCenter (){ return "閭欢鍙戦�佺郴缁�"; }
+    public String MailSendTail (){ return "閭欢鏈嶅姟绯荤粺鑷姩鍙戝嚭锛岃鍕垮洖澶嶏紒"; }
+    public String IpAddresError (){ return "Ip鍦板潃杈撳叆寮傚父锛屾牸寮忎笉姝g‘"; }
+    public String Send (){ return "鍙戦��";}
+    public String Receive(){ return "鎺ユ敹";}
+
+    /***********************************************************************************
+     *
+     *    绯荤粺鐩稿叧鐨勯敊璇俊鎭�
+     *
+     ************************************************************************************/
+
+    public String SystemInstallOperater (){ return "瀹夎鏂扮郴缁燂細IP涓�"; }
+    public String SystemUpdateOperater (){ return "鏇存柊鏂扮郴缁燂細IP涓�"; }
+
+
+    /***********************************************************************************
+     *
+     *    濂楁帴瀛楃浉鍏崇殑淇℃伅鎻忚堪
+     *
+     ************************************************************************************/
+
+    public String SocketIOException (){ return "濂楁帴瀛椾紶閫佹暟鎹紓甯革細"; }
+    public String SocketSendException (){ return "鍚屾鏁版嵁鍙戦�佸紓甯革細"; }
+    public String SocketHeadReceiveException (){ return "鎸囦护澶存帴鏀跺紓甯革細"; }
+    public String SocketContentReceiveException (){ return "鍐呭鏁版嵁鎺ユ敹寮傚父锛�"; }
+    public String SocketContentRemoteReceiveException (){ return "瀵规柟鍐呭鏁版嵁鎺ユ敹寮傚父锛�"; }
+    public String SocketAcceptCallbackException (){ return "寮傛鎺ュ彈浼犲叆鐨勮繛鎺ュ皾璇�"; }
+    public String SocketReAcceptCallbackException (){ return "閲嶆柊寮傛鎺ュ彈浼犲叆鐨勮繛鎺ュ皾璇�"; }
+    public String SocketSendAsyncException (){ return "寮傛鏁版嵁鍙戦�佸嚭閿�:"; }
+    public String SocketEndSendException (){ return "寮傛鏁版嵁缁撴潫鎸傝捣鍙戦�佸嚭閿�"; }
+    public String SocketReceiveException (){ return "寮傛鏁版嵁鍙戦�佸嚭閿�:"; }
+    public String SocketEndReceiveException (){ return "寮傛鏁版嵁缁撴潫鎺ユ敹鎸囦护澶村嚭閿�"; }
+    public String SocketRemoteCloseException (){ return "杩滅▼涓绘満寮鸿揩鍏抽棴浜嗕竴涓幇鏈夌殑杩炴帴"; }
+
+
+    /***********************************************************************************
+     *
+     *    鏂囦欢鐩稿叧鐨勪俊鎭�
+     *
+     ************************************************************************************/
+
+
+    public String FileDownloadSuccess (){ return "鏂囦欢涓嬭浇鎴愬姛"; }
+    public String FileDownloadFailed (){ return "鏂囦欢涓嬭浇寮傚父"; }
+    public String FileUploadFailed (){ return "鏂囦欢涓婁紶寮傚父"; }
+    public String FileUploadSuccess (){ return "鏂囦欢涓婁紶鎴愬姛"; }
+    public String FileDeleteFailed (){ return "鏂囦欢鍒犻櫎寮傚父"; }
+    public String FileDeleteSuccess (){ return "鏂囦欢鍒犻櫎鎴愬姛"; }
+    public String FileReceiveFailed (){ return "纭鏂囦欢鎺ユ敹寮傚父"; }
+    public String FileNotExist (){ return "鏂囦欢涓嶅瓨鍦�"; }
+    public String FileSaveFailed (){ return "鏂囦欢瀛樺偍澶辫触"; }
+    public String FileLoadFailed (){ return "鏂囦欢鍔犺浇澶辫触"; }
+    public String FileSendClientFailed (){ return "鏂囦欢鍙戦�佺殑鏃跺�欏彂鐢熶簡寮傚父"; }
+    public String FileWriteToNetFailed (){ return "鏂囦欢鍐欏叆缃戠粶寮傚父"; }
+    public String FileReadFromNetFailed (){ return "浠庣綉缁滆鍙栨枃浠跺紓甯�"; }
+    public String FilePathCreateFailed (){ return "鏂囦欢澶硅矾寰勫垱寤哄け璐ワ細"; }
+    public String FileRemoteNotExist (){ return "瀵规柟鏂囦欢涓嶅瓨鍦紝鏃犳硶鎺ユ敹锛�"; }
+
+    /***********************************************************************************
+     *
+     *    鏈嶅姟鍣ㄧ殑寮曟搸鐩稿叧鏁版嵁
+     *
+     ************************************************************************************/
+
+    public String TokenCheckFailed (){ return "鎺ユ敹楠岃瘉浠ょ墝涓嶄竴鑷�"; }
+    public String TokenCheckTimeout (){ return "鎺ユ敹楠岃瘉瓒呮椂:"; }
+    public String CommandHeadCodeCheckFailed (){ return "鍛戒护澶存牎楠屽け璐�"; }
+    public String CommandLengthCheckFailed (){ return "鍛戒护闀垮害妫�鏌ュけ璐�"; }
+    public String NetClientAliasFailed (){ return "瀹㈡埛绔殑鍒悕鎺ユ敹澶辫触锛�"; }
+    public String NetEngineStart (){ return "鍚姩寮曟搸"; }
+    public String NetEngineClose (){ return "鍏抽棴寮曟搸"; }
+    public String NetClientOnline (){ return "涓婄嚎"; }
+    public String NetClientOffline (){ return "涓嬬嚎"; }
+    public String NetClientBreak (){ return "寮傚父鎺夌嚎"; }
+    public String NetClientFull (){ return "鏈嶅姟鍣ㄦ壙杞戒笂闄愶紝鏀跺埌瓒呭嚭鐨勮姹傝繛鎺ャ��"; }
+    public String NetClientLoginFailed (){ return "瀹㈡埛绔櫥褰曚腑閿欒锛�"; }
+    public String NetHeartCheckFailed (){ return "蹇冭烦楠岃瘉寮傚父锛�"; }
+    public String NetHeartCheckTimeout (){ return "蹇冭烦楠岃瘉瓒呮椂锛屽己鍒朵笅绾匡細"; }
+    public String DataSourseFormatError (){ return "鏁版嵁婧愭牸寮忎笉姝g‘"; }
+    public String ServerFileCheckFailed (){ return "鏈嶅姟鍣ㄧ‘璁ゆ枃浠跺け璐ワ紝璇烽噸鏂颁笂浼�"; }
+    public String ClientOnlineInfo (){ return "瀹㈡埛绔� [ {0} ] 涓婄嚎"; }
+    public String ClientOfflineInfo (){ return "瀹㈡埛绔� [ {0} ] 涓嬬嚎"; }
+    public String ClientDisableLogin (){ return "瀹㈡埛绔� [ {0} ] 涓嶈淇′换锛岀姝㈢櫥褰�"; }
+
+    /***********************************************************************************
+     *
+     *    Client 鐩稿叧
+     *
+     ************************************************************************************/
+
+    public String ReConnectServerSuccess (){ return "閲嶈繛鏈嶅姟鍣ㄦ垚鍔�"; }
+    public String ReConnectServerAfterTenSeconds (){ return "鍦�10绉掑悗閲嶆柊杩炴帴鏈嶅姟鍣�"; }
+    public String KeyIsNotAllowedNull (){ return "鍏抽敭瀛椾笉鍏佽涓虹┖"; }
+    public String KeyIsExistAlready (){ return "褰撳墠鐨勫叧閿瓧宸茬粡瀛樺湪"; }
+    public String KeyIsNotExist (){ return "褰撳墠璁㈤槄鐨勫叧閿瓧涓嶅瓨鍦�"; }
+    public String ConnectingServer (){ return "姝e湪杩炴帴鏈嶅姟鍣�..."; }
+    public String ConnectFailedAndWait (){ return "杩炴帴鏂紑锛岀瓑寰厈0}绉掑悗閲嶆柊杩炴帴"; }
+    public String AttemptConnectServer (){ return "姝e湪灏濊瘯绗瑊0}娆¤繛鎺ユ湇鍔″櫒"; }
+    public String ConnectServerSuccess (){ return "杩炴帴鏈嶅姟鍣ㄦ垚鍔�"; }
+    public String GetClientIpaddressFailed (){ return "瀹㈡埛绔疘P鍦板潃鑾峰彇澶辫触"; }
+    public String ConnectionIsNotAvailable (){ return "褰撳墠鐨勮繛鎺ヤ笉鍙敤"; }
+    public String DeviceCurrentIsLoginRepeat (){ return "褰撳墠璁惧鐨刬d閲嶅鐧诲綍"; }
+    public String DeviceCurrentIsLoginForbidden (){ return "褰撳墠璁惧鐨刬d绂佹鐧诲綍"; }
+    public String PasswordCheckFailed (){ return "瀵嗙爜楠岃瘉澶辫触"; }
+    public String DataTransformError (){ return "鏁版嵁杞崲澶辫触锛屾簮鏁版嵁锛�"; }
+    public String RemoteClosedConnection (){ return "杩滅▼鍏抽棴浜嗚繛鎺�"; }
+
+    /***********************************************************************************
+     *
+     *    鏃ュ織 鐩稿叧
+     *
+     ************************************************************************************/
+    public String LogNetDebug (){ return "璋冭瘯"; }
+    public String LogNetInfo (){ return "淇℃伅"; }
+    public String LogNetWarn (){ return "璀﹀憡"; }
+    public String LogNetError (){ return "閿欒"; }
+    public String LogNetFatal (){ return "鑷村懡"; }
+    public String LogNetAbandon (){ return "鏀惧純"; }
+    public String LogNetAll (){ return "鍏ㄩ儴"; }
+
+    /***********************************************************************************
+     *
+     *    Modbus鐩稿叧
+     *
+     ************************************************************************************/
+
+    public String ModbusTcpFunctionCodeNotSupport (){ return "涓嶆敮鎸佺殑鍔熻兘鐮�"; }
+    public String ModbusTcpFunctionCodeOverBound (){ return "璇诲彇鐨勬暟鎹秺鐣�"; }
+    public String ModbusTcpFunctionCodeQuantityOver (){ return "璇诲彇闀垮害瓒呰繃鏈�澶у��"; }
+    public String ModbusTcpFunctionCodeReadWriteException (){ return "璇诲啓寮傚父"; }
+    public String ModbusTcpReadCoilException (){ return "璇诲彇绾垮湀寮傚父"; }
+    public String ModbusTcpWriteCoilException (){ return "鍐欏叆绾垮湀寮傚父"; }
+    public String ModbusTcpReadRegisterException (){ return "璇诲彇瀵勫瓨鍣ㄥ紓甯�"; }
+    public String ModbusTcpWriteRegisterException (){ return "鍐欏叆瀵勫瓨鍣ㄥ紓甯�"; }
+    public String ModbusAddressMustMoreThanOne (){ return "鍦板潃鍊煎湪璧峰鍦板潃涓�1鐨勬儏鍐典笅锛屽繀椤诲ぇ浜�1"; }
+    public String ModbusAsciiFormatCheckFailed (){ return "Modbus鐨刟scii鎸囦护妫�鏌ュけ璐ワ紝涓嶆槸modbus-ascii鎶ユ枃"; }
+    public String ModbusCRCCheckFailed (){ return "Modbus鐨凜RC鏍¢獙妫�鏌ュけ璐�"; }
+    public String ModbusLRCCheckFailed (){ return "Modbus鐨凩RC鏍¢獙妫�鏌ュけ璐�"; }
+    public String ModbusMatchFailed (){ return "涓嶆槸鏍囧噯鐨刴odbus鍗忚"; }
+
+
+    /***********************************************************************************
+     *
+     *    Melsec PLC 鐩稿叧
+     *
+     ************************************************************************************/
+    public String MelsecPleaseReferToManulDocument (){ return "璇锋煡鐪嬩笁鑿辩殑閫氳鎵嬪唽鏉ユ煡鐪嬫姤璀︾殑鍏蜂綋淇℃伅"; }
+    public String MelsecReadBitInfo (){ return "璇诲彇浣嶅彉閲忔暟缁勫彧鑳介拡瀵逛綅杞厓浠讹紝濡傛灉璇诲彇瀛楄蒋鍏冧欢锛岃璋冪敤Read鏂规硶"; }
+    public String MelsecCurrentTypeNotSupportedWordOperate (){ return "褰撳墠鐨勭被鍨嬩笉鏀寔瀛楄鍐�"; }
+    public String MelsecCurrentTypeNotSupportedBitOperate (){ return "褰撳墠鐨勭被鍨嬩笉鏀寔浣嶈鍐�"; }
+    public String MelsecFxReceiveZore (){ return "鎺ユ敹鐨勬暟鎹暱搴︿负0"; }
+    public String MelsecFxAckNagative (){ return "PLC鍙嶉鐨勬暟鎹棤鏁�"; }
+    public String MelsecFxAckWrong (){ return "PLC鍙嶉淇″彿閿欒锛�"; }
+    public String MelsecFxCrcCheckFailed (){ return "PLC鍙嶉鎶ユ枃鐨勫拰鏍¢獙澶辫触锛�"; }
+
+    /***********************************************************************************
+     *
+     *    Siemens PLC 鐩稿叧
+     *
+     ************************************************************************************/
+
+    public String SiemensDBAddressNotAllowedLargerThan255 (){ return "DB鍧楁暟鎹棤娉曞ぇ浜�255"; }
+    public String SiemensReadLengthMustBeEvenNumber (){ return "璇诲彇鐨勬暟鎹暱搴﹀繀椤讳负鍋舵暟"; }
+    public String SiemensWriteError (){ return "鍐欏叆鏁版嵁寮傚父锛屼唬鍙蜂负锛�"; }
+    public String SiemensReadLengthCannotLargerThan19 (){ return "璇诲彇鐨勬暟缁勬暟閲忎笉鍏佽澶т簬19"; }
+    public String SiemensDataLengthCheckFailed (){ return "鏁版嵁鍧楅暱搴︽牎楠屽け璐ワ紝璇锋鏌ユ槸鍚﹀紑鍚痯ut/get浠ュ強鍏抽棴db鍧椾紭鍖�"; }
+    public String SiemensFWError (){ return "鍙戠敓浜嗗紓甯革紝鍏蜂綋淇℃伅鏌ユ壘Fetch/Write鍗忚鏂囨。"; }
+
+    /***********************************************************************************
+     *
+     *    Omron PLC 鐩稿叧
+     *
+     ************************************************************************************/
+
+    public String OmronAddressMustBeZeroToFiveteen (){ return "杈撳叆鐨勪綅鍦板潃鍙兘鍦�0-15涔嬮棿"; }
+    public String OmronReceiveDataError (){ return "鏁版嵁鎺ユ敹寮傚父"; }
+    public String OmronStatus0 (){ return "閫氳姝e父"; }
+    public String OmronStatus1 (){ return "娑堟伅澶翠笉鏄疐INS"; }
+    public String OmronStatus2 (){ return "鏁版嵁闀垮害澶暱"; }
+    public String OmronStatus3 (){ return "璇ュ懡浠や笉鏀寔"; }
+    public String OmronStatus20 (){ return "瓒呰繃杩炴帴涓婇檺"; }
+    public String OmronStatus21 (){ return "鎸囧畾鐨勮妭鐐瑰凡缁忓浜庤繛鎺ヤ腑"; }
+    public String OmronStatus22 (){ return "灏濊瘯鍘昏繛鎺ヤ竴涓彈淇濇姢鐨勭綉缁滆妭鐐癸紝璇ヨ妭鐐硅繕鏈厤缃埌PLC涓�"; }
+    public String OmronStatus23 (){ return "褰撳墠瀹㈡埛绔殑缃戠粶鑺傜偣瓒呰繃姝e父鑼冨洿"; }
+    public String OmronStatus24 (){ return "褰撳墠瀹㈡埛绔殑缃戠粶鑺傜偣宸茬粡琚娇鐢�"; }
+    public String OmronStatus25 (){ return "鎵�鏈夌殑缃戠粶鑺傜偣宸茬粡琚娇鐢�"; }
+
+
+
+    /***********************************************************************************
+     *
+     *    AB PLC 鐩稿叧
+     *
+     ************************************************************************************/
+
+
+    public String AllenBradley04 (){ return "瀹冩病鏈夋纭敓鎴愭垨鍖归厤鏍囪涓嶅瓨鍦ㄣ��"; }
+    public String AllenBradley05 (){ return "寮曠敤鐨勭壒瀹氶」锛堥�氬父鏄疄渚嬶級鏃犳硶鎵惧埌銆�"; }
+    public String AllenBradley06 (){ return "璇锋眰鐨勬暟鎹噺涓嶉�傚悎鍝嶅簲缂撳啿鍖恒�� 鍙戠敓浜嗛儴鍒嗘暟鎹紶杈撱��"; }
+    public String AllenBradley0A (){ return "灏濊瘯澶勭悊鍏朵腑涓�涓睘鎬ф椂鍙戠敓閿欒銆�"; }
+    public String AllenBradley13 (){ return "鍛戒护涓病鏈夋彁渚涜冻澶熺殑鍛戒护鏁版嵁/鍙傛暟鏉ユ墽琛屾墍璇锋眰鐨勬湇鍔°��"; }
+    public String AllenBradley1C (){ return "涓庡睘鎬ц鏁扮浉姣旓紝鎻愪緵鐨勫睘鎬ф暟閲忎笉瓒炽��"; }
+    public String AllenBradley1E (){ return "姝ゆ湇鍔′腑鐨勬湇鍔¤姹傚嚭閿欍��"; }
+    public String AllenBradley26 (){ return "IOI瀛楅暱涓庡鐞嗙殑IOI鏁伴噺涓嶅尮閰嶃��"; }
+
+    public String AllenBradleySessionStatus00 (){ return "鎴愬姛"; }
+    public String AllenBradleySessionStatus01 (){ return "鍙戜欢浜哄彂鍑烘棤鏁堟垨涓嶅彈鏀寔鐨勫皝瑁呭懡浠ゃ��"; }
+    public String AllenBradleySessionStatus02 (){ return "鎺ユ敹鍣ㄤ腑鐨勫唴瀛樿祫婧愪笉瓒充互澶勭悊鍛戒护銆� 杩欎笉鏄竴涓簲鐢ㄧ▼搴忛敊璇�� 鐩稿弽锛屽彧鏈夊湪灏佽灞傛棤娉曡幏寰楁墍闇�鍐呭瓨璧勬簮鐨勬儏鍐典笅鎵嶄細瀵艰嚧姝ら棶棰樸��"; }
+    public String AllenBradleySessionStatus03 (){ return "灏佽娑堟伅鐨勬暟鎹儴鍒嗕腑鐨勬暟鎹舰鎴愪笉鑹垨涓嶆纭��"; }
+    public String AllenBradleySessionStatus64 (){ return "鍚戠洰鏍囧彂閫佸皝瑁呮秷鎭椂锛屽鍙戣�呬娇鐢ㄤ簡鏃犳晥鐨勪細璇濆彞鏌勩��"; }
+    public String AllenBradleySessionStatus65 (){ return "鐩爣鏀跺埌涓�涓棤鏁堥暱搴︾殑淇℃伅銆�"; }
+    public String AllenBradleySessionStatus69 (){ return "涓嶆敮鎸佺殑灏佽鍗忚淇銆�"; }
+
+    /***********************************************************************************
+     *
+     *    Panasonic PLC 鐩稿叧
+     *
+     ************************************************************************************/
+    public String PanasonicReceiveLengthMustLargerThan9 (){ return "鎺ユ敹鏁版嵁闀垮害蹇呴』澶т簬9"; }
+    public String PanasonicAddressParameterCannotBeNull (){ return "鍦板潃鍙傛暟涓嶅厑璁镐负绌�"; }
+    public String PanasonicMewStatus20 (){ return "閿欒鏈煡"; }
+    public String PanasonicMewStatus21 (){ return "NACK閿欒锛岃繙绋嬪崟鍏冩棤娉曡姝g‘璇嗗埆锛屾垨鑰呭彂鐢熶簡鏁版嵁閿欒銆�"; }
+    public String PanasonicMewStatus22 (){ return "WACK 閿欒:鐢ㄤ簬杩滅▼鍗曞厓鐨勬帴鏀剁紦鍐插尯宸叉弧銆�"; }
+    public String PanasonicMewStatus23 (){ return "澶氶噸绔彛閿欒:杩滅▼鍗曞厓缂栧彿(01 鑷� 16)璁剧疆涓庢湰鍦板崟鍏冮噸澶嶃��"; }
+    public String PanasonicMewStatus24 (){ return "浼犺緭鏍煎紡閿欒:璇曞浘鍙戦�佷笉绗﹀悎浼犺緭鏍煎紡鐨勬暟鎹紝鎴栬�呮煇涓�甯ф暟鎹孩鍑烘垨鍙戠敓浜嗘暟鎹敊璇��"; }
+    public String PanasonicMewStatus25 (){ return "纭欢閿欒:浼犺緭绯荤粺纭欢鍋滄鎿嶄綔銆�"; }
+    public String PanasonicMewStatus26 (){ return "鍗曞厓鍙烽敊璇�:杩滅▼鍗曞厓鐨勭紪鍙疯缃秴鍑� 01 鑷� 63 鐨勮寖鍥淬��"; }
+    public String PanasonicMewStatus27 (){ return "涓嶆敮鎸侀敊璇�:鎺ユ敹鏂规暟鎹抚婧㈠嚭. 璇曞浘鍦ㄤ笉鍚岀殑妯″潡涔嬮棿鍙戦�佷笉鍚屽抚闀垮害鐨勬暟鎹��"; }
+    public String PanasonicMewStatus28 (){ return "鏃犲簲绛旈敊璇�:杩滅▼鍗曞厓涓嶅瓨鍦�. (瓒呮椂)銆�"; }
+    public String PanasonicMewStatus29 (){ return "缂撳啿鍖哄叧闂敊璇�:璇曞浘鍙戦�佹垨鎺ユ敹澶勪簬鍏抽棴鐘舵�佺殑缂撳啿鍖恒��"; }
+    public String PanasonicMewStatus30 (){ return "瓒呮椂閿欒:鎸佺画澶勪簬浼犺緭绂佹鐘舵�併��"; }
+    public String PanasonicMewStatus40 (){ return "BCC 閿欒:鍦ㄦ寚浠ゆ暟鎹腑鍙戠敓浼犺緭閿欒銆�"; }
+    public String PanasonicMewStatus41 (){ return "鏍煎紡閿欒:鎵�鍙戦�佺殑鎸囦护淇℃伅涓嶇鍚堜紶杈撴牸寮忋��"; }
+    public String PanasonicMewStatus42 (){ return "涓嶆敮鎸侀敊璇�:鍙戦�佷簡涓�涓湭琚敮鎸佺殑鎸囦护銆傚悜鏈鏀寔鐨勭洰鏍囩珯鍙戦�佷簡鎸囦护銆�"; }
+    public String PanasonicMewStatus43 (){ return "澶勭悊姝ラ閿欒:鍦ㄥ浜庝紶杈撹姹備俊鎭寕璧锋椂,鍙戦�佷簡鍏朵粬鎸囦护銆�"; }
+    public String PanasonicMewStatus50 (){ return "閾炬帴璁剧疆閿欒:璁剧疆浜嗗疄闄呬笉瀛樺湪鐨勯摼鎺ョ紪鍙枫��"; }
+    public String PanasonicMewStatus51 (){ return "鍚屾椂鎿嶄綔閿欒:褰撳悜鍏朵粬鍗曞厓鍙戝嚭鎸囦护鏃�,鏈湴鍗曞厓鐨勪紶杈撶紦鍐插尯宸叉弧銆�"; }
+    public String PanasonicMewStatus52 (){ return "浼犺緭绂佹閿欒:鏃犳硶鍚戝叾浠栧崟鍏冧紶杈撱��"; }
+    public String PanasonicMewStatus53 (){ return "蹇欓敊璇�:鍦ㄦ帴鏀跺埌鎸囦护鏃�,姝e湪澶勭悊鍏朵粬鎸囦护銆�"; }
+    public String PanasonicMewStatus60 (){ return "鍙傛暟閿欒:鍦ㄦ寚浠や腑鍖呭惈鏈夋棤娉曚娇鐢ㄧ殑浠g爜,鎴栬�呬唬鐮佹病鏈夐檮甯﹀尯鍩熸寚瀹氬弬鏁�(X, Y, D), 绛変互澶栥��"; }
+    public String PanasonicMewStatus61 (){ return "鏁版嵁閿欒:瑙︾偣缂栧彿,鍖哄煙缂栧彿,鏁版嵁浠g爜鏍煎紡(BCD,hex,绛�)涓婃孩鍑�, 涓嬫孩鍑轰互鍙婂尯鍩熸寚瀹氶敊璇��"; }
+    public String PanasonicMewStatus62 (){ return "瀵勫瓨鍣ㄩ敊璇�:杩囧璁板綍鏁版嵁鍦ㄦ湭璁板綍鐘舵�佷笅鐨勬搷浣滐紙鐩戞帶璁板綍銆佽窡韪褰曠瓑銆�)銆�"; }
+    public String PanasonicMewStatus63 (){ return "PLC 妯″紡閿欒:褰撲竴鏉℃寚浠ゅ彂鍑烘椂锛岃繍琛屾ā寮忎笉鑳藉瀵规寚浠よ繘琛屽鐞嗐��"; }
+    public String PanasonicMewStatus65 (){ return "淇濇姢閿欒:鍦ㄥ瓨鍌ㄤ繚鎶ょ姸鎬佷笅鎵ц鍐欐搷浣滃埌绋嬪簭鍖哄煙鎴栫郴缁熷瘎瀛樺櫒銆�"; }
+    public String PanasonicMewStatus66 (){ return "鍦板潃閿欒:鍦板潃锛堢▼搴忓湴鍧�銆佺粷瀵瑰湴鍧�绛夛級鏁版嵁缂栫爜褰㈠紡锛圔CD銆乭ex 绛夛級銆佷笂婧€�佷笅婧㈡垨鎸囧畾鑼冨洿閿欒銆�"; }
+    public String PanasonicMewStatus67 (){ return "涓㈠け鏁版嵁閿欒:瑕佽鐨勬暟鎹笉瀛樺湪銆傦紙璇诲彇娌℃湁鍐欏叆娉ㄩ噴瀵勫瓨鍖虹殑鏁版嵁銆傘��"; }
+}
diff --git a/src/main/java/com/zy/gateway/core/language/English.java b/src/main/java/com/zy/gateway/core/language/English.java
new file mode 100644
index 0000000..5ab15a7
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/language/English.java
@@ -0,0 +1,463 @@
+package com.zy.gateway.core.language;
+
+/**
+ * English Version Text
+ */
+public class English extends DefaultLanguage {
+
+    /***********************************************************************************
+     *
+     *    Normal Info
+     *
+     ************************************************************************************/
+
+    @Override
+    public String ConnectedFailed (){ return "Connected Failed: "; }
+    @Override
+    public String UnknownError (){ return "Unknown Error"; }
+    @Override
+    public String ErrorCode (){ return "Error Code: "; }
+    @Override
+    public String TextDescription (){ return "Description: "; }
+    @Override
+    public String ExceptionMessage (){ return "Exception Info: "; }
+    @Override
+    public String ExceptionSourse (){ return "Exception Sourse锛�"; }
+    @Override
+    public String ExceptionType (){ return "Exception Type锛�"; }
+    @Override
+    public String ExceptionStackTrace (){ return "Exception Stack: "; }
+    @Override
+    public String ExceptopnTargetSite (){ return "Exception Method: "; }
+    @Override
+    public String ExceprionCustomer (){ return "Error in user-defined method: "; }
+    @Override
+    public String SuccessText (){ return "Success"; }
+    @Override
+    public String TwoParametersLengthIsNotSame (){ return "Two Parameter Length is not same"; }
+    @Override
+    public String NotSupportedDataType (){ return "Unsupported DataType, input again"; }
+    @Override
+    public String DataLengthIsNotEnough (){ return "Receive length is not enough锛孲hould:{0},Actual:{1}"; }
+    @Override
+    public String ReceiveDataTimeout (){ return "Receive timeout: "; }
+    @Override
+    public String ReceiveDataLengthTooShort (){ return "Receive length is too short: "; }
+    @Override
+    public String MessageTip (){ return "Message prompt:"; }
+    @Override
+    public String Close (){ return "Close"; }
+    @Override
+    public String Time (){ return "Time:"; }
+    @Override
+    public String SoftWare (){ return "Software:"; }
+    @Override
+    public String BugSubmit (){ return "Bug submit"; }
+    @Override
+    public String MailServerCenter (){ return "Mail Center System"; }
+    @Override
+    public String MailSendTail (){ return "Mail Service system issued automatically, do not reply"; }
+    @Override
+    public String IpAddresError (){ return "IP address input exception, format is incorrect"; }
+    @Override
+    public String Send (){ return "Send";}
+    @Override
+    public String Receive(){ return "Receive";}
+
+    /***********************************************************************************
+     *
+     *    System about
+     *
+     ************************************************************************************/
+
+    @Override
+    public String SystemInstallOperater (){ return "Install new software: ip address is"; }
+    @Override
+    public String SystemUpdateOperater (){ return "Update software: ip address is"; }
+
+
+    /***********************************************************************************
+     *
+     *    Socket-related Information description
+     *
+     ************************************************************************************/
+
+    @Override
+    public String SocketIOException (){ return "Socket transport error: "; }
+    @Override
+    public String SocketSendException (){ return "Synchronous Data Send exception: "; }
+    @Override
+    public String SocketHeadReceiveException (){ return "Command header receive exception: "; }
+    @Override
+    public String SocketContentReceiveException (){ return "Content Data Receive exception: "; }
+    @Override
+    public String SocketContentRemoteReceiveException (){ return "Recipient content Data Receive exception: "; }
+    @Override
+    public String SocketAcceptCallbackException (){ return "Asynchronously accepts an incoming connection attempt: "; }
+    @Override
+    public String SocketReAcceptCallbackException (){ return "To re-accept incoming connection attempts asynchronously"; }
+    @Override
+    public String SocketSendAsyncException (){ return "Asynchronous Data send Error: "; }
+    @Override
+    public String SocketEndSendException (){ return "Asynchronous data end callback send Error"; }
+    @Override
+    public String SocketReceiveException (){ return "Asynchronous Data send Error: "; }
+    @Override
+    public String SocketEndReceiveException (){ return "Asynchronous data end receive instruction header error"; }
+    @Override
+    public String SocketRemoteCloseException (){ return "An existing connection was forcibly closed by the remote host"; }
+
+
+    /***********************************************************************************
+     *
+     *    File related information
+     *
+     ************************************************************************************/
+
+
+    @Override
+    public String FileDownloadSuccess (){ return "File Download Successful"; }
+    @Override
+    public String FileDownloadFailed (){ return "File Download exception"; }
+    @Override
+    public String FileUploadFailed (){ return "File Upload exception"; }
+    @Override
+    public String FileUploadSuccess (){ return "File Upload Successful"; }
+    @Override
+    public String FileDeleteFailed (){ return "File Delete exception"; }
+    @Override
+    public String FileDeleteSuccess (){ return "File deletion succeeded"; }
+    @Override
+    public String FileReceiveFailed (){ return "Confirm File Receive exception"; }
+    @Override
+    public String FileNotExist (){ return "File does not exist"; }
+    @Override
+    public String FileSaveFailed (){ return "File Store failed"; }
+    @Override
+    public String FileLoadFailed (){ return "File load failed"; }
+    @Override
+    public String FileSendClientFailed (){ return "An exception occurred when the file was sent"; }
+    @Override
+    public String FileWriteToNetFailed (){ return "File Write Network exception"; }
+    @Override
+    public String FileReadFromNetFailed (){ return "Read file exceptions from the network"; }
+    @Override
+    public String FilePathCreateFailed (){ return "Folder path creation failed: "; }
+    @Override
+    public String FileRemoteNotExist (){ return "The other file does not exist, cannot receive!"; }
+
+    /***********************************************************************************
+     *
+     *    Engine-related data for the server
+     *
+     ************************************************************************************/
+
+    @Override
+    public String TokenCheckFailed (){ return "Receive authentication token inconsistency"; }
+    @Override
+    public String TokenCheckTimeout (){ return "Receive authentication timeout: "; }
+    @Override
+    public String CommandHeadCodeCheckFailed (){ return "Command header check failed"; }
+    @Override
+    public String CommandLengthCheckFailed (){ return "Command length check failed"; }
+    @Override
+    public String NetClientAliasFailed (){ return "Client's alias receive failed: "; }
+    @Override
+    public String NetEngineStart (){ return "Start engine"; }
+    @Override
+    public String NetEngineClose (){ return "Shutting down the engine"; }
+    @Override
+    public String NetClientOnline (){ return "Online"; }
+    @Override
+    public String NetClientOffline (){ return "Offline"; }
+    @Override
+    public String NetClientBreak (){ return "Abnormal offline"; }
+    @Override
+    public String NetClientFull (){ return "The server hosts the upper limit and receives an exceeded request connection."; }
+    @Override
+    public String NetClientLoginFailed (){ return "Error in Client logon: "; }
+    @Override
+    public String NetHeartCheckFailed (){ return "Heartbeat Validation exception: "; }
+    @Override
+    public String NetHeartCheckTimeout (){ return "Heartbeat verification timeout, force offline: "; }
+    @Override
+    public String DataSourseFormatError (){ return "Data source format is incorrect"; }
+    @Override
+    public String ServerFileCheckFailed (){ return "Server confirmed file failed, please re-upload"; }
+    @Override
+    public String ClientOnlineInfo (){ return "Client [ {0} ] Online"; }
+    @Override
+    public String ClientOfflineInfo (){ return "Client [ {0} ] Offline"; }
+    @Override
+    public String ClientDisableLogin (){ return "Client [ {0} ] is not trusted, login forbidden"; }
+
+    /***********************************************************************************
+     *
+     *    Client related
+     *
+     ************************************************************************************/
+
+    @Override
+    public String ReConnectServerSuccess (){ return "Re-connect server succeeded"; }
+    @Override
+    public String ReConnectServerAfterTenSeconds (){ return "Reconnect the server after 10 seconds"; }
+    @Override
+    public String KeyIsNotAllowedNull (){ return "The keyword is not allowed to be empty"; }
+    @Override
+    public String KeyIsExistAlready (){ return "The current keyword already exists"; }
+    @Override
+    public String KeyIsNotExist (){ return "The keyword for the current subscription does not exist"; }
+    @Override
+    public String ConnectingServer (){ return "Connecting to Server..."; }
+    @Override
+    public String ConnectFailedAndWait (){ return "Connection disconnected, wait {0} seconds to reconnect"; }
+    @Override
+    public String AttemptConnectServer (){ return "Attempting to connect server {0} times"; }
+    @Override
+    public String ConnectServerSuccess (){ return "Connection Server succeeded"; }
+    @Override
+    public String GetClientIpaddressFailed (){ return "Client IP Address acquisition failed"; }
+    @Override
+    public String ConnectionIsNotAvailable (){ return "The current connection is not available"; }
+    @Override
+    public String DeviceCurrentIsLoginRepeat (){ return "ID of the current device duplicate login"; }
+    @Override
+    public String DeviceCurrentIsLoginForbidden (){ return "The ID of the current device prohibits login"; }
+    @Override
+    public String PasswordCheckFailed (){ return "Password validation failed"; }
+    @Override
+    public String DataTransformError (){ return "Data conversion failed, source data: "; }
+    @Override
+    public String RemoteClosedConnection (){ return "Remote shutdown of connection"; }
+
+    /***********************************************************************************
+     *
+     *    Log related
+     *
+     ************************************************************************************/
+    @Override
+    public String LogNetDebug (){ return "Debug"; }
+    @Override
+    public String LogNetInfo (){ return "Info"; }
+    @Override
+    public String LogNetWarn (){ return "Warn"; }
+    @Override
+    public String LogNetError (){ return "Error"; }
+    @Override
+    public String LogNetFatal (){ return "Fatal"; }
+    @Override
+    public String LogNetAbandon (){ return "Abandon"; }
+    @Override
+    public String LogNetAll (){ return "All"; }
+
+
+    /***********************************************************************************
+     *
+     *    Modbus related
+     *
+     ************************************************************************************/
+
+    @Override
+    public String ModbusTcpFunctionCodeNotSupport (){ return "Unsupported function code"; }
+    @Override
+    public String ModbusTcpFunctionCodeOverBound (){ return "Data read out of bounds"; }
+    @Override
+    public String ModbusTcpFunctionCodeQuantityOver (){ return "Read length exceeds maximum value"; }
+    @Override
+    public String ModbusTcpFunctionCodeReadWriteException (){ return "Read and Write exceptions"; }
+    @Override
+    public String ModbusTcpReadCoilException (){ return "Read Coil anomalies"; }
+    @Override
+    public String ModbusTcpWriteCoilException (){ return "Write Coil exception"; }
+    @Override
+    public String ModbusTcpReadRegisterException (){ return "Read Register exception"; }
+    @Override
+    public String ModbusTcpWriteRegisterException (){ return "Write Register exception"; }
+    @Override
+    public String ModbusAddressMustMoreThanOne (){ return "The address value must be greater than 1 in the case where the start address is 1"; }
+    @Override
+    public String ModbusAsciiFormatCheckFailed (){ return "Modbus ASCII command check failed, not MODBUS-ASCII message"; }
+    @Override
+    public String ModbusCRCCheckFailed (){ return "The CRC checksum check failed for Modbus"; }
+    @Override
+    public String ModbusLRCCheckFailed (){ return "The LRC checksum check failed for Modbus"; }
+    @Override
+    public String ModbusMatchFailed (){ return "Not the standard Modbus protocol"; }
+
+
+    /***********************************************************************************
+     *
+     *    Melsec PLC related
+     *
+     ************************************************************************************/
+    @Override
+    public String MelsecPleaseReferToManulDocument (){ return "Please check Mitsubishi's communication manual for details of the alarm."; }
+    @Override
+    public String MelsecReadBitInfo (){ return "The read bit variable array can only be used for bit soft elements, if you read the word soft component, call the Read method"; }
+    @Override
+    public String MelsecCurrentTypeNotSupportedWordOperate (){ return "The current type does not support word read and write"; }
+    @Override
+    public String MelsecCurrentTypeNotSupportedBitOperate (){ return "The current type does not support bit read and write"; }
+    @Override
+    public String MelsecFxReceiveZore (){ return "The received data length is 0"; }
+    @Override
+    public String MelsecFxAckNagative (){ return "Invalid data from PLC feedback"; }
+    @Override
+    public String MelsecFxAckWrong (){ return "PLC Feedback Signal Error: "; }
+    @Override
+    public String MelsecFxCrcCheckFailed (){ return "PLC Feedback message and check failed!"; }
+
+    /***********************************************************************************
+     *
+     *    Siemens PLC related
+     *
+     ************************************************************************************/
+
+    @Override
+    public String SiemensDBAddressNotAllowedLargerThan255 (){ return "DB block data cannot be greater than 255"; }
+    @Override
+    public String SiemensReadLengthMustBeEvenNumber (){ return "The length of the data read must be an even number"; }
+    @Override
+    public String SiemensWriteError (){ return "Writes the data exception, the code name is: "; }
+    @Override
+    public String SiemensReadLengthCannotLargerThan19 (){ return "The number of arrays read does not allow greater than 19"; }
+    @Override
+    public String SiemensDataLengthCheckFailed (){ return "Block length checksum failed, please check if Put/get is turned on and DB block optimization is turned off"; }
+    @Override
+    public String SiemensFWError (){ return "An exception occurred, the specific information to find the Fetch/write protocol document"; }
+
+    /***********************************************************************************
+     *
+     *    Omron PLC related
+     *
+     ************************************************************************************/
+
+    @Override
+    public String OmronAddressMustBeZeroToFiveteen (){ return "The bit address entered can only be between 0-15"; }
+    @Override
+    public String OmronReceiveDataError (){ return "Data Receive exception"; }
+    @Override
+    public String OmronStatus0 (){ return "Communication is normal."; }
+    @Override
+    public String OmronStatus1 (){ return "The message header is not fins"; }
+    @Override
+    public String OmronStatus2 (){ return "Data length too long"; }
+    @Override
+    public String OmronStatus3 (){ return "This command does not support"; }
+    @Override
+    public String OmronStatus20 (){ return "Exceeding connection limit"; }
+    @Override
+    public String OmronStatus21 (){ return "The specified node is already in the connection"; }
+    @Override
+    public String OmronStatus22 (){ return "Attempt to connect to a protected network node that is not yet configured in the PLC"; }
+    @Override
+    public String OmronStatus23 (){ return "The current client's network node exceeds the normal range"; }
+    @Override
+    public String OmronStatus24 (){ return "The current client's network node is already in use"; }
+    @Override
+    public String OmronStatus25 (){ return "All network nodes are already in use"; }
+
+
+
+    /***********************************************************************************
+     *
+     *    AB PLC 鐩稿叧
+     *
+     ************************************************************************************/
+
+
+    @Override
+    public String AllenBradley04 (){ return "The IOI could not be deciphered. Either it was not formed correctly or the match tag does not exist."; }
+    @Override
+    public String AllenBradley05 (){ return "The particular item referenced (usually instance) could not be found."; }
+    @Override
+    public String AllenBradley06 (){ return "The amount of data requested would not fit into the response buffer. Partial data transfer has occurred."; }
+    @Override
+    public String AllenBradley0A (){ return "An error has occurred trying to process one of the attributes."; }
+    @Override
+    public String AllenBradley13 (){ return "Not enough command data / parameters were supplied in the command to execute the service requested."; }
+    @Override
+    public String AllenBradley1C (){ return "An insufficient number of attributes were provided compared to the attribute count."; }
+    @Override
+    public String AllenBradley1E (){ return "A service request in this service went wrong."; }
+    @Override
+    public String AllenBradley26 (){ return "The IOI word length did not match the amount of IOI which was processed."; }
+
+    @Override
+    public String AllenBradleySessionStatus00 (){ return "success"; }
+    @Override
+    public String AllenBradleySessionStatus01 (){ return "The sender issued an invalid or unsupported encapsulation command."; }
+    @Override
+    public String AllenBradleySessionStatus02 (){ return "Insufficient memory resources in the receiver to handle the command. This is not an application error. Instead, it only results if the encapsulation layer cannot obtain memory resources that it need."; }
+    @Override
+    public String AllenBradleySessionStatus03 (){ return "Poorly formed or incorrect data in the data portion of the encapsulation message."; }
+    @Override
+    public String AllenBradleySessionStatus64 (){ return "An originator used an invalid session handle when sending an encapsulation message."; }
+    @Override
+    public String AllenBradleySessionStatus65 (){ return "The target received a message of invalid length."; }
+    @Override
+    public String AllenBradleySessionStatus69 (){ return "Unsupported encapsulation protocol revision."; }
+
+    /***********************************************************************************
+     *
+     *    Panasonic PLC 鐩稿叧
+     *
+     ************************************************************************************/
+    @Override
+    public String PanasonicReceiveLengthMustLargerThan9 (){ return "The received data length must be greater than 9"; }
+    @Override
+    public String PanasonicAddressParameterCannotBeNull (){ return "Address parameter is not allowed to be empty"; }
+    @Override
+    public String PanasonicMewStatus20 (){ return "Error unknown"; }
+    @Override
+    public String PanasonicMewStatus21 (){ return "Nack error, the remote unit could not be correctly identified, or a data error occurred."; }
+    @Override
+    public String PanasonicMewStatus22 (){ return "WACK Error: The receive buffer for the remote unit is full."; }
+    @Override
+    public String PanasonicMewStatus23 (){ return "Multiple port error: The remote unit number (01 to 16) is set to repeat with the local unit."; }
+    @Override
+    public String PanasonicMewStatus24 (){ return "Transport format error: An attempt was made to send data that does not conform to the transport format, or a frame data overflow or a data error occurred."; }
+    @Override
+    public String PanasonicMewStatus25 (){ return "Hardware error: Transport system hardware stopped operation."; }
+    @Override
+    public String PanasonicMewStatus26 (){ return "Unit Number error: The remote unit's numbering setting exceeds the range of 01 to 63."; }
+    @Override
+    public String PanasonicMewStatus27 (){ return "Error not supported: Receiver data frame overflow. An attempt was made to send data of different frame lengths between different modules."; }
+    @Override
+    public String PanasonicMewStatus28 (){ return "No answer error: The remote unit does not exist. (timeout)."; }
+    @Override
+    public String PanasonicMewStatus29 (){ return "Buffer Close error: An attempt was made to send or receive a buffer that is in a closed state."; }
+    @Override
+    public String PanasonicMewStatus30 (){ return "Timeout error: Persisted in transport forbidden State."; }
+    @Override
+    public String PanasonicMewStatus40 (){ return "BCC Error: A transmission error occurred in the instruction data."; }
+    @Override
+    public String PanasonicMewStatus41 (){ return "Malformed: The sent instruction information does not conform to the transmission format."; }
+    @Override
+    public String PanasonicMewStatus42 (){ return "Error not supported: An unsupported instruction was sent. An instruction was sent to a target station that was not supported."; }
+    @Override
+    public String PanasonicMewStatus43 (){ return "Processing Step Error: Additional instructions were sent when the transfer request information was suspended."; }
+    @Override
+    public String PanasonicMewStatus50 (){ return "Link Settings Error: A link number that does not actually exist is set."; }
+    @Override
+    public String PanasonicMewStatus51 (){ return "Simultaneous operation error: When issuing instructions to other units, the transmit buffer for the local unit is full."; }
+    @Override
+    public String PanasonicMewStatus52 (){ return "Transport suppression Error: Unable to transfer to other units."; }
+    @Override
+    public String PanasonicMewStatus53 (){ return "Busy error: Other instructions are being processed when the command is received."; }
+    @Override
+    public String PanasonicMewStatus60 (){ return "Parameter error: Contains code that cannot be used in the directive, or the code does not have a zone specified parameter (X, Y, D), and so on."; }
+    @Override
+    public String PanasonicMewStatus61 (){ return "Data error: Contact number, area number, Data code format (BCD,HEX, etc.) overflow, overflow, and area specified error."; }
+    @Override
+    public String PanasonicMewStatus62 (){ return "Register ERROR: Excessive logging of data in an unregistered state of operations (Monitoring records, tracking records, etc.). )銆�"; }
+    @Override
+    public String PanasonicMewStatus63 (){ return "PLC mode error: When an instruction is issued, the run mode is not able to process the instruction."; }
+    @Override
+    public String PanasonicMewStatus65 (){ return "Protection Error: Performs a write operation to the program area or system register in the storage protection state."; }
+    @Override
+    public String PanasonicMewStatus66 (){ return "Address Error: Address (program address, absolute address, etc.) Data encoding form (BCD, hex, etc.), overflow, underflow, or specified range error."; }
+    @Override
+    public String PanasonicMewStatus67 (){ return "Missing data error: The data to be read does not exist. (reads data that is not written to the comment register.)"; }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/log/HslMessageDegree.java b/src/main/java/com/zy/gateway/core/log/HslMessageDegree.java
new file mode 100644
index 0000000..37913a3
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/log/HslMessageDegree.java
@@ -0,0 +1,31 @@
+package com.zy.gateway.core.log;
+
+/**
+ * 鏃ュ織鐨勫瓨鍌ㄧ瓑绾�
+ */
+public enum HslMessageDegree {
+    /**
+     * 涓�鏉℃秷鎭兘涓嶈褰�
+     */
+    None,
+    /**
+     * 璁板綍鑷村懡绛夌骇鍙婁互涓婃棩蹇楃殑娑堟伅
+     */
+    FATAL,
+    /**
+     *  璁板綍寮傚父绛夌骇鍙婁互涓婃棩蹇楃殑娑堟伅
+     */
+    ERROR,
+    /**
+     *  璁板綍璀﹀憡绛夌骇鍙婁互涓婃棩蹇楃殑娑堟伅
+     */
+    WARN,
+    /**
+     *  璁板綍淇℃伅绛夌骇鍙婁互涓婃棩蹇楃殑娑堟伅
+     */
+    INFO,
+    /**
+     *  璁板綍璋冭瘯绛夌骇鍙婁互涓婃棩蹇楃殑淇℃伅
+     */
+    DEBUG
+}
diff --git a/src/main/java/com/zy/gateway/core/log/ILogNet.java b/src/main/java/com/zy/gateway/core/log/ILogNet.java
new file mode 100644
index 0000000..f47f575
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/log/ILogNet.java
@@ -0,0 +1,146 @@
+package com.zy.gateway.core.log;
+
+/**
+ * 鏃ュ織鐨勫瓨鍌ㄥ璞�
+ */
+public interface ILogNet {
+
+    /**
+     * 鏂囦欢瀛樺偍妯″紡锛�1:鍗曟枃浠讹紝2:鏍规嵁澶у皬锛�3:鏍规嵁鏃堕棿
+     * @return
+     */
+    int LogSaveMode();
+
+
+    /**
+     * 鑷畾涔夌殑娑堟伅瀛樺偍鏂规硶
+     * @param degree
+     * @param keyWord
+     * @param text
+     */
+    void RecordMessage(HslMessageDegree degree, String keyWord, String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉¤皟璇曠殑鏃ュ織
+     * @param text
+     */
+    void WriteDebug(String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉¤皟璇曠殑鏃ュ織
+     * @param keyWord
+     * @param text
+     */
+    void WriteDebug(String keyWord, String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉¤В閲婃�х殑淇℃伅
+     * @param description
+     */
+    void WriteDescrition(String description);
+
+
+    /**
+     * 鍐欏叆涓�鏉¢敊璇俊鎭�
+     * @param text
+     */
+    void WriteError(String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉¢敊璇俊鎭�
+     * @param keyWord
+     * @param text
+     */
+    void WriteError(String keyWord, String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉″紓甯哥殑淇℃伅
+     * @param keyWord
+     * @param ex
+     */
+    void WriteException(String keyWord, Exception ex);
+
+    /**
+     * 鍐欏叆涓�鏉″紓甯哥殑淇℃伅
+     * @param keyWord
+     * @param text
+     * @param ex
+     */
+    void WriteException(String keyWord, String text, Exception ex);
+
+
+    /**
+     * 鍐欏叆涓�鏉¤嚧鍛界殑淇℃伅
+     * @param text
+     */
+    void WriteFatal(String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉¤嚧鍛界殑淇℃伅
+     * @param keyWord
+     * @param text
+     */
+    void WriteFatal(String keyWord, String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉℃櫘閫氱殑淇℃伅
+     * @param text
+     */
+    void WriteInfo(String text);
+
+    /**
+     * 鍐欏叆涓�鏉℃櫘閫氱殑淇℃伅
+     * @param keyWord
+     * @param text
+     */
+    void WriteInfo(String keyWord, String text);
+
+
+    /**
+     * 鍐欏叆涓�涓┖琛�
+     */
+    void WriteNewLine();
+
+
+    /**
+     * 鍐欏叆涓�鏉¤鍛婁俊鎭�
+     * @param text
+     */
+    void WriteWarn(String text);
+
+
+    /**
+     * 鍐欏叆涓�鏉¤鍛婁俊鎭�
+     * @param keyWord
+     * @param text
+     */
+    void WriteWarn(String keyWord, String text);
+
+
+    /**
+     * 璁剧疆鏃ュ織鐨勫瓨鍌ㄧ瓑绾э紝楂樹簬璇ョ瓑绾х殑鎵嶄細琚瓨鍌�
+     * @param degree
+     */
+    void SetMessageDegree(HslMessageDegree degree);
+
+
+    /**
+     * 杩囨护鎺夋寚瀹氱殑鍏抽敭瀛楃殑鏃ュ織锛岃淇℃伅涓嶅瓨鍌紝浣嗕粛鐒惰Е鍙態eforeSaveToFile浜嬩欢
+     * @param keyword
+     */
+    void FiltrateKeyword(String keyword);
+
+
+    /**
+     * 鑾峰彇宸插瓨鍦ㄧ殑鏃ュ織鏂囦欢鍚嶇О
+     * @return
+     */
+    String[] GetExistLogFileNames();
+}
diff --git a/src/main/java/com/zy/gateway/core/net/HslProtocol.java b/src/main/java/com/zy/gateway/core/net/HslProtocol.java
new file mode 100644
index 0000000..a63e795
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/HslProtocol.java
@@ -0,0 +1,229 @@
+package com.zy.gateway.core.net;
+
+import com.zy.gateway.core.base.HslSecurity;
+import com.zy.gateway.core.base.SoftZipped;
+import com.zy.gateway.core.utils.Utilities;
+
+import java.util.UUID;
+
+public class HslProtocol
+{
+
+    /**
+     * 瑙勫畾鎵�鏈夌殑缃戠粶浼犺緭鐨勬寚浠ゅご闀垮害
+     */
+    public static final int HeadByteLength = 32;
+
+    /**
+     * 鎵�鏈夌綉缁滈�氫俊涓殑缂撳啿姹犵殑鏁版嵁淇℃伅
+     */
+    public static final int ProtocolBufferSize = 1024;
+
+    /**
+     * 鐢ㄤ簬蹇冭烦绋嬪簭鐨勬殫鍙蜂俊鎭�
+     */
+    public static final int ProtocolCheckSecends = 1;
+
+    /**
+     * 瀹㈡埛绔��鍑虹殑娑堟伅
+     */
+    public static final int ProtocolClientQuit = 2;
+
+    /**
+     * 鍥犱负瀹㈡埛绔揪鍒颁笂闄愯�屾嫆缁濈櫥褰�
+     */
+    public static final int ProtocolClientRefuseLogin = 3;
+
+    /**
+     * 鍏佽瀹㈡埛绔櫥褰曞埌鏈嶅姟鍣�
+     */
+    public static final int ProtocolClientAllowLogin = 4;
+
+    /**
+     * 璇存槑鍙戦�佺殑淇℃伅鏄枃鏈暟鎹�
+     */
+    public static final int ProtocolUserString = 1001;
+
+    /**
+     * 璇存槑鍙戦�佺殑淇℃伅鏄瓧鑺傛暟缁勬暟鎹�
+     */
+    public static final int ProtocolUserBytes = 1002;
+
+    /**
+     * 鍙戦�佺殑鏁版嵁鏄櫘閫氱殑鍥剧墖鏁版嵁
+     */
+    public static final int ProtocolUserBitmap = 1003;
+
+    /**
+     * 鍙戦�佺殑鏁版嵁鏄竴鏉″紓甯哥殑鏁版嵁锛屽瓧绗︿覆涓哄紓甯告秷鎭�
+     */
+    public static final int ProtocolUserException = 1004;
+
+    /**
+     * 璇锋眰鏂囦欢涓嬭浇鐨勬殫鍙�
+     */
+    public static final int ProtocolFileDownload = 2001;
+
+    /**
+     * 璇锋眰鏂囦欢涓婁紶鐨勬殫鍙�
+     */
+    public static final int ProtocolFileUpload = 2002;
+
+    /**
+     * 璇锋眰鍒犻櫎鏂囦欢鐨勬殫鍙�
+     */
+    public static final int ProtocolFileDelete = 2003;
+
+    /**
+     * 鏂囦欢鏍¢獙鎴愬姛
+     */
+    public static final int ProtocolFileCheckRight = 2004;
+
+    /**
+     * 鏂囦欢鏍¢獙澶辫触
+     */
+    public static final int ProtocolFileCheckError = 2005;
+
+    /**
+     * 鏂囦欢淇濆瓨澶辫触
+     */
+    public static final int ProtocolFileSaveError = 2006;
+
+    /**
+     * 璇锋眰鏂囦欢鐨勫垪琛ㄧ殑鏆楀彿
+     */
+    public static final int ProtocolFileDirectoryFiles = 2007;
+
+    /**
+     * 璇锋眰瀛愭枃浠剁殑鍒楄〃鏆楀彿
+     */
+    public static final int ProtocolFileDirectories = 2008;
+
+    /**
+     * 杩涘害杩斿洖鏆楀彿
+     */
+    public static final int ProtocolProgressReport = 2009;
+
+
+    /**
+     * 涓嶅帇缂╁瓧鑺傛暟鎹�
+     */
+    public static final int ProtocolNoZipped = 3001;
+
+    /**
+     * 鍘嬬缉瀛楄妭鏁版嵁
+     */
+    public static final int ProtocolZipped  = 3002;
+
+
+
+    /**
+     * 鐢熸垚缁堟瀬浼犻�佹寚浠ょ殑鏂规硶锛屾墍鏈夌殑鏁版嵁鍧囬�氳繃璇ユ柟娉曞嚭鏉�
+     * @param command 鍛戒护澶�
+     * @param customer 鑷敤鑷畾涔�
+     * @param token 浠ょ墝
+     * @param data 瀛楄妭鏁版嵁
+     * @return 鍙戦�佺殑娑堟伅鏁版嵁
+     */
+    public static byte[] CommandBytes(int command, int customer, UUID token, byte[] data )
+    {
+        byte[] _temp = null;
+        int _zipped = ProtocolNoZipped;
+        int _sendLength = 0;
+        if (data == null)
+        {
+            _temp = new byte[HeadByteLength];
+        }
+        else
+        {
+            // 鍔犲瘑
+            data = HslSecurity.ByteEncrypt(data);
+            if (data.length > 10240)
+            {
+                // 10K浠ヤ笂鐨勬暟鎹紝杩涜鏁版嵁鍘嬬缉
+                data = SoftZipped.CompressBytes(data);
+                _zipped = ProtocolZipped;
+            }
+            _temp = new byte[HeadByteLength + data.length];
+            _sendLength = data.length;
+        }
+
+        Utilities.getBytes(command);
+
+        System.arraycopy(Utilities.getBytes(command),0,_temp,0,4);
+        System.arraycopy(Utilities.getBytes(customer),0,_temp,4,4);
+        System.arraycopy(Utilities.getBytes(_zipped),0,_temp,8,4);
+        System.arraycopy(Utilities.UUID2Byte(token),0,_temp,12,16);
+        System.arraycopy(Utilities.getBytes(_sendLength),0,_temp,28,4);
+        if (_sendLength > 0)
+        {
+            System.arraycopy(data,0,_temp,32,_sendLength);
+        }
+        return _temp;
+    }
+
+
+    /**
+     * 瑙f瀽鎺ユ敹鍒版暟鎹紝鍏堣В鍘嬬缉鍚庤繘琛岃В瀵�
+     * @param head
+     * @param content
+     * @return
+     */
+    public static byte[] CommandAnalysis( byte[] head, byte[] content )
+    {
+        if (content != null)
+        {
+            byte[] buffer = new byte[4];
+            buffer[0] = head[8];
+            buffer[1] = head[9];
+            buffer[2] = head[10];
+            buffer[3] = head[11];
+
+            // 鑾峰彇鏄惁鍘嬬缉鐨勬儏鍐�
+            int _zipped = Utilities.getInt(buffer,0);
+
+
+            // 鍏堣繘琛岃В鍘�
+            if (_zipped == ProtocolZipped)
+            {
+                content = SoftZipped.Decompress( content );
+            }
+            // 杩涜瑙e瘑
+            return HslSecurity.ByteDecrypt( content );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+
+    /**
+     * 鑾峰彇鍙戦�佸瓧鑺傛暟鎹殑瀹為檯鏁版嵁锛屽甫鎸囦护澶�
+     * @param customer
+     * @param token
+     * @param data
+     * @return
+     */
+    public static byte[] CommandBytes( int customer, UUID token, byte[] data )
+    {
+        return CommandBytes( ProtocolUserBytes, customer, token, data );
+    }
+
+
+    /**
+     * 鑾峰彇鍙戦�佸瓧鑺傛暟鎹殑瀹為檯鏁版嵁锛屽甫鎸囦护澶�
+     * @param customer
+     * @param token
+     * @param data
+     * @return
+     */
+    public static byte[] CommandBytes( int customer, UUID token, String data )
+    {
+        if (data == null) return CommandBytes( ProtocolUserString, customer, token, null );
+        else return CommandBytes( ProtocolUserString, customer, token,  Utilities.string2Byte(data) );
+    }
+
+
+}
diff --git a/src/main/java/com/zy/gateway/core/net/IReadWriteNet.java b/src/main/java/com/zy/gateway/core/net/IReadWriteNet.java
new file mode 100644
index 0000000..16017e2
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/IReadWriteNet.java
@@ -0,0 +1,227 @@
+package com.zy.gateway.core.net;
+
+import com.zy.gateway.core.domain.IDataTransfer;
+import com.zy.gateway.core.domain.OperateResult;
+import com.zy.gateway.core.domain.OperateResultExOne;
+
+/**
+ * 鎵�鏈夎澶囦氦浜掔被鐨勭粺涓�鐨勮鍐欐帴鍙�
+ */
+public interface IReadWriteNet {
+
+    /**
+     * 鎵归噺璇诲彇搴曞眰鐨勬暟鎹俊鎭紝闇�瑕佹寚瀹氬湴鍧�鍜岄暱搴︼紝鍏蜂綋鐨勭粨鏋滃彇鍐充簬瀹炵幇
+     * @param address 鍦板潃淇℃伅
+     * @param length 鏁版嵁闀垮害
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刡yte[]鏁扮粍
+     */
+    OperateResultExOne<byte[]> Read(String address, short length);
+
+    /**
+     * 璇诲彇16浣嶇殑鏈夌鍙锋暣鍨�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨剆hort鏁版嵁
+     */
+    OperateResultExOne<Short> ReadInt16(String address);
+
+    /**
+     * 璇诲彇16浣嶇殑鏈夌鍙锋暣鍨嬫暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨剆hort鏁扮粍
+     */
+    OperateResultExOne<short []> ReadInt16(String address, short length);
+
+    /**
+     * 璇诲彇32浣嶇殑鏈夌鍙锋暣鍨�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刬nt鏁版嵁
+     */
+    OperateResultExOne<Integer> ReadInt32(String address);
+
+    /**
+     * 璇诲彇32浣嶆湁绗﹀彿鏁村瀷鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<int[]> ReadInt32(String address, short length);
+
+    /**
+     * 璇诲彇64浣嶇殑鏈夌鍙锋暣鍨�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刲ong鏁版嵁
+     */
+    OperateResultExOne<Long> ReadInt64(String address);
+
+    /**
+     * 璇诲彇64浣嶇殑鏈夌鍙锋暣鍨嬫暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<long[]> ReadInt64(String address, short length);
+
+    /**
+     * 璇诲彇鍗曟诞鐐圭簿搴︾殑鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刦loat鏁版嵁
+     */
+    OperateResultExOne<Float> ReadFloat(String address);
+
+    /**
+     * 璇诲彇鍗曟诞鐐圭簿搴︾殑鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<float[]> ReadFloat(String address, short length);
+
+    /**
+     * 璇诲彇鍙屾诞鐐圭簿搴︾殑鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨刣ouble鏁版嵁
+     */
+    OperateResultExOne<Double> ReadDouble(String address);
+
+
+    /**
+     * 璇诲彇鍙屾诞鐐圭簿搴︾殑鏁版嵁鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    OperateResultExOne<double[]> ReadDouble(String address, short length);
+
+    /**
+     * 璇诲彇瀛楃涓叉暟鎹�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁版嵁闀垮害
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨剆tring鏁版嵁
+     */
+    OperateResultExOne<String> ReadString(String address, short length);
+
+
+    /**
+     * 璇诲彇鑷畾涔夌殑鏁版嵁绫诲瀷锛岄渶瑕佺户鎵胯嚜IDataTransfer鎺ュ彛
+     * @param address 璧峰鍦板潃
+     * @param <T> 鑷畾涔夌殑绫诲瀷
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勮嚜瀹氫箟绫诲瀷鏁版嵁
+     */
+    <T extends IDataTransfer> OperateResultExOne<T> ReadCustomer(String address, Class<T> tClass);
+
+
+
+
+
+
+
+
+    /**
+     * 鍐欏叆short鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, short value);
+
+    /**
+     * 鍐欏叆short鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, short[] values);
+
+    /**
+     * 鍐欏叆int鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, int value);
+
+    /**
+     * 鍐欏叆int[]鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, int[] values);
+
+    /**
+     * 鍐欏叆long鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, long value);
+
+    /**
+     * 鍐欏叆long鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, long[] values);
+
+    /**
+     * 鍐欏叆float鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, float value);
+
+    /**
+     * 鍐欏叆float鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, float[] values);
+
+    /**
+     * 鍐欏叆double鏁版嵁
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, double value);
+
+    /**
+     * 鍐欏叆double鏁扮粍
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, double[] values);
+
+    /**
+     * 鍐欏叆瀛楃涓蹭俊鎭紝缂栫爜涓篈SCII
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, String value);
+
+
+    /**
+     * 鍐欏叆瀛楃涓蹭俊鎭紝缂栫爜涓篈SCII
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @param length 鍐欏叆鐨勫瓧绗︿覆鐨勯暱搴�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    OperateResult Write(String address, String value, int length);
+
+    /**
+     * 鍐欏叆鑷畾涔夌被鍨嬬殑鏁版嵁锛岃绫诲瀷蹇呴』缁ф壙鑷狪DataTransfer鎺ュ彛
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @param <T> 绫诲瀷瀵硅薄
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滅被瀵硅薄
+     */
+    <T extends IDataTransfer> OperateResult WriteCustomer(String address, T value);
+
+}
diff --git a/src/main/java/com/zy/gateway/core/net/NetworkBase.java b/src/main/java/com/zy/gateway/core/net/NetworkBase.java
new file mode 100644
index 0000000..6276fef
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/NetworkBase.java
@@ -0,0 +1,317 @@
+package com.zy.gateway.core.net;
+
+import com.zy.gateway.core.StringResources;
+import com.zy.gateway.core.domain.HslTimeOut;
+import com.zy.gateway.core.domain.OperateResult;
+import com.zy.gateway.core.domain.OperateResultExOne;
+import com.zy.gateway.core.domain.siemens.INetMessage;
+import com.zy.gateway.core.log.ILogNet;
+import com.zy.gateway.core.utils.Utilities;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.util.Date;
+import java.util.UUID;
+
+
+/**
+ * 鏈郴缁熸墍鏈夌綉缁滅被鐨勫熀绫伙紝璇ョ被涓烘娊璞$被锛屾棤娉曡繘琛屽疄渚嬪寲
+ */
+public abstract class NetworkBase {
+
+    /**
+     * 瀹炰緥鍖栦竴涓狽etworkBase瀵硅薄
+     */
+    public NetworkBase( )
+    {
+        Token = UUID.fromString("00000000-0000-0000-0000-000000000000");
+    }
+
+
+
+    /**
+     * 閫氳绫荤殑鏍稿績濂楁帴瀛�
+     */
+    protected Socket CoreSocket = null;
+
+
+    /**
+     * 绾跨▼妫�鏌ユ槸鍚﹀彂鐢熶簡瓒呮椂鐨勬柟娉�
+     * @param timeout
+     * @param millisecond
+     */
+    public static void ThreadPoolCheckConnect(HslTimeOut timeout, int millisecond) {
+        while (!timeout.IsSuccessful) {
+            if ((new Date().getTime() - timeout.StartTime.getTime()) > millisecond) {
+                // 杩炴帴瓒呮椂鎴栨槸楠岃瘉瓒呮椂
+                if (!timeout.IsSuccessful) {
+                    try {
+                        if (timeout.WorkSocket != null) {
+                            timeout.WorkSocket.close();
+                        }
+                    } catch (IOException ex) {
+                        // 涓嶅鐞嗭紝鏀惧純
+                    }
+                }
+                break;
+            }
+        }
+    }
+
+
+    /**
+     * 浠庡鎺ュ瓧鎺ユ敹瀹氶暱搴︾殑瀛楄妭鏁扮粍
+     * @param socket 濂楁帴瀛�
+     * @param length 鏁版嵁闀垮害
+     * @return 娑堟伅绫诲璞�
+     */
+    protected OperateResultExOne<byte[]> Receive(Socket socket, int length, int timeout )
+    {
+        OperateResultExOne<byte[]> resultExOne = new OperateResultExOne<>();
+
+        if (length == 0) {
+            resultExOne.IsSuccess = true;
+            resultExOne.Content = new byte[0];
+            return  resultExOne;
+        }
+
+        int count_receive = 0;
+        byte[] bytes_receive = new byte[length];
+        try {
+            if(timeout>0) socket.setSoTimeout(timeout);
+            InputStream input = socket.getInputStream();
+            while (count_receive<length)
+            {
+                count_receive += input.read(bytes_receive, count_receive, length-count_receive);
+            }
+        }
+        catch (IOException ex)
+        {
+            CloseSocket(socket);
+            resultExOne.Message = ex.getMessage();
+            return  resultExOne;
+        }
+
+        resultExOne.IsSuccess = true;
+        resultExOne.Content = bytes_receive;
+        return  resultExOne;
+    }
+
+    /**
+     * 浠庡鎺ュ瓧鎺ユ敹瀹氶暱搴︾殑瀛楄妭鏁扮粍
+     * @param socket 濂楁帴瀛�
+     * @param length 鏁版嵁闀垮害
+     * @return 娑堟伅绫诲璞�
+     */
+    protected OperateResultExOne<byte[]> Receive(Socket socket, int length )
+    {
+        return Receive(socket,length,-1);
+    }
+
+
+    /**
+     * 浠庡鎺ュ瓧鎺ユ敹鎸囧畾闀垮害鐨勫瓧鑺傛暟鎹�
+     * @param socket 缃戠粶濂楁帴瀛�
+     * @param timeOut 瓒呮椂鏃堕棿
+     * @param netMsg 娑堟伅鏍煎紡
+     * @param <TNetMessage> 绫诲瀷
+     * @return 娑堟伅绫�
+     */
+    protected <TNetMessage extends INetMessage> OperateResultExOne<TNetMessage> ReceiveMessage(Socket socket, int timeOut, TNetMessage netMsg)
+    {
+        OperateResultExOne<TNetMessage> resultExOne = new OperateResultExOne<>();
+
+        // 鎺ユ敹鎸囦护澶�
+        OperateResultExOne<byte[]> headResult = Receive( socket, netMsg.ProtocolHeadBytesLength(), timeOut );
+        if (!headResult.IsSuccess)
+        {
+            resultExOne.CopyErrorFromOther( headResult );
+            return resultExOne;
+        }
+
+        netMsg.setHeadBytes( headResult.Content );
+        if (!netMsg.CheckHeadBytesLegal(Utilities.UUID2Byte(Token)))
+        {
+            // 浠ょ墝鏍¢獙澶辫触
+            CloseSocket(socket);
+            if(LogNet != null) LogNet.WriteError( toString( ), StringResources.Language.TokenCheckFailed() );
+            resultExOne.Message = StringResources.Language.TokenCheckFailed();
+            return resultExOne;
+        }
+
+
+        int contentLength = netMsg.GetContentLengthByHeadBytes( );
+        if (contentLength == 0)
+        {
+            netMsg.setContentBytes( new byte[0] );
+        }
+        else
+        {
+            OperateResultExOne<byte[]> contentResult = Receive( socket, contentLength, timeOut );
+            if (!contentResult.IsSuccess)
+            {
+                resultExOne.CopyErrorFromOther( contentResult );
+                return resultExOne;
+            }
+
+            netMsg.setContentBytes( contentResult.Content);
+        }
+
+        // 闃叉娌℃湁瀹炰緥鍖栭�犳垚鍚庣画鐨勬搷浣滃け璐�
+        if (netMsg.getContentBytes() == null){ netMsg.setContentBytes( new byte[0]);}
+        resultExOne.Content = netMsg;
+        resultExOne.IsSuccess = true;
+        return resultExOne;
+    }
+
+
+    /**
+     * 鍙戦�佷竴涓叉暟鎹埌缃戠粶濂楁帴瀛椾腑
+     * @param socket 缃戠粶濂楁帴瀛�
+     * @param data 鏁版嵁
+     * @return 鏄惁鍙戦�佹垚鍔�
+     */
+    protected OperateResult Send(Socket socket,byte[] data){
+        OperateResult result = new OperateResult();
+        if(data == null) {
+            result.IsSuccess = true;
+            return result;
+        }
+        try {
+            DataOutputStream output = new DataOutputStream(socket.getOutputStream());
+            output.write(data, 0, data.length);
+        }
+        catch (IOException ex)
+        {
+            result.Message = ex.getMessage();
+            return  result;
+        }
+
+        result.IsSuccess = true;
+        return  result;
+    }
+
+
+    /**
+     * 鍒涘缓涓�涓鎺ュ瓧骞朵笖杩炴帴鍒版湇鍔″櫒
+     * @param endPoint 鐩爣鑺傜偣
+     * @param timeOut 瓒呮椂鏃堕棿
+     * @return 杩炴帴鎴愬姛鐨勬爣蹇�
+     */
+    protected  OperateResultExOne<Socket> CreateSocketAndConnect(SocketAddress endPoint, int timeOut){
+        OperateResultExOne<Socket> operateResultExOne = new OperateResultExOne<>();
+
+        Socket socket = new Socket();
+        try {
+            socket.connect(endPoint,timeOut);
+            operateResultExOne.Content = socket;
+            operateResultExOne.IsSuccess = true;
+        }
+        catch (IOException ex)
+        {
+            operateResultExOne.Message = ex.getMessage();
+            CloseSocket(socket);
+        }
+
+        return operateResultExOne;
+    }
+
+    /**
+     * 鍒涘缓涓�涓鎺ュ瓧骞朵笖杩炴帴鍒版湇鍔″櫒
+     * @param ipAddress ip鍦板潃
+     * @param port 绔彛鍙�
+     * @param timeOut 瓒呮椂鏃堕棿
+     * @return 杩炴帴鎴愬姛鐨勬爣蹇�
+     */
+    protected  OperateResultExOne<Socket> CreateSocketAndConnect(String ipAddress,int port, int timeOut) {
+        SocketAddress endPoint = new InetSocketAddress(ipAddress,port);
+        return CreateSocketAndConnect(endPoint,timeOut);
+    }
+
+
+    /**
+     * 璇诲彇娴佷腑鐨勬暟鎹埌缂撳瓨鍖�
+     * @param stream 娴佹暟鎹�
+     * @param buffer 缂撳啿鏁版嵁
+     * @return
+     */
+    protected OperateResultExOne<Integer> ReadStream(InputStream stream, byte[] buffer) {
+        OperateResultExOne<Integer> resultExOne = new OperateResultExOne<>();
+        int read_count = 0;
+        try {
+            while (read_count < buffer.length) {
+                read_count += stream.read(buffer, read_count, buffer.length - read_count);
+            }
+            resultExOne.Content = read_count;
+            resultExOne.IsSuccess = true;
+        } catch (IOException ex) {
+            resultExOne.Message = ex.getMessage();
+        }
+
+        return resultExOne;
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛祦鏁版嵁鍐欏叆鍒拌緭鍑烘祦閲岄潰鍘�
+     * @param stream 瀛楄妭娴�
+     * @param buffer 缂撳瓨鏁版嵁
+     * @return 鍐欏叆鏄惁鎴愬姛
+     */
+    protected OperateResult WriteStream(OutputStream stream, byte[] buffer ) {
+        OperateResult result = new OperateResultExOne<>();
+        try {
+            stream.write(buffer, 0, buffer.length);
+            result.IsSuccess = true;
+        } catch (IOException ex) {
+            result.Message = ex.getMessage();
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 瀹夊叏鐨勫叧闂竴涓鎺ュ瓧
+     * @param socket 缃戠粶濂楁帴瀛�
+     */
+    protected void CloseSocket(Socket socket){
+        if(socket != null){
+            try {
+                socket.close();
+            }
+            catch (Exception ex){
+
+            }
+        }
+    }
+
+
+    /**
+     * 缁勪欢鐨勬棩蹇楀伐鍏凤紝鏀寔鏃ュ織璁板綍
+     */
+    public ILogNet LogNet = null;
+
+    /**
+     * 缃戠粶绫荤殑韬唤浠ょ墝
+     */
+    public UUID Token = null;
+
+
+
+    /**
+     * 杩斿洖瀵硅薄鐨勫瓧绗︿覆琛ㄧず褰㈠紡
+     * @return 瀛楃涓�
+     */
+    @Override
+    public String toString(){
+        return "NetworkBase";
+    }
+
+
+}
diff --git a/src/main/java/com/zy/gateway/core/net/NetworkDeviceBase.java b/src/main/java/com/zy/gateway/core/net/NetworkDeviceBase.java
new file mode 100644
index 0000000..161f214
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/NetworkDeviceBase.java
@@ -0,0 +1,443 @@
+package com.zy.gateway.core.net;
+
+import com.zy.gateway.core.base.SoftBasic;
+import com.zy.gateway.core.domain.IDataTransfer;
+import com.zy.gateway.core.domain.OperateResult;
+import com.zy.gateway.core.domain.OperateResultExOne;
+import com.zy.gateway.core.domain.siemens.INetMessage;
+import com.zy.gateway.core.transfer.IByteTransform;
+import com.zy.gateway.core.utils.Utilities;
+
+
+/**
+ * 璁惧绫荤殑鍩虹被锛屾彁渚涗簡鍩虹鐨勫瓧鑺傝鍐欐柟娉曪紝閲囩敤娉涘瀷缁ф壙瀹炵幇
+ * @param <TNetMessage> 娑堟伅绫诲瀷
+ * @param <TTransform> 鍙樻崲绫诲瀷
+ */
+public class NetworkDeviceBase<TNetMessage extends INetMessage,TTransform extends IByteTransform> extends NetworkDoubleBase<TNetMessage,TTransform> implements IReadWriteNet
+{
+
+
+
+    /**************************************************************************************************
+     *
+     *    璇存槑锛氬瓙绫讳腑闇�瑕侀噸鍐欏熀纭�鐨勮鍙栧拰鍐欏叆鏂规硶锛屾潵鏀寔涓嶅悓鐨勬暟鎹闂鍒�
+     *
+     *    姝ゅ娌℃湁灏嗚鍐欎綅绾冲叆杩涙潵锛屽洜涓哄悇绉嶈澶囩殑鏀寔涓嶅敖鐩稿悓锛屾瘮杈冮夯鐑�
+     *
+     **************************************************************************************************/
+
+    protected short WordLength = 1;
+
+
+    /**
+     * 浠庤澶囪鍙栧師濮嬫暟鎹�
+     * @param address 鍦板潃淇℃伅
+     * @param length 鏁版嵁闀垮害
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滃璞�
+     */
+    public OperateResultExOne<byte[]> Read(String address, short length) {
+        return new OperateResultExOne<byte[]>();
+    }
+
+
+    /**
+     * 灏嗗師濮嬫暟鎹啓鍏ヨ澶�
+     * @param address 璧峰鍦板潃
+     * @param value 鍘熷鏁版嵁
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滃璞�
+     */
+    public OperateResult Write(String address, byte[] value) {
+        return new OperateResult();
+    }
+
+
+
+
+
+    /**
+     * 璇诲彇鑷畾涔夌被鍨嬬殑鏁版嵁锛岄渶瑕佽瀹氳В鏋愯鍒�
+     * @param address 璧峰鍦板潃
+     * @param tClass 绫�
+     * @param <T> 绫诲瀷鍚嶇О
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滃璞�
+     */
+    public <T extends IDataTransfer> OperateResultExOne<T> ReadCustomer(String address , Class<T> tClass)
+    {
+        OperateResultExOne<T> result = new OperateResultExOne<T>();
+        T Content;
+        try {
+            Content = tClass.newInstance();
+        }
+        catch (Exception ex){
+            Content = null;
+        }
+        OperateResultExOne<byte[]> read = Read(address, Content.getReadCount());
+        if (read.IsSuccess) {
+            Content.ParseSource(read.Content);
+            result.Content = Content;
+            result.IsSuccess = true;
+        } else {
+            result.ErrorCode = read.ErrorCode;
+            result.Message = read.Message;
+        }
+        return result;
+    }
+
+
+    /**
+     * 鍐欏叆鑷畾涔夌被鍨嬬殑鏁版嵁鍒拌澶囧幓锛岄渶瑕佽瀹氱敓鎴愬瓧鑺傜殑鏂规硶
+     * @param address 璧峰鍦板潃
+     * @param data 瀹炰緥瀵硅薄
+     * @param <T> 鑷畾涔夌被鍨�
+     * @return 甯︽湁鎴愬姛鏍囪瘑鐨勭粨鏋滃璞�
+     */
+    public <T extends IDataTransfer> OperateResult WriteCustomer(String address, T data )
+    {
+        return Write(address, data.ToSource());
+    }
+
+
+    /**
+     * 璇诲彇璁惧鐨剆hort绫诲瀷鐨勬暟鎹�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<Short> ReadInt16(String address) {
+        return GetInt16ResultFromBytes(Read(address, WordLength));
+    }
+
+
+    /**
+     * 璇诲彇璁惧鐨剆hort绫诲瀷鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<short[]> ReadInt16(String address, short length) {
+        OperateResultExOne<byte[]> read = Read(address, (short) (length * WordLength));
+        if (!read.IsSuccess) {
+            OperateResultExOne<short[]> result = new OperateResultExOne<short[]>();
+            result.CopyErrorFromOther(read);
+            return result;
+        }
+        return OperateResultExOne.CreateSuccessResult(super.getByteTransform().TransInt16(read.Content, 0, length));
+    }
+
+
+
+    /**
+     * 璇诲彇璁惧鐨刬nt绫诲瀷鐨勬暟鎹�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<Integer> ReadInt32(String address) {
+        return GetInt32ResultFromBytes(Read(address, (short) (2 * WordLength)));
+    }
+
+
+
+    /**
+     * 璇诲彇璁惧鐨刬nt绫诲瀷鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<int[]> ReadInt32(String address, short length) {
+        OperateResultExOne<byte[]> read = Read(address, (short) (length * WordLength * 2));
+        if (!read.IsSuccess) {
+            OperateResultExOne<int[]> result = new OperateResultExOne<int[]>();
+            result.CopyErrorFromOther(read);
+            return result;
+        }
+        return OperateResultExOne.CreateSuccessResult(super.getByteTransform().TransInt32(read.Content, 0, length));
+    }
+
+
+    /**
+     * 璇诲彇璁惧鐨刦loat绫诲瀷鐨勬暟鎹�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<Float> ReadFloat(String address) {
+        return GetSingleResultFromBytes(Read(address, (short) (2 * WordLength)));
+    }
+
+
+
+    /**
+     * 璇诲彇璁惧鐨刦loat绫诲瀷鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<float[]> ReadFloat(String address, short length) {
+        OperateResultExOne<byte[]> read = Read(address, (short) (length * WordLength * 2));
+        if (!read.IsSuccess)  {
+            OperateResultExOne<float[]> result = new OperateResultExOne<float[]>();
+            result.CopyErrorFromOther(read);
+            return result;
+        }
+        return OperateResultExOne.CreateSuccessResult(super.getByteTransform().TransSingle(read.Content, 0, length));
+    }
+
+
+
+    /**
+     * 璇诲彇璁惧鐨刲ong绫诲瀷鐨勬暟鎹�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<Long> ReadInt64(String address) {
+        return GetInt64ResultFromBytes(Read(address, (short) (4 * WordLength)));
+    }
+
+
+    /**
+     * 璇诲彇璁惧鐨刲ong绫诲瀷鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<long[]> ReadInt64(String address, short length) {
+        OperateResultExOne<byte[]> read = Read(address, (short) (length * WordLength * 4));
+        if (!read.IsSuccess)  {
+            OperateResultExOne<long[]> result = new OperateResultExOne<long[]>();
+            result.CopyErrorFromOther(read);
+            return result;
+        }
+        return OperateResultExOne.CreateSuccessResult(super.getByteTransform().TransInt64(read.Content, 0, length));
+    }
+
+
+
+    /**
+     * 璇诲彇璁惧鐨刣ouble绫诲瀷鐨勬暟鎹�
+     * @param address 璧峰鍦板潃
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<Double> ReadDouble(String address) {
+        return GetDoubleResultFromBytes(Read(address, (short) (4 * WordLength)));
+    }
+
+
+
+    /**
+     * 璇诲彇璁惧鐨刣ouble绫诲瀷鐨勬暟缁�
+     * @param address 璧峰鍦板潃
+     * @param length 鏁扮粍闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<double[]> ReadDouble(String address, short length) {
+        OperateResultExOne<byte[]> read = Read(address, (short) (length * WordLength * 4));
+        if (!read.IsSuccess) {
+            OperateResultExOne<double[]> result = new OperateResultExOne<double[]>();
+            result.CopyErrorFromOther(read);
+            return result;
+        }
+        return OperateResultExOne.CreateSuccessResult(super.getByteTransform().TransDouble(read.Content, 0, length));
+    }
+
+
+
+    /**
+     * 璇诲彇璁惧鐨勫瓧绗︿覆鏁版嵁锛岀紪鐮佷负ASCII
+     * @param address 璧峰鍦板潃
+     * @param length 鏁版嵁闀垮害
+     * @return 甯︽垚鍔熸爣蹇楃殑缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<String> ReadString(String address, short length) {
+        return GetStringResultFromBytes(Read(address, length));
+    }
+
+
+
+
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆short鏁扮粍锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, short[] values) {
+        return Write(address, super.getByteTransform().TransByte(values));
+    }
+
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆short鏁版嵁锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, short value) {
+        return Write(address, new short[]{value});
+    }
+
+
+
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆int鏁扮粍锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    /// <returns>杩斿洖鍐欏叆缁撴灉</returns>
+    public OperateResult Write(String address, int[] values) {
+        return Write(address, super.getByteTransform().TransByte(values));
+    }
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆int鏁版嵁锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, int value) {
+        return Write(address, new int[]{value});
+    }
+
+
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆float鏁扮粍锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, float[] values) {
+        return Write(address, super.getByteTransform().TransByte(values));
+    }
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆float鏁版嵁锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, float value) {
+        return Write(address, new float[]{value});
+    }
+
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆long鏁扮粍锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, long[] values) {
+        return Write(address, getByteTransform().TransByte(values));
+    }
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆long鏁版嵁锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, long value) {
+        return Write(address, new long[]{value});
+    }
+
+
+
+
+
+    /**
+     * 璁惧涓啓鍏ouble鏁扮粍锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param values 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, double[] values) {
+        return Write(address, getByteTransform().TransByte(values));
+    }
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆double鏁版嵁锛岃繑鍥炴槸鍚﹀啓鍏ユ垚鍔�
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 杩斿洖鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, double value) {
+        return Write(address, new double[]{value});
+    }
+
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆瀛楃涓诧紝缂栫爜鏍煎紡涓篈SCII
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @return 杩斿洖璇诲彇缁撴灉
+     */
+    public OperateResult Write(String address, String value) {
+        byte[] temp = getByteTransform().TransByte(value, "US-ASCII");
+        if (WordLength == 1) temp = SoftBasic.ArrayExpandToLengthEven(temp);
+        return Write(address, temp);
+    }
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆瀛楃涓诧紝缂栫爜鏍煎紡涓篈SCII
+     * @param address 璧峰鍦板潃
+     * @param value 鍐欏叆鍊�
+     * @param length 鍐欏叆鐨勫瓧绗︿覆鐨勯暱搴�
+     * @return 杩斿洖璇诲彇缁撴灉
+     */
+    public OperateResult Write(String address, String value, int length) {
+        byte[] temp = getByteTransform().TransByte(value, "US-ASCII");
+        temp = SoftBasic.ArrayExpandToLength(temp, length);
+        if (WordLength == 1) temp = SoftBasic.ArrayExpandToLengthEven(temp);
+        return Write(address, temp);
+    }
+
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆瀛楃涓诧紝缂栫爜鏍煎紡涓篣nicode
+     * @param address 瑕佸啓鍏ョ殑鏁版嵁鍦板潃
+     * @param value 瑕佸啓鍏ョ殑瀹為檯鏁版嵁
+     * @return 鍐欏叆缁撴灉
+     */
+    public OperateResult WriteUnicodeString(String address, String value) {
+        byte[] temp = Utilities.string2Byte(value);
+        return Write(address, temp);
+    }
+
+
+    /**
+     * 鍚戣澶囦腑鍐欏叆瀛楃涓诧紝瓒呭嚭鎴柇锛屼笉澶熻ˉ0锛岀紪鐮佹牸寮忎负Unicode
+     * @param address 瑕佸啓鍏ョ殑鏁版嵁鍦板潃
+     * @param value 瑕佸啓鍏ョ殑瀹為檯鏁版嵁
+     * @param length 鎸囧畾鐨勫瓧绗︿覆闀垮害锛屽繀椤诲ぇ浜�0
+     * @return 鍐欏叆缁撴灉
+     */
+    public OperateResult WriteUnicodeString(String address, String value, int length) {
+        byte[] temp = Utilities.string2Byte(value);
+        temp = SoftBasic.ArrayExpandToLength(temp, length * 2);
+        return Write(address, temp);
+    }
+
+
+    /**
+     * 杩斿洖琛ㄧず褰撳墠瀵硅薄鐨勫瓧绗︿覆
+     * @return 瀛楃涓叉暟鎹�
+     */
+    @Override
+    public String toString() {
+        return "NetworkDeviceBase<TNetMessage, TTransform>";
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/net/NetworkDoubleBase.java b/src/main/java/com/zy/gateway/core/net/NetworkDoubleBase.java
new file mode 100644
index 0000000..58decda
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/NetworkDoubleBase.java
@@ -0,0 +1,621 @@
+package com.zy.gateway.core.net;
+
+import com.zy.gateway.core.StringResources;
+import com.zy.gateway.core.base.SoftBasic;
+import com.zy.gateway.core.domain.OperateResult;
+import com.zy.gateway.core.domain.OperateResultExOne;
+import com.zy.gateway.core.domain.OperateResultExTwo;
+import com.zy.gateway.core.domain.siemens.INetMessage;
+import com.zy.gateway.core.net.session.AlienSession;
+import com.zy.gateway.core.transfer.ByteTransformHelper;
+import com.zy.gateway.core.transfer.IByteTransform;
+
+import java.lang.reflect.ParameterizedType;
+import java.net.Socket;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * 鍙屾ā寮忕殑瀹㈡埛绔熀绫伙紝
+ * @param <TNetMessage> 娑堟伅绫荤殑绫诲瀷
+ * @param <TTransform> 杞崲绫荤殑绫诲瀷
+ */
+public class NetworkDoubleBase<TNetMessage extends INetMessage,TTransform extends IByteTransform> extends NetworkBase
+{
+    /**
+     * 榛樿鐨勬棤鍙傛瀯閫犲嚱鏁�
+     */
+    public NetworkDoubleBase( )
+    {
+        queueLock = new ReentrantLock();                               // 瀹炰緥鍖栨暟鎹闂攣
+        byteTransform = getInstanceOfTTransform();                           // 瀹炰緥鍖栨暟鎹浆鎹㈣鍒�
+        connectionId = SoftBasic.GetUniqueStringByGuidAndRandom( );
+    }
+
+
+
+    private TTransform byteTransform;                // 鏁版嵁鍙樻崲鐨勬帴鍙�
+    private String ipAddress = "127.0.0.1";          // 杩炴帴鐨処P鍦板潃
+    private int port = 10000;                        // 绔彛鍙�
+    private int connectTimeOut = 10000;              // 杩炴帴瓒呮椂鏃堕棿璁剧疆
+    private int receiveTimeOut = 10000;              // 鏁版嵁鎺ユ敹鐨勮秴鏃舵椂闂�
+    private boolean isPersistentConn = false;           // 鏄惁澶勪簬闀胯繛鎺ョ殑鐘舵��
+    private Lock queueLock = null;                      // 鏁版嵁璁块棶鐨勫悓姝ラ攣
+    private boolean IsSocketError = false;              // 鎸囩ず闀胯繛鎺ョ殑濂楁帴瀛楁槸鍚﹀浜庨敊璇殑鐘舵��
+    private boolean isUseSpecifiedSocket = false;       // 鎸囩ず鏄惁浣跨敤鎸囧畾鐨勭綉缁滃鎺ュ瓧璁块棶鏁版嵁
+    private String connectionId = "";                  // 褰撳墠杩炴帴
+
+
+
+    private TTransform getInstanceOfTTransform( )
+    {
+        ParameterizedType superClass = (ParameterizedType) getClass().getGenericSuperclass();
+        Class<TTransform> type = (Class<TTransform>) superClass.getActualTypeArguments()[1];
+        try
+        {
+            return type.newInstance();
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    private TNetMessage getInstanceOfTNetMessage( )
+    {
+        ParameterizedType superClass = (ParameterizedType) getClass().getGenericSuperclass();
+        Class<TNetMessage> type = (Class<TNetMessage>) superClass.getActualTypeArguments()[0];
+        try
+        {
+            return type.newInstance();
+        }
+        catch (Exception e)
+        {
+            // Oops, no default constructor
+            throw new RuntimeException(e);
+        }
+    }
+
+
+
+
+    /**
+     * 鑾峰彇鏁版嵁鍙樻崲鏈哄埗
+     * @return
+     */
+    public TTransform getByteTransform( ){
+        return  byteTransform;
+    }
+
+    /**
+     * 璁剧疆鏁版嵁鍙樻崲鏈哄埗
+     * @param transform 鏁版嵁鍙樻崲
+     */
+    public void setByteTransform(TTransform transform)
+    {
+        byteTransform = transform;
+    }
+
+    /**
+     * 鑾峰彇杩炴帴鐨勮秴鏃舵椂闂�
+     */
+    public int getConnectTimeOut( ){
+        return connectTimeOut;
+    }
+
+    /**
+     * 璁剧疆杩炴帴鐨勮秴鏃舵椂闂�
+     * @param connectTimeOut 瓒呮椂鏃堕棿锛屽崟浣嶆槸绉�
+     */
+    public void setConnectTimeOut(int connectTimeOut) {
+        this.connectTimeOut = connectTimeOut;
+    }
+
+
+    /**
+     * 鑾峰彇鎺ユ敹鏈嶅姟鍣ㄥ弽棣堢殑鏃堕棿锛屽鏋滀负璐熸暟锛屽垯涓嶆帴鏀跺弽棣�
+     * @return
+     */
+    public int getReceiveTimeOut( ){
+        return receiveTimeOut;
+    }
+
+    /**
+     * 璁剧疆鎺ユ敹鏈嶅姟鍣ㄥ弽棣堢殑鏃堕棿锛屽鏋滀负璐熸暟锛屽垯涓嶆帴鏀跺弽棣�
+     * @param receiveTimeOut
+     */
+    public void setReceiveTimeOut(int receiveTimeOut){
+        this.receiveTimeOut = receiveTimeOut;
+    }
+
+
+    /**
+     * 鑾峰彇鏈嶅姟鍣ㄧ殑IP鍦板潃
+     * @return Ip鍦板潃淇℃伅
+     */
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+
+    /**
+     * 璁剧疆鏈嶅姟鍣ㄧ殑IP鍦板潃
+     * @param ipAddress IP鍦板潃
+     */
+    public void setIpAddress(String ipAddress) {
+        if(!ipAddress.isEmpty()){
+            this.ipAddress = ipAddress;
+        }
+    }
+
+
+    /**
+     * 鑾峰彇鏈嶅姟鍣ㄧ殑绔彛
+     * @return 绔彛
+     */
+    public int getPort() {
+        return port;
+    }
+
+
+    /**
+     * 璁剧疆鏈嶅姟鍣ㄧ殑绔彛鍙�
+     * @param port 绔彛鍙�
+     */
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    /**
+     * 褰撳墠杩炴帴鐨勫敮涓�ID鍙凤紝榛樿涓洪暱搴�20鐨刧uid鐮佸姞闅忔満鏁扮粍鎴愶紝涔熷彲浠ヨ嚜宸辨寚瀹�
+     * @return
+     */
+    public String getConnectionId() {
+        return connectionId;
+    }
+
+    /**
+     * 璁剧疆褰撳墠鐨勮繛鎺D
+     * @param connectionId
+     */
+    public void setConnectionId(String connectionId) {
+        this.connectionId = connectionId;
+    }
+
+
+
+    /**
+     * 褰撳墠鐨勫紓褰㈣繛鎺ュ璞★紝濡傛灉璁剧疆浜嗗紓鎬ц繛鎺ョ殑璇�
+     */
+    public AlienSession AlienSession = null;
+
+
+
+    /**
+     * 鍦ㄨ鍙栨暟鎹箣鍓嶅彲浠ヨ皟鐢ㄦ湰鏂规硶灏嗗鎴风璁剧疆涓洪暱杩炴帴妯″紡锛岀浉褰撲簬璺宠繃浜咰onnectServer鐨勭粨鏋滈獙璇侊紝瀵瑰紓褰㈠鎴风鏃犳晥
+     */
+    public void SetPersistentConnection( )
+    {
+        isPersistentConn = true;
+    }
+
+
+    /**
+     * 鍒囨崲鐭繛鎺ユā寮忓埌闀胯繛鎺ユā寮忥紝鍚庨潰鐨勬瘡娆¤姹傞兘鍏变韩涓�涓�氶亾
+     * @return 杩斿洖杩炴帴缁撴灉锛屽鏋滃け璐ョ殑璇濓紙涔熷嵆IsSuccess涓篎alse锛夛紝鍖呭惈澶辫触淇℃伅
+     */
+    public OperateResult ConnectServer( )
+    {
+        isPersistentConn = true;
+        OperateResult result = new OperateResult( );
+
+        // 閲嶆柊杩炴帴涔嬪墠锛屽厛灏嗘棫鐨勬暟鎹繘琛屾竻绌�
+        CloseSocket(CoreSocket);
+
+        OperateResultExOne<Socket> rSocket = CreateSocketAndInitialication( );
+
+        if (!rSocket.IsSuccess)
+        {
+            IsSocketError = true;                         // 鍒涘缓澶辫触
+            rSocket.Content = null;
+            result.Message = rSocket.Message;
+        }
+        else
+        {
+            CoreSocket = rSocket.Content;                 // 鍒涘缓鎴愬姛
+            result.IsSuccess = true;
+            if(LogNet != null) LogNet.WriteDebug( toString( ), StringResources.Language.NetEngineStart() );
+        }
+
+        return result;
+    }
+
+
+
+    /**
+     * 浣跨敤鎸囧畾鐨勫鎺ュ瓧鍒涘缓寮傚舰瀹㈡埛绔�
+     * @param session 浼氳瘽
+     * @return 閫氬父閮戒负鎴愬姛
+     */
+    public OperateResult ConnectServer( AlienSession session )
+    {
+        isPersistentConn = true;
+        isUseSpecifiedSocket = true;
+
+
+        if (session != null)
+        {
+            if(AlienSession != null ) CloseSocket(AlienSession.getSocket());
+
+            if (connectionId.isEmpty())
+            {
+                connectionId = session.getDTU();
+            }
+
+            if (connectionId == session.getDTU())
+            {
+                CoreSocket = session.getSocket();
+                IsSocketError = false;
+                AlienSession = session;
+                return InitializationOnConnect( session.getSocket() );
+            }
+            else
+            {
+                IsSocketError = true;
+                return new OperateResult( );
+            }
+        }
+        else
+        {
+            IsSocketError = true;
+            return new OperateResult( );
+        }
+    }
+
+
+
+    /**
+     * 鍦ㄩ暱杩炴帴妯″紡涓嬶紝鏂紑鏈嶅姟鍣ㄧ殑杩炴帴锛屽苟鍒囨崲鍒扮煭杩炴帴妯″紡
+     * @return 鍏抽棴杩炴帴锛屼笉闇�瑕佹煡鐪婭sSuccess灞炴�ф煡鐪�
+     */
+    public OperateResult ConnectClose( )
+    {
+        OperateResult result = new OperateResult( );
+        isPersistentConn = false;
+
+        queueLock.lock();
+
+        // 棰濆鎿嶄綔
+        result = ExtraOnDisconnect( CoreSocket );
+        // 鍏抽棴淇℃伅
+        if(CoreSocket != null ) CloseSocket(CoreSocket);
+        CoreSocket = null;
+
+        queueLock.unlock();
+
+        if(LogNet != null ) LogNet.WriteDebug( toString( ), StringResources.Language.NetEngineClose() );
+        return result;
+    }
+
+
+    /**
+     * 鍦ㄨ繛鎺ョ殑鏃跺�欒繘琛屽垵濮嬪寲
+     * @param socket 缃戠粶濂楁帴瀛�
+     * @return 缁撴灉绫诲璞�
+     */
+    protected OperateResult InitializationOnConnect( Socket socket ) {
+        return OperateResult.CreateSuccessResult();
+    }
+
+
+    /**
+     * 鍦ㄥ皢瑕佸拰鏈嶅姟鍣ㄨ繘琛屾柇寮�鐨勬儏鍐典笅棰濆鐨勬搷浣�
+     * @param socket 缃戠粶濂楁帴瀛�
+     * @return 缁撴灉绫诲璞�
+     */
+    protected OperateResult ExtraOnDisconnect( Socket socket ) {
+        return OperateResult.CreateSuccessResult();
+    }
+
+
+    /***************************************************************************************
+     *
+     *    涓昏鐨勬暟鎹氦浜掑垎涓�4姝�
+     *    1. 杩炴帴鏈嶅姟鍣紝鎴栨槸鑾峰彇鍒版棫鐨勪娇鐢ㄧ殑缃戠粶淇℃伅
+     *    2. 鍙戦�佹暟鎹俊鎭�
+     *    3. 鎺ユ敹鍙嶉鐨勬暟鎹俊鎭�
+     *    4. 鍏抽棴缃戠粶杩炴帴锛屽鏋滄槸鐭繛鎺ョ殑璇�
+     *
+     **************************************************************************************/
+
+
+    /**
+     * 鑾峰彇鏈鎿嶄綔鐨勫彲鐢ㄧ殑缃戠粶濂楁帴瀛�
+     * @return 鏄惁鎴愬姛锛屽鏋滄垚鍔燂紝浣跨敤杩欎釜濂楁帴瀛�
+     */
+    private OperateResultExOne<Socket> GetAvailableSocket( ) {
+        // 鏄惁澶勪簬闀胯繛鎺ョ殑鐘舵��
+        if (isPersistentConn) {
+            // 濡傛灉鏄紓褰㈡ā寮�
+            if (isUseSpecifiedSocket) {
+                // 鎸囩ず闀胯繛鎺ョ殑濂楁帴瀛楁槸鍚﹀浜庨敊璇殑鐘舵��
+                if(IsSocketError) {
+                    OperateResultExOne<Socket> rSocket = new OperateResultExOne<>();
+                    rSocket.Message = "杩炴帴涓嶅彲鐢�";
+                    return rSocket;
+                } else {
+                    return OperateResultExOne.CreateSuccessResult( CoreSocket );
+                }
+            } else {
+                // 闀胯繛鎺ユā寮�
+                if (IsSocketError || CoreSocket == null) {
+                    OperateResult connect = ConnectServer( );
+                    if (!connect.IsSuccess) {
+                        IsSocketError = true;
+                        OperateResultExOne<Socket> rSocket = new OperateResultExOne<>();
+                        rSocket.Message = connect.Message;
+                        rSocket.ErrorCode = connect.ErrorCode;
+                        return rSocket;
+                    } else {
+                        IsSocketError = false;
+                        return OperateResultExOne.CreateSuccessResult( CoreSocket );
+                    }
+                } else {
+                    return OperateResultExOne.CreateSuccessResult( CoreSocket );
+                }
+            }
+
+        } else {
+            // 鐭繛鎺ユā寮�
+            return CreateSocketAndInitialication( );
+        }
+    }
+
+
+
+    /**
+     * 杩炴帴骞跺垵濮嬪寲缃戠粶濂楁帴瀛�
+     * @return 鏈�缁堢殑杩炴帴瀵硅薄
+     */
+    private OperateResultExOne<Socket> CreateSocketAndInitialication( )
+    {
+        OperateResultExOne<Socket> result = CreateSocketAndConnect(  ipAddress , port , connectTimeOut );
+        if (result.IsSuccess)
+        {
+            // 鍒濆鍖�
+            OperateResult initi = InitializationOnConnect( result.Content );
+            if (!initi.IsSuccess)
+            {
+                CloseSocket(result.Content);
+                result.IsSuccess = initi.IsSuccess;
+                result.CopyErrorFromOther( initi );
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * 鍦ㄥ叾浠栨寚瀹氱殑濂楁帴瀛椾笂锛屼娇鐢ㄦ姤鏂囨潵閫氳锛屼紶鍏ラ渶瑕佸彂閫佺殑娑堟伅锛岃繑鍥炰竴鏉″畬鏁寸殑鏁版嵁鎸囦护
+     * @param socket 鎸囧畾鐨勫鎺ュ瓧
+     * @param send 鍙戦�佺殑瀹屾暣鐨勬姤鏂囦俊鎭�
+     * @return 鎺ユ敹鐨勫畬鏁寸殑鎶ユ枃淇℃伅
+     */
+    public OperateResultExOne<byte[]> ReadFromCoreServer( Socket socket, byte[] send )
+    {
+        OperateResultExOne<byte[]> result = new OperateResultExOne<byte[]>( );
+
+        OperateResultExTwo<byte[], byte[]> read = ReadFromCoreServerBase( socket, send );
+        if (read.IsSuccess)
+        {
+            result.IsSuccess = read.IsSuccess;
+            result.Content = new byte[read.Content1.length + read.Content2.length];
+            if (read.Content1.length > 0) System.arraycopy(read.Content1,0,result.Content,0,read.Content1.length);
+            if (read.Content2.length > 0) System.arraycopy(read.Content2,0,result.Content,read.Content1.length,read.Content2.length);
+        }
+        else
+        {
+            result.CopyErrorFromOther( read );
+        }
+        return result;
+    }
+
+
+
+    /**
+     * 浣跨敤搴曞眰鐨勬暟鎹姤鏂囨潵閫氳锛屼紶鍏ラ渶瑕佸彂閫佺殑娑堟伅锛岃繑鍥炰竴鏉″畬鏁寸殑鏁版嵁鎸囦护
+     * @param send 鍙戦�佺殑瀹屾暣鐨勬姤鏂囦俊鎭�
+     * @return 鎺ユ敹鐨勫畬鏁寸殑鎶ユ枃淇℃伅
+     */
+    public OperateResultExOne<byte[]> ReadFromCoreServer( byte[] send )
+    {
+        OperateResultExOne<byte[]> result = new OperateResultExOne<byte[]>( );
+        // string tmp1 = BasicFramework.SoftBasic.ByteToHexString( send, '-' );
+
+        queueLock.lock( );
+
+        // 鑾峰彇鏈夌敤鐨勭綉缁滈�氶亾锛屽鏋滄病鏈夛紝灏卞缓绔嬫柊鐨勮繛鎺�
+        OperateResultExOne<Socket> resultSocket = GetAvailableSocket( );
+        if (!resultSocket.IsSuccess)
+        {
+            IsSocketError = true;
+            if (AlienSession != null) AlienSession.setIsStatusOk( false);
+            queueLock.unlock();
+            result.CopyErrorFromOther( resultSocket );
+            return result;
+        }
+
+        OperateResultExOne<byte[]> read = ReadFromCoreServer( resultSocket.Content, send );
+
+        if (read.IsSuccess)
+        {
+            IsSocketError = false;
+            result.IsSuccess = read.IsSuccess;
+            result.Content = read.Content;
+            // string tmp2 = BasicFramework.SoftBasic.ByteToHexString( result.Content ) ;
+        }
+        else
+        {
+            IsSocketError = true;
+            if (AlienSession != null) AlienSession.setIsStatusOk(false);
+            result.CopyErrorFromOther( read );
+        }
+
+        queueLock.unlock();
+        if (!isPersistentConn) CloseSocket(resultSocket.Content );
+        return result;
+    }
+
+
+    /**
+     * 浣跨敤搴曞眰鐨勬暟鎹姤鏂囨潵閫氳锛屼紶鍏ラ渶瑕佸彂閫佺殑娑堟伅锛岃繑鍥炴渶缁堢殑鏁版嵁缁撴灉锛岃鎷嗗垎鎴愪簡澶村瓙鑺傚拰鍐呭瀛楄妭淇℃伅
+     * @param socket 缃戠粶濂楁帴瀛�
+     * @param send 鍙戦�佺殑鏁版嵁
+     * @return 缁撴灉瀵硅薄
+     */
+    protected OperateResultExTwo<byte[], byte[]> ReadFromCoreServerBase(Socket socket, byte[] send )
+    {
+        OperateResultExTwo<byte[], byte[]> result = new OperateResultExTwo<byte[], byte[]>( );
+        // LogNet?.WriteDebug( ToString( ), "Command: " + BasicFramework.SoftBasic.ByteToHexString( send ) );
+        TNetMessage netMsg = getInstanceOfTNetMessage();
+        netMsg.setSendBytes(send);
+
+        // 鍙戦�佹暟鎹俊鎭�
+        OperateResult resultSend = Send( socket, send );
+        if (!resultSend.IsSuccess)
+        {
+            CloseSocket(socket);
+            result.CopyErrorFromOther( resultSend );
+            return result;
+        }
+
+        // 鎺ユ敹瓒呮椂鏃堕棿澶т簬0鏃舵墠鍏佽鎺ユ敹杩滅▼鐨勬暟鎹�
+        if (receiveTimeOut >= 0)
+        {
+            // 鎺ユ敹鏁版嵁淇℃伅
+            OperateResultExOne<TNetMessage> resultReceive = ReceiveMessage(socket, receiveTimeOut, netMsg);
+            if (!resultReceive.IsSuccess)
+            {
+                CloseSocket(socket );
+                result.CopyErrorFromOther( resultReceive );
+                // result.Message = "Receive data timeout: " + receiveTimeOut;
+                return result;
+            }
+
+            // 澶嶅埗缁撴灉
+            result.Content1 = resultReceive.Content.getHeadBytes();
+            result.Content2 = resultReceive.Content.getContentBytes();
+        }
+
+        result.IsSuccess = true;
+        return result;
+    }
+
+
+
+    /**
+     * 杩斿洖琛ㄧず褰撳墠瀵硅薄鐨勫瓧绗︿覆
+     * @return
+     */
+    @Override
+    public String toString( ) {
+        return "NetworkDoubleBase<TNetMessage>";
+    }
+
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<Boolean> GetBoolResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetBoolResultFromBytes( result, byteTransform);
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<Byte> GetByteResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetByteResultFromBytes( result, byteTransform );
+    }
+
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<Short> GetInt16ResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetInt16ResultFromBytes( result, byteTransform );
+    }
+
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<Integer> GetInt32ResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetInt32ResultFromBytes( result, byteTransform );
+    }
+
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<Long> GetInt64ResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetInt64ResultFromBytes( result, byteTransform );
+    }
+
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<Float> GetSingleResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetSingleResultFromBytes( result, byteTransform );
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<Double> GetDoubleResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetDoubleResultFromBytes( result, byteTransform );
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    protected OperateResultExOne<String> GetStringResultFromBytes( OperateResultExOne<byte[]> result )
+    {
+        return ByteTransformHelper.GetStringResultFromBytes( result, byteTransform );
+    }
+
+
+
+}
diff --git a/src/main/java/com/zy/gateway/core/net/session/AlienSession.java b/src/main/java/com/zy/gateway/core/net/session/AlienSession.java
new file mode 100644
index 0000000..eee6e96
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/session/AlienSession.java
@@ -0,0 +1,74 @@
+package com.zy.gateway.core.net.session;
+
+import java.net.Socket;
+
+/**
+ * 寮傚舰瀹㈡埛绔殑瀵硅薄
+ */
+public class AlienSession {
+
+    /**
+     * 瀹炰緥鍖栦竴涓粯璁ゅ璞�
+     */
+    public AlienSession()
+    {
+        this.isStatusOk = true;
+    }
+
+
+    /**
+     * 鑾峰彇濂楁帴瀛�
+     * @return
+     */
+    public Socket getSocket() {
+        return socket;
+    }
+
+    /**
+     * 璁剧疆濂楁帴瀛椾俊鎭�
+     * @param socket 褰撳墠鐨勫��
+     */
+    public void setSocket(Socket socket) {
+        this.socket = socket;
+    }
+
+    /**
+     * 鑾峰彇璁惧鍞竴鐨凞TU瀵硅薄
+     * @return
+     */
+    public String getDTU() {
+        return DTU;
+    }
+
+    /**
+     * 璁剧疆璁惧鐨勫敮涓�鐨凞TU淇℃伅
+     * @param DTU
+     */
+    public void setDTU(String DTU) {
+        this.DTU = DTU;
+    }
+
+    /**
+     * 鑾峰彇褰撳墠鐨勮繛鎺ョ姸鎬佹槸鍚︽甯�
+     * @return
+     */
+    public boolean getIsStatusOk() {
+        return this.isStatusOk;
+    }
+
+    /**
+     * 璁剧疆褰撳墠鐨勮繛鎺ョ姸鎬�
+     * @param isStatusOk
+     */
+    public void setIsStatusOk(boolean isStatusOk) {
+        this.isStatusOk = isStatusOk;
+    }
+
+
+
+
+    private Socket socket = null;               // 缃戠粶濂楁帴瀛�
+    private String DTU = "";                    // 鍞竴鐨勬爣璇�
+    private boolean isStatusOk = false;         // 褰撳墠鐨勭綉缁滅姸鎬�
+
+}
diff --git a/src/main/java/com/zy/gateway/core/net/session/AppSession.java b/src/main/java/com/zy/gateway/core/net/session/AppSession.java
new file mode 100644
index 0000000..f3b41b3
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/session/AppSession.java
@@ -0,0 +1,228 @@
+package com.zy.gateway.core.net.session;
+
+import com.zy.gateway.core.base.SoftBasic;
+import com.zy.gateway.core.net.HslProtocol;
+
+import java.net.InetAddress;
+import java.net.Socket;
+import java.util.Date;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * 缃戠粶浼氳瘽淇℃伅
+ */
+public class AppSession {
+
+    /**
+     * 瀹炰緥鍖栦竴涓瀯閫犳柟娉�
+     */
+    public AppSession() {
+
+        ClientUniqueID = SoftBasic.GetUniqueStringByGuidAndRandom();
+        HybirdLockSend = new ReentrantLock();
+        HeartTime = new Date();
+        BytesHead = new byte[HslProtocol.HeadByteLength];
+    }
+
+
+    /**
+     * 鑾峰彇IP鍦板潃淇℃伅
+     * @return
+     */
+    public String getIpAddress() {
+        return IpAddress;
+    }
+
+    /**
+     * 璁剧疆IP鍦板潃淇℃伅
+     * @param ipAddress
+     */
+    void setIpAddress(String ipAddress) {
+        IpAddress = ipAddress;
+    }
+
+    /**
+     * 鑾峰彇姝ゅ璞¤繛鎺ョ殑杩滅▼瀹㈡埛绔�
+     * @return 杩滅▼瀹㈡埛绔�
+     */
+    public InetAddress getIpEndPoint() {
+        return IpEndPoint;
+    }
+
+    /**
+     * 璁剧疆姝ゅ璞$殑杩滅▼杩炴帴瀹㈡埛绔�
+     * @param ipEndPoint 杩滅▼瀹㈡埛绔�
+     */
+    public void setIpEndPoint(InetAddress ipEndPoint) {
+        IpEndPoint = ipEndPoint;
+    }
+
+    /**
+     * 鑾峰彇杩滅▼瀵硅薄鐨勫埆鍚�
+     * @return 鍒悕
+     */
+    public String getLoginAlias() {
+        return LoginAlias;
+    }
+
+    /**
+     * 璁剧疆杩滅▼瀵硅薄鐨勫埆鍚�
+     * @param loginAlias 鍒悕
+     */
+    public void setLoginAlias(String loginAlias) {
+        LoginAlias = loginAlias;
+    }
+
+    /**
+     * 鑾峰彇褰撳墠鐨勫績璺虫椂闂�
+     * @return 蹇冭烦鏃堕棿
+     */
+    public Date getHeartTime() {
+        return HeartTime;
+    }
+
+    /**
+     * 璁剧疆褰撳墠鐨勫績璺虫椂闂�
+     * @param date 蹇冭烦鏃堕棿
+     */
+    public void setHeartTime(Date date){
+        this.HeartTime = date;
+    }
+
+    /**
+     * 鑾峰彇瀹㈡埛绔殑绫诲瀷
+     * @return 瀹㈡埛绔被鍨�
+     */
+    public String getClientType() {
+        return ClientType;
+    }
+
+    /**
+     * 璁剧疆瀹㈡埛绔殑绫诲瀷
+     * @param clientType 瀹㈡埛绔殑绫诲瀷
+     */
+    public void setClientType(String clientType) {
+        ClientType = clientType;
+    }
+
+    /**
+     * 鑾峰彇瀹㈡埛绔殑鍞竴鐨勬爣璇�
+     * @return
+     */
+    public String getClientUniqueID() {
+        return ClientUniqueID;
+    }
+
+
+    private String IpAddress = null;
+    private InetAddress IpEndPoint = null;
+    private String LoginAlias = null;
+    private Date HeartTime = null;
+    private String ClientType = null;
+    private String ClientUniqueID = null;
+    private byte[] BytesHead = null;
+    private byte[] BytesContent = null;
+    private String KeyGroup = null;
+    private Socket WorkSocket = null;
+    private Lock HybirdLockSend = null;
+
+    /**
+     * 鑾峰彇澶村瓙鑺備俊鎭�
+     * @return 瀛楄妭鏁扮粍
+     */
+    public byte[] getBytesHead() {
+        return BytesHead;
+    }
+
+    /**
+     * 璁剧疆澶村瓙鑺備俊鎭�
+     * @param bytesHead 澶村瓙鑺傛暟缁�
+     */
+    public void setBytesHead(byte[] bytesHead) {
+        BytesHead = bytesHead;
+    }
+
+    /**
+     * 鑾峰彇鍐呭瀛楄妭
+     * @return 瀛楄妭鏁扮粍
+     */
+    public byte[] getBytesContent() {
+        return BytesContent;
+    }
+
+    /**
+     * 璁剧疆鍐呭瀛楄妭
+     * @param bytesContent 瀛楄妭鏁扮粍
+     */
+    public void setBytesContent(byte[] bytesContent) {
+        BytesContent = bytesContent;
+    }
+
+    /**
+     * 鑾峰彇鐢ㄤ簬鍒嗙被鐨勫叧閿瓧
+     * @return 鍏抽敭瀛�
+     */
+    public String getKeyGroup() {
+        return KeyGroup;
+    }
+
+    /**
+     * 璁剧疆鐢ㄤ簬鍒嗙被鐨勫叧閿瓧
+     * @param keyGroup 鍏抽敭瀛�
+     */
+    public void setKeyGroup(String keyGroup) {
+        KeyGroup = keyGroup;
+    }
+
+    /**
+     * 鑾峰彇缃戠粶濂楁帴瀛�
+     * @return socket瀵硅薄
+     */
+    public Socket getWorkSocket() {
+        return WorkSocket;
+    }
+
+    /**
+     * 璁剧疆缃戠粶濂楁帴瀛�
+     * @param workSocket socket瀵硅薄
+     */
+    public void setWorkSocket(Socket workSocket) {
+        WorkSocket = workSocket;
+    }
+
+    /**
+     * 鑾峰彇鍚屾閿�
+     * @return
+     */
+    public Lock getHybirdLockSend() {
+        return HybirdLockSend;
+    }
+
+
+
+
+
+    /**
+     * 娓呴櫎鏈鐨勬帴鏀跺唴瀹�
+     */
+    public void Clear() {
+        BytesHead = new byte[HslProtocol.HeadByteLength];
+        BytesContent = null;
+    }
+
+
+    /**
+     * 杩斿洖琛ㄧず褰撳墠瀵硅薄鐨勫瓧绗︿覆锛屼互IP锛岀鍙o紝瀹㈡埛绔悕绉扮粍鎴�
+     * @return 瀛楃涓叉暟鎹�
+     */
+    @Override
+    public String toString() {
+        if (LoginAlias.isEmpty()) {
+            return "[" + IpEndPoint.toString() + "]";
+        } else {
+            return "[" + IpEndPoint + "] [" + LoginAlias + "]";
+        }
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/net/siemens/SiemensS7Net.java b/src/main/java/com/zy/gateway/core/net/siemens/SiemensS7Net.java
new file mode 100644
index 0000000..ed1e73a
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/net/siemens/SiemensS7Net.java
@@ -0,0 +1,808 @@
+package com.zy.gateway.core.net.siemens;
+
+import com.zy.gateway.core.StringResources;
+import com.zy.gateway.core.base.SoftBasic;
+import com.zy.gateway.core.domain.OperateResult;
+import com.zy.gateway.core.domain.OperateResultExOne;
+import com.zy.gateway.core.domain.OperateResultExThree;
+import com.zy.gateway.core.domain.OperateResultExTwo;
+import com.zy.gateway.core.domain.siemens.S7Message;
+import com.zy.gateway.core.domain.siemens.SiemensPLCS;
+import com.zy.gateway.core.net.NetworkDeviceBase;
+import com.zy.gateway.core.transfer.ReverseBytesTransform;
+import com.zy.gateway.core.utils.Utilities;
+
+import java.io.ByteArrayOutputStream;
+import java.net.Socket;
+import java.util.Arrays;
+
+/**
+ * 瑗块棬瀛愮殑鏁版嵁浜や簰绫伙紝閲囩敤s7鍗忚瀹炵幇
+ */
+public class SiemensS7Net extends NetworkDeviceBase<S7Message, ReverseBytesTransform> {
+
+
+    /**
+     * 瀹炰緥鍖栦竴涓タ闂ㄥ瓙鐨凷7鍗忚鐨勯�氳瀵硅薄
+     * @param siemens 鎸囧畾瑗块棬瀛愮殑鍨嬪彿
+     */
+    public SiemensS7Net(SiemensPLCS siemens) {
+        Initialization(siemens, "");
+    }
+
+
+
+    /**
+     * 瀹炰緥鍖栦竴涓タ闂ㄥ瓙鐨凷7鍗忚鐨勯�氳瀵硅薄骞舵寚瀹欼p鍦板潃
+     * @param siemens 鎸囧畾瑗块棬瀛愮殑鍨嬪彿
+     * @param ipAddress Ip鍦板潃
+     */
+    public SiemensS7Net(SiemensPLCS siemens, String ipAddress) {
+        Initialization(siemens, ipAddress);
+    }
+
+
+    /**
+     * 鍒濆鍖栨柟娉�
+     * @param siemens 瑗块棬瀛愮被鍨�
+     * @param ipAddress Ip鍦板潃
+     */
+    private void Initialization(SiemensPLCS siemens, String ipAddress) {
+        WordLength = 2;
+        setIpAddress(ipAddress);
+        setPort(102);
+        CurrentPlc = siemens;
+
+        switch (siemens) {
+            case S1200:
+                plcHead1[21] = 0;
+                break;
+            case S300:
+                plcHead1[21] = 2;
+                break;
+            case S1500:
+                plcHead1[21] = 0;
+                break;
+            case S200Smart: {
+                plcHead1 = plcHead1_200smart;
+                plcHead2 = plcHead2_200smart;
+                break;
+            }
+            default:
+                plcHead1[18] = 0;
+                break;
+        }
+    }
+
+
+    /**
+     * 鍦ㄥ鎴风杩炴帴涓婃湇鍔″櫒鍚庯紝鎵�鍋氱殑涓�浜涘垵濮嬪寲鎿嶄綔 ->
+     * Two handshake actions required after connecting to the server
+     * @param socket 缃戠粶濂楁帴瀛�
+     * @return 杩斿洖杩炴帴缁撴灉
+     */
+    @Override
+    protected OperateResult InitializationOnConnect(Socket socket) {
+        // 绗竴灞傞�氫俊鐨勫垵濮嬪寲
+        OperateResultExTwo<byte[], byte[]> read_first = ReadFromCoreServerBase(socket, plcHead1);
+        if (!read_first.IsSuccess) return read_first;
+
+        // 绗簩灞傞�氫俊鐨勫垵濮嬪寲
+        OperateResultExTwo<byte[], byte[]> read_second = ReadFromCoreServerBase(socket, plcHead2);
+        if (!read_second.IsSuccess) return read_second;
+
+        // 杩斿洖鎴愬姛鐨勪俊鍙�
+        return OperateResult.CreateSuccessResult();
+    }
+
+
+
+    /**
+     * 浠嶱LC璇诲彇璁㈣揣鍙蜂俊鎭�
+     * @return
+     */
+    public OperateResultExOne<String> ReadOrderNumber() {
+        OperateResultExOne<String> result = new OperateResultExOne<String>();
+        OperateResultExOne<byte[]> read = ReadFromCoreServer(plcOrderNumber);
+        if (read.IsSuccess) {
+            if (read.Content.length > 100) {
+                result.IsSuccess = true;
+                result.Content = Utilities.getString(Arrays.copyOfRange(read.Content, 71, 20), "ASCII");
+            }
+        }
+
+        if (!result.IsSuccess) {
+            result.CopyErrorFromOther(read);
+        }
+
+        return result;
+    }
+
+
+
+    /**
+     * 浠嶱LC璇诲彇鏁版嵁锛屽湴鍧�鏍煎紡涓篒100锛孮100锛孌B20.100锛孧100锛孴100锛孋100浠ュ瓧鑺備负鍗曚綅
+     * @param address 璧峰鍦板潃锛屾牸寮忎负I100锛孧100锛孮100锛孌B20.100
+     * @param length 璇诲彇鐨勬暟閲忥紝浠ュ瓧鑺備负鍗曚綅
+     * @return 缁撴灉瀵硅薄
+     */
+    @Override
+    public OperateResultExOne<byte[]> Read(String address, short length) {
+        OperateResultExThree<Byte, Integer, Integer> addressResult = AnalysisAddress(address);
+        if (!addressResult.IsSuccess) return OperateResultExOne.<byte[]>CreateFailedResult(addressResult);
+
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+        short alreadyFinished = 0;
+        while (alreadyFinished < length) {
+            short readLength = (short) Math.min(length - alreadyFinished, 200);
+
+            OperateResultExThree<Byte, Integer, Integer>[] list = new OperateResultExThree[1];
+            list[0] = addressResult;
+
+            OperateResultExOne<byte[]> read = Read(list, new short[]{readLength});
+            if (read.IsSuccess) {
+                try {
+                    outputStream.write(read.Content);
+                } catch (Exception ex) {
+
+                }
+            } else {
+                return read;
+            }
+
+            alreadyFinished += readLength;
+            addressResult.Content2 += readLength * 8;
+        }
+
+        byte[] buffer = outputStream.toByteArray();
+
+        try {
+            outputStream.close();
+        } catch (Exception ex) {
+
+        }
+
+        return OperateResultExOne.CreateSuccessResult(buffer);
+    }
+
+
+    /**
+     * 浠嶱LC璇诲彇鏁版嵁锛屽湴鍧�鏍煎紡涓篒100锛孮100锛孌B20.100锛孧100锛屼互浣嶄负鍗曚綅
+     * @param address 璧峰鍦板潃锛屾牸寮忎负I100锛孧100锛孮100锛孌B20.100
+     * @return 缁撴灉瀵硅薄
+     */
+    private OperateResultExOne<byte[]> ReadBitFromPLC(String address) {
+        OperateResultExOne<byte[]> command = BuildBitReadCommand(address);
+        if (!command.IsSuccess) return command;
+
+        OperateResultExOne<byte[]> read = ReadFromCoreServer(command.Content);
+        if (!read.IsSuccess) return read;
+
+
+        int receiveCount = 1;
+        if (read.Content.length >= 21 && read.Content[20] == 1) {
+            // 鍒嗘瀽缁撴灉
+            byte[] buffer = new byte[receiveCount];
+
+            if (22 < read.Content.length) {
+                if (read.Content[21] == (byte) 0xFF && read.Content[22] == 0x03) {
+                    // 鏈夋暟鎹�
+                    buffer[0] = read.Content[25];
+                }
+            }
+
+            return OperateResultExOne.CreateSuccessResult(buffer);
+        }
+        else {
+            return new OperateResultExOne<byte[]>(read.ErrorCode, StringResources.Language.SiemensDataLengthCheckFailed());
+        }
+    }
+
+
+    /**
+     * 涓�娆℃�т粠PLC鑾峰彇鎵�鏈夌殑鏁版嵁锛屾寜鐓у厛鍚庨『搴忚繑鍥炰竴涓粺涓�鐨凚uffer锛岄渶瑕佹寜鐓ч『搴忓鐞嗭紝涓や釜鏁扮粍闀垮害蹇呴』涓�鑷�
+     * @param address 璧峰鍦板潃鏁扮粍
+     * @param length 鏁版嵁闀垮害鏁扮粍
+     * @return 缁撴灉鏁版嵁瀵硅薄
+     */
+    public OperateResultExOne<byte[]> Read(String[] address, short[] length) {
+
+        OperateResultExThree<Byte, Integer, Integer>[] list = new OperateResultExThree[address.length];
+        for (int i = 0; i < address.length; i++) {
+            OperateResultExThree<Byte, Integer, Integer> tmp = AnalysisAddress(address[i]);
+            if (!tmp.IsSuccess) return OperateResultExOne.CreateFailedResult(tmp);
+
+            list[i] = tmp;
+        }
+
+        return Read(list, length);
+    }
+
+
+    /**
+     * 璇诲彇鐪熷疄鐨勬暟鎹�
+     * @param address 璧峰鍦板潃
+     * @param length 闀垮害
+     * @return 缁撴灉绫诲璞�
+     */
+    private OperateResultExOne<byte[]> Read(OperateResultExThree<Byte, Integer, Integer>[] address, short[] length) {
+
+        OperateResultExOne<byte[]> command = BuildReadCommand(address, length);
+        if (!command.IsSuccess) return command;
+
+        OperateResultExOne<byte[]> read = ReadFromCoreServer(command.Content);
+        if (!read.IsSuccess) return read;
+
+        int receiveCount = 0;
+        for (int i = 0; i < length.length; i++) {
+            receiveCount += length[i];
+        }
+
+        if (read.Content.length >= 21 && read.Content[20] == length.length) {
+            // 鍒嗘瀽缁撴灉
+            byte[] buffer = new byte[receiveCount];
+            int kk = 0;
+            int ll = 0;
+            for (int ii = 21; ii < read.Content.length; ii++) {
+                if ((ii + 1) < read.Content.length) {
+                    if (read.Content[ii] == (byte) 0xFF &&
+                            read.Content[ii + 1] == 0x04) {
+                        // 鏈夋暟鎹�
+                        System.arraycopy(read.Content, ii + 4, buffer, ll, length[kk]);
+                        ii += length[kk] + 3;
+                        ll += length[kk];
+                        kk++;
+                    }
+                }
+            }
+
+            return OperateResultExOne.CreateSuccessResult(buffer);
+        } else {
+            return new OperateResultExOne<byte[]>(read.ErrorCode,StringResources.Language.SiemensDataLengthCheckFailed());
+        }
+    }
+
+
+
+    /**
+     * 璇诲彇鎸囧畾鍦板潃鐨刡ool鏁版嵁
+     * @param address 璧峰鍦板潃锛屾牸寮忎负I100锛孧100锛孮100锛孌B20.100
+     * @return 缁撴灉绫诲璞�
+     */
+    public OperateResultExOne<Boolean> ReadBool(String address) {
+        return GetBoolResultFromBytes(ReadBitFromPLC(address));
+    }
+
+
+
+    /**
+     * 璇诲彇鎸囧畾鍦板潃鐨刡yte鏁版嵁
+     * @param address 璧峰鍦板潃锛屾牸寮忎负I100锛孧100锛孮100锛孌B20.100
+     * @return 缁撴灉绫诲璞�
+     */
+    public OperateResultExOne<Byte> ReadByte(String address) {
+        return GetByteResultFromBytes(Read(address, (short) 1));
+    }
+
+
+
+    /**
+     * 鍩虹鐨勫啓鍏ユ暟鎹殑鎿嶄綔鏀寔
+     * @param entireValue 瀹屾暣鐨勫瓧鑺傛暟鎹�
+     * @return 鍐欏叆缁撴灉
+     */
+    private OperateResult WriteBase(byte[] entireValue) {
+        OperateResultExOne<byte[]> write = ReadFromCoreServer(entireValue);
+        if (!write.IsSuccess) return write;
+
+        if (write.Content[write.Content.length - 1] != (byte) 0xFF) {
+            return new OperateResult(write.Content[write.Content.length - 1], StringResources.Language.SiemensWriteError() + write.Content[write.Content.length - 1]);
+        } else {
+            return OperateResult.CreateSuccessResult();
+        }
+    }
+
+
+
+    /**
+     * 灏嗘暟鎹啓鍏ュ埌PLC鏁版嵁锛屽湴鍧�鏍煎紡涓篒100锛孮100锛孌B20.100锛孧100锛屼互瀛楄妭涓哄崟浣�
+     * @param address 璧峰鍦板潃锛屾牸寮忎负I100锛孧100锛孮100锛孌B20.100
+     * @param value 鍐欏叆鐨勬暟鎹紝闀垮害鏍规嵁data鐨勯暱搴︽潵鎸囩ず
+     * @return 鍐欏叆缁撴灉
+     */
+    @Override
+    public OperateResult Write(String address, byte[] value) {
+        OperateResultExThree<Byte, Integer, Integer> analysis = AnalysisAddress( address );
+        if (!analysis.IsSuccess) return OperateResultExOne.CreateFailedResult( analysis );
+
+        int length = value.length;
+        int alreadyFinished = 0;
+        while (alreadyFinished < length) {
+            short writeLength = (short) Math.min( length - alreadyFinished, 200 );
+            byte[] buffer = getByteTransform().TransByte( value, alreadyFinished, writeLength );
+
+            OperateResultExOne<byte[]> command = BuildWriteByteCommand( analysis, buffer );
+            if (!command.IsSuccess) return command;
+
+            OperateResult write = WriteBase( command.Content );
+            if (!write.IsSuccess) return write;
+
+            alreadyFinished += writeLength;
+            analysis.Content2 += writeLength * 8;
+        }
+        return OperateResult.CreateSuccessResult( );
+    }
+
+
+
+
+    /**
+     * 鍐欏叆PLC鐨勪竴涓綅锛屼緥濡�"M100.6"锛�"I100.7"锛�"Q100.0"锛�"DB20.100.0"锛屽鏋滃彧鍐欎簡"M100"榛樿涓�"M100.0
+     * @param address 璧峰鍦板潃锛屾牸寮忎负I100锛孧100锛孮100锛孌B20.100
+     * @param value 鍐欏叆鐨勬暟鎹紝True鎴栨槸False
+     * @return 鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, boolean value) {
+        // 鐢熸垚鎸囦护
+        OperateResultExOne<byte[]> command = BuildWriteBitCommand(address, value);
+        if (!command.IsSuccess) return command;
+
+        return WriteBase(command.Content);
+    }
+
+
+    /**
+     * 鍚慞LC涓啓鍏ool鏁扮粍锛岃繑鍥炲�艰鏄庯紝姣斿浣犲啓鍏100,閭d箞data[0]瀵瑰簲M100.0
+     * @param address 瑕佸啓鍏ョ殑鏁版嵁鍦板潃
+     * @param values 瑕佸啓鍏ョ殑瀹為檯鏁版嵁锛岄暱搴︿负8鐨勫�嶆暟
+     * @return 鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, boolean[] values) {
+        return Write(address, SoftBasic.BoolArrayToByte(values));
+    }
+
+
+
+
+    /**
+     * 鍚慞LC涓啓鍏yte鏁版嵁锛岃繑鍥炲�艰鏄�
+     * @param address 瑕佸啓鍏ョ殑鏁版嵁鍦板潃
+     * @param value 瑕佸啓鍏ョ殑瀹為檯鏁版嵁
+     * @return 鍐欏叆缁撴灉
+     */
+    public OperateResult Write(String address, byte value) {
+        return Write(address, new byte[]{value});
+    }
+
+
+    private byte[] plcHead1 = new byte[]
+            {
+                    0x03,0x00,0x00,0x16,0x11,(byte) 0xE0,0x00,0x00,0x00,0x01,0x00,(byte) 0xC0,0x01,
+                    0x0A,(byte) 0xC1,0x02,0x01,0x02,(byte) 0xC2,0x02,0x01,0x00
+            };
+    private byte[] plcHead2 = new byte[]
+            {
+                    0x03,0x00,0x00,0x19,0x02,(byte) 0xF0,(byte) 0x80,0x32,0x01,0x00,0x00,0x04,0x00,0x00,0x08,0x00,0x00,
+                    (byte) 0xF0,0x00,0x00,0x01,0x00,0x01,0x01,(byte) 0xE0
+            };
+    private byte[] plcOrderNumber = new byte[]
+            {
+                    0x03,0x00,0x00,0x21,0x02,(byte) 0xF0,(byte) 0x80,0x32,0x07,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x08,
+                    0x00,0x01,0x12,0x04,0x11,0x44,0x01,0x00,(byte) 0xFF,0x09,0x00,0x04,0x00,0x11,0x00,0x00
+            };
+    private SiemensPLCS CurrentPlc = SiemensPLCS.S1200;
+    private byte[] plcHead1_200smart = new byte[]
+            {
+                    0x03,0x00,0x00,0x16,0x11,(byte) 0xE0,0x00,0x00,0x00,0x01,0x00,(byte) 0xC1,0x02,0x10,0x00,(byte) 0xC2,
+                    0x02,0x03,0x00,(byte) 0xC0,0x01,0x0A
+            };
+    private byte[] plcHead2_200smart = new byte[]
+            {
+                    0x03,0x00,0x00,0x19,0x02,(byte) 0xF0,(byte) 0x80,0x32,0x01,0x00,0x00,(byte) 0xCC,(byte) 0xC1,
+                    0x00,0x08,0x00,0x00,(byte) 0xF0,0x00,0x00,0x01,0x00,0x01,0x03,(byte) 0xC0
+            };
+
+
+    /**
+     * 杩斿洖琛ㄧず褰撳墠瀵硅薄鐨勫瓧绗︿覆
+     * @return 瀛楃涓蹭俊鎭�
+     */
+    @Override
+    public String toString() {
+        return "SiemensS7Net";
+    }
+
+
+
+    /**
+     * 璁$畻鐗规畩鐨勫湴鍧�淇℃伅
+     * @param address 瀛楃涓蹭俊鎭�
+     * @return 瀹為檯鍊�
+     */
+    public static int CalculateAddressStarted(String address) {
+        if (address.indexOf('.') < 0) {
+            return Integer.parseInt(address) * 8;
+        } else {
+            String[] temp = address.split("\\.");
+            return Integer.parseInt(temp[0]) * 8 + Integer.parseInt(temp[1]);
+        }
+    }
+
+    /**
+     * 瑙f瀽鏁版嵁鍦板潃锛岃В鏋愬嚭鍦板潃绫诲瀷锛岃捣濮嬪湴鍧�锛孌B鍧楃殑鍦板潃
+     * @param address 鏁版嵁鍦板潃
+     * @return 瑙f瀽鍑哄湴鍧�绫诲瀷锛岃捣濮嬪湴鍧�锛孌B鍧楃殑鍦板潃
+     */
+    public static OperateResultExThree<Byte, Integer, Integer> AnalysisAddress(String address) {
+        OperateResultExThree<Byte, Integer, Integer> result = new OperateResultExThree<Byte, Integer, Integer>();
+        try {
+            result.Content3 = 0;
+            if (address.charAt(0) == 'I') {
+                result.Content1 = (byte) 0x81;
+                result.Content2 = CalculateAddressStarted(address.substring(1));
+            } else if (address.charAt(0) == 'Q') {
+                result.Content1 = (byte) 0x82;
+                result.Content2 = CalculateAddressStarted(address.substring(1));
+            } else if (address.charAt(0) == 'M') {
+                result.Content1 = (byte) 0x83;
+                result.Content2 = CalculateAddressStarted(address.substring(1));
+            } else if (address.charAt(0) == 'D' || address.substring(0, 2).equals("DB")) {
+                result.Content1 = (byte) 0x84;
+                String[] adds = address.split("\\.");
+                if (address.charAt(1) == 'B') {
+                    result.Content3 = Integer.parseInt(adds[0].substring(2));
+                } else {
+                    result.Content3 = Integer.parseInt(adds[0].substring(1));
+                }
+                result.Content2 = CalculateAddressStarted(address.substring(address.indexOf('.') + 1));
+            } else if (address.charAt(0) == 'T') {
+                result.Content1 = 0x1D;
+                result.Content2 = CalculateAddressStarted(address.substring(1));
+            } else if (address.charAt(0) == 'C') {
+                result.Content1 = 0x1C;
+                result.Content2 = CalculateAddressStarted(address.substring(1));
+            }
+            else if (address.charAt(0) == 'V') {
+                result.Content1 = (byte) 0x84;
+                result.Content3 = 1;
+                result.Content2 = CalculateAddressStarted( address.substring( 1 ) );
+            } else {
+                return new OperateResultExThree<Byte, Integer, Integer>(StringResources.Language.NotSupportedDataType());
+            }
+        } catch (Exception ex) {
+            result.Message = ex.getMessage();
+            return result;
+        }
+        result.IsSuccess = true;
+        return result;
+    }
+
+    /**
+     * 鐢熸垚涓�涓鍙栧瓧鏁版嵁鎸囦护澶寸殑閫氱敤鏂规硶 ->
+     * A general method for generating a command header to read a Word data
+     * @param address 璧峰鍦板潃锛屼緥濡侻100锛孖0锛孮0锛孌B2.100 -> Start address, such as M100,I0,Q0,DB2.100
+     * @param length 璇诲彇鏁版嵁闀垮害 -> Read Data length
+     * @return 鍖呭惈缁撴灉瀵硅薄鐨勬姤鏂� -> Message containing the result object
+     */
+    public static OperateResultExOne<byte[]> BuildReadCommand( String address, short length )
+    {
+        OperateResultExThree<Byte, Integer, Integer> analysis = AnalysisAddress( address );
+        if (!analysis.IsSuccess) return OperateResultExOne.<byte[]>CreateFailedResult( analysis );
+
+        OperateResultExThree<Byte, Integer, Integer>[] addressList = new OperateResultExThree[1];
+        addressList[0] = analysis;
+        short[] lengthList = new short[1];
+        lengthList[0] = length;
+
+        return BuildReadCommand( addressList, lengthList );
+    }
+
+
+    /**
+     * 鐢熸垚涓�涓鍙栧瓧鏁版嵁鎸囦护澶寸殑閫氱敤鏂规硶
+     * @param address 瑙f瀽鍚庣殑鍦板潃
+     * @param length 姣忎釜鍦板潃鐨勮鍙栭暱搴�
+     * @return 鎼哄甫鏈夊懡浠ゅ瓧鑺�
+     */
+    public static OperateResultExOne<byte[]> BuildReadCommand(OperateResultExThree<Byte, Integer, Integer>[] address, short[] length) {
+        if (address == null) throw new RuntimeException("address is null");
+        if (length == null) throw new RuntimeException("count is null");
+        if (address.length != length.length) throw new RuntimeException(StringResources.Language.TwoParametersLengthIsNotSame());
+        if (length.length > 19) throw new RuntimeException(StringResources.Language.SiemensReadLengthCannotLargerThan19());
+
+        int readCount = length.length;
+
+        byte[] _PLCCommand = new byte[19 + readCount * 12];
+
+        // ======================================================================================
+        // Header
+        // 鎶ユ枃澶�
+        _PLCCommand[0] = 0x03;
+        _PLCCommand[1] = 0x00;
+        // 闀垮害
+        _PLCCommand[2] = (byte) (_PLCCommand.length / 256);
+        _PLCCommand[3] = (byte) (_PLCCommand.length % 256);
+        // 鍥哄畾
+        _PLCCommand[4] = 0x02;
+        _PLCCommand[5] = (byte) 0xF0;
+        _PLCCommand[6] = (byte) 0x80;
+        // 鍗忚鏍囪瘑
+        _PLCCommand[7] = 0x32;
+        // 鍛戒护锛氬彂
+        _PLCCommand[8] = 0x01;
+        // redundancy identification (reserved): 0x0000;
+        _PLCCommand[9] = 0x00;
+        _PLCCommand[10] = 0x00;
+        // protocol data unit reference; it鈥檚 increased by request event;
+        _PLCCommand[11] = 0x00;
+        _PLCCommand[12] = 0x01;
+        // 鍙傛暟鍛戒护鏁版嵁鎬婚暱搴�
+        _PLCCommand[13] = (byte) ((_PLCCommand.length - 17) / 256);
+        _PLCCommand[14] = (byte) ((_PLCCommand.length - 17) % 256);
+
+        // 璇诲彇鍐呴儴鏁版嵁鏃朵负00锛岃鍙朇PU鍨嬪彿涓篋ata鏁版嵁闀垮害
+        _PLCCommand[15] = 0x00;
+        _PLCCommand[16] = 0x00;
+
+
+        // ======================================================================================
+        // Parameter
+
+        // 璇诲啓鎸囦护锛�04璇伙紝05鍐�
+        _PLCCommand[17] = 0x04;
+        // 璇诲彇鏁版嵁鍧椾釜鏁�
+        _PLCCommand[18] = (byte) readCount;
+
+
+        for (int ii = 0; ii < readCount; ii++) {
+            //===========================================================================================
+            // 鎸囧畾鏈夋晥鍊肩被鍨�
+            _PLCCommand[19 + ii * 12] = 0x12;
+            // 鎺ヤ笅鏉ユ湰娆″湴鍧�璁块棶闀垮害
+            _PLCCommand[20 + ii * 12] = 0x0A;
+            // 璇硶鏍囪锛孉NY
+            _PLCCommand[21 + ii * 12] = 0x10;
+            // 鎸夊瓧涓哄崟浣�
+            _PLCCommand[22 + ii * 12] = 0x02;
+            // 璁块棶鏁版嵁鐨勪釜鏁�
+            _PLCCommand[23 + ii * 12] = (byte) (length[ii] / 256);
+            _PLCCommand[24 + ii * 12] = (byte) (length[ii] % 256);
+            // DB鍧楃紪鍙凤紝濡傛灉璁块棶鐨勬槸DB鍧楃殑璇�
+            _PLCCommand[25 + ii * 12] = (byte) (address[ii].Content3 / 256);
+            _PLCCommand[26 + ii * 12] = (byte) (address[ii].Content3 % 256);
+            // 璁块棶鏁版嵁绫诲瀷
+            _PLCCommand[27 + ii * 12] = address[ii].Content1;
+            // 鍋忕Щ浣嶇疆
+            _PLCCommand[28 + ii * 12] = (byte) (address[ii].Content2 / 256 / 256 % 256);
+            _PLCCommand[29 + ii * 12] = (byte) (address[ii].Content2 / 256 % 256);
+            _PLCCommand[30 + ii * 12] = (byte) (address[ii].Content2 % 256);
+        }
+
+        return OperateResultExOne.CreateSuccessResult(_PLCCommand);
+    }
+
+
+    /**
+     * 鐢熸垚涓�涓綅璇诲彇鏁版嵁鎸囦护澶寸殑閫氱敤鏂规硶
+     * @param address 璧峰鍦板潃
+     * @return 鎸囦护
+     */
+    public static OperateResultExOne<byte[]> BuildBitReadCommand(String address) {
+        byte[] _PLCCommand = new byte[31];
+        // 鎶ユ枃澶�
+        _PLCCommand[0] = 0x03;
+        _PLCCommand[1] = 0x00;
+        // 闀垮害
+        _PLCCommand[2] = (byte) (_PLCCommand.length / 256);
+        _PLCCommand[3] = (byte) (_PLCCommand.length % 256);
+        // 鍥哄畾
+        _PLCCommand[4] = 0x02;
+        _PLCCommand[5] = (byte) 0xF0;
+        _PLCCommand[6] = (byte) 0x80;
+        _PLCCommand[7] = 0x32;
+        // 鍛戒护锛氬彂
+        _PLCCommand[8] = 0x01;
+        // 鏍囪瘑搴忓垪鍙�
+        _PLCCommand[9] = 0x00;
+        _PLCCommand[10] = 0x00;
+        _PLCCommand[11] = 0x00;
+        _PLCCommand[12] = 0x01;
+        // 鍛戒护鏁版嵁鎬婚暱搴�
+        _PLCCommand[13] = (byte) ((_PLCCommand.length - 17) / 256);
+        _PLCCommand[14] = (byte) ((_PLCCommand.length - 17) % 256);
+
+        _PLCCommand[15] = 0x00;
+        _PLCCommand[16] = 0x00;
+
+        // 鍛戒护璧峰绗�
+        _PLCCommand[17] = 0x04;
+        // 璇诲彇鏁版嵁鍧椾釜鏁�
+        _PLCCommand[18] = 0x01;
+
+
+        // 濉厖鏁版嵁
+        OperateResultExThree<Byte, Integer, Integer> analysis = AnalysisAddress(address);
+        if (!analysis.IsSuccess) return OperateResultExOne.CreateFailedResult(analysis);
+
+        //===========================================================================================
+        // 璇诲彇鍦板潃鐨勫墠缂�
+        _PLCCommand[19] = 0x12;
+        _PLCCommand[20] = 0x0A;
+        _PLCCommand[21] = 0x10;
+        // 璇诲彇鐨勬暟鎹椂浣�
+        _PLCCommand[22] = 0x01;
+        // 璁块棶鏁版嵁鐨勪釜鏁�
+        _PLCCommand[23] = 0x00;
+        _PLCCommand[24] = 0x01;
+        // DB鍧楃紪鍙凤紝濡傛灉璁块棶鐨勬槸DB鍧楃殑璇�
+        _PLCCommand[25] = (byte) (analysis.Content3 / 256);
+        _PLCCommand[26] = (byte) (analysis.Content3 % 256);
+        // 璁块棶鏁版嵁绫诲瀷
+        _PLCCommand[27] = analysis.Content1;
+        // 鍋忕Щ浣嶇疆
+        _PLCCommand[28] = (byte) (analysis.Content2 / 256 / 256 % 256);
+        _PLCCommand[29] = (byte) (analysis.Content2 / 256 % 256);
+        _PLCCommand[30] = (byte) (analysis.Content2 % 256);
+
+        return OperateResultExOne.CreateSuccessResult(_PLCCommand);
+    }
+
+
+    /**
+     * 鐢熸垚涓�涓啓鍏ュ瓧鑺傛暟鎹殑鎸囦护 -> Generate an instruction to write byte data
+     * @param address 璧峰鍦板潃锛岀ず渚婱100,I100,Q100,DB1.100 -> Start Address, example M100,I100,Q100,DB1.100
+     * @param data 鍘熷鐨勫瓧鑺傛暟鎹� -> Raw byte data
+     * @return 鍖呭惈缁撴灉瀵硅薄鐨勬姤鏂� -> Message containing the result object
+     */
+    public static OperateResultExOne<byte[]> BuildWriteByteCommand( String address, byte[] data )
+    {
+        if (data == null) data = new byte[0];
+
+        OperateResultExThree<Byte, Integer, Integer> analysis = AnalysisAddress( address );
+        if (!analysis.IsSuccess) return OperateResultExOne.CreateFailedResult( analysis );
+
+        return BuildWriteByteCommand( analysis, data );
+    }
+
+    /**
+     * 鐢熸垚涓�涓啓鍏ュ瓧鑺傛暟鎹殑鎸囦护
+     * @param analysis 鍦板潃
+     * @param data 鏁版嵁
+     * @return 鎸囦护
+     */
+    public static OperateResultExOne<byte[]> BuildWriteByteCommand(OperateResultExThree<Byte, Integer, Integer> analysis, byte[] data) {
+        if (data == null) data = new byte[0];
+
+        byte[] _PLCCommand = new byte[35 + data.length];
+        _PLCCommand[0] = 0x03;
+        _PLCCommand[1] = 0x00;
+        // 闀垮害
+        _PLCCommand[2] = (byte) ((35 + data.length) / 256);
+        _PLCCommand[3] = (byte) ((35 + data.length) % 256);
+        // 鍥哄畾
+        _PLCCommand[4] = 0x02;
+        _PLCCommand[5] = (byte) 0xF0;
+        _PLCCommand[6] = (byte) 0x80;
+        _PLCCommand[7] = 0x32;
+        // 鍛戒护 鍙�
+        _PLCCommand[8] = 0x01;
+        // 鏍囪瘑搴忓垪鍙�
+        _PLCCommand[9] = 0x00;
+        _PLCCommand[10] = 0x00;
+        _PLCCommand[11] = 0x00;
+        _PLCCommand[12] = 0x01;
+        // 鍥哄畾
+        _PLCCommand[13] = 0x00;
+        _PLCCommand[14] = 0x0E;
+        // 鍐欏叆闀垮害+4
+        _PLCCommand[15] = (byte) ((4 + data.length) / 256);
+        _PLCCommand[16] = (byte) ((4 + data.length) % 256);
+        // 璇诲啓鎸囦护
+        _PLCCommand[17] = 0x05;
+        // 鍐欏叆鏁版嵁鍧椾釜鏁�
+        _PLCCommand[18] = 0x01;
+        // 鍥哄畾锛岃繑鍥炴暟鎹暱搴�
+        _PLCCommand[19] = 0x12;
+        _PLCCommand[20] = 0x0A;
+        _PLCCommand[21] = 0x10;
+        // 鍐欏叆鏂瑰紡锛�1鏄寜浣嶏紝2鏄寜瀛�
+        _PLCCommand[22] = 0x02;
+        // 鍐欏叆鏁版嵁鐨勪釜鏁�
+        _PLCCommand[23] = (byte) (data.length / 256);
+        _PLCCommand[24] = (byte) (data.length % 256);
+        // DB鍧楃紪鍙凤紝濡傛灉璁块棶鐨勬槸DB鍧楃殑璇�
+        _PLCCommand[25] = (byte) (analysis.Content3 / 256);
+        _PLCCommand[26] = (byte) (analysis.Content3 % 256);
+        // 鍐欏叆鏁版嵁鐨勭被鍨�
+        _PLCCommand[27] = analysis.Content1;
+        // 鍋忕Щ浣嶇疆
+        _PLCCommand[28] = (byte) (analysis.Content2 / 256 / 256 % 256);
+        ;
+        _PLCCommand[29] = (byte) (analysis.Content2 / 256 % 256);
+        _PLCCommand[30] = (byte) (analysis.Content2 % 256);
+        // 鎸夊瓧鍐欏叆
+        _PLCCommand[31] = 0x00;
+        _PLCCommand[32] = 0x04;
+        // 鎸変綅璁$畻鐨勯暱搴�
+        _PLCCommand[33] = (byte) (data.length * 8 / 256);
+        _PLCCommand[34] = (byte) (data.length * 8 % 256);
+
+        System.arraycopy(data, 0, _PLCCommand, 35, data.length);
+
+        return OperateResultExOne.CreateSuccessResult(_PLCCommand);
+    }
+
+
+    /**
+     * 鐢熸垚涓�涓啓鍏ヤ綅鏁版嵁鐨勬寚浠�
+     * @param address 璧峰鍦板潃
+     * @param data 鏁版嵁
+     * @return 鎸囦护
+     */
+    public static OperateResultExOne<byte[]> BuildWriteBitCommand(String address, boolean data) {
+        OperateResultExThree<Byte, Integer, Integer> analysis = AnalysisAddress(address);
+        if (!analysis.IsSuccess) return OperateResultExOne.CreateFailedResult(analysis);
+
+
+        byte[] buffer = new byte[1];
+        buffer[0] = data ? (byte) 0x01 : (byte) 0x00;
+
+        byte[] _PLCCommand = new byte[35 + buffer.length];
+        _PLCCommand[0] = 0x03;
+        _PLCCommand[1] = 0x00;
+        // 闀垮害
+        _PLCCommand[2] = (byte) ((35 + buffer.length) / 256);
+        _PLCCommand[3] = (byte) ((35 + buffer.length) % 256);
+        // 鍥哄畾
+        _PLCCommand[4] = 0x02;
+        _PLCCommand[5] = (byte) 0xF0;
+        _PLCCommand[6] = (byte) 0x80;
+        _PLCCommand[7] = 0x32;
+        // 鍛戒护 鍙�
+        _PLCCommand[8] = 0x01;
+        // 鏍囪瘑搴忓垪鍙�
+        _PLCCommand[9] = 0x00;
+        _PLCCommand[10] = 0x00;
+        _PLCCommand[11] = 0x00;
+        _PLCCommand[12] = 0x01;
+        // 鍥哄畾
+        _PLCCommand[13] = 0x00;
+        _PLCCommand[14] = 0x0E;
+        // 鍐欏叆闀垮害+4
+        _PLCCommand[15] = (byte) ((4 + buffer.length) / 256);
+        _PLCCommand[16] = (byte) ((4 + buffer.length) % 256);
+        // 鍛戒护璧峰绗�
+        _PLCCommand[17] = 0x05;
+        // 鍐欏叆鏁版嵁鍧椾釜鏁�
+        _PLCCommand[18] = 0x01;
+        _PLCCommand[19] = 0x12;
+        _PLCCommand[20] = 0x0A;
+        _PLCCommand[21] = 0x10;
+        // 鍐欏叆鏂瑰紡锛�1鏄寜浣嶏紝2鏄寜瀛�
+        _PLCCommand[22] = 0x01;
+        // 鍐欏叆鏁版嵁鐨勪釜鏁�
+        _PLCCommand[23] = (byte) (buffer.length / 256);
+        _PLCCommand[24] = (byte) (buffer.length % 256);
+        // DB鍧楃紪鍙凤紝濡傛灉璁块棶鐨勬槸DB鍧楃殑璇�
+        _PLCCommand[25] = (byte) (analysis.Content3 / 256);
+        _PLCCommand[26] = (byte) (analysis.Content3 % 256);
+        // 鍐欏叆鏁版嵁鐨勭被鍨�
+        _PLCCommand[27] = analysis.Content1;
+        // 鍋忕Щ浣嶇疆
+        _PLCCommand[28] = (byte) (analysis.Content2 / 256 / 256);
+        _PLCCommand[29] = (byte) (analysis.Content2 / 256);
+        _PLCCommand[30] = (byte) (analysis.Content2 % 256);
+        // 鎸変綅鍐欏叆
+        _PLCCommand[31] = 0x00;
+        _PLCCommand[32] = 0x03;
+        // 鎸変綅璁$畻鐨勯暱搴�
+        _PLCCommand[33] = (byte) (buffer.length / 256);
+        _PLCCommand[34] = (byte) (buffer.length % 256);
+
+        System.arraycopy(buffer, 0, _PLCCommand, 35, buffer.length);
+
+        return OperateResultExOne.CreateSuccessResult(_PLCCommand);
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/transfer/ByteTransformBase.java b/src/main/java/com/zy/gateway/core/transfer/ByteTransformBase.java
new file mode 100644
index 0000000..51f7267
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/transfer/ByteTransformBase.java
@@ -0,0 +1,545 @@
+package com.zy.gateway.core.transfer;
+
+import com.zy.gateway.core.utils.Utilities;
+
+
+/**
+ * 瀛楄妭杞崲绫荤殑鍩虹被锛屾彁渚涗簡涓�浜涘熀纭�鐨勮浆鎹㈡柟娉�
+ */
+public class ByteTransformBase implements IByteTransform {
+
+    /**
+     * 瀹炰緥鍖栦竴涓璞�
+     */
+    public ByteTransformBase(){
+        this.dataFormat = DataFormat.DCBA;
+    }
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇鍑篵ool缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @return boolean鍊�
+     */
+    public boolean TransBool(byte[] buffer, int index) {
+        return buffer[index] != 0x00;
+    }
+
+    /**
+     * 缂撳瓨涓彁鍙朾yte缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @return byte瀵硅薄
+     */
+    public byte TransByte(byte[] buffer, int index) {
+        return buffer[index];
+    }
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇byte鏁扮粍缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return byte鏁扮粍
+     */
+    public byte[] TransByte(byte[] buffer, int index, int length) {
+        byte[] tmp = new byte[length];
+        System.arraycopy(buffer, index, tmp, 0, length);
+        return tmp;
+    }
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇short缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @return short瀵硅薄
+     */
+    public short TransInt16(byte[] buffer, int index) {
+        return Utilities.getShort(buffer, index);
+    }
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇short缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return short鏁扮粍瀵硅薄
+     */
+    public short[] TransInt16(byte[] buffer, int index, int length) {
+        short[] tmp = new short[length];
+        for (int i = 0; i < length; i++) {
+            tmp[i] = TransInt16(buffer, index + 2 * i);
+        }
+        return tmp;
+    }
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇int缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @return int瀵硅薄
+     */
+    public int TransInt32(byte[] buffer, int index) {
+        return Utilities.getInt(ByteTransDataFormat4(buffer, index),0);
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇int鏁扮粍缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return int鏁扮粍瀵硅薄
+     */
+    public int[] TransInt32(byte[] buffer, int index, int length) {
+        int[] tmp = new int[length];
+        for (int i = 0; i < length; i++) {
+            tmp[i] = TransInt32(buffer, index + 4 * i);
+        }
+        return tmp;
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇long缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @return long瀵硅薄
+     */
+    public long TransInt64(byte[] buffer, int index) {
+        return Utilities.getLong(ByteTransDataFormat8(buffer, index),0);
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇long鏁扮粍缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return long鏁扮粍瀵硅薄
+     */
+    public long[] TransInt64(byte[] buffer, int index, int length) {
+        long[] tmp = new long[length];
+        for (int i = 0; i < length; i++) {
+            tmp[i] = TransInt64(buffer, index + 8 * i);
+        }
+        return tmp;
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇float缁撴灉
+     *
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index  绱㈠紩浣嶇疆
+     * @return float瀵硅薄
+     */
+    public float TransSingle(byte[] buffer, int index) {
+        return Utilities.getFloat(ByteTransDataFormat4(buffer, index),0);
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇float鏁扮粍缁撴灉
+     *
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index  绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return float鏁扮粍瀵硅薄
+     */
+    public float[] TransSingle(byte[] buffer, int index, int length) {
+        float[] tmp = new float[length];
+        for (int i = 0; i < length; i++) {
+            tmp[i] = TransSingle(buffer, index + 4 * i);
+        }
+        return tmp;
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇double缁撴灉
+     *
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index  绱㈠紩浣嶇疆
+     * @return double瀵硅薄
+     */
+    public double TransDouble(byte[] buffer, int index) {
+        return Utilities.getDouble(ByteTransDataFormat8(buffer, index),0);
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇double鏁扮粍缁撴灉
+     *
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index  绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return double鏁扮粍
+     */
+    public double[] TransDouble(byte[] buffer, int index, int length) {
+        double[] tmp = new double[length];
+        for (int i = 0; i < length; i++) {
+            tmp[i] = TransDouble(buffer, index + 8 * i);
+        }
+        return tmp;
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇string缁撴灉锛屼娇鐢ㄦ寚瀹氱殑缂栫爜
+     *
+     * @param buffer   缂撳瓨瀵硅薄
+     * @param index    绱㈠紩浣嶇疆
+     * @param length   byte鏁扮粍闀垮害
+     * @param encoding 瀛楃涓茬殑缂栫爜
+     * @return string瀵硅薄
+     */
+    public String TransString(byte[] buffer, int index, int length, String encoding) {
+        return Utilities.getString(TransByte(buffer, index, length), encoding);
+    }
+
+
+    /**
+     * bool鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(boolean value) {
+        return TransByte(new boolean[]{value});
+    }
+
+
+    /**
+     * bool鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(boolean[] values) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length];
+        for (int i = 0; i < values.length; i++) {
+            if (values[i]) buffer[i] = 0x01;
+        }
+
+        return buffer;
+    }
+
+
+    /**
+     * byte鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(byte value) {
+        return new byte[]{value};
+    }
+
+    /**
+     * short鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(short value) {
+        return TransByte(new short[]{value});
+    }
+
+    /**
+     * short鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(short[] values) {
+        if (values == null) return null;
+        byte[] buffer = new byte[values.length * 2];
+        for (int i = 0; i < values.length; i++) {
+            System.arraycopy(Utilities.getBytes(values[i]), 0, buffer, 2 * i, 2);
+        }
+        return buffer;
+    }
+
+
+    /**
+     * int鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(int value) {
+        return TransByte(new int[]{value});
+    }
+
+
+    /**
+     * int鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(int[] values) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 4];
+        for (int i = 0; i < values.length; i++) {
+            System.arraycopy(ByteTransDataFormat4(Utilities.getBytes(values[i])), 0, buffer, 4 * i, 4);
+        }
+
+        return buffer;
+    }
+
+    /**
+     * long鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(long value) {
+        return TransByte(new long[]{value});
+    }
+
+
+    /**
+     * long鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(long[] values) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 8];
+        for (int i = 0; i < values.length; i++) {
+            System.arraycopy(ByteTransDataFormat8(Utilities.getBytes(values[i])), 0, buffer, 8 * i, 8);
+        }
+
+        return buffer;
+    }
+
+
+    /**
+     * float鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(float value) {
+        return TransByte(new float[]{value});
+    }
+
+
+    /**
+     * float鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(float[] values) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 4];
+        for (int i = 0; i < values.length; i++) {
+            System.arraycopy(ByteTransDataFormat4(Utilities.getBytes(values[i])), 0, buffer, 4 * i, 4);
+        }
+
+        return buffer;
+    }
+
+
+    /**
+     * double鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(double value) {
+        return TransByte(new double[]{value});
+    }
+
+    /**
+     * double鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     *
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(double[] values) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 8];
+        for (int i = 0; i < values.length; i++) {
+            System.arraycopy(ByteTransDataFormat8(Utilities.getBytes(values[i])), 0, buffer, 8 * i, 8);
+        }
+
+        return buffer;
+    }
+
+    /**
+     * 浣跨敤鎸囧畾鐨勭紪鐮佸瓧绗︿覆杞寲缂撳瓨鏁版嵁
+     *
+     * @param value    绛夊緟杞寲鐨勬暟鎹�
+     * @param encoding 瀛楃涓茬殑缂栫爜鏂瑰紡
+     * @return buffer鏁版嵁
+     */
+    public byte[] TransByte(String value, String encoding) {
+        return Utilities.getBytes(value, encoding);
+    }
+
+
+    private DataFormat dataFormat = DataFormat.ABCD;
+
+    /**
+     * 璁剧疆鏁版嵁瑙f瀽鐨勬牸寮忥紝ABCD锛孊ADC锛孋DAB锛孌CBA鏍煎紡
+     *
+     * @param dataFormat
+     */
+    public void setDataFormat(DataFormat dataFormat) {
+        this.dataFormat = dataFormat;
+    }
+
+    /**
+     * 鑾峰彇鏁版嵁瑙f瀽鐨勬牸寮忥紝榛樿ABCD锛屽彲閫塀ADC锛孋DAB锛孌CBA鏍煎紡
+     *
+     * @return
+     */
+    public DataFormat getDataFormat() {
+        return this.dataFormat;
+    }
+
+
+    /**
+     * 鍙嶈浆澶氬瓧鑺傜殑鏁版嵁淇℃伅
+     *
+     * @param value 鏁版嵁瀛楄妭
+     * @param Index 璧峰绱㈠紩锛岄粯璁ゅ�间负0
+     * @return 瀹為檯瀛楄妭淇℃伅
+     */
+    protected byte[] ByteTransDataFormat4(byte[] value, int Index) {
+        byte[] buffer = new byte[4];
+        switch (dataFormat) {
+            case ABCD: {
+                buffer[0] = value[Index + 3];
+                buffer[1] = value[Index + 2];
+                buffer[2] = value[Index + 1];
+                buffer[3] = value[Index + 0];
+                break;
+            }
+            case BADC: {
+                buffer[0] = value[Index + 2];
+                buffer[1] = value[Index + 3];
+                buffer[2] = value[Index + 0];
+                buffer[3] = value[Index + 1];
+                break;
+            }
+            case CDAB: {
+                buffer[0] = value[Index + 1];
+                buffer[1] = value[Index + 0];
+                buffer[2] = value[Index + 3];
+                buffer[3] = value[Index + 2];
+                break;
+            }
+            case DCBA: {
+                buffer[0] = value[Index + 0];
+                buffer[1] = value[Index + 1];
+                buffer[2] = value[Index + 2];
+                buffer[3] = value[Index + 3];
+                break;
+            }
+        }
+        return buffer;
+    }
+
+
+    /**
+     * 鍙嶈浆澶氬瓧鑺傜殑鏁版嵁淇℃伅
+     *
+     * @param value 鏁版嵁瀛楄妭
+     * @return 瀹為檯瀛楄妭淇℃伅
+     */
+    protected byte[] ByteTransDataFormat4(byte[] value) {
+        return ByteTransDataFormat4(value, 0);
+    }
+
+
+    /**
+     * 鍙嶈浆澶氬瓧鑺傜殑鏁版嵁淇℃伅
+     *
+     * @param value 鏁版嵁瀛楄妭
+     * @param Index 璧峰绱㈠紩锛岄粯璁ゅ�间负0
+     * @return 瀹為檯瀛楄妭淇℃伅
+     */
+    protected byte[] ByteTransDataFormat8(byte[] value, int Index) {
+        byte[] buffer = new byte[8];
+        switch (dataFormat) {
+            case ABCD: {
+                buffer[0] = value[Index + 7];
+                buffer[1] = value[Index + 6];
+                buffer[2] = value[Index + 5];
+                buffer[3] = value[Index + 4];
+                buffer[4] = value[Index + 3];
+                buffer[5] = value[Index + 2];
+                buffer[6] = value[Index + 1];
+                buffer[7] = value[Index + 0];
+                break;
+            }
+            case BADC: {
+                buffer[0] = value[Index + 6];
+                buffer[1] = value[Index + 7];
+                buffer[2] = value[Index + 4];
+                buffer[3] = value[Index + 5];
+                buffer[4] = value[Index + 2];
+                buffer[5] = value[Index + 3];
+                buffer[6] = value[Index + 0];
+                buffer[7] = value[Index + 1];
+                break;
+            }
+
+            case CDAB: {
+                buffer[0] = value[Index + 1];
+                buffer[1] = value[Index + 0];
+                buffer[2] = value[Index + 3];
+                buffer[3] = value[Index + 2];
+                buffer[4] = value[Index + 5];
+                buffer[5] = value[Index + 4];
+                buffer[6] = value[Index + 7];
+                buffer[7] = value[Index + 6];
+                break;
+            }
+            case DCBA: {
+                buffer[0] = value[Index + 0];
+                buffer[1] = value[Index + 1];
+                buffer[2] = value[Index + 2];
+                buffer[3] = value[Index + 3];
+                buffer[4] = value[Index + 4];
+                buffer[5] = value[Index + 5];
+                buffer[6] = value[Index + 6];
+                buffer[7] = value[Index + 7];
+                break;
+            }
+        }
+        return buffer;
+    }
+
+
+    /**
+     * 鍙嶈浆澶氬瓧鑺傜殑鏁版嵁淇℃伅
+     *
+     * @param value 鏁版嵁瀛楄妭
+     * @return 瀹為檯瀛楄妭淇℃伅
+     */
+    protected byte[] ByteTransDataFormat8(byte[] value) {
+        return ByteTransDataFormat8(value, 0);
+    }
+}
diff --git a/src/main/java/com/zy/gateway/core/transfer/ByteTransformHelper.java b/src/main/java/com/zy/gateway/core/transfer/ByteTransformHelper.java
new file mode 100644
index 0000000..bec4ff0
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/transfer/ByteTransformHelper.java
@@ -0,0 +1,175 @@
+package com.zy.gateway.core.transfer;
+
+import com.zy.gateway.core.base.SoftBasic;
+import com.zy.gateway.core.domain.FunctionOperateExOne;
+import com.zy.gateway.core.domain.OperateResultExOne;
+
+public class ByteTransformHelper {
+
+    /**
+     * 缁撴灉杞崲鎿嶄綔鐨勫熀纭�鏂规硶锛岄渶瑕佹敮鎸佺被鍨嬶紝鍙婅浆鎹㈢殑濮旀墭
+     * @param result 鏁版嵁婧�
+     * @param translator 杞崲鏂瑰紡
+     * @param <TResult> 缁撴灉绫诲瀷
+     * @return 鏈�鏂扮殑缁撴灉瀵硅薄
+     */
+    public static <TResult> OperateResultExOne<TResult> GetResultFromBytes(OperateResultExOne<byte[]> result, FunctionOperateExOne<byte[], TResult> translator )
+    {
+        OperateResultExOne<TResult> tmp = new OperateResultExOne<TResult>( );
+        try
+        {
+            if (result.IsSuccess)
+            {
+                tmp.Content = translator.Action( result.Content );
+                tmp.IsSuccess = result.IsSuccess;
+            }
+            tmp.CopyErrorFromOther( result );
+        }
+        catch (Exception ex)
+        {
+            tmp.Message = "鏁版嵁杞寲澶辫触锛屾簮鏁版嵁锛�" + SoftBasic.ByteToHexString( result.Content ) + " 娑堟伅锛�" + ex.getMessage();
+        }
+
+        return tmp;
+
+    }
+
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<Boolean> GetBoolResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result, new FunctionOperateExOne<byte[], Boolean>(){
+            @Override
+            public Boolean Action(byte[] content) {
+                return byteTransform.TransBool( content, 0 );
+            }
+        });
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<Byte> GetByteResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result,new FunctionOperateExOne<byte[], Byte>(){
+            @Override
+            public Byte Action(byte[] content) {
+                return byteTransform.TransByte( content, 0 );
+            }
+        });
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<Short> GetInt16ResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result,new FunctionOperateExOne<byte[], Short>(){
+            @Override
+            public Short Action(byte[] content) {
+                return byteTransform.TransInt16( content, 0 );
+            }
+        } );
+    }
+
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<Integer> GetInt32ResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result, new FunctionOperateExOne<byte[], Integer>(){
+            @Override
+            public Integer Action(byte[] content) {
+                return byteTransform.TransInt32( content, 0 );
+            }
+        });
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<Long> GetInt64ResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result, new FunctionOperateExOne<byte[], Long>(){
+            @Override
+            public Long Action(byte[] content) {
+                return byteTransform.TransInt64( content, 0 );
+            }
+        });
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<Float> GetSingleResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result, new FunctionOperateExOne<byte[], Float>(){
+            @Override
+            public Float Action(byte[] content) {
+                return byteTransform.TransSingle( content, 0 );
+            }
+        } );
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<Double> GetDoubleResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result, new FunctionOperateExOne<byte[], Double>(){
+            @Override
+            public Double Action(byte[] content) {
+                return byteTransform.TransDouble( content, 0 );
+            }
+        });
+    }
+
+
+    /**
+     * 灏嗘寚瀹氱殑OperateResult绫诲瀷杞寲
+     * @param result 鍘熷鐨勭被鍨�
+     * @param byteTransform 鏁版嵁杞崲鏂规硶
+     * @return 杞寲鍚庣殑绫诲瀷
+     */
+    public static OperateResultExOne<String> GetStringResultFromBytes( OperateResultExOne<byte[]> result, IByteTransform byteTransform )
+    {
+        return GetResultFromBytes( result, new FunctionOperateExOne<byte[], String>(){
+            @Override
+            public String Action(byte[] content) {
+                return byteTransform.TransString( content, 0, content.length, "US-ASCII" );
+            }
+        } );
+    }
+
+}
diff --git a/src/main/java/com/zy/gateway/core/transfer/DataFormat.java b/src/main/java/com/zy/gateway/core/transfer/DataFormat.java
new file mode 100644
index 0000000..c3d62c9
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/transfer/DataFormat.java
@@ -0,0 +1,23 @@
+package com.zy.gateway.core.transfer;
+
+/**
+ * 搴旂敤浜庡瀛楄妭鏁版嵁鐨勮В鏋愭垨鏄敓鎴愭牸寮�
+ */
+public enum DataFormat {
+    /**
+     * 鎸夌収椤哄簭鐨勬牸寮忕敓鎴愮殑瑙f瀽瑙勫垯
+     */
+    ABCD,
+    /**
+     * 鎸夌収鍗曞瓧鍙嶈浆
+     */
+    BADC,
+    /**
+     * 鎸夌収鍙屽瓧鍙嶈浆
+     */
+    CDAB,
+    /**
+     * 鎸夌収鍊掑簭鎺掑簭
+     */
+    DCBA
+}
diff --git a/src/main/java/com/zy/gateway/core/transfer/IByteTransform.java b/src/main/java/com/zy/gateway/core/transfer/IByteTransform.java
new file mode 100644
index 0000000..3f286e9
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/transfer/IByteTransform.java
@@ -0,0 +1,264 @@
+package com.zy.gateway.core.transfer;
+
+public interface IByteTransform {
+
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇鍑篵ool缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return boolean鍊�
+     */
+    boolean TransBool(byte[] buffer, int index);
+
+    /**
+     * 缂撳瓨涓彁鍙朾yte缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return byte瀵硅薄
+     */
+    byte TransByte(byte[] buffer, int index);
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇byte鏁扮粍缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return
+     */
+    byte[] TransByte(byte[] buffer, int index, int length);
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇short缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return short瀵硅薄
+     */
+    short TransInt16(byte[] buffer, int index);
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇short缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return short鏁扮粍瀵硅薄
+     */
+    short[] TransInt16(byte[] buffer, int index, int length);
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇int缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return int瀵硅薄
+     */
+    int TransInt32(byte[] buffer, int index);
+
+
+    /**
+     *  浠庣紦瀛樹腑鎻愬彇int鏁扮粍缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return int鏁扮粍瀵硅薄
+     */
+    int[] TransInt32(byte[] buffer, int index, int length);
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇long缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return long瀵硅薄
+     */
+    long TransInt64(byte[] buffer, int index);
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇long鏁扮粍缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return long鏁扮粍瀵硅薄
+     */
+    long[] TransInt64(byte[] buffer, int index, int length);
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇float缁撴灉
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index 绱㈠紩浣嶇疆
+     * @return float瀵硅薄
+     */
+    float TransSingle(byte[] buffer, int index);
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇float鏁扮粍缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return float鏁扮粍瀵硅薄
+     */
+    float[] TransSingle(byte[] buffer, int index, int length);
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇double缁撴灉
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index 绱㈠紩浣嶇疆
+     * @return double瀵硅薄
+     */
+    double TransDouble(byte[] buffer, int index);
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇double鏁扮粍缁撴灉
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index 绱㈠紩浣嶇疆
+     * @param length 璇诲彇鐨勬暟缁勯暱搴�
+     * @return double鏁扮粍
+     */
+    double[] TransDouble(byte[] buffer, int index, int length);
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇string缁撴灉锛屼娇鐢ㄦ寚瀹氱殑缂栫爜
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index 绱㈠紩浣嶇疆
+     * @param length byte鏁扮粍闀垮害
+     * @param encoding 瀛楃涓茬殑缂栫爜
+     * @return string瀵硅薄
+     */
+    String TransString(byte[] buffer, int index, int length, String encoding);
+
+
+
+
+
+
+
+
+
+
+
+    /**
+     * bool鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(boolean value);
+
+
+    /**
+     * bool鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(boolean[] values);
+
+
+    /**
+     * byte鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(byte value);
+
+    /**
+     * short鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(short value);
+
+    /**
+     * short鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(short[] values);
+
+
+    /**
+     * int鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(int value);
+
+
+    /**
+     * int鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(int[] values);
+
+    /**
+     * long鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(long value);
+
+
+    /**
+     * long鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return v
+     */
+    byte[] TransByte(long[] values);
+
+
+    /**
+     * float鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(float value);
+
+
+    /**
+     * float鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(float[] values);
+
+
+    /**
+     * double鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(double value);
+
+    /**
+     * double鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(double[] values);
+
+    /**
+     * 浣跨敤鎸囧畾鐨勭紪鐮佸瓧绗︿覆杞寲缂撳瓨鏁版嵁
+     * @param value 绛夊緟杞寲鐨勬暟鎹�
+     * @param encoding 瀛楃涓茬殑缂栫爜鏂瑰紡
+     * @return buffer鏁版嵁
+     */
+    byte[] TransByte(String value, String encoding);
+
+
+    /**
+     * 璁剧疆鏁版嵁瑙f瀽鐨勬牸寮忥紝ABCD锛孊ADC锛孋DAB锛孌CBA鏍煎紡
+     * @param dataFormat
+     */
+    void setDataFormat(DataFormat dataFormat);
+
+    /**
+     * 鑾峰彇鏁版嵁瑙f瀽鐨勬牸寮忥紝榛樿ABCD锛屽彲閫塀ADC锛孋DAB锛孌CBA鏍煎紡
+     * @return
+     */
+    DataFormat getDataFormat();
+}
diff --git a/src/main/java/com/zy/gateway/core/transfer/ReverseBytesTransform.java b/src/main/java/com/zy/gateway/core/transfer/ReverseBytesTransform.java
new file mode 100644
index 0000000..eeba225
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/transfer/ReverseBytesTransform.java
@@ -0,0 +1,212 @@
+package com.zy.gateway.core.transfer;
+
+import com.zy.gateway.core.utils.Utilities;
+
+/**
+ * 鍙嶈浆鐨勫瓧鑺傚彉鎹㈢被
+ */
+public class ReverseBytesTransform extends ByteTransformBase
+{
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇short缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return short瀵硅薄
+     */
+    @Override
+    public short TransInt16( byte[] buffer, int index ) {
+        byte[] tmp = new byte[2];
+        tmp[0] = buffer[1 + index];
+        tmp[1] = buffer[0 + index];
+        return Utilities.getShort(tmp, 0);
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇int缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return int瀵硅薄
+     */
+    @Override
+    public int TransInt32( byte[] buffer, int index ) {
+        byte[] tmp = new byte[4];
+        tmp[0] = buffer[3 + index];
+        tmp[1] = buffer[2 + index];
+        tmp[2] = buffer[1 + index];
+        tmp[3] = buffer[0 + index];
+        return Utilities.getInt(ByteTransDataFormat4(tmp),0);
+    }
+
+
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇long缁撴灉
+     * @param buffer 缂撳瓨鏁版嵁
+     * @param index 绱㈠紩浣嶇疆
+     * @return long瀵硅薄
+     */
+    @Override
+    public long TransInt64( byte[] buffer, int index ) {
+        byte[] tmp = new byte[8];
+        tmp[0] = buffer[7 + index];
+        tmp[1] = buffer[6 + index];
+        tmp[2] = buffer[5 + index];
+        tmp[3] = buffer[4 + index];
+        tmp[4] = buffer[3 + index];
+        tmp[5] = buffer[2 + index];
+        tmp[6] = buffer[1 + index];
+        tmp[7] = buffer[0 + index];
+        return Utilities.getLong(ByteTransDataFormat8(tmp), 0);
+    }
+
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇float缁撴灉
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index 绱㈠紩浣嶇疆
+     * @return float瀵硅薄
+     */
+    @Override
+    public float TransSingle( byte[] buffer, int index ) {
+        byte[] tmp = new byte[4];
+        tmp[0] = buffer[3 + index];
+        tmp[1] = buffer[2 + index];
+        tmp[2] = buffer[1 + index];
+        tmp[3] = buffer[0 + index];
+        return Utilities.getFloat(ByteTransDataFormat4(tmp), 0);
+    }
+
+
+    /**
+     * 浠庣紦瀛樹腑鎻愬彇double缁撴灉
+     * @param buffer 缂撳瓨瀵硅薄
+     * @param index 绱㈠紩浣嶇疆
+     * @return double瀵硅薄
+     */
+    @Override
+    public double TransDouble( byte[] buffer, int index ) {
+        byte[] tmp = new byte[8];
+        tmp[0] = buffer[7 + index];
+        tmp[1] = buffer[6 + index];
+        tmp[2] = buffer[5 + index];
+        tmp[3] = buffer[4 + index];
+        tmp[4] = buffer[3 + index];
+        tmp[5] = buffer[2 + index];
+        tmp[6] = buffer[1 + index];
+        tmp[7] = buffer[0 + index];
+        return Utilities.getDouble(ByteTransDataFormat8(tmp), 0);
+    }
+
+
+
+
+
+
+    /**
+     * short鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    @Override
+    public byte[] TransByte( short[] values ) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 2];
+        for (int i = 0; i < values.length; i++) {
+            byte[] tmp = Utilities.getBytes(values[i]);
+            Utilities.bytesReverse(tmp);
+            System.arraycopy(tmp, 0, buffer, 2 * i, tmp.length);
+        }
+
+        return buffer;
+    }
+
+
+
+    /**
+     * int鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    @Override
+    public byte[] TransByte( int[] values ) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 4];
+        for (int i = 0; i < values.length; i++) {
+            byte[] tmp = Utilities.getBytes(values[i]);
+            Utilities.bytesReverse(tmp);
+            System.arraycopy(ByteTransDataFormat4(tmp), 0, buffer, 4 * i, tmp.length);
+        }
+
+        return buffer;
+    }
+
+
+    /**
+     * long鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    @Override
+    public byte[] TransByte( long[] values ) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 8];
+        for (int i = 0; i < values.length; i++) {
+            byte[] tmp = Utilities.getBytes(values[i]);
+            Utilities.bytesReverse(tmp);
+            System.arraycopy(ByteTransDataFormat8(tmp), 0, buffer, 8 * i, tmp.length);
+        }
+
+        return buffer;
+    }
+
+
+
+    /**
+     * float鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    @Override
+    public byte[] TransByte( float[] values ) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 4];
+        for (int i = 0; i < values.length; i++) {
+            byte[] tmp = Utilities.getBytes(values[i]);
+            Utilities.bytesReverse(tmp);
+            System.arraycopy(ByteTransDataFormat4(tmp), 0, buffer, 4 * i, tmp.length);
+        }
+
+        return buffer;
+    }
+
+
+
+    /**
+     * double鏁扮粍鍙橀噺杞寲缂撳瓨鏁版嵁
+     * @param values 绛夊緟杞寲鐨勬暟缁�
+     * @return buffer鏁版嵁
+     */
+    @Override
+    public byte[] TransByte( double[] values ) {
+        if (values == null) return null;
+
+        byte[] buffer = new byte[values.length * 8];
+        for (int i = 0; i < values.length; i++) {
+            byte[] tmp = Utilities.getBytes(values[i]);
+            Utilities.bytesReverse(tmp);
+            System.arraycopy(ByteTransDataFormat8(tmp), 0, buffer, 8 * i, tmp.length);
+        }
+
+        return buffer;
+    }
+
+
+}
diff --git a/src/main/java/com/zy/gateway/core/utils/Utilities.java b/src/main/java/com/zy/gateway/core/utils/Utilities.java
new file mode 100644
index 0000000..c001703
--- /dev/null
+++ b/src/main/java/com/zy/gateway/core/utils/Utilities.java
@@ -0,0 +1,379 @@
+package com.zy.gateway.core.utils;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+
+/**
+ * 涓�涓伐鍏风被锛屼负浜嗘敮鎸佸拰C#绋嬪簭閫氫俊浜や簰鐨勮浆鎹㈠伐鍏风被
+ */
+public class Utilities {
+
+    /**
+     * 灏唖hort鏁版嵁绫诲瀷杞寲鎴怋yte鏁扮粍
+     * @param data short鍊�
+     * @return byte[]鏁扮粍
+     */
+    public static byte[] getBytes(short data) {
+        byte[] bytes = new byte[2];
+        bytes[0] = (byte) (data & 0xff);
+        bytes[1] = (byte) ((data & 0xff00) >> 8);
+        return bytes;
+    }
+
+    /**
+     * 灏唅nt鏁版嵁绫诲瀷杞寲鎴怋yte鏁扮粍
+     * @param data int鍊�
+     * @return byte[]鏁扮粍
+     */
+    public static byte[] getBytes(int data) {
+        byte[] bytes = new byte[4];
+        bytes[0] = (byte) (data & 0xff);
+        bytes[1] = (byte) ((data >> 8) & 0xff);
+        bytes[2] = (byte) ((data >> 16) & 0xff);
+        bytes[3] = (byte) ((data >> 24) & 0xff);
+        return bytes;
+    }
+
+    /**
+     * 灏唋ong鏁版嵁绫诲瀷杞寲鎴怋yte鏁扮粍
+     * @param data long鍊�
+     * @return byte[]鏁扮粍
+     */
+    public static byte[] getBytes(long data) {
+        byte[] bytes = new byte[8];
+        bytes[0] = (byte) (data & 0xff);
+        bytes[1] = (byte) ((data >> 8) & 0xff);
+        bytes[2] = (byte) ((data >> 16) & 0xff);
+        bytes[3] = (byte) ((data >> 24) & 0xff);
+        bytes[4] = (byte) ((data >> 32) & 0xff);
+        bytes[5] = (byte) ((data >> 40) & 0xff);
+        bytes[6] = (byte) ((data >> 48) & 0xff);
+        bytes[7] = (byte) ((data >> 56) & 0xff);
+        return bytes;
+    }
+
+    /**
+     * 灏唂loat鏁版嵁绫诲瀷杞寲鎴怋yte鏁扮粍
+     * @param data float鍊�
+     * @return byte[]鏁扮粍
+     */
+    public static byte[] getBytes(float data) {
+        int intBits = Float.floatToIntBits(data);
+        return getBytes(intBits);
+    }
+
+    /**
+     * 灏哾ouble鏁版嵁绫诲瀷杞寲鎴怋yte鏁扮粍
+     * @param data double鍊�
+     * @return byte[]鏁扮粍
+     */
+    public static byte[] getBytes(double data) {
+        long intBits = Double.doubleToLongBits(data);
+        return getBytes(intBits);
+    }
+
+
+    /**
+     * 灏嗗瓧绗︿覆杞崲鎴恇yte[]鏁扮粍
+     * @param data 瀛楃涓插��
+     * @param charsetName 缂栫爜鏂瑰紡
+     * @return 瀛楄妭鏁扮粍
+     */
+    public static byte[] getBytes(String data, String charsetName) {
+        Charset charset = Charset.forName(charsetName);
+        return data.getBytes(charset);
+    }
+
+
+    /**
+     * 灏唅nt杞崲鎴愪竴涓瓧鑺傜殑鏁版嵁
+     * @param num int鏁版嵁
+     * @return 涓�涓瓧鑺傜殑鏁版嵁
+     */
+    public static byte int2OneByte(int num) {
+        return (byte) (num & 0x000000ff);
+    }
+
+
+    /**
+     * 灏嗕竴涓湁绗﹀彿鐨刡yte杞崲鎴愪竴涓猧nt鏁版嵁瀵硅薄
+     * @param byteNum 鏈夌鍙风殑瀛楄妭瀵硅薄
+     * @return int鏁版嵁绫诲瀷
+     */
+    public static int oneByte2Int(byte byteNum) {
+        //閽堝姝f暟鐨刬nt
+        return byteNum > 0 ? byteNum : 256+ byteNum;
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚short鏁版嵁
+     * @param bytes 瀛楄妭鏁扮粍
+     * @param index 璧峰浣嶇疆
+     * @return short鍊�
+     */
+    public static short getShort(byte[] bytes,int index) {
+        return (short) ((0xff & bytes[0 + index]) | (0xff00 & (bytes[1 + index] << 8)));
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚int鏁版嵁
+     * @param bytes 瀛楄妭鏁扮粍
+     * @param index 璧峰浣嶇疆
+     * @return int鍊�
+     */
+    public static int getInt(byte[] bytes,int index) {
+        return (0xff & bytes[0 + index]) |
+                (0xff00 & (bytes[1 + index] << 8)) |
+                (0xff0000 & (bytes[2 + index] << 16)) |
+                (0xff000000 & (bytes[3 + index] << 24));
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚long鏁版嵁
+     * @param bytes 瀛楄妭鏁扮粍
+     * @param index 璧峰浣嶇疆
+     * @return long鍊�
+     */
+    public static long getLong(byte[] bytes,int index) {
+        return (0xffL & (long) bytes[0 + index]) |
+                (0xff00L & ((long) bytes[1 + index] << 8)) |
+                (0xff0000L & ((long) bytes[2 + index] << 16)) |
+                (0xff000000L & ((long) bytes[3 + index] << 24)) |
+                (0xff00000000L & ((long) bytes[4 + index] << 32)) |
+                (0xff0000000000L & ((long) bytes[5 + index] << 40)) |
+                (0xff000000000000L & ((long) bytes[6 + index] << 48)) |
+                (0xff00000000000000L & ((long) bytes[7 + index] << 56));
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚float鏁版嵁
+     * @param bytes 瀛楄妭鏁扮粍
+     * @param index 璧峰浣嶇疆
+     * @return float鍊�
+     */
+    public static float getFloat(byte[] bytes,int index) {
+        return Float.intBitsToFloat(getInt(bytes,index));
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚double鏁版嵁
+     * @param bytes 瀛楄妭鏁扮粍
+     * @param index 璧峰浣嶇疆
+     * @return double鍊�
+     */
+    public static double getDouble(byte[] bytes,int index) {
+        long l = getLong(bytes, index);
+        System.out.println(l);
+        return Double.longBitsToDouble(l);
+    }
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚string鏁版嵁
+     * @param bytes 瀛楄妭鏁扮粍
+     * @param charsetName 瀛楃缂栫爜
+     * @return string鍊�
+     */
+    public static String getString(byte[] bytes, String charsetName) {
+        return new String(bytes, Charset.forName(charsetName));
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚string鏁版嵁
+     * @param bytes 瀛楄妭鏁扮粍
+     * @param index 璧峰浣嶇疆
+     * @param length 鏁版嵁闀垮害
+     * @param charsetName 瀛楃缂栫爜
+     * @return string鍊�
+     */
+    public static String getString(byte[] bytes,int index, int length, String charsetName) {
+        return new String(bytes,index,length,Charset.forName(charsetName));
+    }
+
+
+    /**
+     * 灏嗕竴涓猙yte[]鏁扮粍杞崲鎴恥uid瀵硅薄
+     * @param data 瀛楄妭鏁扮粍
+     * @return uuid瀵硅薄
+     */
+    public static UUID Byte2UUID(byte[] data) {
+        if (data.length != 16) {
+            throw new IllegalArgumentException("Invalid UUID byte[]");
+        }
+        long msb = 0;
+        long lsb = 0;
+        for (int i = 0; i < 8; i++)
+            msb = (msb << 8) | (data[i] & 0xff);
+        for (int i = 8; i < 16; i++)
+            lsb = (lsb << 8) | (data[i] & 0xff);
+
+        return new UUID(msb, lsb);
+    }
+
+
+    /**
+     * 灏嗕竴涓猽uid瀵硅薄杞寲鎴恇yte[]
+     * @param uuid uuid瀵硅薄
+     * @return 瀛楄妭鏁扮粍
+     */
+    public static byte[] UUID2Byte(UUID uuid) {
+        ByteArrayOutputStream ba = new ByteArrayOutputStream(16);
+        DataOutputStream da = new DataOutputStream(ba);
+        try {
+            da.writeLong(uuid.getMostSignificantBits());
+            da.writeLong(uuid.getLeastSignificantBits());
+            ba.close();
+            da.close();
+        }
+        catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        byte[] buffer = ba.toByteArray();
+        // 杩涜閿欎綅
+        byte temp=buffer[0];
+        buffer[0] = buffer[3];
+        buffer[3] =temp;
+        temp=buffer[1];
+        buffer[1]=buffer[2];
+        buffer[2]=temp;
+
+        temp = buffer[4];
+        buffer[4]=buffer[5];
+        buffer[5] =temp;
+
+        temp = buffer[6];
+        buffer[6]=buffer[7];
+        buffer[7] =temp;
+
+        return buffer;
+    }
+
+
+
+    /**
+     * 灏嗗瓧绗︿覆鏁版嵁杞崲鎴愬瓧鑺傛暟缁勶紝涓昏杞崲鐢盋#鐨勫瓧绗︿覆鐨勬暟鎹�
+     * @param str 瀛楃涓蹭俊鎭�
+     * @return 杞寲鍚庣殑瀛楄妭鏁扮粍
+     */
+    public static byte[] string2Byte(String str) {
+        if (str == null) {
+            return null;
+        }
+        byte[] byteArray;
+        try {
+            byteArray = str.getBytes("unicode");
+        } catch (Exception ex) {
+            byteArray = str.getBytes();
+        }
+
+        if (byteArray.length >= 2) {
+            if (byteArray[0] == -1 && byteArray[1] == -2) {
+                byte[] newArray = new byte[byteArray.length - 2];
+                System.arraycopy(byteArray, 2, newArray, 0, newArray.length);
+                byteArray = newArray;
+            } else if (byteArray[0] == -2 && byteArray[1] == -1) {
+                for (int i = 0; i < byteArray.length; i++) {
+                    byte temp = byteArray[i];
+                    byteArray[i] = byteArray[i + 1];
+                    byteArray[i + 1] = temp;
+                    i++;
+                }
+
+
+                byte[] newArray = new byte[byteArray.length - 2];
+                System.arraycopy(byteArray, 2, newArray, 0, newArray.length);
+                byteArray = newArray;
+            }
+        }
+
+        return byteArray;
+    }
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚瀛楃涓插璞★紝涓昏杞崲鐢盋#鐨勫瓧绗︿覆鐨勬暟鎹�
+     * @param byteArray
+     * @return
+     */
+    public static String byte2String(byte[] byteArray) {
+        if (byteArray == null) {
+            return null;
+        }
+
+        for (int i = 0; i < byteArray.length; i++) {
+            byte temp = byteArray[i];
+            byteArray[i] = byteArray[i + 1];
+            byteArray[i + 1] = temp;
+            i++;
+        }
+        String str;
+        try {
+            str = new String(byteArray, "unicode");
+        } catch (Exception ex) {
+            str = new String(byteArray);
+        }
+        return str;
+    }
+
+    /**
+     * 灏哹yte[]鏁扮粍鐨勬暟鎹繘琛岀炕杞�
+     * @param reverse 绛夊緟鍙嶈浆鐨勫瓧绗︿覆
+     */
+    public static void bytesReverse(byte[] reverse) {
+        if (reverse != null) {
+            byte tmp = 0;
+            for (int i = 0; i < reverse.length / 2; i++) {
+                tmp = reverse[i];
+                reverse[i] = reverse[reverse.length - 1 - i];
+                reverse[reverse.length - 1 - i] = tmp;
+            }
+        }
+    }
+
+
+
+    private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5',
+            '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+
+    /**
+     * 灏嗗瓧鑺傛暟缁勮浆鎹㈡垚鍗佸叚杩涘埗鐨勫瓧绗︿覆褰㈠紡
+     * @param bytes 鍘熷鐨勫瓧鑺傛暟缁�
+     * @return 瀛楃涓蹭俊鎭�
+     */
+    public static String bytes2HexString(byte[] bytes) {
+        char[] buf = new char[bytes.length * 2];
+        int index = 0;
+        for(byte b : bytes) { // 鍒╃敤浣嶈繍绠楄繘琛岃浆鎹紝鍙互鐪嬩綔鏂规硶涓�鐨勫彉绉�
+            buf[index++] = HEX_CHAR[b >>> 4 & 0xf];
+            buf[index++] = HEX_CHAR[b & 0xf];
+        }
+
+        return new String(buf);
+    }
+
+    /**
+     * 鑾峰彇鎸囧畾鏃堕棿鐨勬寚瀹氭牸寮忕殑瀛楃涓�
+     * @param date 鎸囧畾鐨勬椂闂�
+     * @param format 鎸囧畾鐨勬牸寮�
+     * @return 鏈�鍚庡瓧绗︿覆淇℃伅
+     */
+    public static String getStringDateShort(Date date,String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String dateString = formatter.format(date);
+        return dateString;
+    }
+}
diff --git a/src/main/java/com/zy/gateway/pipeline/Bootstrap.java b/src/main/java/com/zy/gateway/pipeline/Bootstrap.java
new file mode 100644
index 0000000..b9d6fb3
--- /dev/null
+++ b/src/main/java/com/zy/gateway/pipeline/Bootstrap.java
@@ -0,0 +1,12 @@
+package com.zy.gateway.pipeline;
+
+
+/**
+ * Created by vincent on 2020-06-04
+ */
+public interface Bootstrap {
+
+    void serverStart() throws Exception;
+
+    void destroy();
+}
diff --git a/src/main/java/com/zy/gateway/pipeline/HandlerInitializer.java b/src/main/java/com/zy/gateway/pipeline/HandlerInitializer.java
new file mode 100644
index 0000000..cdd15bd
--- /dev/null
+++ b/src/main/java/com/zy/gateway/pipeline/HandlerInitializer.java
@@ -0,0 +1,51 @@
+package com.zy.gateway.pipeline;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelInitializer;
+import io.netty.handler.timeout.IdleStateHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * handler绠¢亾
+ * 鎺у埗鎵�鏈塶etty handler娴佸悜
+ * 寰呭畬鎴�: 鍔ㄦ�佺鐞唄andler
+ * Created by vincent on 2019-04-02
+ */
+@Component
+@ChannelHandler.Sharable
+public class HandlerInitializer extends ChannelInitializer<Channel> {
+
+    @Autowired
+    private PipelineProperties pipelineProperties;
+
+    /**
+     * Set some channel handlers on channel pipeline
+     */
+    @Override
+    protected void initChannel(Channel channel) {
+        channel.pipeline()
+                // 蹇冭烦
+                .addLast(new IdleStateHandler(pipelineProperties.getHeartSeconds(), 0, 0))
+//                // 缂栫爜鍣�
+//                .addLast(protocolEncoder)
+//                // 瑙g爜鍣�
+//                .addLast(new ProtocolDecoder(4096))
+//                // 鏍¢獙鐮佸鐞嗗櫒
+//                .addLast(validateHandler)
+//                // 璁よ瘉澶勭悊鍣�
+//                .addLast(vehAuthHandler)
+//                // 涓氬姟澶勭悊鍣�
+//                .addLast(gbPackageServerHandler)
+//                // 閫氶亾淇濇姢鍣�
+//                .addLast(protectorHandler)
+        ;
+
+        // Channel灞�閮ㄥ彉閲忥紝鐩稿綋浜庣嚎绋嬬殑ThreadLocal
+//        initAttrTrack(channel);
+    }
+
+
+}
diff --git a/src/main/java/com/zy/gateway/pipeline/PipelineBootstrap.java b/src/main/java/com/zy/gateway/pipeline/PipelineBootstrap.java
new file mode 100644
index 0000000..f8ccf06
--- /dev/null
+++ b/src/main/java/com/zy/gateway/pipeline/PipelineBootstrap.java
@@ -0,0 +1,81 @@
+package com.zy.gateway.pipeline;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.buffer.PooledByteBufAllocator;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.util.ResourceLeakDetector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+/**
+ * 杈撻�佽澶囩綉鍏冲紩瀵肩被
+ * Created by vincent on 2020-06-04
+ */
+@Component
+public class PipelineBootstrap implements Bootstrap {
+
+    private static Logger log = LoggerFactory.getLogger(PipelineBootstrap.class);
+
+    private Channel channel;
+    private ServerBootstrap bootstrap;
+    private EventLoopGroup bossGroup;
+    private EventLoopGroup workerGroup;
+    @Autowired
+    private PipelineProperties pipelineProperties;
+    @Autowired
+    private HandlerInitializer handlerInitializer;
+
+    {
+        bootstrap = new ServerBootstrap();
+        bossGroup = new NioEventLoopGroup(1);
+        workerGroup = new NioEventLoopGroup();
+    }
+
+    /**
+     * 缃戝叧鍚姩鍒濆鍖�
+     */
+    @Override
+    @PostConstruct
+    public void serverStart() throws Exception {
+        bootstrap.group(bossGroup, workerGroup)
+                .channel(NioServerSocketChannel.class)
+                .childHandler(handlerInitializer)
+                .option(ChannelOption.SO_BACKLOG, pipelineProperties.getBacklog())
+                .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
+                .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
+                .childOption(ChannelOption.SO_KEEPALIVE, pipelineProperties.isKeepAlive())
+                .childOption(ChannelOption.SO_SNDBUF, pipelineProperties.getSndbuf())
+                .childOption(ChannelOption.SO_RCVBUF, pipelineProperties.getRcvbuf());
+
+        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
+
+        log.info("TCP server started successfully, port锛歿}", pipelineProperties.getTcpPort());
+
+        channel = bootstrap.bind(pipelineProperties.getTcpPort()).sync().channel();
+    }
+
+    @Override
+    @PreDestroy
+    public void destroy() {
+        if (channel != null && channel.isActive()) {
+            channel.close();
+        }
+        if (bossGroup != null) {
+            bossGroup.shutdownGracefully();
+        }
+        if (workerGroup != null) {
+            workerGroup.shutdownGracefully();
+        }
+        log.info("TCP server stopped successfully, port: {}", pipelineProperties.getTcpPort());
+    }
+}
+
diff --git a/src/main/java/com/zy/gateway/pipeline/PipelineProperties.java b/src/main/java/com/zy/gateway/pipeline/PipelineProperties.java
new file mode 100644
index 0000000..a2d1a1f
--- /dev/null
+++ b/src/main/java/com/zy/gateway/pipeline/PipelineProperties.java
@@ -0,0 +1,96 @@
+package com.zy.gateway.pipeline;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * vc绯荤粺閰嶇疆
+ * Created by luxiaotao on 2018/10/15
+ */
+@Configuration
+@ConfigurationProperties(prefix = "pipeline")
+public class PipelineProperties {
+
+    public static String HOST_NAME;
+
+    static {
+        try {
+            HOST_NAME = InetAddress.getLocalHost().getHostName();
+        } catch (UnknownHostException e) {
+            System.err.println("find hostname err");
+        }
+    }
+
+    private int tcpPort;
+
+    private int heartSeconds;
+
+    private int backlog;
+
+    private boolean keepAlive;
+
+    private int sndbuf;
+
+    private int rcvbuf;
+
+    private boolean printPacLog;
+
+    public int getTcpPort() {
+        return tcpPort;
+    }
+
+    public void setTcpPort(int tcpPort) {
+        this.tcpPort = tcpPort;
+    }
+
+    public int getHeartSeconds() {
+        return heartSeconds;
+    }
+
+    public void setHeartSeconds(int heartSeconds) {
+        this.heartSeconds = heartSeconds;
+    }
+
+    public int getBacklog() {
+        return backlog;
+    }
+
+    public void setBacklog(int backlog) {
+        this.backlog = backlog;
+    }
+
+    public boolean isKeepAlive() {
+        return keepAlive;
+    }
+
+    public void setKeepAlive(boolean keepAlive) {
+        this.keepAlive = keepAlive;
+    }
+
+    public int getSndbuf() {
+        return sndbuf;
+    }
+
+    public void setSndbuf(int sndbuf) {
+        this.sndbuf = sndbuf;
+    }
+
+    public int getRcvbuf() {
+        return rcvbuf;
+    }
+
+    public void setRcvbuf(int rcvbuf) {
+        this.rcvbuf = rcvbuf;
+    }
+
+    public boolean isPrintPacLog() {
+        return printPacLog;
+    }
+
+    public void setPrintPacLog(final boolean printPacLog) {
+        this.printPacLog = printPacLog;
+    }
+}
diff --git a/src/main/java/com/zy/gateway/pipeline/Test.java b/src/main/java/com/zy/gateway/pipeline/Test.java
new file mode 100644
index 0000000..35bd9f7
--- /dev/null
+++ b/src/main/java/com/zy/gateway/pipeline/Test.java
@@ -0,0 +1,21 @@
+package com.zy.gateway.pipeline;
+
+import com.github.s7connector.api.S7Connector;
+import com.github.s7connector.api.factory.S7ConnectorFactory;
+
+/**
+ * Created by vincent on 2020-06-04
+ */
+public class Test {
+
+    public static void main(String[] args) {
+        S7Connector connector = S7ConnectorFactory
+                        .buildTCPConnector()
+                        .withHost("10.0.0.220")
+                        .withPort(90)
+                        .withRack(0) //鏈烘灦
+                        .withSlot(2) //optional
+                        .build();
+
+    }
+}

--
Gitblit v1.9.1