using System.Xml.Linq; using BatCharging.Model; using BatCharging.Service.Encoder.New; using CommonClass; using Module.Socket.Tool; using Monitor.LogService; using Newtonsoft.Json; using static BatCharging.Service.Encoder.New.UpModelStationRespEcoder; namespace BatCharging.Service { /// /// 1号充电机发送字节消息类 /// internal class ChargerSendMsgUtils { PubCommonClass pubCommonClass = new PubCommonClass(); #region #region 充放电启动指令 /// /// 充电鉴权 /// /// 是否写成功 internal Auth SendCharingSignIn(TcpClientChargerTool tcp_client, byte[] dest_addr) { Auth auth; byte[] bytes = new MsgSignCmdEncoder().GetMsgPackSignIn(dest_addr, out auth); string result = "充电鉴权-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; result += "\r\n" + "充电鉴权对象:" + JsonConvert.SerializeObject(auth); Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); if (auth != null) { tcp_client.Write(bytes); } return auth; } /// /// 监控平台应答充电设备登录签到 /// /// 是否写成功 internal void SendCharingLoginRes(TcpClientChargerTool tcp_client, byte[] dest_addr) { LoginRes lgRes = new LoginRes(); byte[] bytes = new MsgLoginResEncoder().GetMsgLoginRes(dest_addr, lgRes); string result1 = "监控平台应答充电设备登录签到-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; result1 = "\r\n" + "监控平台应答充电设备登录签到对象:" + JsonConvert.SerializeObject(lgRes); Log.LogInstance.WriteLog(result1, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 监控平台心跳应答 /// /// 是否写成功 internal void SendCharingHeartRes(TcpClientChargerTool tcp_client, byte[] dest_addr) { byte[] bytes = new MsgHeartResEncoder().GetMsgPackHeartRes(dest_addr); string result = "监控平台心跳应答-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 监控平台发送远程开始充电指令 /// /// SOC限制.百分比 /// 功率调节指令类型.默认1 绝对功率值 /// 0.1kw/位,默认3600 /// 是否写成功 internal void SendRemoteStartCharing(TcpClientChargerTool tcp_client, byte[] dest_addr, byte socLimit, byte changePowerCmdType, ushort changePower, byte startModel) { RemoteStartCharging startChrg = new RemoteStartCharging(socLimit, changePowerCmdType, changePower, startModel); byte[] bytes = new MsgStartChrgEncoder().GetMsgPackRomoteStartCharging(dest_addr, startChrg); string result = "发送远程开始充电-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; result = "\r\n" + "发送远程开始充电对象:" + JsonConvert.SerializeObject(startChrg); Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 监控平台发送远程停止充电指令 /// /// 停止原因.0正常停机 1服务器发现桩异常,强制停机 /// 是否写成功 internal void SendRemoteStopCharing(TcpClientChargerTool tcp_client, byte[] dest_addr, byte stopReason) { byte[] bytes = new MsgStopChrgEncoder().GetMsgPackRomoteStopCharging(dest_addr, stopReason); string result = "发送远程停止充电-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 监控平台应答充电启动完成帧 /// /// 成功标识.0:成功;1:失败 /// 失败原因.0:成功 1:交易流水号数据异常 2:充电方式数据异常 internal void SendStartChargingFinishedRes(TcpClientChargerTool tcp_client, byte[] dest_addr, byte resResult, byte failReason) { byte[] bytes = new MsgStartFsdResEncoder().GetStartChargingFinishedRes(dest_addr, resResult, failReason); string result = "监控平台应答充电启动完成帧-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 监控平台应答充电停止完成帧-4.1.9 /// /// 成功标识.0:成功;1:失败 internal void SendStopChargingFinishedRes(TcpClientChargerTool tcp_client, byte[] dest_addr, byte resResult) { byte[] bytes = new MsgStopFsdResEncoder().GetStopChargingFinishedRes(dest_addr, resResult); string result = "监控平台应答充电停止完成帧-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion 充放电启动指令 /// /// 3.4.1 监控平台发送功率调节指令 帧类型45 记录类型 5 /// /// /// /// internal void SendPowerRegulate(TcpClientChargerTool tcp_client, byte[] dest_addr, ushort expectePower) { byte[] bytes = new MsgPowerRegulateEncoder().GetPowerRegulateMsg(dest_addr, expectePower); string result = "监控平台发送功率调节指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes); Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 3.4.3 监控平台下发辅源控制指令 /// /// /// /// 打开辅助电源标志 1:电池包辅助电源导通 0:电池包辅助电源断开 internal void SendAuxiliaryPowerControl(TcpClientChargerTool tcp_client, byte[] dest_addr, byte onAuxiliaryFlag) { byte[] bytes = new MsgAuxiliaryPowerControlEncoder().GetAuxiliaryPowerControl(dest_addr, onAuxiliaryFlag); string result = "监控平台下发辅源控制指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes); Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 3.4.5 监控平台下发掉线停止充电 /// /// /// /// 应答结果 /// 保留 internal void SendDisconnectStopCharge(TcpClientChargerTool tcp_client, byte[] dest_addr, byte responseResults, ushort reserve) { byte[] bytes = new MsgDisconnectStopChargeEncoder().GetDisconnectStopChargeMsg(dest_addr, responseResults, reserve); string result = "监控平台下发掉线停止充电-发送字节内容:" + ByteUtils.BytesToHexStr(bytes); Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 3.4.7 监控平台下发站外允许充电SOC /// /// /// /// SOC限制值 internal void SendOutsideAllowChargeSOC(TcpClientChargerTool tcp_client, byte[] dest_addr, byte SOCLimitValue) { byte[] bytes = new MsgOutsideAllowChargeSOCEcoder().GetOutsideAllowChargeSOCEcoderMsg(dest_addr, SOCLimitValue); string result = "监控平台下发站外允许充电SOC-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 3.4.9 站控设置尖峰平谷时间段标识 /// /// /// /// internal void SendPeakTimePeriod(TcpClientChargerTool tcp_client, byte[] dest_addr, SharpPeakTimeRangeIde timeRng) { byte[] bytes = new MsgPeakTimeEncoder().GetMsgPeakTimePeriod(dest_addr, timeRng); string result = "站控设置尖峰平谷时间段标识-发送字节内容:" + ByteUtils.BytesToHexStr(bytes); Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 3.4.11 监控平台下发版本号查询 /// /// internal void SendVersionNumber(TcpClientChargerTool tcp_client, byte[] dest_addr) { byte[] bytes = new MsgVerNumEncoder().GetMsgPackRomoteStopCharging(dest_addr); string result = "充电鉴权-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 3.5.7 主动上送充电记录响应 /// /// /// /// 保留1 /// 保留2 internal void SendRecordChargResp(TcpClientChargerTool tcp_client, byte[] dest_addr, byte reserve1, byte reserve2) { byte[] bytes = new MsgChargRespEcoder().GetRecordChargRespEcoderMsg(dest_addr, reserve1, reserve2); string result = "主动上送充电记录响应-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 3.5.8 站控查询监控网关尖峰平谷设置 /// /// /// /// internal void SendQueryPeakTime(TcpClientChargerTool tcp_client, byte[] dest_addr, byte reserve) { byte[] bytes = new MsgQueryPeakTimeEcoder().GetQueryPeakTimeEcoderMsg(dest_addr, reserve); string result = "站控查询监控网关尖峰平谷设置-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } /// /// 站控响应充放电机上报模块状态 /// /// /// /// internal void SendUpModelStationResp(TcpClientChargerTool tcp_client, byte[] dest_addr, byte respResult) { byte[] bytes = new UpModelStationRespEcoder().GetUpModelStationRespEcoderMsg(dest_addr, respResult); string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region 服务器向充电桩设置/查询工作参数和命令 /// /// (CMD=1)后台服务器下发充电桩整形工作参数 /// /// /// /// /// /// internal void Send1(TcpClientChargerTool tcp_client, byte type, uint startAddress, byte num, byte[] setData) { APDUModel APDUModel; CMD1 CMD1 = new CMD1(); CMD1.value3 = type; CMD1.value4 = startAddress; CMD1.value5 = num; CMD1.value6 = (ushort)(num * 4); CMD1.value7 = setData; byte[] bytes = new ChargerSendCMD().SendRCMD1(out APDUModel, CMD1); if (APDUModel != null) { string result = "1后台服务器下发充电桩整形工作参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// (CMD=3) /// /// /// /// internal void Send3(TcpClientChargerTool tcp_client, byte type, uint startAddress, byte[] setData) { APDUModel APDUModel; CMD3 CMD3 = new CMD3(); CMD3.value1 = 0; CMD3.value2 = 0; CMD3.value3 = type; CMD3.value4 = startAddress; CMD3.value5 = PubCommonClass.cmd3StartAddress[startAddress]; CMD3.value6 = setData; byte[] bytes = new ChargerSendCMD().SendRCMD3(out APDUModel, CMD3); if (APDUModel != null) { string result = "3后台服务器下发充电桩字符型参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// 后台服务器下发充电桩控制命令 /// /// /// 充电枪口 /// 启始命令地址 /// 命令个数 /// 命令参数 internal void Send5(TcpClientChargerTool tcp_client, byte chargeMuzzle, uint startAddress, byte num, byte[] setData) { APDUModel APDUModel; CMD5 CMD = new CMD5(); CMD.value3 = chargeMuzzle; CMD.value4 = startAddress; CMD.value5 = num; CMD.value6 = (ushort)(num * 4); CMD.value7 = setData; byte[] bytes = new ChargerSendCMD().SendRCMD5(out APDUModel, CMD); if (APDUModel != null) { string result = "5后台服务器下发充电桩控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// 后台服务器下发充电桩开启充电控制命令 /// /// /// internal void Send7(TcpClientChargerTool tcp_client, CMD7 CMD) { APDUModel APDUModel; byte[] bytes = new ChargerSendCMD().SendRCMD7(out APDUModel, CMD); if (APDUModel != null) { string result = "7后台服务器下发充电桩开启充电控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } internal void Send9(TcpClientChargerTool tcp_client, byte chargeMuzzle, uint executeResult, uint address, byte[] setData) { APDUModel APDUModel; CMD9 CMD = new CMD9(); CMD.value03 = chargeMuzzle; CMD.value04 = executeResult; CMD.value05 = address; CMD.value06 = 4; CMD.value07 = new byte[4]; byte[] bytes = new ChargerSendCMD().SendRCMD9(out APDUModel, CMD); if (APDUModel != null) { string result = "9后台服务器应答桩上传命令请求(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } #endregion #region 充电桩主动上传数据 /// /// 服务器应答心跳包信息 /// /// /// 心跳应答 internal void Send101(TcpClientChargerTool tcp_client, ushort heartbeatNum) { APDUModel APDUModel; CMD101 CMD = new CMD101(); CMD.value03 = heartbeatNum; byte[] bytes = new ChargerSendCMD().SendRCMD101(out APDUModel, CMD); if (APDUModel != null) { string result = "101服务器应答心跳包信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// 服务器应答充电桩状态信息包 /// /// /// 充电口号 /// 是否立即上报一次104报文 0-否 、1-是 internal void Send103(TcpClientChargerTool tcp_client, byte chargeNum, bool reportMessage) { APDUModel APDUModel; CMD103 CMD = new CMD103(); CMD.value03 = chargeNum; CMD.value04 = reportMessage; byte[] bytes = new ChargerSendCMD().SendRCMD103(out APDUModel, CMD); if (APDUModel != null) { string result = "103服务器应答充电桩状态信息包-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// 服务器应答充电桩签到命令 /// /// /// internal void Send105(TcpClientChargerTool tcp_client, CMD105 CMD) { APDUModel APDUModel; byte[] bytes = new ChargerSendCMD().SendRCMD105(out APDUModel, CMD); if (APDUModel != null) { string result = "105服务器应答充电桩签到命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// 服务器应答充电桩告警信息 /// /// internal void Send107(TcpClientChargerTool tcp_client) { APDUModel APDUModel; CMD107 CMD = new CMD107(); byte[] bytes = new ChargerSendCMD().SendRCMD107(out APDUModel, CMD); if (APDUModel != null) { string result = "107服务器应答充电桩告警信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// 服务器应答充电桩告警信息 /// /// internal void Send109(TcpClientChargerTool tcp_client) { APDUModel APDUModel; CMD109 CMD = new CMD109(); byte[] bytes = new ChargerSendCMD().SendRCMD109(out APDUModel, CMD); if (APDUModel != null) { 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; CMD111 CMD = new CMD111(); CMD.value03 = messageType; byte[] bytes = new ChargerSendCMD().SendRCMD111(out APDUModel, CMD); if (APDUModel != null) { string result = "111服务器应答充电桩上报模块信息(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } /// /// 服务器查询最近一次充电各时段信息 /// /// /// 充电口号 /// 标志 internal void Send113(TcpClientChargerTool tcp_client, byte chargeNum, byte sign) { APDUModel APDUModel; CMD113 CMD = new CMD113(); CMD.value03 = chargeNum; CMD.value04 = sign; byte[] bytes = new ChargerSendCMD().SendRCMD113(out APDUModel, CMD); if (APDUModel != null) { string result = "113服务器查询最近一次充电各时段信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } } #endregion #region 充电信息数据 /// /// (CMD=5) /// /// /// /// internal void Send201(TcpClientChargerTool tcp_client, CMD201 CMD,uint func) { byte[] bytes = new ChargerSendCMD().SendRCMD201(out APDUModel APDUModel, CMD, func); string result = "201服务器应答充电桩上报充电信息报文-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } 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(); CMD.value01 = 0; CMD.value02 = 0; CMD.value03 = value03; CMD.value04 = value04; CMD.value05 = value05; CMD.value06 = value06; CMD.value07 = value07; CMD.value08 = value08; CMD.value09 = value09; CMD.value10 = value10; CMD.value11 = value11; CMD.value12 = value12; CMD.value13 = CMD204.value11; byte[] bytes = new ChargerSendCMD().SendRCMD203(out APDUModel APDUModel, CMD); string result = "203服务器应答账户查询信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send205(TcpClientChargerTool tcp_client, uint value03, uint value04) { CMD205 CMD = new CMD205(); CMD.value01 = 0; CMD.value02 = 0; CMD.value03 = value03; if (CMD.value03 == 0) { CMD.value04 = value04; } else { CMD.value04 = 0; } byte[] bytes = new ChargerSendCMD().SendRCMD205(out APDUModel APDUModel, CMD); string result = "205服务器应答充电密码验证报文(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send207(TcpClientChargerTool tcp_client, CMD208 CMD208, string value06, string value07, byte value08, byte value09, uint value10, ulong value11) { CMD207 CMD = new CMD207(); CMD.value01 = 0; CMD.value02 = 0; CMD.value03 = CMD208.value03; CMD.value04 = CMD208.value04; CMD.value05 = CMD208.value05; CMD.value06 = value06; CMD.value07 = value07; CMD.value08 = value08; CMD.value09 = value09; CMD.value10 = value10; CMD.value11 = value11; byte[] bytes = new ChargerSendCMD().SendRCMD207(out APDUModel APDUModel, CMD); string result = "207平台回复“即插即充”请求充电结果-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send209(TcpClientChargerTool tcp_client, CMD210 CMD210, string value05) { CMD209 CMD = new CMD209(); CMD.value01 = CMD210.value01; CMD.value02 = CMD210.value02; CMD.value03 = CMD210.value03; CMD.value04 = CMD210.value04; CMD.value05 = value05; byte[] bytes = new ChargerSendCMD().SendRCMD209(out APDUModel APDUModel, CMD); string result = "209平台回复“即插即充”启动充电结果-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send221(TcpClientChargerTool tcp_client, CMD221 CMD221, uint value05) { CMD221 CMD = new CMD221(); CMD.value01 = CMD221.value01; CMD.value02 = CMD221.value02; CMD.value03 = CMD221.value03; CMD.value04 = CMD221.value04; CMD.value05 = value05; byte[] bytes = new ChargerSendCMD().SendRCMD221(out APDUModel APDUModel, CMD); string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region 直流充电桩 BMS 信息数据(预留) 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 = "301服务器应答充电桩上报BMS信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } 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 = "303服务器应答充电桩上报BMS信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region 历史记录 internal void Send401(TcpClientChargerTool tcp_client, string chargingSerialNum, uint startIndex) { CMD401 CMD = new CMD401(); CMD.reserved1 = 0; CMD.reserved2 = 0; CMD.startingIndexOfQueryRecord = startIndex; CMD.chargingSerialNumber = chargingSerialNum; byte[] bytes = new ChargerSendCMD().SendRCMD401(out APDUModel APDUModel, CMD); string result = "401/421服务器查询充电桩历史充电记录-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region 升级命令 internal void Send1001(TcpClientChargerTool tcp_client, uint instruct) { CMD1001 CMD = new CMD1001(); CMD.eraseOrQueryInstructions = instruct; byte[] bytes = new ChargerSendCMD().SendRCMD1001(out APDUModel APDUModel, CMD); string result = "1001服务器下发擦除指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } 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 = "1003服务器下发升级文件名指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } 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 = "1005服务器下发升级文件大小-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } 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 = "1007服务器下发升级文件数据-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send1009(TcpClientChargerTool tcp_client) { CMD1009 CMD = new CMD1009(); CMD.Value01 = 0; byte[] bytes = new ChargerSendCMD().SendRCMD1009(out APDUModel APDUModel, CMD); string result = "1009服务器下发升级文件数据结束指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send1011(TcpClientChargerTool tcp_client) { CMD1011 CMD = new CMD1011(); CMD.reserved1 = 0; byte[] bytes = new ChargerSendCMD().SendRCMD1011(out APDUModel APDUModel, CMD); string result = "1011服务器下发重启指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } 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 = "1021服务器回复充电桩主动请求升级命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region 与计费策略相关的指令 internal void Send1101(TcpClientChargerTool tcp_client) { byte[] bytes = new ChargerSendCMD().SendRCMD1101(out APDUModel APDUModel); string result = "1101后台服务器查询24时电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send1103(TcpClientChargerTool tcp_client, CMD1103 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1103(out APDUModel APDUModel, CMD); string result = "1103后台服务器设置24时段电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send1105(TcpClientChargerTool tcp_client, CMD1105 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1105(out APDUModel APDUModel,CMD); string result = "1105后台服务器设置分时段计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send1107(TcpClientChargerTool tcp_client) { byte[] bytes = new ChargerSendCMD().SendRCMD1107(out APDUModel APDUModel); string result = "1107后台服务器查询分时电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region 白名单报文 internal void Send1301(TcpClientChargerTool tcp_client, CMD1301 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1301(out APDUModel APDUModel, CMD); string result = "1301服务器下发白名单操作日志数据包-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region FTP 远程升级和 FTP 方式日志上传 internal void Send1401(TcpClientChargerTool tcp_client, CMD1401 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1401(out APDUModel APDUModel, CMD); string result = "1401服务器下发FTP远程升级命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send1406(TcpClientChargerTool tcp_client, CMD1406 CMD) { byte[] bytes = new ChargerSendCMD().SendRCMD1406(out APDUModel APDUModel, CMD); string result = "1406服务器下发获取充电桩日志信息命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion #region 协议方式日志上传 internal void Send1502(TcpClientChargerTool tcp_client,uint responseCode) { CMD1502 CMD = new CMD1502(); CMD.responseCode = responseCode; byte[] bytes = new ChargerSendCMD().SendRCMD1502(out APDUModel APDUModel, CMD); string result = "cmd1502 服务器允许上传-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } internal void Send1504(TcpClientChargerTool tcp_client, uint logo, uint successReservedMessageNum) { CMD1504 CMD = new CMD1504(); CMD.reserved1 = 0; CMD.reserved2 = 0; CMD.logo = logo; CMD.successReservedMessageNum = successReservedMessageNum; byte[] bytes = new ChargerSendCMD().SendRCMD1504(out APDUModel APDUModel, CMD); string result = "1504服务器应答上传日志-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } 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 = "1506当前文件接收完成-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); tcp_client.Write(bytes); } #endregion } }