From 43b0d5870d528f23ecd6aeceb6cfd4325188b46f Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 01 七月 2021 15:50:43 +0800 Subject: [PATCH] Revert "1" --- HDL_ON/DAL/DriverLayer/Target.cs | 142 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Target.cs b/HDL_ON/DAL/DriverLayer/Target.cs new file mode 100644 index 0000000..e156080 --- /dev/null +++ b/HDL_ON/DAL/DriverLayer/Target.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Text; +using HDL_ON.Entity; + +namespace HDL_ON.DriverLayer +{ + /// <summary> + /// 鎺у埗鏁版嵁鍖呭ご + /// bus鏁版嵁鍖呭ご + /// </summary> + public class Target + { + /// <summary> + /// 鐩爣绔彛 + /// </summary> + public System.Net.IPEndPoint IPEndPoint; + /// <summary> + /// 鏈満璁惧绫诲瀷 + /// </summary> + int deviceType = 58037; + + public Target() + { } + + public Target(System.Net.IPEndPoint ipEndPoint) + { + this.IPEndPoint = ipEndPoint; + } + + /// <summary> + /// 闄勫姞鏁版嵁 + /// </summary> + public byte[] AddData; + + /// <summary> + /// 鐩爣瀛愮綉鍙� + /// </summary> + public byte SubnetID; + + /// <summary> + /// 鐩爣璁惧鍙� + /// </summary> + public byte DeviceID; + + public byte[] GetGatewayIp_SendBytes; + + public byte [] SendBytes { + get { + if (2 + 9 + AddData.Length + 2 <= 81&&Command!=Command.SuperGatewayAgent) { + byte [] bytes = new byte [16 + 9 + AddData.Length + 2]; + + string [] ipAddress = "192.168.1.20".Split ('.');//new Net.NetWiFi().IpAddress.ToString().Split('.'); + + bytes [0] = byte.Parse (ipAddress [0]); + bytes [1] = byte.Parse (ipAddress [1]); + bytes [2] = byte.Parse (ipAddress [2]); + bytes [3] = byte.Parse (ipAddress [3]); + + bytes [4] = (byte)'H';//H + bytes [5] = (byte)'D';//D + bytes [6] = (byte)'L';//L + bytes [7] = (byte)'M';//M + bytes [8] = (byte)'I';//I + bytes [9] = (byte)'R';//R + bytes [10] = (byte)'A';//A + bytes [11] = (byte)'C';//C + bytes [12] = (byte)'L';//L + bytes [13] = (byte)'E';//E + + bytes [14] = 0xAA; + bytes [15] = 0xAA; + + bytes [16] = (byte)(11 + AddData.Length); + bytes [17] = 0; //婧愬瓙缃戝彿 + bytes [18] = 252; //婧愯澶囧彿 + bytes [19] = (byte)(deviceType/256); + bytes [20] = (byte)(deviceType%256); + bytes [21] = (byte)((int)this.Command / 256); + bytes [22] = (byte)((int)this.Command % 256); + bytes [23] = this.SubnetID;//鐩爣瀛愮綉鍙� + bytes [24] = this.DeviceID;//鐩爣璁惧鍙� + + Array.Copy (AddData, 0, bytes, 25, AddData.Length); + //CRC鏍¢獙浣� + bytes [bytes.Length - 2] = 0; + bytes [bytes.Length - 1] = 0; + + + CRC.ConCRC (ref bytes, 16, bytes.Length - 2); + + return bytes; + } else { + byte [] bytes = new byte [16 + 9 + 2 + AddData.Length]; + + string [] ipAddress = "192.168.1.20".Split ('.');//new Net.NetWiFi().IpAddress.ToString().Split('.'); + + bytes [0] = byte.Parse (ipAddress [0]); + bytes [1] = byte.Parse (ipAddress [1]); + bytes [2] = byte.Parse (ipAddress [2]); + bytes [3] = byte.Parse (ipAddress [3]); + + bytes [4] = (byte)'H';//H + bytes [5] = (byte)'D';//D + bytes [6] = (byte)'L';//L + bytes [7] = (byte)'M';//M + bytes [8] = (byte)'I';//I + bytes [9] = (byte)'R';//R + bytes [10] = (byte)'A';//A + bytes [11] = (byte)'C';//C + bytes [12] = (byte)'L';//L + bytes [13] = (byte)'E';//E + bytes [14] = 0xAA; + bytes [15] = 0xAA; + + bytes [16] = 0xFF;//鏁版嵁鍖呴暱搴� + bytes [17] = 0;//婧愬瓙缃戝彿 + bytes [18] = 252;//婧愯澶囧彿 + bytes [19] = (byte)(deviceType/256); + bytes [20] = (byte)(deviceType%256); + bytes [21] = (byte)((int)this.Command / 256); + bytes [22] = (byte)((int)this.Command % 256); + bytes [23] = this.SubnetID; + bytes [24] = this.DeviceID; + + // + bytes [25] = (byte)(AddData.Length / 256); + // + bytes [26] = (byte)(AddData.Length % 256); + + Array.Copy (AddData, 0, bytes, 27, AddData.Length); + + return bytes; + } + } + } + /// <summary> + /// 鎿嶄綔鐮� + /// </summary> + public Command Command; + } +} \ No newline at end of file -- Gitblit v1.8.0