diff --git a/BatCharging.Model/客户端发送/CMD7.cs b/BatCharging.Model/客户端发送/CMD7.cs index cfce0dd..61ade42 100644 --- a/BatCharging.Model/客户端发送/CMD7.cs +++ b/BatCharging.Model/客户端发送/CMD7.cs @@ -67,7 +67,7 @@ namespace BatCharging.Model /// /// 用户卡号/用户识别号(内容只能”0~9、A~Z、a~z 字符 ASCII 码,不够长度填’\0’) /// - public UInt32 value10 { get; set; } + public string value10 { get; set; } /// /// 断网充电标志 /// 0-不允许 diff --git a/BatCharging.Service/ChargerMgrTool.cs b/BatCharging.Service/ChargerMgrTool.cs index ebe998a..5bf3071 100644 --- a/BatCharging.Service/ChargerMgrTool.cs +++ b/BatCharging.Service/ChargerMgrTool.cs @@ -943,7 +943,6 @@ namespace BatCharging.Service } } - /// /// 接收事件 /// diff --git a/BatCharging.Service/Common/ByteUtils.cs b/BatCharging.Service/Common/ByteUtils.cs index c991897..e9d6b3d 100644 --- a/BatCharging.Service/Common/ByteUtils.cs +++ b/BatCharging.Service/Common/ByteUtils.cs @@ -170,12 +170,12 @@ namespace BatCharging.Service { Array.Copy(byteArray, 0, bytes, 0, byteArray.Length); } - else if (byteArray.Length > leng) - { - // 长度超过32字节,可以截断或者抛出异常 - Array.Copy(byteArray, 0, new byte[leng], 0, leng); // 截断数组到32字节 - } - return byteArray; + //else if (byteArray.Length > leng) + //{ + // // 长度超过32字节,可以截断或者抛出异常 + // Array.Copy(byteArray, 0, new byte[leng], 0, leng); // 截断数组到32字节 + //} + return bytes; } /// diff --git a/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs b/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs index 0f2d549..2f42ee0 100644 --- a/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs +++ b/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs @@ -341,6 +341,57 @@ namespace BatCharging.Service.DataRlt CMD114.value04 = data[44]; CMD114.value05 = data[45]; CMD114.value06 = Encoding.ASCII.GetString(data, 46, 8); + /* + 7 54 + 8 56 + 9 58 + 10 60 + 11 62 + 12 64 + 13 66 + 14 68 + 15 70 + 16 72 + 17 74 + 18 76 + 19 78 + 20 80 + 21 82 + 22 84 + 23 86 + 24 88 + 25 90 + 26 92 + 27 94 + 28 96 + 29 98 + 30 100 + 31 102 + 32 104 + 33 106 + 34 108 + 35 110 + 36 112 + 37 114 + 38 116 + 39 118 + 40 120 + 41 122 + 42 124 + 43 126 + 44 128 + 45 130 + 46 132 + 47 134 + 48 136 + 49 138 + 50 140 + 51 142 + 52 144 + 53 146 + 54 148 + + */ CMD114.value07 = ByteUtils.DToUInt16(data, 54); CMD114.value08 = ByteUtils.DToUInt16(data, 56); CMD114.value09 = ByteUtils.DToUInt16(data, 58); diff --git a/BatCharging.Service/发送方法/ChargerSendCMD.cs b/BatCharging.Service/发送方法/ChargerSendCMD.cs index 3b490d6..dec34d3 100644 --- a/BatCharging.Service/发送方法/ChargerSendCMD.cs +++ b/BatCharging.Service/发送方法/ChargerSendCMD.cs @@ -50,9 +50,9 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD1.value1)); lstContent.AddRange(BitConverter.GetBytes(CMD1.value2)); lstContent.Add(CMD1.value3); - lstContent.AddRange(BitConverter.GetBytes(CMD1.value4)); - lstContent.Add(CMD1.value5); - lstContent.AddRange(BitConverter.GetBytes(CMD1.value6)); + lstContent.AddRange(BitConverter.GetBytes(CMD1.value4));//起始地址 + lstContent.Add(CMD1.value5);//查询个数 + lstContent.AddRange(BitConverter.GetBytes(CMD1.value6));//参数字节数 if (CMD1.value3 == 1) { lstContent.AddRange(CMD1.value7); @@ -199,19 +199,20 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.value01)); lstContent.AddRange(BitConverter.GetBytes(CMD.value02)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value03)); + lstContent.Add(CMD.value03); lstContent.AddRange(BitConverter.GetBytes(CMD.value04)); lstContent.AddRange(BitConverter.GetBytes(CMD.value05)); + lstContent.AddRange(BitConverter.GetBytes(CMD.value06)); lstContent.AddRange(BitConverter.GetBytes(CMD.value07)); lstContent.AddRange(BitConverter.GetBytes(CMD.value08)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value09)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value10)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value11)); + lstContent.Add(CMD.value09); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value10, 32)); + lstContent.Add(CMD.value11); lstContent.AddRange(BitConverter.GetBytes(CMD.value12)); lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value13, 32)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value14)); + lstContent.Add(CMD.value14); lstContent.AddRange(BitConverter.GetBytes(CMD.value15)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value16)); + lstContent.Add(CMD.value16); results = lstContent.ToArray(); } return results; @@ -356,8 +357,8 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.value01)); lstContent.AddRange(BitConverter.GetBytes(CMD.value02)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value03)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value04)); + lstContent.Add(CMD.value03); + lstContent.Add(Convert.ToByte(CMD.value04)); results = lstContent.ToArray(); } @@ -571,8 +572,6 @@ namespace BatCharging.Service model.CMD = 113; model.checksumDomain = 0x01; - - model.dataDomain = GetRCMD113DataInfo(CMD); //数据域 model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度 @@ -598,8 +597,8 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.value01)); lstContent.AddRange(BitConverter.GetBytes(CMD.value02)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value03)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value04)); + lstContent.Add(CMD.value03); + lstContent.Add(Convert.ToByte(CMD.value04)); results = lstContent.ToArray(); } diff --git a/Monitor.ChargeTest/FrmChargeResult.cs b/Monitor.ChargeTest/FrmChargeResult.cs index b0f05aa..6387757 100644 --- a/Monitor.ChargeTest/FrmChargeResult.cs +++ b/Monitor.ChargeTest/FrmChargeResult.cs @@ -226,7 +226,7 @@ namespace Monitor.ChargeTest { byte type = 1;//类型 0-查询/1-设置 uint startAddress = 2;//设置/查询参数起始地址 - byte num = 3;//设置/查询个数 + byte num = 2;//设置/查询个数 byte[] setData = new byte[8];//设置数据 setData[0] = 0; setData[1] = 1; @@ -265,10 +265,18 @@ namespace Monitor.ChargeTest /// private void button16_Click(object sender, EventArgs e) { - byte type = 0; - uint startAddress = 9; - byte num = 10; - byte[] setData = null; + byte type = 1;//充电枪口 + uint startAddress = 1;//启始命令地址 + byte num = 2;//命令个数 + byte[] setData = new byte[8];//命令参数 + setData[0] = 0; + setData[1] = 1; + setData[2] = 2; + setData[3] = 3; + setData[4] = 4; + setData[5] = 5; + setData[6] = 6; + setData[7] = 7; CmnChargerParam._CHR00TCPCLIENT.Send5(type, startAddress, num, setData); } #endregion @@ -645,7 +653,7 @@ namespace Monitor.ChargeTest CMD.value07 = 5; CMD.value08 = 6; CMD.value09 = 7; - CMD.value10 = 8; + CMD.value10 = "123456789"; CMD.value11 = 9; CMD.value12 = 10; CMD.value13 = "12345678";