From 01b13f9d3edbf6f3ab366bf5bd883c59f06c074e Mon Sep 17 00:00:00 2001 From: lch <1627445470@qq.com> Date: Wed, 20 Mar 2024 14:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=97=A5=E5=BF=97=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatCharging.Model/客户端发送/CMD1502.cs | 2 +- BatCharging.Service/ChargerMgrTool.cs | 16 +- BatCharging.Service/ChargerSendMsg.cs | 287 ++++-------------- .../发送方法/ChargerSendCMD.cs | 32 +- Monitor.ChargeTest/FrmChargeResult.cs | 10 + 5 files changed, 99 insertions(+), 248 deletions(-) diff --git a/BatCharging.Model/客户端发送/CMD1502.cs b/BatCharging.Model/客户端发送/CMD1502.cs index e158d88..f769284 100644 --- a/BatCharging.Model/客户端发送/CMD1502.cs +++ b/BatCharging.Model/客户端发送/CMD1502.cs @@ -20,6 +20,6 @@ namespace BatCharging.Model /// 应答码 /// 0-允许发送 其他-不支持日志上传 /// - public UInt16 responseCode { get; set; } + public uint responseCode { get; set; } } } diff --git a/BatCharging.Service/ChargerMgrTool.cs b/BatCharging.Service/ChargerMgrTool.cs index 7d34543..ebe998a 100644 --- a/BatCharging.Service/ChargerMgrTool.cs +++ b/BatCharging.Service/ChargerMgrTool.cs @@ -1325,7 +1325,7 @@ namespace BatCharging.Service case 402: case 422: { - CMD402 CMD402 = new MsgReceiveCMDCom().ConCMD402(func,data); + CMD402 CMD402 = new MsgReceiveCMDCom().ConCMD402(func, data); string result = "充电桩上报历史的充电记录 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩上报历史的充电记录:" + JsonConvert.SerializeObject(CMD402); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); @@ -1563,11 +1563,15 @@ namespace BatCharging.Service if (CMD1501 != null) { - PublicProgram.failName01 = CMD1501.value03 + "/" + CMD1501.value04 + "/" + DateTime.Now.ToString("yyyyMMddHHmmss"); + //判断是否允许上传 todo + //应答码responseCode 0-允许发送,其他-不支持日志上传 + uint responseCode = 0; - //(CMD=9)后台服务器应答桩上传命令请求(预留) - CmnChargerParam._CHR00TCPCLIENT.Send1502(0); + //服务器允许上传 + CmnChargerParam._CHR00TCPCLIENT.Send1502(responseCode); + + PublicProgram.failName01 = CMD1501.value03 + "/" + CMD1501.value04 + "/" + DateTime.Now.ToString("yyyyMMddHHmmss"); //获取桌面路径 string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); @@ -2236,7 +2240,7 @@ namespace BatCharging.Service #region 充电信息数据 - public void Send201(CMD201 CMD201,uint func) + public void Send201(CMD201 CMD201, uint func) { if (_chr_client != null) { @@ -2514,7 +2518,7 @@ namespace BatCharging.Service #region 协议方式日志上传 - public void Send1502(ushort responseCode) + public void Send1502(uint responseCode) { if (_chr_client != null) { diff --git a/BatCharging.Service/ChargerSendMsg.cs b/BatCharging.Service/ChargerSendMsg.cs index 549bd80..9c8e4ae 100644 --- a/BatCharging.Service/ChargerSendMsg.cs +++ b/BatCharging.Service/ChargerSendMsg.cs @@ -301,7 +301,7 @@ namespace BatCharging.Service if (APDUModel != null) { - string result = "后台服务器下发充电桩整形工作参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1后台服务器下发充电桩整形工作参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } @@ -330,7 +330,7 @@ namespace BatCharging.Service if (APDUModel != null) { - string result = "后台服务器下发充电桩字符型参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "3后台服务器下发充电桩字符型参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } @@ -362,7 +362,7 @@ namespace BatCharging.Service if (APDUModel != null) { - string result = "后台服务器下发充电桩控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "5后台服务器下发充电桩控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -384,7 +384,7 @@ namespace BatCharging.Service if (APDUModel != null) { - string result = "后台服务器下发充电桩开启充电控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "7后台服务器下发充电桩开启充电控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -393,14 +393,7 @@ namespace BatCharging.Service - /// - /// 后台服务器应答桩上传命令请求(预留) - /// - /// - /// 充电枪号 - /// 执行结果 - /// 命令地址 - /// 数据 + internal void Send9(TcpClientChargerTool tcp_client, byte chargeMuzzle, uint executeResult, uint address, byte[] setData) { APDUModel APDUModel; @@ -417,7 +410,7 @@ namespace BatCharging.Service if (APDUModel != null) { - string result = "后台服务器应答桩上传命令请求(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "9后台服务器应答桩上传命令请求(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -445,7 +438,7 @@ namespace BatCharging.Service if (APDUModel != null) { - string result = "服务器应答心跳包信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "101服务器应答心跳包信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -471,7 +464,7 @@ namespace BatCharging.Service byte[] bytes = new ChargerSendCMD().SendRCMD103(out APDUModel, CMD); if (APDUModel != null) { - string result = "服务器应答充电桩状态信息包-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "103服务器应答充电桩状态信息包-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -490,7 +483,7 @@ namespace BatCharging.Service byte[] bytes = new ChargerSendCMD().SendRCMD105(out APDUModel, CMD); if (APDUModel != null) { - string result = "服务器应答充电桩签到命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "105服务器应答充电桩签到命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -510,7 +503,7 @@ namespace BatCharging.Service byte[] bytes = new ChargerSendCMD().SendRCMD107(out APDUModel, CMD); if (APDUModel != null) { - string result = "服务器应答充电桩告警信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "107服务器应答充电桩告警信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -533,18 +526,13 @@ namespace BatCharging.Service byte[] bytes = new ChargerSendCMD().SendRCMD109(out APDUModel, CMD); if (APDUModel != null) { - string result = "服务器应答充电桩告警信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "109服务器应答充电桩启动完成命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } - /// - /// 服务器应答充电桩上报模块信息(预留) - /// - /// - /// 报文类型 internal void Send111(TcpClientChargerTool tcp_client, byte messageType) { APDUModel APDUModel; @@ -558,7 +546,7 @@ namespace BatCharging.Service byte[] bytes = new ChargerSendCMD().SendRCMD111(out APDUModel, CMD); if (APDUModel != null) { - string result = "服务器应答充电桩上报模块信息(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "111服务器应答充电桩上报模块信息(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -584,7 +572,7 @@ namespace BatCharging.Service byte[] bytes = new ChargerSendCMD().SendRCMD113(out APDUModel, CMD); if (APDUModel != null) { - string result = "服务器查询最近一次充电各时段信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "113服务器查询最近一次充电各时段信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -605,19 +593,14 @@ namespace BatCharging.Service { byte[] bytes = new ChargerSendCMD().SendRCMD201(out APDUModel APDUModel, CMD, func); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "201服务器应答充电桩上报充电信息报文-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send203(TcpClientChargerTool tcp_client, CMD204 CMD204, uint value03, uint value04, ushort value05, ushort value06, byte value07, byte value08, byte value09, byte value10, string value11, string value12) { CMD203 CMD = new CMD203(); @@ -636,19 +619,14 @@ namespace BatCharging.Service CMD.value13 = CMD204.value11; byte[] bytes = new ChargerSendCMD().SendRCMD203(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "203服务器应答账户查询信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send205(TcpClientChargerTool tcp_client, uint value03, uint value04) { CMD205 CMD = new CMD205(); @@ -665,19 +643,14 @@ namespace BatCharging.Service } byte[] bytes = new ChargerSendCMD().SendRCMD205(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "205服务器应答充电密码验证报文(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send207(TcpClientChargerTool tcp_client, CMD208 CMD208, string value06, string value07, byte value08, byte value09, uint value10, ulong value11) { CMD207 CMD = new CMD207(); @@ -693,19 +666,14 @@ namespace BatCharging.Service CMD.value10 = value10; CMD.value11 = value11; byte[] bytes = new ChargerSendCMD().SendRCMD207(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "207平台回复“即插即充”请求充电结果-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send209(TcpClientChargerTool tcp_client, CMD210 CMD210, string value05) { CMD209 CMD = new CMD209(); @@ -715,17 +683,12 @@ namespace BatCharging.Service CMD.value04 = CMD210.value04; CMD.value05 = value05; byte[] bytes = new ChargerSendCMD().SendRCMD209(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "209平台回复“即插即充”启动充电结果-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send221(TcpClientChargerTool tcp_client, CMD221 CMD221, uint value05) { CMD221 CMD = new CMD221(); @@ -745,37 +708,27 @@ namespace BatCharging.Service #endregion #region 直流充电桩 BMS 信息数据(预留) - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send301(TcpClientChargerTool tcp_client) { CMD301 CMD = new CMD301(); CMD.reserved1 = 0; CMD.reserved2 = 0; byte[] bytes = new ChargerSendCMD().SendRCMD301(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "301服务器应答充电桩上报BMS信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send303(TcpClientChargerTool tcp_client) { CMD303 CMD = new CMD303(); CMD.reserved1 = 0; CMD.reserved2 = 0; byte[] bytes = new ChargerSendCMD().SendRCMD303(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "303服务器应答充电桩上报BMS信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -783,12 +736,7 @@ namespace BatCharging.Service #endregion #region 历史记录 - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send401(TcpClientChargerTool tcp_client, string chargingSerialNum, uint startIndex) { CMD401 CMD = new CMD401(); @@ -797,7 +745,7 @@ namespace BatCharging.Service CMD.startingIndexOfQueryRecord = startIndex; CMD.chargingSerialNumber = chargingSerialNum; byte[] bytes = new ChargerSendCMD().SendRCMD401(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "401/421服务器查询充电桩历史充电记录-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -805,115 +753,80 @@ namespace BatCharging.Service #endregion #region 升级命令 - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1001(TcpClientChargerTool tcp_client, int instruct) { CMD1001 CMD = new CMD1001(); CMD.eraseOrQueryInstructions = instruct; byte[] bytes = new ChargerSendCMD().SendRCMD1001(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1001服务器下发擦除指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1003(TcpClientChargerTool tcp_client, string fileName) { CMD1003 CMD = new CMD1003(); CMD.fileName = fileName; byte[] bytes = new ChargerSendCMD().SendRCMD1003(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1003服务器下发升级文件名指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1005(TcpClientChargerTool tcp_client, uint fileLength) { CMD1005 CMD = new CMD1005(); CMD.fileLength = fileLength; byte[] bytes = new ChargerSendCMD().SendRCMD1005(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1005服务器下发升级文件大小-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1007(TcpClientChargerTool tcp_client, string updata) { CMD1007 CMD = new CMD1007(); CMD.upgradeFileData = updata; byte[] bytes = new ChargerSendCMD().SendRCMD1007(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1007服务器下发升级文件数据-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1009(TcpClientChargerTool tcp_client) { CMD1009 CMD = new CMD1009(); CMD.Value01 = 0; byte[] bytes = new ChargerSendCMD().SendRCMD1009(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1009服务器下发升级文件数据结束指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1011(TcpClientChargerTool tcp_client) { CMD1011 CMD = new CMD1011(); CMD.reserved1 = 0; byte[] bytes = new ChargerSendCMD().SendRCMD1011(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1011服务器下发重启指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1021(TcpClientChargerTool tcp_client, uint results, string description) { CMD1021 CMD = new CMD1021(); CMD.responseResults = results; CMD.responseDescription = description; byte[] bytes = new ChargerSendCMD().SendRCMD1021(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1021服务器回复充电桩主动请求升级命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -922,58 +835,38 @@ namespace BatCharging.Service #region 与计费策略相关的指令 - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1101(TcpClientChargerTool tcp_client) { byte[] bytes = new ChargerSendCMD().SendRCMD1101(out APDUModel APDUModel); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1101后台服务器查询24时电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1103(TcpClientChargerTool tcp_client, CMD1103 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1103(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1103后台服务器设置24时段电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1105(TcpClientChargerTool tcp_client, CMD1105 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1105(out APDUModel APDUModel,CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1105后台服务器设置分时段计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1107(TcpClientChargerTool tcp_client) { byte[] bytes = new ChargerSendCMD().SendRCMD1107(out APDUModel APDUModel); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1107后台服务器查询分时电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -982,16 +875,11 @@ namespace BatCharging.Service #region 白名单报文 - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1301(TcpClientChargerTool tcp_client, CMD1301 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1301(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1301服务器下发白名单操作日志数据包-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -1000,45 +888,20 @@ namespace BatCharging.Service #endregion #region FTP 远程升级和 FTP 方式日志上传 - /// - /// (CMD=5) - /// - /// - /// - /// - /// - /// - /// - /// - /// + internal void Send1401(TcpClientChargerTool tcp_client, CMD1401 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1401(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1401服务器下发FTP远程升级命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// - /// - /// + internal void Send1406(TcpClientChargerTool tcp_client, CMD1406 CMD) { - //CMD1406 CMD = new CMD1406(); - //CMD.reserved1 = 0; - //CMD.reserved2 = 0; - //CMD.getLogType = 0; - //CMD.ftpServerIPaddress = null; - //CMD.ftpUserName = null; - //CMD.ftpPassWord = null; - //CMD.ftpSavePath = null; - //CMD.executeWay = 0; - byte[] bytes = new ChargerSendCMD().SendRCMD1406(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1406服务器下发获取充电桩日志信息命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); @@ -1046,32 +909,20 @@ namespace BatCharging.Service #endregion #region 协议方式日志上传 - /// - /// (CMD=5) - /// - /// - /// - /// - internal void Send1502(TcpClientChargerTool tcp_client,ushort responseCode) + + internal void Send1502(TcpClientChargerTool tcp_client,uint responseCode) { CMD1502 CMD = new CMD1502(); - CMD.reserved1 = 0; - CMD.reserved2 = 0; + CMD.responseCode = responseCode; byte[] bytes = new ChargerSendCMD().SendRCMD1502(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "cmd1502 服务器允许上传-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// TCP - /// 标识 - /// 已成功接收的报文编号 - /// 这个要与最后一次收到的 1503 报文中的字段 4 一样。 - internal void Send1504(TcpClientChargerTool tcp_client, uint logo,uint successReservedMessageNum) + + internal void Send1504(TcpClientChargerTool tcp_client, uint logo, uint successReservedMessageNum) { CMD1504 CMD = new CMD1504(); CMD.reserved1 = 0; @@ -1079,25 +930,19 @@ namespace BatCharging.Service CMD.logo = logo; CMD.successReservedMessageNum = successReservedMessageNum; byte[] bytes = new ChargerSendCMD().SendRCMD1504(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1504服务器应答上传日志-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } - /// - /// (CMD=5) - /// - /// TCP - /// 标识 - /// 已成功接收的报文编号 - /// 这个要与最后一次收到的 1503 报文中的字段 4 一样。 + internal void Send1506(TcpClientChargerTool tcp_client) { CMD1506 CMD = new CMD1506(); CMD.value01 = 0; CMD.value01 = 0; byte[] bytes = new ChargerSendCMD().SendRCMD1506(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; + string result = "1506当前文件接收完成-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); diff --git a/BatCharging.Service/发送方法/ChargerSendCMD.cs b/BatCharging.Service/发送方法/ChargerSendCMD.cs index 1ccf832..3b490d6 100644 --- a/BatCharging.Service/发送方法/ChargerSendCMD.cs +++ b/BatCharging.Service/发送方法/ChargerSendCMD.cs @@ -1851,22 +1851,13 @@ namespace BatCharging.Service List lstContent = new List(); lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2)); + lstContent.AddRange(BitConverter.GetBytes((ushort)(Convert.ToSingle(CMD.UpgradeSoftwareFileVersionNum) * 100))); - lstContent.AddRange(BitConverter.GetBytes(Convert.ToUInt16(CMD.UpgradeSoftwareFileVersionNum) * 100)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpServerIPaddress), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpUserName), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpPassWord), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpDownloadPath), 64)); - string[] parts = CMD.ftpServerIPaddress.Split("."); - if (parts.Length == 4) - { - lstContent.Add(byte.Parse(parts[0])); - lstContent.Add(byte.Parse(parts[1])); - lstContent.Add(byte.Parse(parts[2])); - lstContent.Add(byte.Parse(parts[3])); - } - - - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpUserName)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpPassWord)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpDownloadPath)); lstContent.Add(CMD.executeWay); lstContent.Add(CMD.nowUpgradeDeviceType); @@ -1878,7 +1869,7 @@ namespace BatCharging.Service public byte[] SendRCMD1406(out APDUModel APDUModel, CMD1406 CMD) { - byte[] result = null; + byte[] result; APDUModel model = new APDUModel(); model.OriginDomain1 = 0xAA; @@ -1913,11 +1904,12 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2)); lstContent.Add(CMD.getLogType); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpServerIPaddress)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpUserName)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpPassWord)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpSavePath)); - lstContent.AddRange(BitConverter.GetBytes(CMD.executeWay)); + + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpServerIPaddress),32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpUserName),16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpPassWord),16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpSavePath),32)); + lstContent.Add(CMD.executeWay); results = lstContent.ToArray(); } diff --git a/Monitor.ChargeTest/FrmChargeResult.cs b/Monitor.ChargeTest/FrmChargeResult.cs index 911994b..b0f05aa 100644 --- a/Monitor.ChargeTest/FrmChargeResult.cs +++ b/Monitor.ChargeTest/FrmChargeResult.cs @@ -570,6 +570,9 @@ namespace Monitor.ChargeTest cMD1401.ftpServerIPaddress = "16.80.1.20"; cMD1401.ftpUserName = "ftpuserName"; cMD1401.ftpPassWord = "123456"; + cMD1401.ftpDownloadPath = "ftp://172.16.4.254/SINEXCEL/dcharg.bin"; + cMD1401.executeWay = 1; + cMD1401.nowUpgradeDeviceType = 1; CmnChargerParam._CHR00TCPCLIENT.Send1401(cMD1401); } @@ -582,6 +585,13 @@ namespace Monitor.ChargeTest { CMD1406 cMD1406 = new CMD1406(); + cMD1406.getLogType = 1; + cMD1406.ftpServerIPaddress = "16.80.1.20"; + cMD1406.ftpUserName = "ftpuserName"; + cMD1406.ftpPassWord = "123456"; + cMD1406.ftpSavePath = ""; + cMD1406.executeWay = 1; + CmnChargerParam._CHR00TCPCLIENT.Send1406(cMD1406); } #endregion