From 6095053a1c78f864680d956642e6e216a85029bd Mon Sep 17 00:00:00 2001 From: lch <1627445470@qq.com> Date: Tue, 19 Mar 2024 20:51:36 +0800 Subject: [PATCH] =?UTF-8?q?402=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatCharging.Service/ChargerMgrTool.cs | 1 + .../DataRlt/解析数据/MsgReceiveCMDCom.cs | 128 +++++++++--------- .../发送方法/ChargerSendCMD.cs | 2 +- 3 files changed, 66 insertions(+), 65 deletions(-) diff --git a/BatCharging.Service/ChargerMgrTool.cs b/BatCharging.Service/ChargerMgrTool.cs index f322f40..7d34543 100644 --- a/BatCharging.Service/ChargerMgrTool.cs +++ b/BatCharging.Service/ChargerMgrTool.cs @@ -1208,6 +1208,7 @@ namespace BatCharging.Service { //todo 实例化CMD201对象 CMD201 cMD201 = new CMD201(); + cMD201.value04 = "0"; //201中其他字段如何赋值 cMD201.value05 = CMD202.value17; diff --git a/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs b/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs index 134d405..d050dab 100644 --- a/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs +++ b/BatCharging.Service/DataRlt/解析数据/MsgReceiveCMDCom.cs @@ -866,51 +866,51 @@ namespace BatCharging.Service.DataRlt CMD402.timeUInt32erval7ChargingElectLevel = ((ByteUtils.DToUInt16(data, 179)) * 0.01).ToString("F2"); CMD402.timeUInt32erval8ChargingElectLevel = ((ByteUtils.DToUInt16(data, 181)) * 0.01).ToString("F2"); CMD402.timeUInt32erval9ChargingElectLevel = ((ByteUtils.DToUInt16(data, 183)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval10ChargingElectLevel = ((ByteUtils.DToUInt16(data, 183)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval11ChargingElectLevel = ((ByteUtils.DToUInt16(data, 185)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval12ChargingElectLevel = ((ByteUtils.DToUInt16(data, 187)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval13ChargingElectLevel = ((ByteUtils.DToUInt16(data, 189)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval14ChargingElectLevel = ((ByteUtils.DToUInt16(data, 191)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval15ChargingElectLevel = ((ByteUtils.DToUInt16(data, 193)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval16ChargingElectLevel = ((ByteUtils.DToUInt16(data, 195)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval17ChargingElectLevel = ((ByteUtils.DToUInt16(data, 197)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval18ChargingElectLevel = ((ByteUtils.DToUInt16(data, 199)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval19ChargingElectLevel = ((ByteUtils.DToUInt16(data, 201)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval20ChargingElectLevel = ((ByteUtils.DToUInt16(data, 203)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval21ChargingElectLevel = ((ByteUtils.DToUInt16(data, 205)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval22ChargingElectLevel = ((ByteUtils.DToUInt16(data, 207)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval23ChargingElectLevel = ((ByteUtils.DToUInt16(data, 209)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval24ChargingElectLevel = ((ByteUtils.DToUInt16(data, 211)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval25ChargingElectLevel = ((ByteUtils.DToUInt16(data, 213)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval26ChargingElectLevel = ((ByteUtils.DToUInt16(data, 215)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval27ChargingElectLevel = ((ByteUtils.DToUInt16(data, 217)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval28ChargingElectLevel = ((ByteUtils.DToUInt16(data, 219)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval29ChargingElectLevel = ((ByteUtils.DToUInt16(data, 221)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval30ChargingElectLevel = ((ByteUtils.DToUInt16(data, 223)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval31ChargingElectLevel = ((ByteUtils.DToUInt16(data, 225)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval32ChargingElectLevel = ((ByteUtils.DToUInt16(data, 227)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval33ChargingElectLevel = ((ByteUtils.DToUInt16(data, 229)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval34ChargingElectLevel = ((ByteUtils.DToUInt16(data, 231)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval35ChargingElectLevel = ((ByteUtils.DToUInt16(data, 233)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval36ChargingElectLevel = ((ByteUtils.DToUInt16(data, 235)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval37ChargingElectLevel = ((ByteUtils.DToUInt16(data, 237)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval38ChargingElectLevel = ((ByteUtils.DToUInt16(data, 239)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval39ChargingElectLevel = ((ByteUtils.DToUInt16(data, 241)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval40ChargingElectLevel = ((ByteUtils.DToUInt16(data, 243)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval41ChargingElectLevel = ((ByteUtils.DToUInt16(data, 245)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval42ChargingElectLevel = ((ByteUtils.DToUInt16(data, 247)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval43ChargingElectLevel = ((ByteUtils.DToUInt16(data, 249)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval44ChargingElectLevel = ((ByteUtils.DToUInt16(data, 251)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval45ChargingElectLevel = ((ByteUtils.DToUInt16(data, 253)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval46ChargingElectLevel = ((ByteUtils.DToUInt16(data, 255)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval47ChargingElectLevel = ((ByteUtils.DToUInt16(data, 257)) * 0.01).ToString("F2"); - CMD402.timeUInt32erval48ChargingElectLevel = ((ByteUtils.DToUInt16(data, 259)) * 0.01).ToString("F2"); - - CMD402.startWay = data[261]; - CMD402.chargingSerialNum = Encoding.ASCII.GetString(data, 262, 32); - CMD402.chargingServiceCharge = ByteUtils.DToUInt32(data, 294); - CMD402.millennialpowerConsumption = (data[298]*0.001).ToString("F4"); - CMD402.parallelChargingMark = data[299]; + CMD402.timeUInt32erval10ChargingElectLevel = ((ByteUtils.DToUInt16(data, 185)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval11ChargingElectLevel = ((ByteUtils.DToUInt16(data, 187)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval12ChargingElectLevel = ((ByteUtils.DToUInt16(data, 189)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval13ChargingElectLevel = ((ByteUtils.DToUInt16(data, 191)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval14ChargingElectLevel = ((ByteUtils.DToUInt16(data, 193)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval15ChargingElectLevel = ((ByteUtils.DToUInt16(data, 195)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval16ChargingElectLevel = ((ByteUtils.DToUInt16(data, 197)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval17ChargingElectLevel = ((ByteUtils.DToUInt16(data, 199)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval18ChargingElectLevel = ((ByteUtils.DToUInt16(data, 201)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval19ChargingElectLevel = ((ByteUtils.DToUInt16(data, 203)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval20ChargingElectLevel = ((ByteUtils.DToUInt16(data, 205)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval21ChargingElectLevel = ((ByteUtils.DToUInt16(data, 207)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval22ChargingElectLevel = ((ByteUtils.DToUInt16(data, 209)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval23ChargingElectLevel = ((ByteUtils.DToUInt16(data, 211)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval24ChargingElectLevel = ((ByteUtils.DToUInt16(data, 213)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval25ChargingElectLevel = ((ByteUtils.DToUInt16(data, 215)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval26ChargingElectLevel = ((ByteUtils.DToUInt16(data, 217)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval27ChargingElectLevel = ((ByteUtils.DToUInt16(data, 219)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval28ChargingElectLevel = ((ByteUtils.DToUInt16(data, 221)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval29ChargingElectLevel = ((ByteUtils.DToUInt16(data, 223)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval30ChargingElectLevel = ((ByteUtils.DToUInt16(data, 225)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval31ChargingElectLevel = ((ByteUtils.DToUInt16(data, 227)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval32ChargingElectLevel = ((ByteUtils.DToUInt16(data, 229)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval33ChargingElectLevel = ((ByteUtils.DToUInt16(data, 231)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval34ChargingElectLevel = ((ByteUtils.DToUInt16(data, 233)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval35ChargingElectLevel = ((ByteUtils.DToUInt16(data, 235)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval36ChargingElectLevel = ((ByteUtils.DToUInt16(data, 237)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval37ChargingElectLevel = ((ByteUtils.DToUInt16(data, 239)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval38ChargingElectLevel = ((ByteUtils.DToUInt16(data, 241)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval39ChargingElectLevel = ((ByteUtils.DToUInt16(data, 243)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval40ChargingElectLevel = ((ByteUtils.DToUInt16(data, 245)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval41ChargingElectLevel = ((ByteUtils.DToUInt16(data, 247)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval42ChargingElectLevel = ((ByteUtils.DToUInt16(data, 249)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval43ChargingElectLevel = ((ByteUtils.DToUInt16(data, 251)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval44ChargingElectLevel = ((ByteUtils.DToUInt16(data, 253)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval45ChargingElectLevel = ((ByteUtils.DToUInt16(data, 255)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval46ChargingElectLevel = ((ByteUtils.DToUInt16(data, 257)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval47ChargingElectLevel = ((ByteUtils.DToUInt16(data, 259)) * 0.01).ToString("F2"); + CMD402.timeUInt32erval48ChargingElectLevel = ((ByteUtils.DToUInt16(data, 261)) * 0.01).ToString("F2"); + + CMD402.startWay = data[263]; + CMD402.chargingSerialNum = Encoding.ASCII.GetString(data, 264, 32); + CMD402.chargingServiceCharge = ByteUtils.DToUInt32(data, 296); + CMD402.millennialpowerConsumption = (data[300]*0.001).ToString("F4"); + CMD402.parallelChargingMark = data[301]; } else if (func == 422) { @@ -951,25 +951,25 @@ namespace BatCharging.Service.DataRlt CMD402.timeUInt32erval32ChargingElectLevel = ((ByteUtils.DToUInt32(data, 291)*0.001)).ToString("F3"); CMD402.timeUInt32erval33ChargingElectLevel = ((ByteUtils.DToUInt32(data, 295)*0.001)).ToString("F3"); CMD402.timeUInt32erval34ChargingElectLevel = ((ByteUtils.DToUInt32(data, 299)*0.001)).ToString("F3"); - CMD402.timeUInt32erval35ChargingElectLevel = ((ByteUtils.DToUInt32(data, 301)*0.001)).ToString("F3"); - CMD402.timeUInt32erval36ChargingElectLevel = ((ByteUtils.DToUInt32(data, 305)*0.001)).ToString("F3"); - CMD402.timeUInt32erval37ChargingElectLevel = ((ByteUtils.DToUInt32(data, 309)*0.001)).ToString("F3"); - CMD402.timeUInt32erval38ChargingElectLevel = ((ByteUtils.DToUInt32(data, 313)*0.001)).ToString("F3"); - CMD402.timeUInt32erval39ChargingElectLevel = ((ByteUtils.DToUInt32(data, 317)*0.001)).ToString("F3"); - CMD402.timeUInt32erval40ChargingElectLevel = ((ByteUtils.DToUInt32(data, 321)*0.001)).ToString("F3"); - CMD402.timeUInt32erval41ChargingElectLevel = ((ByteUtils.DToUInt32(data, 325)*0.001)).ToString("F3"); - CMD402.timeUInt32erval42ChargingElectLevel = ((ByteUtils.DToUInt32(data, 329)*0.001)).ToString("F3"); - CMD402.timeUInt32erval43ChargingElectLevel = ((ByteUtils.DToUInt32(data, 333)*0.001)).ToString("F3"); - CMD402.timeUInt32erval44ChargingElectLevel = ((ByteUtils.DToUInt32(data, 337)*0.001)).ToString("F3"); - CMD402.timeUInt32erval45ChargingElectLevel = ((ByteUtils.DToUInt32(data, 341)*0.001)).ToString("F3"); - CMD402.timeUInt32erval46ChargingElectLevel = ((ByteUtils.DToUInt32(data, 345)*0.001)).ToString("F3"); - CMD402.timeUInt32erval47ChargingElectLevel = ((ByteUtils.DToUInt32(data, 349)*0.001)).ToString("F3"); - CMD402.timeUInt32erval48ChargingElectLevel = ((ByteUtils.DToUInt32(data, 353)*0.001)).ToString("F3"); - CMD402.startWay = data[357]; - CMD402.chargingSerialNum = Encoding.ASCII.GetString(data, 358, 32); - CMD402.chargingServiceCharge = ByteUtils.DToUInt32(data, 390); - CMD402.millennialpowerConsumption = (data[394] * 0.001).ToString("F4"); - CMD402.parallelChargingMark = data[395]; + CMD402.timeUInt32erval35ChargingElectLevel = ((ByteUtils.DToUInt32(data, 303)*0.001)).ToString("F3"); + CMD402.timeUInt32erval36ChargingElectLevel = ((ByteUtils.DToUInt32(data, 307)*0.001)).ToString("F3"); + CMD402.timeUInt32erval37ChargingElectLevel = ((ByteUtils.DToUInt32(data, 311)*0.001)).ToString("F3"); + CMD402.timeUInt32erval38ChargingElectLevel = ((ByteUtils.DToUInt32(data, 315)*0.001)).ToString("F3"); + CMD402.timeUInt32erval39ChargingElectLevel = ((ByteUtils.DToUInt32(data, 319)*0.001)).ToString("F3"); + CMD402.timeUInt32erval40ChargingElectLevel = ((ByteUtils.DToUInt32(data, 323)*0.001)).ToString("F3"); + CMD402.timeUInt32erval41ChargingElectLevel = ((ByteUtils.DToUInt32(data, 327)*0.001)).ToString("F3"); + CMD402.timeUInt32erval42ChargingElectLevel = ((ByteUtils.DToUInt32(data, 331)*0.001)).ToString("F3"); + CMD402.timeUInt32erval43ChargingElectLevel = ((ByteUtils.DToUInt32(data, 335)*0.001)).ToString("F3"); + CMD402.timeUInt32erval44ChargingElectLevel = ((ByteUtils.DToUInt32(data, 339)*0.001)).ToString("F3"); + CMD402.timeUInt32erval45ChargingElectLevel = ((ByteUtils.DToUInt32(data, 343)*0.001)).ToString("F3"); + CMD402.timeUInt32erval46ChargingElectLevel = ((ByteUtils.DToUInt32(data, 347)*0.001)).ToString("F3"); + CMD402.timeUInt32erval47ChargingElectLevel = ((ByteUtils.DToUInt32(data, 351)*0.001)).ToString("F3"); + CMD402.timeUInt32erval48ChargingElectLevel = ((ByteUtils.DToUInt32(data, 355)*0.001)).ToString("F3"); + CMD402.startWay = data[359]; + CMD402.chargingSerialNum = Encoding.ASCII.GetString(data, 360, 32); + CMD402.chargingServiceCharge = ByteUtils.DToUInt32(data, 392); + CMD402.millennialpowerConsumption = (data[396] * 0.001).ToString("F4"); + CMD402.parallelChargingMark = data[397]; } CMD402.beforeChargingElectMeter = ByteUtils.DToUInt32(data, 108); diff --git a/BatCharging.Service/发送方法/ChargerSendCMD.cs b/BatCharging.Service/发送方法/ChargerSendCMD.cs index 904b5cb..a992436 100644 --- a/BatCharging.Service/发送方法/ChargerSendCMD.cs +++ b/BatCharging.Service/发送方法/ChargerSendCMD.cs @@ -668,7 +668,7 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.value01)); lstContent.AddRange(BitConverter.GetBytes(CMD.value02)); lstContent.AddRange(BitConverter.GetBytes(CMD.value03)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value04)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value04,32)); lstContent.AddRange(BitConverter.GetBytes(CMD.value05)); lstContent.AddRange(BitConverter.GetBytes(CMD.value06)); lstContent.AddRange(BitConverter.GetBytes(CMD.value07));